Epidemic::EpidemicStore Class Reference

A persistent store class for epidemically propagated DTN::Bundles. More...

#include <epidemic/EpidemicStore.h>

Inheritance diagram for Epidemic::EpidemicStore:

Inheritance graph
[legend]
Collaboration diagram for Epidemic::EpidemicStore:

Collaboration graph
[legend]

List of all members.

Public Types

typedef std::set< EpidemicBundleBundleList
 The internal storage type.
typedef BundleList::key_type key_type
 Convenient shorter version of the index type.
typedef BundleList::iterator iterator
 An iterator into the internal store.
typedef BundleList::const_iterator const_iterator
 A const iterator into the internal store.
typedef std::map
< DTN::ByteString, iterator
DigestMap
 The type for the store of transferrable bundles.
typedef std::list< iteratorDestList
 The type for a list of bundles addressed to a single destination.
typedef std::map
< DTN::ByteString, DestList
DestMap
 The type for the store of last-hop-only bundles.
typedef std::set< DTN::ByteString > HistorySet
 The type for the store of all bundles seen.
typedef std::list
< DTN::ByteString > 
DigestList
 A simple type for lists of digests.

Public Member Functions

 EpidemicStore (DTN::Node *owner, uint32_t h=0)
 Constructor.
virtual ~EpidemicStore ()
 Virtual destructor.
virtual void consume (DTN::Bundle *b)
 Perform an action on a Bundle received by its destination.
DTN::BundlePointer getPointer (const DTN::ByteString &digest)
 Find a DTN::BundlePointer for a DTN::Bundle with a particular digest.
iterator begin ()
 
Returns:
the first item in the store

iterator lower_bound (const key_type &x)
 
Parameters:
x An index into the store

iterator upper_bound (const key_type &x)
 
Parameters:
x An index into the store

iterator end ()
 
Returns:
the end of the store

const_iterator begin () const
 
Returns:
the first item in the store

const_iterator lower_bound (const key_type &x) const
 
Parameters:
x An index into the store

const_iterator upper_bound (const key_type &x) const
 
Parameters:
x An index into the store

const_iterator end () const
 
Returns:
the end of the store

DTN::ByteString * summaryVector () const
 Construct the summary vector for this data store.
void set_max_hops (uint32_t h)
 Set the maximum number of epidemic transfers permitted for a bundle.
void forwardLastHop (const DTN::ByteString &addr, DTN::Node &node)
 Enqueue the last-hop-only bundles for a newly arrived neighbor.
bool seen (const DTN::ByteString &digest)
 Check for a digest in the history list.

Static Public Member Functions

static DTN::ByteString digest (const DTN::Bundle &b)
 Create an epidemic digest for a bundle.
static DTN::ByteString digest (const DTN::ByteString &originator, uint32_t seqNum)
 Create an epidemic digest.
static DigestListparseSummaryVector (const DTN::ByteString &sv)
 Split a summary vector into a list of bundle digests.

Protected Member Functions

virtual DTN::BundlePointer p_addBundle (DTN::Bundle *b)
 Add a DTN::Bundle to the store.
virtual void p_deleteBundle (DTN::Bundle *b)
 Remove a DTN::Bundle from the store.
virtual DTN::BundlePointer p_getPointer (const DTN::BundlePointer &p)
 Update a DTN::BundlePointer from the store.
virtual DTN::BundlePointer p_getPointer (const DTN::ByteString &sender, uint32_t seqNum)
 Find a DTN::BundlePointer for a particular DTN::Bundle.
virtual bool p_validatePointer (const DTN::BundlePointer &p)
 Test the validity of a DTN::BundlePointer.
virtual size_t p_bytesUsed ()
 The size of the data store.
virtual size_t p_bundles ()
 The number of bundles stored.
virtual void p_shrinkStore (size_t s)
 Change the size of the data store.


Detailed Description

A persistent store class for epidemically propagated DTN::Bundles.

Definition at line 90 of file EpidemicStore.h.


Constructor & Destructor Documentation

EpidemicStore::EpidemicStore ( DTN::Node owner,
uint32_t  h = 0 
)

Constructor.

Parameters:
owner The node at which this store resides
h The maximum number of times a bundle may be transferred

Definition at line 96 of file EpidemicStore.cc.


Member Function Documentation

