dtn::CLConnection Class Reference

#include <CLConnection.h>

Inheritance diagram for dtn::CLConnection:

dtn::CLInfo oasys::Thread oasys::Logger dtn::StreamConvergenceLayer::Connection List of all members.

Detailed Description

Helper class (and thread) that manages an established connection with a peer daemon.

Definition at line 58 of file CLConnection.h.

Public Types

typedef ConnectionConvergenceLayer::LinkParams LinkParams

Public Member Functions

 CLConnection (const char *classname, const char *logpath, ConvergenceLayer *cl, LinkParams *params, bool active_connector)
 Constructor.
virtual ~CLConnection ()
 Destructor.
void set_contact (const ContactRef &contact)
 Attach to the given contact.

Protected Types

enum  clmsg_t { CLMSG_INVALID = 0, CLMSG_SEND_BUNDLE = 1, CLMSG_CANCEL_BUNDLE = 2, CLMSG_BREAK_CONTACT = 3 }
 Enum for messages from the daemon thread to the connection thread. More...
typedef oasys::SparseBitmap<
size_t > 
DataBitmap
 Typedef for bitmaps used to record sent/received/acked data.
typedef std::list< InFlightBundle * > InFlightList
 Typedef for the list of in-flight bundles.
typedef std::list< IncomingBundle * > IncomingList
 Typedef for the list of in-flight bundles.

Protected Member Functions

void run ()
 Main run loop.
void set_nexthop (const std::string &nexthop)
 Assignment function for the nexthop identifier.
virtual void connect ()=0
 Initiate a connection to the remote side.
virtual void accept ()=0
 Accept a connection from the remote side.
virtual void disconnect ()=0
 Shut down the connection.
virtual void initialize_pollfds ()=0
 Fill in the pollfds array with any file descriptors that should be waited on for activity from the peer.
virtual void handle_send_bundle (Bundle *b)=0
 Handle a newly arriving bundle for transmission.
virtual void handle_cancel_bundle (Bundle *b)=0
 Handle a cancel bundle request.
virtual bool send_pending_data ()=0
 Start or continue transmission of bundle data or cl acks.
virtual void handle_poll_activity ()=0
 Handle network activity from the remote side.
virtual void handle_poll_timeout ()=0
 Handle network activity from the remote side.
const char * clmsg_to_str (clmsg_t type)
 Message to string conversion.
void contact_up ()
 Utility functions.
void break_contact (ContactEvent::reason_t reason)
 Utility functions.
void close_contact ()
 Utility functions.
void process_command ()
 Utility functions.
void handle_announce_bundle (Bundle *bundle)
 Utility functions.

Protected Attributes

ContactRef contact_
 Ref to the Contact.
bool contact_up_
 Has contact_up been called.
oasys::MsgQueue< CLMsgcmdqueue_
 Queue of commands from daemon.
ConvergenceLayercl_
 Pointer to the CL.
LinkParamsparams_
 Pointer to Link parameters, or to defaults until Link is bound.
bool active_connector_
 Should we connect() or accept().
std::string nexthop_
 Nexthop identifier set by CL.
int num_pollfds_
 Number of pollfds in use.
pollfd pollfds_ [MAXPOLL]
 Array of pollfds.
int poll_timeout_
 Timeout to wait for poll data.
oasys::StreamBuffer sendbuf_
 Buffer for outgoing data.
oasys::StreamBuffer recvbuf_
 Buffer for incoming data.
InFlightList inflight_
 Bundles going out the wire.
IncomingList incoming_
 Bundles arriving on the wire.
volatile bool contact_broken_
 Contact has been broken.

Static Protected Attributes

static const int MAXPOLL = 8
 Maximum number of pollfds.

Friends

class ConnectionConvergenceLayer

Classes

struct  CLMsg
 struct used for messages going from the daemon thread to the connection thread. More...
class  IncomingBundle
 Struct used to record bundles that are in the process of being received along with their transmission state and relevant acknowledgement data. More...
class  InFlightBundle
 Struct used to record bundles that are in-flight along with their transmission state and optionally acknowledgement data. More...


Member Typedef Documentation

typedef ConnectionConvergenceLayer::LinkParams dtn::CLConnection::LinkParams

Definition at line 63 of file CLConnection.h.

typedef oasys::SparseBitmap<size_t> dtn::CLConnection::DataBitmap [protected]

Typedef for bitmaps used to record sent/received/acked data.

Definition at line 203 of file CLConnection.h.

