#include <ForwardingLog.h>
Inheritance diagram for dtn::ForwardingLog:
This state can be (and is) used by the router logic to prevent it from naively forwarding a bundle to the same next hop multiple times. It also is used to store the custody timer spec as supplied by the router so the main forwarding engine knows how to set the appropriate timer.
Although a bundle can be sent over multiple links, and may even be sent over the same link multiple times, the forwarding logic assumes that for a given link and bundle, there is only one active transmission. Thus the accessors below always return / update the last entry in the log for a given link.
Definition at line 51 of file ForwardingLog.h.
Public Types | |
typedef ForwardingInfo::state_t | state_t |
typedef std::vector< ForwardingInfo > | Log |
Typedef for the log itself. | |
Public Member Functions | |
ForwardingLog (oasys::SpinLock *lock) | |
Constructor that takes a pointer to the relevant Bundle's lock, used when querying or updating the log. | |
bool | get_latest_entry (Link *link, ForwardingInfo *info) const |
Get the most recent entry for the given link from the log. | |
state_t | get_latest_entry (Link *link) const |
Get the most recent state for the given link from the log. | |
size_t | get_transmission_count (ForwardingInfo::action_t action=ForwardingInfo::INVALID_ACTION, bool include_inflight=false) const |
Return the transmission count of the bundle, optionally including inflight entries as well. | |
void | add_entry (Link *link, ForwardingInfo::action_t action, state_t state, const CustodyTimerSpec &custody_timer) |
Add a new forwarding info entry for the given link. | |
bool | update (Link *link, state_t state) |
Update the state for the latest forwarding info entry for the given link. | |
size_t | get_count (state_t state) const |
Return a count of the number of entries in the given state. | |
void | dump (oasys::StringBuffer *buf) const |
Dump a string representation of the log. | |
Protected Attributes | |
Log | log_ |
The actual log. | |
oasys::SpinLock * | lock_ |
Copy of the bundle's lock. |
Definition at line 53 of file ForwardingLog.h.
typedef std::vector<ForwardingInfo> dtn::ForwardingLog::Log |
dtn::ForwardingLog::ForwardingLog | ( | oasys::SpinLock * | lock | ) |
Constructor that takes a pointer to the relevant Bundle's lock, used when querying or updating the log.
Definition at line 27 of file ForwardingLog.cc.
bool dtn::ForwardingLog::get_latest_entry | ( | Link * | link, | |
ForwardingInfo * | info | |||
) | const |
Get the most recent entry for the given link from the log.
Definition at line 34 of file ForwardingLog.cc.
References dtn::Link::clayer(), info, ExamineDump::l, lock_, log_, dtn::ConvergenceLayer::name(), and dtn::Link::nexthop().
Referenced by get_latest_entry(), dtn::BundleDaemon::handle_bundle_transmitted(), dtn::BundleActions::send_bundle(), dtn::TableBasedRouter::should_fwd(), and dtn::ProphetDecider::should_fwd().
ForwardingLog::state_t dtn::ForwardingLog::get_latest_entry | ( | Link * | link | ) | const |
Get the most recent state for the given link from the log.
Definition at line 54 of file ForwardingLog.cc.
References get_latest_entry(), info, and dtn::ForwardingInfo::NONE.
size_t dtn::ForwardingLog::get_transmission_count | ( | ForwardingInfo::action_t | action = ForwardingInfo::INVALID_ACTION , |
|
bool | include_inflight = false | |||
) | const |
Return the transmission count of the bundle, optionally including inflight entries as well.
If an action is specified (i.e. not ForwardingInfo::INVALID_ACTION), only count log entries that match the action code.
Definition at line 66 of file ForwardingLog.cc.
References dtn::ForwardingInfo::IN_FLIGHT, dtn::ForwardingInfo::INVALID_ACTION, ExamineDump::l, lock_, log_, and dtn::ForwardingInfo::TRANSMITTED.
Referenced by dtn::Bundle::format_verbose().
void dtn::ForwardingLog::add_entry | ( | Link * | link, | |
ForwardingInfo::action_t | action, | |||
state_t | state, | |||
const CustodyTimerSpec & | custody_timer | |||
) |
Add a new forwarding info entry for the given link.
Definition at line 137 of file ForwardingLog.cc.
References dtn::Link::clayer(), ExamineDump::l, lock_, log_, dtn::ConvergenceLayer::name(), and dtn::Link::nexthop().
Referenced by dtn::BundleActions::send_bundle().
Update the state for the latest forwarding info entry for the given link.
Definition at line 150 of file ForwardingLog.cc.
References dtn::Link::clayer(), ExamineDump::l, lock_, log_, dtn::ConvergenceLayer::name(), and dtn::Link::nexthop().
Referenced by dtn::BundleActions::cancel_bundle(), dtn::BundleDaemon::handle_bundle_transmit_failed(), dtn::BundleDaemon::handle_bundle_transmitted(), and dtn::BundleDaemon::handle_custody_timeout().
size_t dtn::ForwardingLog::get_count | ( | state_t | state | ) | const |
Return a count of the number of entries in the given state.
Definition at line 92 of file ForwardingLog.cc.
References ExamineDump::l, lock_, and log_.
Referenced by dtn::BundleDaemon::try_delete_from_pending().
void dtn::ForwardingLog::dump | ( | oasys::StringBuffer * | buf | ) | const |
Dump a string representation of the log.
Definition at line 111 of file ForwardingLog.cc.
References dtn::ForwardingInfo::action_to_str(), oasys::StringBuffer::appendf(), info, ExamineDump::l, lock_, log_, and dtn::ForwardingInfo::state_to_str().
Log dtn::ForwardingLog::log_ [protected] |
The actual log.
Definition at line 113 of file ForwardingLog.h.
Referenced by add_entry(), dump(), get_count(), get_latest_entry(), get_transmission_count(), and update().
oasys::SpinLock* dtn::ForwardingLog::lock_ [protected] |
Copy of the bundle's lock.
Definition at line 114 of file ForwardingLog.h.
Referenced by add_entry(), dump(), get_count(), get_latest_entry(), get_transmission_count(), and update().