#include <BundleRouter.h>
It receives events from the BundleDaemon having been posted by other components. These events include all operations and occurrences that may affect bundle delivery, including new bundle arrival, contact arrival, timeouts, etc.
In response to each event the router may call one of the action functions implemented by the BundleDaemon. Note that to support the simulator environment, all interactions with the rest of the system should go through the singleton BundleAction classs.
To support prototyping of different routing protocols and frameworks, the base class has a list of prospective BundleRouter implementations, and at boot time, one of these is selected as the active routing algorithm. As new algorithms are added to the system, new cases should be added to the "create_router" function.
Definition at line 60 of file BundleRouter.h.
Public Member Functions | |
virtual | ~BundleRouter () |
Destructor. | |
virtual void | initialize () |
virtual void | handle_event (BundleEvent *event)=0 |
Pure virtual event handler function (copied from BundleEventHandler for clarity). | |
virtual bool | accept_bundle (Bundle *bundle, int *errp) |
Synchronous probe indicating whether or not this bundle should be accepted by the system. | |
virtual bool | can_delete_bundle (const BundleRef &bundle) |
Synchronous probe indicating whether or not this bundle can be deleted by the system. | |
virtual void | delete_bundle (const BundleRef &bundle) |
Synchronous call indicating that the bundle is being deleted from the system and that the router should remove it from any lists where it may be queued. | |
virtual void | get_routing_state (oasys::StringBuffer *buf)=0 |
Format the given StringBuffer with current routing info. | |
virtual bool | should_fwd (const Bundle *bundle, const LinkRef &link, ForwardingInfo::action_t action=ForwardingInfo::COPY_ACTION) |
Check if the bundle should be forwarded to the given next hop. | |
virtual void | tcl_dump_state (oasys::StringBuffer *buf) |
Format the given StringBuffer with a tcl-parsable version of the routing state. | |
virtual void | recompute_routes () |
Hook to force route recomputation from the command interpreter. | |
virtual void | shutdown () |
for registration with the BundleDaemon | |
Static Public Member Functions | |
static BundleRouter * | create_router (const char *type) |
Factory method to create the correct subclass of BundleRouter for the registered algorithm type. | |
Static Public Attributes | |
static struct dtn::BundleRouter::Config | config_ |
Config variables. | |
Protected Member Functions | |
BundleRouter (const char *classname, const std::string &name) | |
Constructor. | |
Protected Attributes | |
std::string | name_ |
Name of this particular router. | |
BundleList * | pending_bundles_ |
The list of all bundles still pending delivery. | |
BundleList * | custody_bundles_ |
The list of all bundles that I have custody of. | |
BundleActions * | actions_ |
The actions interface, set by the BundleDaemon when the router is initialized. | |
Classes | |
struct | Config |
Config variables. More... |
dtn::BundleRouter::~BundleRouter | ( | ) | [virtual] |
dtn::BundleRouter::BundleRouter | ( | const char * | classname, | |
const std::string & | name | |||
) | [protected] |
Constructor.
Definition at line 84 of file BundleRouter.cc.
References actions_, custody_bundles_, and pending_bundles_.
BundleRouter * dtn::BundleRouter::create_router | ( | const char * | type | ) | [static] |
Factory method to create the correct subclass of BundleRouter for the registered algorithm type.
Definition at line 53 of file BundleRouter.cc.
References dtn::TcaRouter::TCA_GATEWAY, and dtn::TcaRouter::TCA_ROUTER.
Referenced by dtn::BundleDaemon::run().
void dtn::BundleRouter::initialize | ( | ) | [virtual] |
Reimplemented in dtn::DTLSRRouter, dtn::FloodBundleRouter, and dtn::ProphetRouter.
Definition at line 190 of file BundleRouter.cc.
Referenced by dtnsim::Node::configure(), dtn::FloodBundleRouter::initialize(), dtn::DTLSRRouter::initialize(), and dtn::BundleDaemon::run().
virtual void dtn::BundleRouter::handle_event | ( | BundleEvent * | event | ) | [pure virtual] |
Pure virtual event handler function (copied from BundleEventHandler for clarity).
Implements dtn::BundleEventHandler.
Implemented in dtn::ProphetRouter, and dtn::TableBasedRouter.
Referenced by dtn::BundleDaemon::handle_event().
Synchronous probe indicating whether or not this bundle should be accepted by the system.
The default implementation checks if the bundle size will exceed the configured storage quota (if any).
Reimplemented in dtn::ProphetRouter.
Definition at line 201 of file BundleRouter.cc.
References dtn::BundlePayload::length(), dtn::Bundle::payload(), dtn::BundleStore::payload_quota(), dtn::BundleProtocol::REASON_DEPLETED_STORAGE, and dtn::BundleStore::total_size().
Referenced by dtn::ProphetRouter::accept_bundle(), dtn::BundleDaemon::handle_bundle_accept(), and dtn::BundleDaemon::handle_bundle_received().
Synchronous probe indicating whether or not this bundle can be deleted by the system.
The default implementation returns true if the bundle is queued on more than one list (i.e. the pending bundles list).
Reimplemented in dtn::DTLSRRouter, and dtn::TableBasedRouter.
Definition at line 224 of file BundleRouter.cc.
Referenced by dtn::BundleDaemon::try_to_delete().
void dtn::BundleRouter::delete_bundle | ( | const BundleRef & | bundle | ) | [virtual] |
Synchronous call indicating that the bundle is being deleted from the system and that the router should remove it from any lists where it may be queued.
Reimplemented in dtn::DTLSRRouter, and dtn::TableBasedRouter.
Definition at line 239 of file BundleRouter.cc.
Referenced by dtn::BundleDaemon::delete_bundle().
virtual void dtn::BundleRouter::get_routing_state | ( | oasys::StringBuffer * | buf | ) | [pure virtual] |
Format the given StringBuffer with current routing info.
Implemented in dtn::DTLSRRouter, dtn::ProphetRouter, and dtn::TableBasedRouter.
Referenced by dtn::BundleDaemon::get_routing_state().
bool dtn::BundleRouter::should_fwd | ( | const Bundle * | bundle, | |
const LinkRef & | link, | |||
ForwardingInfo::action_t | action = ForwardingInfo::COPY_ACTION | |||
) | [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 99 of file BundleRouter.cc.
References ASSERT, dtn::Bundle::bundleid(), count, dtn::ForwardingInfo::FORWARD_ACTION, dtn::Bundle::fwdlog(), dtn::ForwardingLog::get_count(), dtn::ForwardingLog::get_latest_entry(), info, dtn::ForwardingInfo::NONE, dtn::EndpointID::NULL_EID(), dtn::ForwardingInfo::QUEUED, dtn::Bundle::singleton_dest(), dtn::ForwardingInfo::state(), dtn::ForwardingInfo::state_to_str(), dtn::ForwardingInfo::SUPPRESSED, and dtn::ForwardingInfo::TRANSMITTED.
Referenced by dtn::TableBasedRouter::check_next_hop(), dtn::TableBasedRouter::should_fwd(), and dtn::ProphetBundleCore::should_fwd().
void dtn::BundleRouter::tcl_dump_state | ( | oasys::StringBuffer * | buf | ) | [virtual] |
Format the given StringBuffer with a tcl-parsable version of the routing state.
The expected format is:
{ {dest_eid1 nexthop_link1 [params]} {dest_eid2 nexthop_link2 [params]} }
where [params] is a var val list.
Reimplemented in dtn::TableBasedRouter.
Definition at line 246 of file BundleRouter.cc.
void dtn::BundleRouter::recompute_routes | ( | ) | [virtual] |
Hook to force route recomputation from the command interpreter.
The default implementation does nothing.
Reimplemented in dtn::DTLSRRouter, and dtn::TableBasedRouter.
Definition at line 253 of file BundleRouter.cc.
void dtn::BundleRouter::shutdown | ( | ) | [virtual] |
for registration with the BundleDaemon
Reimplemented in dtn::ProphetRouter.
Definition at line 259 of file BundleRouter.cc.
Config variables.
These must be static since they're set by the config parser before any router objects are created.
Definition at line 49 of file BundleRouter.cc.
Referenced by dtn::TableBasedRouter::add_nexthop_route(), dtn::DTLSRRouter::DTLSRRouter(), dtn::RouteTable::get_matching_helper(), dtn::TableBasedRouter::handle_link_available(), dtn::FloodBundleRouter::initialize(), dtn::RouteCommand::RouteCommand(), dtn::BundleDaemon::run(), and dtn::TableBasedRouter::subscribe_to_session().
std::string dtn::BundleRouter::name_ [protected] |
Name of this particular router.
Definition at line 194 of file BundleRouter.h.
Referenced by dtn::TableBasedRouter::get_routing_state().
BundleList* dtn::BundleRouter::pending_bundles_ [protected] |
The list of all bundles still pending delivery.
Definition at line 197 of file BundleRouter.h.
Referenced by BundleRouter(), and dtn::TableBasedRouter::reroute_all_bundles().
BundleList* dtn::BundleRouter::custody_bundles_ [protected] |
The list of all bundles that I have custody of.
Definition at line 200 of file BundleRouter.h.
Referenced by BundleRouter().
BundleActions* dtn::BundleRouter::actions_ [protected] |
The actions interface, set by the BundleDaemon when the router is initialized.
Definition at line 204 of file BundleRouter.h.
Referenced by BundleRouter(), dtn::TableBasedRouter::check_next_hop(), dtn::TableBasedRouter::fwd_to_nexthop(), dtn::TableBasedRouter::handle_link_available(), dtn::ProphetRouter::handle_link_available(), dtn::ProphetRouter::initialize(), and dtn::TableBasedRouter::reroute_bundles().