typedef std::list<InFlightBundle*> dtn::CLConnection::InFlightList [protected]

Typedef for the list of in-flight bundles.

Definition at line 235 of file CLConnection.h.

typedef std::list<IncomingBundle*> dtn::CLConnection::IncomingList [protected]

Typedef for the list of in-flight bundles.

Definition at line 266 of file CLConnection.h.


Member Enumeration Documentation

enum dtn::CLConnection::clmsg_t [protected]

Enum for messages from the daemon thread to the connection thread.

Enumerator:
CLMSG_INVALID 
CLMSG_SEND_BUNDLE 
CLMSG_CANCEL_BUNDLE 
CLMSG_BREAK_CONTACT 

Definition at line 163 of file CLConnection.h.


Constructor & Destructor Documentation

dtn::CLConnection::CLConnection ( const char *  classname,
const char *  logpath,
ConvergenceLayer cl,
LinkParams params,
bool  active_connector 
)

Constructor.

Definition at line 49 of file CLConnection.cc.

References params_, recvbuf_, dtn::ConnectionConvergenceLayer::LinkParams::recvbuf_len_, oasys::StreamBuffer::reserve(), sendbuf_, and dtn::ConnectionConvergenceLayer::LinkParams::sendbuf_len_.

dtn::CLConnection::~CLConnection (  )  [virtual]

Destructor.

Definition at line 71 of file CLConnection.cc.


Member Function Documentation

void dtn::CLConnection::set_contact ( const ContactRef contact  )  [inline]

Attach to the given contact.

Definition at line 82 of file CLConnection.h.

References contact_.

Referenced by dtn::ConnectionConvergenceLayer::open_contact().

void dtn::CLConnection::run (  )  [protected, virtual]

Main run loop.

Implements oasys::Thread.

Definition at line 77 of file CLConnection.cc.

References accept(), active_connector_, break_contact(), dtn::ContactEvent::BROKEN, cmdqueue_, connect(), contact_broken_, handle_poll_activity(), handle_poll_timeout(), initialize_pollfds(), oasys::IOTIMEOUT, log_debug, log_err, oasys::Logger::logpath_, num_pollfds_, oasys::IO::poll_multiple(), poll_timeout_, pollfds_, process_command(), and send_pending_data().

void dtn::CLConnection::contact_up (  )  [protected]

Utility functions.

Definition at line 202 of file CLConnection.cc.

References ASSERT, contact_, contact_up_, log_debug, and dtn::BundleDaemon::post().

Referenced by dtn::StreamConvergenceLayer::Connection::handle_contact_initiation().

void dtn::CLConnection::break_contact ( ContactEvent::reason_t  reason  )  [protected]

Utility functions.

Definition at line 215 of file CLConnection.cc.

References dtn::ContactEvent::BROKEN, dtn::Link::CLOSED, contact_, contact_broken_, disconnect(), log_debug, dtn::BundleDaemon::post(), dtn::ContactEvent::reason_to_str(), and dtn::ContactEvent::USER.