void EpidemicStore::consume ( DTN::Bundle b  )  [virtual]

Perform an action on a Bundle received by its destination.

This only really makes sense for persistent stores, and then only in select cases, so for most policy classes this no-op default will be sufficient.

Parameters:
b A pointer to a delivered Bundle

Reimplemented from DTN::BundleStore.

Definition at line 195 of file EpidemicStore.cc.

References digest(), DTN::Bundle::kACK, DTN::Bundle::kCustodial, and DTN::Bundle::type().

DTN::BundlePointer EpidemicStore::getPointer ( const DTN::ByteString &  digest  ) 

Find a DTN::BundlePointer for a DTN::Bundle with a particular digest.

Parameters:
digest The epidemic-forwarding digest of a bundle
Returns:
a DTN::BundlePointer for the identified DTN::Bundle, if it is in the store, or a NULL DTN::BundlePointer if it isn't

Definition at line 240 of file EpidemicStore.cc.

References DTN::PersistentBundleStore::clean().

Referenced by Epidemic::EpidemicApp::process().

EpidemicStore::iterator EpidemicStore::lower_bound ( const key_type x  ) 

Parameters:
x An index into the store

Returns:
the item with index x, the item with the smallest index greater than x if x is not present, or the end of the store if no such item exists

Definition at line 294 of file EpidemicStore.cc.

EpidemicStore::iterator EpidemicStore::upper_bound ( const key_type x  ) 

Parameters:
x An index into the store

Returns:
the item with the smallest index greater than x, or the end of the store if no such item exists

Definition at line 300 of file EpidemicStore.cc.

Referenced by Epidemic::EpidemicStoreItr::next().

EpidemicStore::const_iterator EpidemicStore::lower_bound ( const key_type x  )  const

Parameters:
x An index into the store

Returns:
the item with index x, the item with the smallest index greater than x if x is not present, or the end of the store if no such item exists

Definition at line 318 of file EpidemicStore.cc.

EpidemicStore::const_iterator EpidemicStore::upper_bound ( const key_type x  )  const

Parameters:
x An index into the store

Returns:
the item with the smallest index greater than x, or the end of the store if no such item exists

Definition at line 324 of file EpidemicStore.cc.

DTN::ByteString * EpidemicStore::summaryVector (  )  const

Construct the summary vector for this data store.

Returns:
a pointer to a summary; the caller takes ownership of the memory

Todo:
Technically, we should probably check for expiry here.

Definition at line 336 of file EpidemicStore.cc.

References end().

Referenced by Epidemic::EpidemicApp::newNeighbor().

DTN::ByteString EpidemicStore::digest ( const DTN::Bundle b  )  [static]

Create an epidemic digest for a bundle.

Parameters:
b The bundle to digest
Returns:
the digest, used for bookkeeping and the summary vector

Definition at line 351 of file EpidemicStore.cc.

References DTN::Bundle::seqNum(), and DTN::Bundle::source().

Referenced by consume(), Epidemic::EpidemicBundle::EpidemicBundle(), p_addBundle(), and p_deleteBundle().

DTN::ByteString EpidemicStore::digest ( const DTN::ByteString &  originator,
uint32_t  seqNum 
) [static]

Create an epidemic digest.

Parameters:
originator The originator of a bundle
seqNum The bundle's sequence number
Returns:
the digest

Definition at line 357 of file EpidemicStore.cc.

EpidemicStore::DigestList * EpidemicStore::parseSummaryVector ( const DTN::ByteString &  sv  )  [static]

Split a summary vector into a list of bundle digests.

Parameters:
sv A summary vector
Returns:
a pointer to a list of digests, or NULL on error

Definition at line 374 of file EpidemicStore.cc.

Referenced by Epidemic::EpidemicApp::process().

void Epidemic::EpidemicStore::set_max_hops ( uint32_t  h  )  [inline]

Set the maximum number of epidemic transfers permitted for a bundle.

Parameters:
h The maximum number of hops

Definition at line 184 of file EpidemicStore.h.

void EpidemicStore::forwardLastHop ( const DTN::ByteString &  addr,
DTN::Node node 
)

Enqueue the last-hop-only bundles for a newly arrived neighbor.

Parameters:
addr The neighbor's address
node The node to which this store is attached

