dtn::TableBasedRouter Class Reference

#include <TableBasedRouter.h>

Inheritance diagram for dtn::TableBasedRouter:

dtn::BundleRouter dtn::BundleEventHandler oasys::Logger dtn::FloodBundleRouter dtn::NeighborhoodRouter dtn::ProphetRouter dtn::StaticBundleRouter dtn::TcaRouter List of all members.

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 51 of file TableBasedRouter.h.

Protected Member Functions

 TableBasedRouter (const char *classname, const std::string &name)
 Constructor -- protected since this class is never instantiated by itself.
virtual void handle_event (BundleEvent *event)
 Event handler overridden from BundleRouter / BundleEventHandler that dispatches to the type specific handlers where appropriate.
virtual void handle_bundle_received (BundleReceivedEvent *event)
 Handler for new bundle arrivals simply forwards the newly arrived bundle to all matching entries in the table.
virtual void handle_bundle_transmit_failed (BundleTransmitFailedEvent *event)
 Handler for transmission failures.
virtual void handle_route_add (RouteAddEvent *event)
 Default event handler when a new route is added by the command or management interface.
virtual void handle_route_del (RouteDelEvent *event)
 Default event handler when a route is deleted by the command or management interface.
virtual void handle_contact_up (ContactUpEvent *event)
 When a contact comes up, check to see if there are any matching bundles for it.
virtual void handle_link_available (LinkAvailableEvent *event)
 Ditto if a link becomes available.
virtual void handle_link_created (LinkCreatedEvent *event)
 If a link gets created with a remote eid, add the route.
virtual void handle_custody_timeout (CustodyTimeoutEvent *event)
 Handle a custody transfer timeout.
void get_routing_state (oasys::StringBuffer *buf)
 Dump 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.
virtual void 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 fwd_to_matching (Bundle *bundle, Link *this_link_only=NULL)
 Check the route table entries that match the given bundle and have not already been found in the bundle history.