Referenced by dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::StreamConvergenceLayer::Connection::handle_data_todo(), dtn::StreamConvergenceLayer::Connection::handle_end_bundle(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::StreamConvergenceLayer::Connection::handle_shutdown(), dtn::StreamConvergenceLayer::Connection::handle_start_bundle(), process_command(), dtn::StreamConvergenceLayer::Connection::process_data(), and run().

void dtn::CLConnection::close_contact (  )  [protected]

Utility functions.

Definition at line 242 of file CLConnection.cc.

References ASSERT, CLMSG_SEND_BUNDLE, clmsg_to_str(), cmdqueue_, contact_, dtn::EVENTSRC_PEER, incoming_, inflight_, log_debug, log_warn, dtn::BundleDaemon::post(), and dtn::ConnectionConvergenceLayer::LinkParams::reactive_frag_enabled_.

void dtn::CLConnection::process_command (  )  [protected]

Utility functions.

Definition at line 160 of file CLConnection.cc.

References ASSERT, dtn::Link::AVAILABLE, break_contact(), dtn::CLConnection::CLMsg::bundle_, dtn::Link::BUSY, dtn::ConnectionConvergenceLayer::LinkParams::busy_queue_depth_, CLMSG_BREAK_CONTACT, CLMSG_CANCEL_BUNDLE, CLMSG_SEND_BUNDLE, cmdqueue_, contact_, handle_cancel_bundle(), handle_send_bundle(), log_debug, oasys::Ref< _Type >::object(), params_, dtn::BundleDaemon::post(), dtn::CLConnection::CLMsg::type_, dtn::ContactEvent::UNBLOCKED, and dtn::ContactEvent::USER.

Referenced by run().

void dtn::CLConnection::handle_announce_bundle ( Bundle bundle  )  [protected]

Utility functions.

Definition at line 357 of file CLConnection.cc.

References ASSERT, dtn::Link::AVAILABLE, dtn::EndpointID::c_str(), cl_, dtn::Link::cl_info(), contact_, dtn::BundleDaemon::contactmgr(), dtn::ContactManager::find_link_to(), dtn::BundleDaemon::instance(), dtn::Link::isopen(), log_debug, dtn::ContactManager::new_opportunistic_link(), nexthop_, dtn::Link::OPPORTUNISTIC, params_, dtn::Link::set_contact(), dtn::Link::set_nexthop(), dtn::Bundle::source_, and dtn::Link::UNAVAILABLE.

Referenced by dtn::StreamConvergenceLayer::Connection::handle_contact_initiation().

void dtn::CLConnection::set_nexthop ( const std::string &  nexthop  )  [inline, protected]

Assignment function for the nexthop identifier.

Definition at line 102 of file CLConnection.h.

References nexthop_.

virtual void dtn::CLConnection::connect (  )  [protected, pure virtual]

Initiate a connection to the remote side.

Referenced by run().

virtual void dtn::CLConnection::accept (  )  [protected, pure virtual]

Accept a connection from the remote side.

Referenced by run().

virtual void dtn::CLConnection::disconnect (  )  [protected, pure virtual]

Shut down the connection.

Referenced by break_contact().

virtual void dtn::CLConnection::initialize_pollfds (  )  [protected, pure virtual]

Fill in the pollfds array with any file descriptors that should be waited on for activity from the peer.

Referenced by run().

virtual void dtn::CLConnection::handle_send_bundle ( Bundle b  )  [protected, pure virtual]

Handle a newly arriving bundle for transmission.

Implemented in dtn::StreamConvergenceLayer::Connection.

Referenced by process_command().

virtual void dtn::CLConnection::handle_cancel_bundle ( Bundle b  )  [protected, pure virtual]

Handle a cancel bundle request.

Implemented in dtn::StreamConvergenceLayer::Connection.

Referenced by process_command().

virtual bool dtn::CLConnection::send_pending_data (  )  [protected, pure virtual]

Start or continue transmission of bundle data or cl acks.

This is called each time through the main run loop. Note that in general, this function should send one "unit" of data, i.e. a chunk of bundle data, a packet, etc.

Returns:
true if some data was sent, which will trigger another call, or false if the main loop should poll() on the socket before calling again

Implemented in dtn::StreamConvergenceLayer::Connection.

Referenced by run().

virtual void dtn::CLConnection::handle_poll_activity (  )  [protected, pure virtual]

Handle network activity from the remote side.

Referenced by run().

virtual void dtn::CLConnection::handle_poll_timeout (  )  [protected, pure virtual]

Handle network activity from the remote side.

Implemented in dtn::StreamConvergenceLayer::Connection.

Referenced by run().

const char* dtn::CLConnection::clmsg_to_str ( clmsg_t  type  )  [inline, protected]

Message to string conversion.

Definition at line 173 of file CLConnection.h.

References CLMSG_BREAK_CONTACT, CLMSG_CANCEL_BUNDLE, CLMSG_INVALID, and CLMSG_SEND_BUNDLE.

Referenced by close_contact().


Friends And Related Function Documentation

friend class ConnectionConvergenceLayer [friend]

Definition at line 62 of file CLConnection.h.


Member Data Documentation

ContactRef dtn::CLConnection::contact_ [protected]

Ref to the Contact.

Definition at line 268 of file CLConnection.h.

Referenced by break_contact(), close_contact(), contact_up(), dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), handle_announce_bundle(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), process_command(), and set_contact().

bool dtn::CLConnection::contact_up_ [protected]

Has contact_up been called.

Definition at line 269 of file CLConnection.h.

Referenced by contact_up(), dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), and dtn::StreamConvergenceLayer::Connection::process_data().

oasys::MsgQueue<CLMsg> dtn::CLConnection::cmdqueue_ [protected]

Queue of commands from daemon.

Definition at line 270 of file CLConnection.h.

Referenced by close_contact(), process_command(), and run().

ConvergenceLayer* dtn::CLConnection::cl_ [protected]

