dtn::CLConnection Class Reference

#include <CLConnection.h>

Inheritance diagram for dtn::CLConnection:

dtn::CLInfo oasys::Thread oasys::Logger oasys::SerializableObject 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 38 of file CLConnection.h.


Public Types

typedef
ConnectionConvergenceLayer::LinkParams 
LinkParams

Public Member Functions

 CLConnection (const char *classname, const char *logpath, ConnectionConvergenceLayer *cl, LinkParams *params, bool active_connector)
 Constructor.
virtual ~CLConnection ()
 Destructor.
void set_contact (const ContactRef &contact)
 Attach to the given contact.
void queue_bundle (Bundle *bundle)
 Queue a bundle for transmission.

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
< u_int32_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.
virtual void check_unblock_link ()
virtual void contact_up ()
virtual void break_contact (ContactEvent::reason_t reason)
virtual void close_contact ()
virtual void process_command ()
virtual void find_contact (const EndpointID &peer_eid)

Protected Attributes

ContactRef contact_
 Ref to the Contact.
bool contact_up_
 Has contact_up been called.
oasys::MsgQueue< CLMsgcmdqueue_
 Queue of commands from daemon.
ConnectionConvergenceLayercl_
 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.
struct 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.
oasys::atomic_t num_pending_
 Bundles pending transmission.

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 43 of file CLConnection.h.

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

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

Definition at line 189 of file CLConnection.h.

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

Typedef for the list of in-flight bundles.

Definition at line 221 of file CLConnection.h.

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

Typedef for the list of in-flight bundles.

Definition at line 251 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 149 of file CLConnection.h.


Constructor & Destructor Documentation

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

Constructor.

Definition at line 28 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 51 of file CLConnection.cc.


Member Function Documentation

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

Attach to the given contact.

Definition at line 62 of file CLConnection.h.

References contact_.

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

void dtn::CLConnection::queue_bundle ( Bundle bundle  ) 

Queue a bundle for transmission.

Definition at line 143 of file CLConnection.cc.

References ASSERT, oasys::atomic_incr(), dtn::Link::BUSY, dtn::ConnectionConvergenceLayer::LinkParams::busy_queue_depth_, CLMSG_SEND_BUNDLE, cmdqueue_, contact_, log_debug, num_pending_, and oasys::atomic_t::value.

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

Main run loop.

Implements oasys::Thread.

Definition at line 57 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::check_unblock_link (  )  [protected, virtual]

Utility functions, all virtual so subclasses could override them

Definition at line 203 of file CLConnection.cc.

References ASSERT, oasys::atomic_decr(), dtn::Link::AVAILABLE, dtn::Link::BUSY, dtn::ConnectionConvergenceLayer::LinkParams::busy_queue_depth_, contact_, log_debug, num_pending_, dtn::BundleDaemon::post_at_head(), dtn::ContactEvent::UNBLOCKED, and oasys::atomic_t::value.

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

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

Utility functions, all virtual so subclasses could override them

Definition at line 243 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, virtual]

Utility functions, all virtual so subclasses could override them

Reimplemented in dtn::StreamConvergenceLayer::Connection.

Definition at line 256 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::break_contact(), process_command(), and run().

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

Utility functions, all virtual so subclasses could override them

Definition at line 283 of file CLConnection.cc.

References dtn::CLConnection::InFlightBundle::ack_data_, ASSERT, dtn::CLConnection::CLMsg::bundle_, dtn::CLConnection::IncomingBundle::bundle_, dtn::CLConnection::InFlightBundle::bundle_, CLMSG_SEND_BUNDLE, clmsg_to_str(), cmdqueue_, contact_, oasys::SparseBitmap< _inttype_t >::empty(), dtn::EVENTSRC_PEER, incoming_, inflight_, oasys::SparseBitmap< _inttype_t >::last(), log_debug, log_warn, oasys::SparseBitmap< _inttype_t >::num_contiguous(), oasys::Ref< _Type >::object(), dtn::BundleProtocol::payload_offset(), dtn::BundleDaemon::post(), dtn::CLConnection::IncomingBundle::rcvd_data_, dtn::ConnectionConvergenceLayer::LinkParams::reactive_frag_enabled_, dtn::CLConnection::InFlightBundle::sent_data_, dtn::CLConnection::IncomingBundle::total_length_, and dtn::CLConnection::CLMsg::type_.

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