Definition at line 389 of file EpidemicStore.cc.

References end(), DTN::Node::forward(), and DTN::Bundle::recv().

Referenced by Epidemic::EpidemicApp::newNeighbor().

bool EpidemicStore::seen ( const DTN::ByteString &  digest  ) 

Check for a digest in the history list.

Parameters:
digest A bundle digest
Returns:
whether the digest appears in the history list

Definition at line 409 of file EpidemicStore.cc.

Referenced by Epidemic::EpidemicApp::process().

DTN::BundlePointer EpidemicStore::p_addBundle ( DTN::Bundle b  )  [protected, virtual]

Add a DTN::Bundle to the store.

Parameters:
b The bundle to add; ownership of the memory is taken by the store
Returns:
a reference to the stored DTN::Bundle

Implements DTN::PersistentBundleStore.

Definition at line 108 of file EpidemicStore.cc.

References DTN::Bundle::destination(), digest(), DTN::Bundle::hopCount(), and DTN::Bundle::size().

void EpidemicStore::p_deleteBundle ( DTN::Bundle b  )  [protected, virtual]

Remove a DTN::Bundle from the store.

Parameters:
b The bundle to delete

Implements DTN::PersistentBundleStore.

Definition at line 140 of file EpidemicStore.cc.

References DTN::Bundle::destination(), digest(), end(), and DTN::Bundle::size().

Referenced by p_shrinkStore().

DTN::BundlePointer EpidemicStore::p_getPointer ( const DTN::BundlePointer p  )  [protected, virtual]

Update a DTN::BundlePointer from the store.

Parameters:
p A cached DTN::BundlePointer
Returns:
A DTN::BundlePointer either equal to p or following it in the store. If p.isNull(), a DTN::BundlePointer to the beginning of the store is returned. If there is no valid DTN::BundlePointer to return, a NULL pointer will be returned.

Implements DTN::PersistentBundleStore.

Definition at line 209 of file EpidemicStore.cc.

References DTN::BundlePointer::isNull(), and DTN::BundlePointer::repr().

DTN::BundlePointer EpidemicStore::p_getPointer ( const DTN::ByteString &  sender,
uint32_t  seqNum 
) [protected, virtual]

Find a DTN::BundlePointer for a particular DTN::Bundle.

This uses the unique identifying information for a DTN::Bundle, rather than a pointer, so that we can match acknowledgements.

Parameters:
sender The originator of a DTN::Bundle
seqNum The originator's unique ID for a DTN::Bundle
Returns:
A DTN::BundlePointer for the identified DTN::Bundle, if it is in the store, or a NULL DTN::BundlePointer if it isn't

Implements DTN::PersistentBundleStore.

Definition at line 229 of file EpidemicStore.cc.

bool EpidemicStore::p_validatePointer ( const DTN::BundlePointer p  )  [protected, virtual]

Test the validity of a DTN::BundlePointer.

Parameters:
p A cached DTN::BundlePointer
Return values:
true The referenced DTN::Bundle is in the store
false The referenced DTN::Bundle is not in the store

Implements DTN::PersistentBundleStore.

Definition at line 252 of file EpidemicStore.cc.

References DTN::BundlePointer::isNull(), and DTN::BundlePointer::repr().

virtual size_t Epidemic::EpidemicStore::p_bytesUsed (  )  [inline, protected, virtual]

The size of the data store.

Returns:
the total size used by the store, in bytes

Implements DTN::PersistentBundleStore.

Definition at line 240 of file EpidemicStore.h.

virtual size_t Epidemic::EpidemicStore::p_bundles (  )  [inline, protected, virtual]

The number of bundles stored.

Returns:
the total number of bundles in the store

Implements DTN::PersistentBundleStore.

Definition at line 245 of file EpidemicStore.h.

void EpidemicStore::p_shrinkStore ( size_t  s  )  [protected, virtual]

Change the size of the data store.

Parameters:
s The new size for the data store
See also:
DTN::BundleStore::shrinkStore()

Implements DTN::PersistentBundleStore.

Definition at line 261 of file EpidemicStore.cc.

References end(), DTN::BundleStore::m_owner, and p_deleteBundle().


The documentation for this class was generated from the following files:
Generated on Mon Mar 24 11:15:48 2008 for Pydtn Simulator by  doxygen 1.5.4