Pointer to the CL.

Definition at line 271 of file CLConnection.h.

Referenced by handle_announce_bundle(), dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), and dtn::StreamConvergenceLayer::Connection::initiate_contact().

LinkParams* dtn::CLConnection::params_ [protected]

Pointer to Link parameters, or to defaults until Link is bound.

Definition at line 272 of file CLConnection.h.

Referenced by CLConnection(), handle_announce_bundle(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), process_command(), and dtn::StreamConvergenceLayer::Connection::stream_lparams().

bool dtn::CLConnection::active_connector_ [protected]

Should we connect() or accept().

Definition at line 274 of file CLConnection.h.

Referenced by run().

std::string dtn::CLConnection::nexthop_ [protected]

Nexthop identifier set by CL.

Definition at line 275 of file CLConnection.h.

Referenced by handle_announce_bundle(), and set_nexthop().

int dtn::CLConnection::num_pollfds_ [protected]

Number of pollfds in use.

Definition at line 276 of file CLConnection.h.

Referenced by run().

const int dtn::CLConnection::MAXPOLL = 8 [static, protected]

Maximum number of pollfds.

Definition at line 277 of file CLConnection.h.

struct pollfd dtn::CLConnection::pollfds_[MAXPOLL] [protected]

Array of pollfds.

Definition at line 278 of file CLConnection.h.

Referenced by run().

int dtn::CLConnection::poll_timeout_ [protected]

Timeout to wait for poll data.

Definition at line 279 of file CLConnection.h.

Referenced by run().

oasys::StreamBuffer dtn::CLConnection::sendbuf_ [protected]

Buffer for outgoing data.

Definition at line 280 of file CLConnection.h.

Referenced by CLConnection(), dtn::StreamConvergenceLayer::Connection::finish_bundle(), dtn::StreamConvergenceLayer::Connection::initiate_contact(), dtn::ConnectionConvergenceLayer::reconfigure_link(), dtn::StreamConvergenceLayer::Connection::send_data_todo(), dtn::StreamConvergenceLayer::Connection::send_keepalive(), dtn::StreamConvergenceLayer::Connection::send_next_segment(), dtn::StreamConvergenceLayer::Connection::send_pending_acks(), dtn::StreamConvergenceLayer::Connection::send_pending_data(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().

oasys::StreamBuffer dtn::CLConnection::recvbuf_ [protected]

Buffer for incoming data.

Definition at line 281 of file CLConnection.h.

Referenced by CLConnection(), dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::StreamConvergenceLayer::Connection::handle_data_todo(), dtn::StreamConvergenceLayer::Connection::handle_end_bundle(), dtn::StreamConvergenceLayer::Connection::handle_keepalive(), dtn::StreamConvergenceLayer::Connection::handle_shutdown(), dtn::StreamConvergenceLayer::Connection::handle_start_bundle(), dtn::StreamConvergenceLayer::Connection::process_data(), and dtn::ConnectionConvergenceLayer::reconfigure_link().

InFlightList dtn::CLConnection::inflight_ [protected]

Bundles going out the wire.

Definition at line 282 of file CLConnection.h.

Referenced by dtn::StreamConvergenceLayer::Connection::check_completed(), close_contact(), dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::Connection::handle_send_bundle(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().

IncomingList dtn::CLConnection::incoming_ [protected]

Bundles arriving on the wire.

Definition at line 283 of file CLConnection.h.

Referenced by close_contact(), dtn::StreamConvergenceLayer::Connection::handle_data_segment(), dtn::StreamConvergenceLayer::Connection::handle_data_todo(), dtn::StreamConvergenceLayer::Connection::handle_end_bundle(), dtn::StreamConvergenceLayer::Connection::handle_start_bundle(), and dtn::StreamConvergenceLayer::Connection::send_pending_acks().

volatile bool dtn::CLConnection::contact_broken_ [protected]

Contact has been broken.

Definition at line 284 of file CLConnection.h.

Referenced by break_contact(), dtn::StreamConvergenceLayer::Connection::process_data(), run(), dtn::StreamConvergenceLayer::Connection::send_data_todo(), dtn::StreamConvergenceLayer::Connection::send_pending_acks(), dtn::StreamConvergenceLayer::Connection::send_pending_data(), and dtn::StreamConvergenceLayer::Connection::start_next_bundle().


The documentation for this class was generated from the following files:
Generated on Fri Dec 22 14:48:04 2006 for DTN Reference Implementation by  doxygen 1.5.1