dtn::TableBasedRouter Class Reference

This is an abstract class that is intended to be used for all routing algorithms that store routing state in a table. More...

#include <TableBasedRouter.h>

Inheritance diagram for dtn::TableBasedRouter:
dtn::BundleRouter dtn::BundleEventHandler dtn::DTLSRRouter dtn::FloodBundleRouter dtn::StaticBundleRouter dtn::TcaRouter

List of all members.

Classes

class  DeferredList
 Per-link class used to store deferred transmission bundles that helps cache route computations. More...
class  RerouteTimer
 Timer class used to cancel transmission on down links after waiting for them to potentially reopen. More...
class  ResubscribeTimer
 Timer class used to periodically refresh subscriptions. More...

Protected Types

typedef oasys::StringMap
< RerouteTimer * > 
RerouteTimerMap
 Table of reroute timers, indexed by the link name.

Protected Member Functions

 TableBasedRouter (const char *classname, const std::string &name)
 Constructor -- protected since this class is never instantiated by itself.
virtual ~TableBasedRouter ()
 Destructor.
virtual void handle_event (BundleEvent *event)
 Event handler overridden from BundleRouter / BundleEventHandler that dispatches to the type specific handlers where appropriate.
void get_routing_state (oasys::StringBuffer *buf)
 Dump the routing state.
void tcl_dump_state (oasys::StringBuffer *buf)
 Get a tcl version of the routing state.
void add_route (RouteEntry *entry)
 Add a route entry to the routing table.
void del_route (const EndpointIDPattern &id)
 Remove matrhing route entry(s) from the routing table.
void handle_changed_routes ()
 Update forwarding state due to changed routes.
virtual bool fwd_to_nexthop (Bundle *bundle, RouteEntry *route)
 Try to forward a bundle to a next hop route.
virtual bool should_fwd (const Bundle *bundle, RouteEntry *route)
 Check if the bundle should be forwarded to the given next hop.
virtual int route_bundle (Bundle *bundle)
 Check the route table entries that match the given bundle and have not already been found in the bundle history.
virtual void sort_routes (Bundle *bundle, RouteEntryVec *routes)
 Once a vector of matching routes has been found, sort the vector.
