Utility class for maintain a cache of recently received bundles, indexed by GbofId. More...
#include <BundleInfoCache.h>
Public Member Functions | |
BundleInfoCache (const std::string &logpath, size_t capacity) | |
Constructor that takes the logpath and the number of entries to maintain in the cache. | |
bool | add_entry (const Bundle *bundle, const EndpointID &prevhop) |
Try to add the bundle to the cache. | |
bool | lookup (const Bundle *bundle, EndpointID *prevhop) |
Check if the given bundle is in the cache, returning the EID of the node from which it arrived (if known). | |
void | evict_all () |
Flush the cache. | |
Protected Types | |
typedef oasys::CacheCapacityHelper < GbofId, EndpointID > | CacheCapacityHelper |
typedef oasys::Cache< GbofId, EndpointID, CacheCapacityHelper > | Cache |
Protected Attributes | |
Cache | cache_ |
Utility class for maintain a cache of recently received bundles, indexed by GbofId.
Used for routers to detect redundant BundleInfos and to avoid duplicate deliveries to registrations.
Definition at line 33 of file BundleInfoCache.h.
typedef oasys::Cache<GbofId, EndpointID, CacheCapacityHelper> dtn::BundleInfoCache::Cache [protected] |
Definition at line 60 of file BundleInfoCache.h.
typedef oasys::CacheCapacityHelper<GbofId, EndpointID> dtn::BundleInfoCache::CacheCapacityHelper [protected] |
Definition at line 59 of file BundleInfoCache.h.
dtn::BundleInfoCache::BundleInfoCache | ( | const std::string & | logpath, | |
size_t | capacity | |||
) |
Constructor that takes the logpath and the number of entries to maintain in the cache.
Definition at line 25 of file BundleInfoCache.cc.
bool dtn::BundleInfoCache::add_entry | ( | const Bundle * | bundle, | |
const EndpointID & | prevhop | |||
) |
Try to add the bundle to the cache.
If it already exists in the cache, adding it again fails, and the method returns false.
Definition at line 33 of file BundleInfoCache.cc.
References cache_, dtn::Bundle::creation_ts(), dtn::Bundle::frag_offset(), dtn::Bundle::is_fragment(), dtn::BundlePayload::length(), dtn::Bundle::payload(), and dtn::Bundle::source().
Referenced by dtn::Registration::deliver_if_not_duplicate(), and dtn::TableBasedRouter::handle_bundle_received().
void dtn::BundleInfoCache::evict_all | ( | ) |
Flush the cache.
Definition at line 66 of file BundleInfoCache.cc.
References cache_.
Referenced by dtn::TableBasedRouter::del_route(), and dtn::TableBasedRouter::handle_changed_routes().
bool dtn::BundleInfoCache::lookup | ( | const Bundle * | bundle, | |
EndpointID * | prevhop | |||
) |
Check if the given bundle is in the cache, returning the EID of the node from which it arrived (if known).
Definition at line 53 of file BundleInfoCache.cc.
References cache_, dtn::Bundle::creation_ts(), dtn::Bundle::frag_offset(), dtn::Bundle::is_fragment(), dtn::BundlePayload::length(), dtn::Bundle::payload(), and dtn::Bundle::source().
Referenced by dtn::TableBasedRouter::should_fwd().
Cache dtn::BundleInfoCache::cache_ [protected] |
Definition at line 61 of file BundleInfoCache.h.
Referenced by add_entry(), evict_all(), and lookup().