dtn::ConnectionConvergenceLayer Class Reference

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

#include <ConnectionConvergenceLayer.h>

Inheritance diagram for dtn::ConnectionConvergenceLayer:

dtn::ConvergenceLayer dtn::StreamConvergenceLayer dtn::SerialConvergenceLayer dtn::TCPConvergenceLayer

List of all members.

Classes

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

Public Member Functions

 ConnectionConvergenceLayer (const char *logpath, const char *cl_name)
 Constructor.
virtual bool parse_nexthop (const LinkRef &link, LinkParams *params)=0
 Parse and validate the nexthop address for the given link.
bool init_link (const LinkRef &link, int argc, const char *argv[])
 Virtual from ConvergenceLayer.
void delete_link (const LinkRef &link)
 Virtual from ConvergenceLayer.
void dump_link (const LinkRef &link, oasys::StringBuffer *buf)
 Virtual from ConvergenceLayer.
bool reconfigure_link (const LinkRef &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 bundle_queued (const LinkRef &link, const BundleRef &bundle)
 Virtual from ConvergenceLayer.
void cancel_bundle (const LinkRef &link, const BundleRef &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 (const LinkRef &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 (const LinkRef &link, LinkParams *params)=0
 Create a new CL-specific connection object.


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.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 45 of file ConnectionConvergenceLayer.cc.


Member Function Documentation

void dtn::ConnectionConvergenceLayer::bundle_queued ( const LinkRef link,
const BundleRef bundle 
) [virtual]

void dtn::ConnectionConvergenceLayer::cancel_bundle ( const LinkRef link,
const BundleRef bundle 
) [virtual]

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

void dtn::ConnectionConvergenceLayer::delete_link ( const LinkRef link  )  [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

Definition at line 156 of file ConnectionConvergenceLayer.cc.

References ASSERT.

void dtn::ConnectionConvergenceLayer::dump_link ( const LinkRef link,
oasys::StringBuffer *  buf 
) [virtual]

Virtual from ConvergenceLayer.

Reimplemented from dtn::ConvergenceLayer.

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

Definition at line 96 of file ConnectionConvergenceLayer.cc.

References ASSERT.

bool dtn::ConnectionConvergenceLayer::finish_init_link ( const LinkRef 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 180 of file ConnectionConvergenceLayer.cc.

Referenced by init_link().

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

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

Create a new CL-specific connection object.

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

Referenced by open_contact().

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

Create a new LinkParams structure.

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

Referenced by init_link().

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

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

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

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


The documentation for this class was generated from the following files:

Generated on Fri Jan 30 09:43:14 2009 for DTN Reference Implementation by  doxygen 1.5.8