virtual void check_next_hop (Link *next_hop)
 Called when the next hop link is available for transmission (i.e.

Protected Attributes

RouteTableroute_table_
 The static routing table.


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 49 of file TableBasedRouter.cc.

References route_table_.


Member Function Documentation

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 73 of file TableBasedRouter.cc.

References dtn::BundleEventHandler::dispatch_event().

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

Handler for new bundle arrivals simply forwards the newly arrived bundle to all matching entries in the table.

Reimplemented from dtn::BundleEventHandler.

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

Definition at line 80 of file TableBasedRouter.cc.

References dtn::BundleReceivedEvent::bundleref_, fwd_to_matching(), log_debug, and oasys::Ref< _Type >::object().

void dtn::TableBasedRouter::handle_bundle_transmit_failed ( BundleTransmitFailedEvent event  )  [protected, virtual]

Handler for transmission failures.

Reimplemented from dtn::BundleEventHandler.

Definition at line 89 of file TableBasedRouter.cc.

References dtn::BundleTransmitFailedEvent::bundleref_, fwd_to_matching(), log_debug, and oasys::Ref< _Type >::object().

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

Default event handler when a new route is added by the command or management interface.

Adds an entry to the route table, then walks the pending list to see if any bundles match the new route.

Reimplemented from dtn::BundleEventHandler.

Definition at line 98 of file TableBasedRouter.cc.

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

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

Default event handler when a route is deleted by the command or management interface.

Reimplemented from dtn::BundleEventHandler.

Definition at line 105 of file TableBasedRouter.cc.

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

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

When a contact comes up, check to see if there are any matching bundles for it.

Reimplemented from dtn::BundleEventHandler.

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

Definition at line 112 of file TableBasedRouter.cc.

References check_next_hop(), and dtn::ContactUpEvent::contact_.

Referenced by dtn::TcaRouter::handle_contact_up(), and dtn::NeighborhoodRouter::handle_contact_up().

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

Ditto if a link becomes available.

Reimplemented from dtn::BundleEventHandler.

Reimplemented in dtn::TcaRouter.

Definition at line 119 of file TableBasedRouter.cc.

References check_next_hop(), and dtn::LinkAvailableEvent::link_.

Referenced by dtn::TcaRouter::handle_link_available().

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

If a link gets created with a remote eid, add the route.

Reimplemented from dtn::BundleEventHandler.

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

Definition at line 126 of file TableBasedRouter.cc.

References dtn::BundleRouter::config_t::add_nexthop_routes_, dtn::BundleRouter::Config, dtn::EndpointID::equals(), dtn::ForwardingInfo::FORWARD_ACTION, dtn::LinkCreatedEvent::link_, dtn::EndpointID::NULL_EID(), dtn::BundleDaemon::post(), dtn::Link::remote_eid(), and dtn::EndpointID::str().

Referenced by dtn::ProphetRouter::handle_link_created().

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

Handle a custody transfer timeout.

Reimplemented from dtn::BundleEventHandler.

Definition at line 144 of file TableBasedRouter.cc.

References dtn::CustodyTimeoutEvent::bundle_, fwd_to_matching(), and oasys::Ref< _Type >::object().

void dtn::TableBasedRouter::get_routing_state ( oasys::StringBuffer buf  )  [protected, virtual]

Dump the routing state.

Implements dtn::BundleRouter.

Definition at line 158 of file TableBasedRouter.cc.

References oasys::StringBuffer::append(), oasys::StringBuffer::appendf(), dtn::RouteTable::dump(), dtn::BundleRouter::name_, and route_table_.

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

Add a route entry to the routing table.

Definition at line 58 of file TableBasedRouter.cc.

References dtn::RouteTable::add_entry(), check_next_hop(), dtn::RouteEntry::next_hop_, and route_table_.

Referenced by dtn::NeighborhoodRouter::handle_contact_up(), dtn::FloodBundleRouter::handle_link_created(), and handle_route_add().

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

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

Definition at line 66 of file TableBasedRouter.cc.

References dtn::RouteTable::del_entries(), and route_table_.

Referenced by handle_route_del().

void dtn::TableBasedRouter::fwd_to_nexthop ( Bundle bundle,
RouteEntry route 
) [protected, virtual]

Try to forward a bundle to a next hop route.

Definition at line 178 of file TableBasedRouter.cc.

References dtn::RouteEntry::action_, dtn::BundleRouter::actions_, dtn::RouteEntry::custody_timeout_, dtn::Link::isavailable(), dtn::Link::isbusy(), dtn::Link::isopen(), dtn::Link::isopening(), log_debug, dtn::RouteEntry::next_hop_, dtn::BundleActions::open_link(), and dtn::BundleActions::send_bundle().

Referenced by dtn::TcaRouter::fwd_to_all(), fwd_to_matching(), and dtn::TcaRouter::fwd_to_matching_r().

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 215 of file TableBasedRouter.cc.

References dtn::RouteEntry::action_, ASSERT, dtn::Bundle::bundleid_, count, dtn::ForwardingInfo::FORWARD_ACTION, dtn::Bundle::fwdlog_, dtn::ForwardingLog::get_latest_entry(), dtn::ForwardingInfo::IN_FLIGHT, info, log_debug, dtn::Link::name(), dtn::RouteEntry::next_hop_, dtn::ForwardingInfo::NONE, dtn::ForwardingInfo::state_to_str(), dtn::ForwardingInfo::TRANSMIT_FAILED, and dtn::ForwardingInfo::TRANSMITTED.

Referenced by fwd_to_matching().

int dtn::TableBasedRouter::fwd_to_matching ( Bundle bundle,
Link this_link_only = NULL 
) [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
this_link_only if specified, restricts forwarding to the given next hop link
Returns the number of matches found and assigned.

Reimplemented in dtn::TcaRouter.

Definition at line 272 of file TableBasedRouter.cc.

References dtn::Bundle::bundleid_, count, dtn::Bundle::dest_, fwd_to_nexthop(), dtn::RouteTable::get_matching(), log_debug, route_table_, should_fwd(), and dtn::RouteEntryVec::sort_by_priority().

Referenced by check_next_hop(), handle_bundle_received(), dtn::FloodBundleRouter::handle_bundle_received(), handle_bundle_transmit_failed(), and handle_custody_timeout().

void dtn::TableBasedRouter::check_next_hop ( Link 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 303 of file TableBasedRouter.cc.

References dtn::BundleList::begin(), dtn::BundleList::end(), fwd_to_matching(), ExamineDump::l, dtn::BundleList::lock(), log_debug, dtn::Link::nexthop(), and dtn::BundleRouter::pending_bundles_.

Referenced by add_route(), handle_contact_up(), and handle_link_available().


Member Data Documentation

RouteTable* dtn::TableBasedRouter::route_table_ [protected]

The static routing table.

Definition at line 166 of file TableBasedRouter.h.

Referenced by add_route(), dtn::TcaRouter::create_route(), del_route(), dtn::TcaRouter::fwd_to_all(), fwd_to_matching(), dtn::TcaRouter::fwd_to_matching_r(), get_routing_state(), dtn::ProphetRouter::handle_contact_down(), dtn::NeighborhoodRouter::handle_contact_down(), dtn::TcaRouter::handle_del_route(), dtn::TcaRouter::handle_get_routes(), and TableBasedRouter().


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