virtual void check_next_hop (const LinkRef &next_hop)
 Called when the next hop link is available for transmission (i.e.
virtual void reroute_all_bundles ()
 Go through all known bundles in the system and try to re-route them.
virtual void recompute_routes ()
 Generic hook in response to the command line indication that we should reroute all bundles.
void add_nexthop_route (const LinkRef &link)
 When new links are added or opened, and if we're configured to add nexthop routes, try to add a new route for the given link.
bool can_delete_bundle (const BundleRef &bundle)
 Hook to ask the router if the bundle can be deleted.
void delete_bundle (const BundleRef &bundle)
 Hook to tell the router that the bundle should be deleted.
void remove_from_deferred (const BundleRef &bundle, int actions)
 Remove matching deferred transmission entries.
void reroute_bundles (const LinkRef &link)
 Helper function for rerouting.
DeferredListdeferred_list (const LinkRef &link)
 Helper accessor to return the deferred queue for a link.

virtual void handle_bundle_received (BundleReceivedEvent *event)
 Event handlers.
virtual void handle_bundle_transmitted (BundleTransmittedEvent *event)
 Event handlers.
virtual void handle_bundle_cancelled (BundleSendCancelledEvent *event)
 Event handlers.
virtual void handle_route_add (RouteAddEvent *event)
 Event handlers.
virtual void handle_route_del (RouteDelEvent *event)
 Event handlers.
virtual void handle_contact_up (ContactUpEvent *event)
 Event handlers.
virtual void handle_contact_down (ContactDownEvent *event)
 Event handlers.
virtual void handle_link_available (LinkAvailableEvent *event)
 Event handlers.
virtual void handle_link_created (LinkCreatedEvent *event)
 Event handlers.
virtual void handle_link_deleted (LinkDeletedEvent *event)
 Event handlers.
virtual void handle_custody_timeout (CustodyTimeoutEvent *event)
 Event handlers.
virtual void handle_registration_added (RegistrationAddedEvent *event)
 Event handlers.
virtual void handle_registration_removed (RegistrationRemovedEvent *event)
 Event handlers.
virtual void handle_registration_expired (RegistrationExpiredEvent *event)
 Event handlers.

Sessionget_session_for_bundle (Bundle *bundle)
 Session management helper functions.
bool add_bundle_to_session (Bundle *bundle, Session *session)
 Session management helper functions.
bool subscribe_to_session (int action, Session *session)
 Session management helper functions.
bool find_session_upstream (Session *session)
 Session management helper functions.
void reroute_all_sessions ()
 Session management helper functions.
bool handle_session_bundle (BundleReceivedEvent *event)
 Session management helper functions.
void add_subscriber (Session *session, const EndpointID &peer, const SequenceID &known_seqid)
 Session management helper functions.

Protected Attributes

BundleInfoCache reception_cache_
 Cache to check for duplicates and to implement a simple RPF check.
RouteTableroute_table_
 The routing table.
SessionTable sessions_
 Session state management table.
RegistrationList session_custodians_
 Vector of session custodian registrations.
RerouteTimerMap reroute_timers_

Friends

class RerouteTimer

Detailed Description

This is an abstract class that is intended to be used for all routing algorithms that store routing state in a table.

Definition at line 38 of file TableBasedRouter.h.


Member Typedef Documentation

typedef oasys::StringMap<RerouteTimer*> dtn::TableBasedRouter::RerouteTimerMap [protected]

Table of reroute timers, indexed by the link name.

Definition at line 223 of file TableBasedRouter.h.


Constructor & Destructor Documentation

dtn::TableBasedRouter::TableBasedRouter ( const char *  classname,
const std::string &  name 
) [protected]

Constructor -- protected since this class is never instantiated by itself.

Definition at line 35 of file TableBasedRouter.cc.

References route_table_.

dtn::TableBasedRouter::~TableBasedRouter (  )  [protected, virtual]

Destructor.

Definition at line 45 of file TableBasedRouter.cc.

References route_table_.


Member Function Documentation

bool dtn::TableBasedRouter::add_bundle_to_session ( Bundle bundle,
Session session 
) [protected]
void dtn::TableBasedRouter::add_nexthop_route ( const LinkRef link  )  [protected]

When new links are added or opened, and if we're configured to add nexthop routes, try to add a new route for the given link.

Definition at line 394 of file TableBasedRouter.cc.

References dtn::BundleRouter::Config::add_nexthop_routes_, add_route(), dtn::BundleRouter::config_, dtn::ForwardingInfo::FORWARD_ACTION, dtn::RouteTable::get_matching(), dtn::EndpointID::NULL_EID(), route_table_, and dtn::RouteEntry::set_action().

Referenced by handle_contact_up(), and handle_link_created().

void dtn::TableBasedRouter::add_route ( RouteEntry entry  )  [protected]

Add a route entry to the routing table.

Definition at line 52 of file TableBasedRouter.cc.

References dtn::RouteTable::add_entry(), handle_changed_routes(), and route_table_.

Referenced by add_nexthop_route(), and handle_route_add().

void dtn::TableBasedRouter::add_subscriber ( Session session,
const EndpointID peer,
const SequenceID known_seqid 
) [protected]
bool dtn::TableBasedRouter::can_delete_bundle ( const BundleRef bundle  )  [protected, virtual]

Hook to ask the router if the bundle can be deleted.

Reimplemented from dtn::BundleRouter.

Reimplemented in dtn::DTLSRRouter.

Definition at line 304 of file TableBasedRouter.cc.

References dtn::ForwardingInfo::DELIVERED, get_session_for_bundle(), dtn::Session::subscribers(), and dtn::ForwardingInfo::TRANSMITTED.

Referenced by dtn::DTLSRRouter::can_delete_bundle().

void dtn::TableBasedRouter::check_next_hop ( const LinkRef next_hop  )  [protected, virtual]

Called when the next hop link is available for transmission (i.e.

either when it first arrives and the contact is brought up or when a bundle is completed and it's no longer busy).

Loops through the bundle list and calls fwd_to_matching on all bundles.

Definition at line 802 of file TableBasedRouter.cc.

References dtn::ForwardingInfo::action(), dtn::BundleRouter::actions_, dtn::ForwardingInfo::custody_spec(), deferred_list(), info, dtn::BundleActions::open_link(), dtn::BundleActions::queue_bundle(), and dtn::BundleRouter::should_fwd().

Referenced by handle_bundle_transmitted(), handle_contact_up(), handle_link_available(), and route_bundle().

TableBasedRouter::DeferredList * dtn::TableBasedRouter::deferred_list ( const LinkRef link  )  [protected]

Helper accessor to return the deferred queue for a link.

Definition at line 990 of file TableBasedRouter.cc.

References ASSERT.

Referenced by check_next_hop(), fwd_to_nexthop(), remove_from_deferred(), and route_bundle().

void dtn::TableBasedRouter::del_route ( const EndpointIDPattern id  )  [protected]

Remove matrhing route entry(s) from the routing table.

Definition at line 60 of file TableBasedRouter.cc.

References dtn::RouteTable::del_entries(), dtn::BundleInfoCache::evict_all(), reception_cache_, and route_table_.

Referenced by handle_route_del().

void dtn::TableBasedRouter::delete_bundle ( const BundleRef bundle  )  [protected, virtual]

Hook to tell the router that the bundle should be deleted.

Reimplemented from dtn::BundleRouter.

Reimplemented in dtn::DTLSRRouter.

Definition at line 342 of file TableBasedRouter.cc.

References dtn::ForwardingInfo::ANY_ACTION, dtn::Session::bundles(), dtn::BundleList::erase(), get_session_for_bundle(), and remove_from_deferred().

bool dtn::TableBasedRouter::find_session_upstream ( Session session  )  [protected]
bool dtn::TableBasedRouter::fwd_to_nexthop ( Bundle bundle,
RouteEntry route 
) [protected, virtual]
void dtn::TableBasedRouter::get_routing_state ( oasys::StringBuffer *  buf  )  [protected, virtual]
Session * dtn::TableBasedRouter::get_session_for_bundle ( Bundle bundle  )  [protected]
void dtn::TableBasedRouter::handle_bundle_cancelled ( BundleSendCancelledEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 366 of file TableBasedRouter.cc.

References dtn::Bundle::expired(), and route_bundle().

void dtn::TableBasedRouter::handle_bundle_received ( BundleReceivedEvent event  )  [protected, virtual]
void dtn::TableBasedRouter::handle_bundle_transmitted ( BundleTransmittedEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::TcaRouter.

Definition at line 287 of file TableBasedRouter.cc.

References check_next_hop(), dtn::ForwardingInfo::FORWARD_ACTION, and remove_from_deferred().

void dtn::TableBasedRouter::handle_changed_routes (  )  [protected]

Update forwarding state due to changed routes.

Definition at line 73 of file TableBasedRouter.cc.

References dtn::BundleInfoCache::evict_all(), reception_cache_, reroute_all_bundles(), and reroute_all_sessions().

Referenced by add_route(), and dtn::DTLSRRouter::recompute_routes().

void dtn::TableBasedRouter::handle_contact_down ( ContactDownEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::DTLSRRouter, and dtn::TcaRouter.

Definition at line 484 of file TableBasedRouter.cc.

References ASSERT, reroute_timers_, and RerouteTimer.

void dtn::TableBasedRouter::handle_contact_up ( ContactUpEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::DTLSRRouter, and dtn::TcaRouter.

Definition at line 450 of file TableBasedRouter.cc.

References add_nexthop_route(), ASSERT, check_next_hop(), and reroute_timers_.

void dtn::TableBasedRouter::handle_custody_timeout ( CustodyTimeoutEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 608 of file TableBasedRouter.cc.

References dtn::CustodyTimeoutEvent::bundle_, and route_bundle().

void dtn::TableBasedRouter::handle_event ( BundleEvent event  )  [protected, virtual]

Event handler overridden from BundleRouter / BundleEventHandler that dispatches to the type specific handlers where appropriate.

Implements dtn::BundleRouter.

Definition at line 84 of file TableBasedRouter.cc.

References dtn::BundleEventHandler::dispatch_event().

void dtn::TableBasedRouter::handle_link_available ( LinkAvailableEvent event  )  [protected, virtual]
void dtn::TableBasedRouter::handle_link_created ( LinkCreatedEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::DTLSRRouter, and dtn::FloodBundleRouter.

Definition at line 577 of file TableBasedRouter.cc.

References add_nexthop_route(), and ASSERT.

void dtn::TableBasedRouter::handle_link_deleted ( LinkDeletedEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::DTLSRRouter.

Definition at line 590 of file TableBasedRouter.cc.

References ASSERT, dtn::RouteTable::del_entries_for_nexthop(), reroute_timers_, and route_table_.

void dtn::TableBasedRouter::handle_registration_added ( RegistrationAddedEvent event  )  [protected, virtual]
void dtn::TableBasedRouter::handle_registration_expired ( RegistrationExpiredEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 1342 of file TableBasedRouter.cc.

void dtn::TableBasedRouter::handle_registration_removed ( RegistrationRemovedEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 1335 of file TableBasedRouter.cc.

void dtn::TableBasedRouter::handle_route_add ( RouteAddEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 380 of file TableBasedRouter.cc.

References add_route(), and dtn::RouteAddEvent::entry_.

void dtn::TableBasedRouter::handle_route_del ( RouteDelEvent event  )  [protected, virtual]

Event handlers.

Reimplemented from dtn::BundleEventHandler.

Definition at line 387 of file TableBasedRouter.cc.

References del_route(), and dtn::RouteDelEvent::dest_.

bool dtn::TableBasedRouter::handle_session_bundle ( BundleReceivedEvent event  )  [protected]
void dtn::TableBasedRouter::recompute_routes (  )  [protected, virtual]

Generic hook in response to the command line indication that we should reroute all bundles.

Reimplemented from dtn::BundleRouter.

Reimplemented in dtn::DTLSRRouter.

Definition at line 902 of file TableBasedRouter.cc.

References reroute_all_bundles().

void dtn::TableBasedRouter::remove_from_deferred ( const BundleRef bundle,
int  actions 
) [protected]
void dtn::TableBasedRouter::reroute_all_bundles (  )  [protected, virtual]

Go through all known bundles in the system and try to re-route them.

Definition at line 880 of file TableBasedRouter.cc.

References dtn::BundleList::begin(), dtn::BundleList::end(), dtn::BundleList::lock(), dtn::BundleRouter::pending_bundles_, route_bundle(), and dtn::BundleList::size().

Referenced by handle_changed_routes(), and recompute_routes().

void dtn::TableBasedRouter::reroute_all_sessions (  )  [protected]
void dtn::TableBasedRouter::reroute_bundles ( const LinkRef link  )  [protected]
int dtn::TableBasedRouter::route_bundle ( Bundle bundle  )  [protected, virtual]

Check the route table entries that match the given bundle and have not already been found in the bundle history.

If a match is found, call fwd_to_nexthop on it.

Parameters:
bundle the bundle to forward

Returns the number of links on which the bundle was queued (i.e. the number of matching route entries.

Definition at line 728 of file TableBasedRouter.cc.

References dtn::Bundle::bundleid(), check_next_hop(), count, deferred_list(), dtn::Bundle::dest(), fwd_to_nexthop(), dtn::Bundle::fwdlog(), dtn::ForwardingLog::get_count(), dtn::RouteTable::get_matching(), dtn::RouteEntry::link(), route_table_, should_fwd(), sort_routes(), dtn::ForwardingInfo::SUPPRESSED, and dtn::EndpointIDPattern::WILDCARD_EID().

Referenced by add_subscriber(), handle_bundle_cancelled(), handle_bundle_received(), handle_custody_timeout(), and reroute_all_bundles().

bool dtn::TableBasedRouter::should_fwd ( const Bundle bundle,
RouteEntry route 
) [protected, virtual]

Check if the bundle should be forwarded to the given next hop.

Reasons why it would not be forwarded include that it was already transmitted or is currently in flight on the link, or that the route indicates ForwardingInfo::FORWARD_ACTION and it is already in flight on another route.

Definition at line 424 of file TableBasedRouter.cc.

References dtn::RouteEntry::action(), dtn::Bundle::bundleid(), dtn::RouteEntry::link(), dtn::BundleInfoCache::lookup(), dtn::EndpointID::NULL_EID(), and reception_cache_.

Referenced by route_bundle().

void dtn::TableBasedRouter::sort_routes ( Bundle bundle,
RouteEntryVec routes 
) [protected, virtual]

Once a vector of matching routes has been found, sort the vector.

The default uses the route priority, breaking ties by using the number of bytes queued.

Definition at line 794 of file TableBasedRouter.cc.

Referenced by route_bundle().

bool dtn::TableBasedRouter::subscribe_to_session ( int  action,
Session session 
) [protected]
void dtn::TableBasedRouter::tcl_dump_state ( oasys::StringBuffer *  buf  )  [protected, virtual]

Friends And Related Function Documentation

friend class RerouteTimer [friend]

Definition at line 217 of file TableBasedRouter.h.

Referenced by handle_contact_down().


Member Data Documentation

Cache to check for duplicates and to implement a simple RPF check.

Definition at line 191 of file TableBasedRouter.h.

Referenced by del_route(), handle_bundle_received(), handle_changed_routes(), and should_fwd().

Definition at line 224 of file TableBasedRouter.h.

Referenced by handle_contact_down(), handle_contact_up(), and handle_link_deleted().

Vector of session custodian registrations.

Definition at line 200 of file TableBasedRouter.h.

Referenced by find_session_upstream(), get_routing_state(), and handle_registration_added().


The documentation for this class was generated from the following files:
Generated on Sun Nov 21 11:41:12 2010 for DTN Reference Implementation by  doxygen 1.6.3