Utility functions, all virtual so subclasses could override them

Definition at line 175 of file CLConnection.cc.

References ASSERT, break_contact(), dtn::CLConnection::CLMsg::bundle_, CLMSG_BREAK_CONTACT, CLMSG_CANCEL_BUNDLE, CLMSG_SEND_BUNDLE, cmdqueue_, handle_cancel_bundle(), handle_send_bundle(), log_debug, oasys::Ref< _Type >::object(), dtn::CLConnection::CLMsg::type_, and dtn::ContactEvent::USER.

Referenced by run().

void dtn::CLConnection::find_contact ( const EndpointID peer_eid  )  [protected, virtual]

Utility functions, all virtual so subclasses could override them

Definition at line 382 of file CLConnection.cc.

References ASSERT, dtn::Link::AVAILABLE, cl_, contact_, dtn::ContactManager::find_link_to(), ExamineDump::l, dtn::ContactManager::lock(), log_debug, log_warn, dtn::ContactManager::new_opportunistic_link(), nexthop_, dtn::Link::OPPORTUNISTIC, params_, dtn::Link::set_nexthop(), 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 88 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 159 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 42 of file CLConnection.h.


Member Data Documentation

ContactRef dtn::CLConnection::contact_ [protected]

Ref to the Contact.

Definition at line 253 of file CLConnection.h.

Referenced by break_contact(), dtn::StreamConvergenceLayer::Connection::check_completed(), dtn::StreamConvergenceLayer::Connection::check_keepalive(), check_unblock_link(), close_contact(), contact_up(), find_contact(), dtn::StreamConvergenceLayer::Connection::handle_ack_segment(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::StreamConvergenceLayer::Connection::handle_send_bundle(), queue_bundle(), and set_contact().

bool dtn::CLConnection::contact_up_ [protected]

Has contact_up been called.

Definition at line 254 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 255 of file CLConnection.h.

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

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

Pointer to the CL.

Definition at line 256 of file CLConnection.h.

Referenced by find_contact(), 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 257 of file CLConnection.h.

Referenced by dtn::StreamConvergenceLayer::Connection::check_keepalive(), CLConnection(), find_contact(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), dtn::StreamConvergenceLayer::Connection::send_data(), dtn::StreamConvergenceLayer::Connection::stream_lparams(), and dtn::TCPConvergenceLayer::Connection::tcp_lparams().

bool dtn::CLConnection::active_connector_ [protected]

Should we connect() or accept().

Definition at line 259 of file CLConnection.h.

Referenced by run().

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

Nexthop identifier set by CL.

Definition at line 260 of file CLConnection.h.

Referenced by find_contact(), and set_nexthop().

int dtn::CLConnection::num_pollfds_ [protected]

Number of pollfds in use.

Definition at line 261 of file CLConnection.h.

Referenced by run().

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

Maximum number of pollfds.

Definition at line 262 of file CLConnection.h.

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

Array of pollfds.

Definition at line 263 of file CLConnection.h.

Referenced by run().

int dtn::CLConnection::poll_timeout_ [protected]

Timeout to wait for poll data.

Definition at line 264 of file CLConnection.h.

Referenced by dtn::StreamConvergenceLayer::Connection::handle_contact_initiation(), dtn::StreamConvergenceLayer::Connection::handle_poll_timeout(), and run().

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

Buffer for outgoing data.

Definition at line 265 of file CLConnection.h.

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

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

Buffer for incoming data.

Definition at line 266 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_keepalive(), dtn::StreamConvergenceLayer::Connection::handle_shutdown(), dtn::StreamConvergenceLayer::Connection::process_data(), and dtn::ConnectionConvergenceLayer::reconfigure_link().

InFlightList dtn::CLConnection::inflight_ [protected]

Bundles going out the wire.

Definition at line 267 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 268 of file CLConnection.h.

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

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

Contact has been broken.

Definition at line 269 of file CLConnection.h.

Referenced by break_contact(), dtn::StreamConvergenceLayer::Connection::process_data(), run(), dtn::StreamConvergenceLayer::Connection::send_data(), 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().

oasys::atomic_t dtn::CLConnection::num_pending_ [protected]

Bundles pending transmission.

Definition at line 270 of file CLConnection.h.

Referenced by dtn::StreamConvergenceLayer::Connection::check_keepalive(), check_unblock_link(), and queue_bundle().


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