dtn::ConnectionConvergenceLayer Class Reference

#include <ConnectionConvergenceLayer.h>

Inheritance diagram for dtn::ConnectionConvergenceLayer:

dtn::ConvergenceLayer oasys::Logger dtn::StreamConvergenceLayer dtn::BluetoothConvergenceLayer dtn::TCPConvergenceLayer

List of all members.


Detailed Description

All convergence layers that maintain a connection (i.e.

a TCP socket) to next hop peers derive from this base class. As such, it manages all communication to/from the main bundle daemon thread, handles the main thread of control for each connection, and dispatches to the specific CL implementation to handle the actual wire protocol.

The design is as follows:

Open links contain a Connection class stored in the Contact's cl_info slot. The lifetime of this object is one-to-one with the duration of the Contact object. The Connection class is a thread that contains a MsgQueue for commands to be sent from the bundle daemon. The commands are SEND_BUNDLE, CANCEL_BUNDLE, and BREAK_CONTACT. When in an idle state, the thread blocks on this queue as well as the socket or other connection object so it can be notified of events coming from either the daemon or the peer node.

To enable backpressure, each connection has a maximum queue depth for bundles that have been pushed onto the queue but have not yet been sent or registered as in-flight by the CL. The state of the link is set to BUSY when this limit is reached, but is re-set to AVAILABLE if By default, there is no hard limit on the number of bundles that can be in-flight, instead the limit is determined by the capacity of the underlying link.

The hardest case to handle is how to close a contact, as there is a race condition between the underlying connection breaking and the higher layers determining that the link should be closed. If the underlying link breaks due to a timeout or goes idle for an on demand link, a ContactDownEvent is posted and the thread terminates, setting the is_stopped() bit in the thread class. In response to this event, the daemon will call the close_contact method. In this case, the connection thread has already terminated so it is cleaned up when the Contact object goes away.

If the link is closed by the daemon thread due to user configuration or a scheduled link's open time elapsing, then close_contact will be called while the connection is still open. The connection thread is informed by sending it a BREAK_CONTACT command. Reception of this command closes the connection and terminates, setting the is_stopped() bit when it is done. All this logic is handled by the break_contact method in the Connection class.

Finally, for bidirectional protocols, opportunistic links can be created in response to new connections arriving from a peer node.

Definition at line 75 of file ConnectionConvergenceLayer.h.


Public Member Functions

 ConnectionConvergenceLayer (const char *logpath, const char *cl_name)
 Constructor.
virtual bool parse_nexthop (Link *link, LinkParams *params)=0
 Parse and validate the nexthop address for the given link.
bool init_link (Link *link, int argc, const char *argv[])
 Virtual from ConvergenceLayer.
void dump_link (Link *link, oasys::StringBuffer *buf)
 Virtual from ConvergenceLayer.
bool reconfigure_link (Link *link, int argc, const char *argv[])
 Virtual from ConvergenceLayer.
bool open_contact (const ContactRef &contact)
 Virtual from ConvergenceLayer.
bool close_contact (const ContactRef &contact)
 Virtual from ConvergenceLayer.
void send_bundle (const ContactRef &contact, Bundle *bundle)
 Virtual from ConvergenceLayer.

Protected Member Functions

virtual LinkParamsnew_link_params ()=0
 Create a new LinkParams structure.
virtual bool parse_link_params (LinkParams *params, int argc, const char **argv, const char **invalidp)
 Parse the link parameters, returning true iff the args are valid for the given nexthop address.
virtual bool finish_init_link (Link *link, LinkParams *params)
 After the link parameters are parsed, do any initialization of the link that's necessary before starting up a connection.
virtual CLConnectionnew_connection (LinkParams *params)=0
 Create a new CL-specific connection object.

Classes

class  LinkParams
 Tunable parameter structure stored in each Link's CLInfo slot. More...

Constructor & Destructor Documentation

dtn::ConnectionConvergenceLayer::ConnectionConvergenceLayer ( const char *  logpath,
const char *  cl_name 
)

Constructor.

Definition at line 41 of file ConnectionConvergenceLayer.cc.


Member Function Documentation

bool dtn::ConnectionConvergenceLayer::init_link ( Link link,
int  argc,
const char *  argv[] 
) [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

Definition at line 106 of file ConnectionConvergenceLayer.cc.

References finish_init_link(), log_debug, log_err, new_link_params(), dtn::Link::nexthop(), parse_link_params(), parse_nexthop(), dtn::Link::set_cl_info(), and dtn::Link::type_str().

void dtn::ConnectionConvergenceLayer::dump_link ( Link link,
oasys::StringBuffer buf 
) [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

Reimplemented in dtn::BluetoothConvergenceLayer, dtn::StreamConvergenceLayer, and dtn::TCPConvergenceLayer.

Definition at line 89 of file ConnectionConvergenceLayer.cc.

References oasys::StringBuffer::appendf(), ASSERT, dtn::ConnectionConvergenceLayer::LinkParams::busy_queue_depth_, dtn::Link::cl_info(), dtn::ConnectionConvergenceLayer::LinkParams::data_timeout_, dtn::ConnectionConvergenceLayer::LinkParams::reactive_frag_enabled_, dtn::ConnectionConvergenceLayer::LinkParams::recvbuf_len_, dtn::ConnectionConvergenceLayer::LinkParams::sendbuf_len_, dtn::ConnectionConvergenceLayer::LinkParams::test_read_delay_, dtn::ConnectionConvergenceLayer::LinkParams::test_recv_delay_, and dtn::ConnectionConvergenceLayer::LinkParams::test_write_delay_.

Referenced by dtn::StreamConvergenceLayer::dump_link().

bool dtn::ConnectionConvergenceLayer::reconfigure_link ( Link link,
int  argc,
const char *  argv[] 
) [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

Definition at line 149 of file ConnectionConvergenceLayer.cc.

References ASSERT, dtn::Link::cl_info(), dtn::Link::contact(), oasys::StreamBuffer::fullbytes(), dtn::Link::isopen(), log_err, log_info, parse_link_params(), dtn::CLConnection::recvbuf_, dtn::ConnectionConvergenceLayer::LinkParams::recvbuf_len_, dtn::CLConnection::sendbuf_, dtn::ConnectionConvergenceLayer::LinkParams::sendbuf_len_, oasys::StreamBuffer::set_size(), and oasys::StreamBuffer::size().

bool dtn::ConnectionConvergenceLayer::open_contact ( const ContactRef contact  )  [virtual]

Virtual from ConvergenceLayer.

Implements dtn::ConvergenceLayer.

Definition at line 190 of file ConnectionConvergenceLayer.cc.

References ASSERT, dtn::Link::cl_info(), log_debug, new_connection(), dtn::CLConnection::set_contact(), and oasys::Thread::start().

bool dtn::ConnectionConvergenceLayer::close_contact ( const ContactRef contact  )  [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

Definition at line 210 of file ConnectionConvergenceLayer.cc.

References ASSERT, dtn::CLConnection::CLMSG_BREAK_CONTACT, log_debug, log_info, oasys::Ref< _Type >::object(), and oasys::Thread::yield().

void dtn::ConnectionConvergenceLayer::send_bundle ( const ContactRef contact,
Bundle bundle 
) [virtual]

Virtual from ConvergenceLayer.

Implements dtn::ConvergenceLayer.

Definition at line 240 of file ConnectionConvergenceLayer.cc.

References ASSERT, log_debug, and oasys::Ref< _Type >::object().

virtual bool dtn::ConnectionConvergenceLayer::parse_nexthop ( Link link,
LinkParams params 
) [pure virtual]

Parse and validate the nexthop address for the given link.

Implemented in dtn::BluetoothConvergenceLayer, and dtn::TCPConvergenceLayer.

Referenced by init_link().

virtual LinkParams* dtn::ConnectionConvergenceLayer::new_link_params (  )  [protected, pure virtual]

Create a new LinkParams structure.

Implemented in dtn::BluetoothConvergenceLayer, and dtn::TCPConvergenceLayer.

Referenced by init_link().

bool dtn::ConnectionConvergenceLayer::parse_link_params ( LinkParams params,
int  argc,
const char **  argv,
const char **  invalidp 
) [protected, virtual]

Parse the link parameters, returning true iff the args are valid for the given nexthop address.

Reimplemented in dtn::BluetoothConvergenceLayer, dtn::StreamConvergenceLayer, and dtn::TCPConvergenceLayer.

Definition at line 49 of file ConnectionConvergenceLayer.cc.

References oasys::OptParser::addopt(), dtn::ConnectionConvergenceLayer::LinkParams::busy_queue_depth_, dtn::ConnectionConvergenceLayer::LinkParams::data_timeout_, oasys::OptParser::parse(), dtn::ConnectionConvergenceLayer::LinkParams::reactive_frag_enabled_, dtn::ConnectionConvergenceLayer::LinkParams::recvbuf_len_, dtn::ConnectionConvergenceLayer::LinkParams::sendbuf_len_, dtn::ConnectionConvergenceLayer::LinkParams::test_read_delay_, dtn::ConnectionConvergenceLayer::LinkParams::test_recv_delay_, and dtn::ConnectionConvergenceLayer::LinkParams::test_write_delay_.

Referenced by init_link(), dtn::StreamConvergenceLayer::parse_link_params(), and reconfigure_link().

bool dtn::ConnectionConvergenceLayer::finish_init_link ( Link link,
LinkParams params 
) [protected, virtual]

After the link parameters are parsed, do any initialization of the link that's necessary before starting up a connection.

Reimplemented in dtn::StreamConvergenceLayer.

Definition at line 140 of file ConnectionConvergenceLayer.cc.

Referenced by init_link().

virtual CLConnection* dtn::ConnectionConvergenceLayer::new_connection ( LinkParams params  )  [protected, pure virtual]

Create a new CL-specific connection object.

Implemented in dtn::BluetoothConvergenceLayer, and dtn::TCPConvergenceLayer.

Referenced by open_contact().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:36:22 2007 for DTN Reference Implementation by  doxygen 1.5.3