prophet::Table Class Reference

Container for Prophet nodes (routes and predictability values). More...

#include <Table.h>

List of all members.

Public Types

typedef std::map< std::string,
Node *, less_string
rib_table
typedef std::map< std::string,
Node *, less_string >
::const_iterator 
const_iterator
typedef std::vector< Node * > Sequence
typedef Sequence::const_iterator heap_iterator

Public Member Functions

 Table (BundleCore *core, const std::string &name, bool persistent=false)
 Default constructor.
 Table (const Table &t)
 Copy constructor.
 ~Table ()
 Destructor.
const Nodefind (const std::string &dest_id) const
 Find and return route for given destination ID; else return NULL.
void update (Node *n)
 Table takes ownership of memory pointed to by Node*, updating its member list (replacing element if n->dest_id() already exists).
void update_route (const std::string &dest_id, bool relay=Node::DEFAULT_RELAY, bool custody=Node::DEFAULT_CUSTODY, bool internet=Node::DEFAULT_INTERNET)
 Convenience function for updating directly-encountered route in table.
void update_transitive (const std::string &dest_id, const std::string &peer_id, double peer_pvalue, bool relay=Node::DEFAULT_RELAY, bool custody=Node::DEFAULT_CUSTODY, bool internet=Node::DEFAULT_INTERNET)
 Convenience function for updating transitively-discovered route in table.
void update_transitive (const std::string &peer_id, const RIBNodeList &nodes, const Dictionary &ribd)
 Convenience wrapper around update_transitive to import entire RIB.
double p_value (const std::string &dest_id) const
 Convenience function for looking up predictability of a given route.
double p_value (const Bundle *b) const
 Convenience function for lookup of predictability of route to b's dest.
size_t clone (NodeList &list) const
 Create duplicate list of Nodes, return number of elements.
size_t size () const
 Returns number of routes held by Table.
void set_max_route (u_int max_route)
 Set upper limit on number of routes retained by Table.
size_t truncate (double epsilon)
 The predictability of Nodes should diminish with time; to allow for maintenance of routes, the Prophet spec allows for removing routes whose predictability falls below some arbitrary epsilon.
void assign (const RIBNodeList &list, const Dictionary &ribd)
 Update Table from peer's RIB.
void assign (const std::list< const Node * > &list, const NodeParams *params)
 Persistent storage interface: clear contents of Table and assign from deserialization routine.
size_t age_nodes ()
 For maintenance routines, visit each Node in table and invoke its aging algorithm; return the number of Nodes visited.

const_iterator begin () const
 Iterators.
const_iterator end () const
 Iterators.
heap_iterator heap_begin () const
 Iterators.
heap_iterator heap_end () const
 Iterators.

Protected Types

typedef rib_table::iterator iterator
typedef Heap< Node
*, std::vector< Node * >
, struct heap_compare, struct
heap_pos
NodeHeap

Protected Member Functions

void heap_add (Node *n)
 Add route to heap.
void heap_del (Node *n)
 Remove node from heap.
void enforce_quota ()
 Enforce upper bound by eliminating minimum routes.
void remove (iterator *i)
 Clean up memory and remove pointer from internal map for this element.
void free ()
 Clean up memory pointed to by each Node*.
bool find (const std::string &dest_id, iterator *i)
 Utility function for finding route by dest_id.

Protected Attributes

BundleCore *const core_
 facade interface into Bundle host
rib_table table_
 Mapped collection of <dest_id,Node*> pairs.
NodeHeap heap_
 Min-heap for quota-enforcement eviction ordering.
bool persistent_
 whether to utilize BundleCore's persistent storage interface for Nodes
std::string name_
 object name
u_int max_route_
 upper limit to number of routes to retain

Detailed Description

Container for Prophet nodes (routes and predictability values).

Assumes ownership of memory pointed to by member Node*'s

Definition at line 57 of file Table.h.


Member Typedef Documentation

Definition at line 62 of file Table.h.

typedef Sequence::const_iterator prophet::Table::heap_iterator

Definition at line 64 of file Table.h.

typedef rib_table::iterator prophet::Table::iterator [protected]

Definition at line 192 of file Table.h.

typedef Heap<Node*, std::vector<Node*>, struct heap_compare, struct heap_pos> prophet::Table::NodeHeap [protected]

Definition at line 196 of file Table.h.

typedef std::map<std::string,Node*,less_string> prophet::Table::rib_table

Definition at line 60 of file Table.h.

typedef std::vector<Node*> prophet::Table::Sequence

Definition at line 63 of file Table.h.


Constructor & Destructor Documentation

prophet::Table::Table ( BundleCore core,
const std::string &  name,
bool  persistent = false 
)

Default constructor.

Definition at line 29 of file Table.cc.

prophet::Table::Table ( const Table t  ) 

Copy constructor.

Definition at line 36 of file Table.cc.

References heap_add(), and table_.

prophet::Table::~Table (  ) 

Destructor.

Definition at line 52 of file Table.cc.

References free(), and table_.


Member Function Documentation

size_t prophet::Table::age_nodes (  ) 

For maintenance routines, visit each Node in table and invoke its aging algorithm; return the number of Nodes visited.

Definition at line 424 of file Table.cc.

References core_, heap_add(), heap_del(), prophet::BundleCore::LOG_INFO, name_, persistent_, prophet::BundleCore::print_log(), table_, prophet::Node::update_age(), and prophet::BundleCore::update_node().

Referenced by prophet::Controller::handle_timeout(), and dtn::ProphetBundleCore::load_prophet_nodes().

void prophet::Table::assign ( const std::list< const Node * > &  list,
const NodeParams params 
)

Persistent storage interface: clear contents of Table and assign from deserialization routine.

Definition at line 401 of file Table.cc.

References core_, prophet::BundleCore::LOG_INFO, name_, persistent_, prophet::BundleCore::print_log(), prophet::Node::set_params(), and update().

void prophet::Table::assign ( const RIBNodeList list,
const Dictionary ribd 
)
const_iterator prophet::Table::begin (  )  const [inline]

Iterators.

Definition at line 185 of file Table.h.

References table_.

Referenced by prophet::TLVCreator::rib(), and prophet::TLVCreator::ribd().

size_t prophet::Table::clone ( NodeList list  )  const

Create duplicate list of Nodes, return number of elements.

Definition at line 302 of file Table.cc.

References prophet::PointerList< T >::clear(), and table_.

const_iterator prophet::Table::end (  )  const [inline]

Iterators.

Definition at line 186 of file Table.h.

References table_.

Referenced by prophet::TLVCreator::rib(), and prophet::TLVCreator::ribd().

void prophet::Table::enforce_quota (  )  [protected]
bool prophet::Table::find ( const std::string &  dest_id,
iterator i 
) [protected]

Utility function for finding route by dest_id.

Definition at line 496 of file Table.cc.

References LOG_LT_MIN_LENGTH, MIN_LENGTH, and table_.

const Node * prophet::Table::find ( const std::string &  dest_id  )  const

Find and return route for given destination ID; else return NULL.

Definition at line 76 of file Table.cc.

References LOG_LT_MIN_LENGTH, MIN_LENGTH, and table_.

Referenced by enforce_quota(), p_value(), truncate(), update(), update_route(), and update_transitive().

void prophet::Table::free (  )  [protected]

Clean up memory pointed to by each Node*.

Definition at line 486 of file Table.cc.

References heap_del(), and table_.

Referenced by truncate(), and ~Table().

void prophet::Table::heap_add ( Node n  )  [protected]

Add route to heap.

Definition at line 58 of file Table.cc.

References prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::add(), and heap_.

Referenced by age_nodes(), Table(), update(), update_route(), and update_transitive().

heap_iterator prophet::Table::heap_begin (  )  const [inline]

Iterators.

Definition at line 187 of file Table.h.

References heap_, and prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::sequence().

void prophet::Table::heap_del ( Node n  )  [protected]
heap_iterator prophet::Table::heap_end (  )  const [inline]

Iterators.

Definition at line 188 of file Table.h.

References heap_, and prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::sequence().

double prophet::Table::p_value ( const Bundle b  )  const

Convenience function for lookup of predictability of route to b's dest.

Definition at line 100 of file Table.cc.

References core_, prophet::Bundle::destination_id(), find(), prophet::BundleCore::get_route(), and prophet::Node::p_value().

double prophet::Table::p_value ( const std::string &  dest_id  )  const
void prophet::Table::remove ( iterator i  )  [protected]

Clean up memory and remove pointer from internal map for this element.

Definition at line 448 of file Table.cc.

References core_, prophet::BundleCore::delete_node(), heap_del(), persistent_, and table_.

void prophet::Table::set_max_route ( u_int  max_route  )  [inline]

Set upper limit on number of routes retained by Table.

Definition at line 148 of file Table.h.

References enforce_quota(), and max_route_.

Referenced by prophet::Controller::Controller(), and prophet::Controller::set_max_route().

size_t prophet::Table::size (  )  const [inline]

Returns number of routes held by Table.

Definition at line 143 of file Table.h.

References table_.

size_t prophet::Table::truncate ( double  epsilon  ) 

The predictability of Nodes should diminish with time; to allow for maintenance of routes, the Prophet spec allows for removing routes whose predictability falls below some arbitrary epsilon.

Given epsilon as a minimum predictability, remove all routes whose predictability is below epsilon. Return the number of routes removed.

Definition at line 320 of file Table.cc.

References core_, prophet::Node::dest_id(), prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::empty(), find(), free(), heap_, prophet::BundleCore::LOG_INFO, name_, prophet::Node::p_value(), prophet::BundleCore::print_log(), prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::remove(), prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::size(), table_, and prophet::Heap< UnitType, Sequence, Compare, UpdateElem >::top().

Referenced by prophet::Controller::handle_timeout(), and dtn::ProphetBundleCore::load_prophet_nodes().

void prophet::Table::update ( Node n  ) 

Table takes ownership of memory pointed to by Node*, updating its member list (replacing element if n->dest_id() already exists).

Definition at line 112 of file Table.cc.

References core_, prophet::Node::dest_id(), enforce_quota(), find(), heap_add(), heap_del(), prophet::BundleCore::LOG_INFO, LOG_LT_MIN_LENGTH, MIN_LENGTH, name_, prophet::Node::p_value(), persistent_, prophet::BundleCore::print_log(), table_, and prophet::BundleCore::update_node().

Referenced by assign().

void prophet::Table::update_route ( const std::string &  dest_id,
bool  relay = Node::DEFAULT_RELAY,
bool  custody = Node::DEFAULT_CUSTODY,
bool  internet = Node::DEFAULT_INTERNET 
)

Convenience function for updating directly-encountered route in table.

Adds new node to table, or updates if route already exists. On success, post-condition is that update_pvalue is called on the node, then the node is updated in Table.

Definition at line 158 of file Table.cc.

References core_, prophet::Node::dest_id(), enforce_quota(), find(), heap_add(), heap_del(), prophet::BundleCore::LOG_INFO, LOG_LT_MIN_LENGTH, MIN_LENGTH, name_, prophet::Node::p_value(), persistent_, prophet::BundleCore::print_log(), prophet::Node::set_custody(), prophet::Node::set_internet_gw(), prophet::Node::set_relay(), table_, prophet::BundleCore::update_node(), and prophet::Node::update_pvalue().

Referenced by prophet::Encounter::handle_rib_tlv().

void prophet::Table::update_transitive ( const std::string &  peer_id,
const RIBNodeList nodes,
const Dictionary ribd 
)
void prophet::Table::update_transitive ( const std::string &  dest_id,
const std::string &  peer_id,
double  peer_pvalue,
bool  relay = Node::DEFAULT_RELAY,
bool  custody = Node::DEFAULT_CUSTODY,
bool  internet = Node::DEFAULT_INTERNET 
)

Convenience function for updating transitively-discovered route in table.

Creates new node, else updates existing. On success, post-condition is update_transitive is called on node, then node is updated in Table.

Definition at line 200 of file Table.cc.

References core_, prophet::Node::dest_id(), enforce_quota(), find(), heap_add(), heap_del(), prophet::BundleCore::LOG_INFO, LOG_LT_MIN_LENGTH, MIN_LENGTH, name_, prophet::Node::p_value(), p_value(), persistent_, prophet::BundleCore::print_log(), prophet::Node::set_custody(), prophet::Node::set_internet_gw(), prophet::Node::set_relay(), table_, prophet::BundleCore::update_node(), and prophet::Node::update_transitive().

Referenced by prophet::Encounter::handle_rib_tlv().


Member Data Documentation

BundleCore* const prophet::Table::core_ [protected]

facade interface into Bundle host

Definition at line 229 of file Table.h.

Referenced by age_nodes(), assign(), enforce_quota(), p_value(), remove(), truncate(), update(), update_route(), and update_transitive().

Min-heap for quota-enforcement eviction ordering.

Definition at line 231 of file Table.h.

Referenced by enforce_quota(), heap_add(), heap_begin(), heap_del(), heap_end(), and truncate().

u_int prophet::Table::max_route_ [protected]

upper limit to number of routes to retain

Definition at line 235 of file Table.h.

Referenced by enforce_quota(), and set_max_route().

std::string prophet::Table::name_ [protected]

object name

Definition at line 234 of file Table.h.

Referenced by age_nodes(), assign(), enforce_quota(), truncate(), update(), update_route(), and update_transitive().

whether to utilize BundleCore's persistent storage interface for Nodes

Definition at line 232 of file Table.h.

Referenced by age_nodes(), assign(), remove(), update(), update_route(), and update_transitive().

Mapped collection of <dest_id,Node*> pairs.

Definition at line 230 of file Table.h.

Referenced by age_nodes(), begin(), clone(), end(), enforce_quota(), find(), free(), remove(), size(), Table(), truncate(), update(), update_route(), update_transitive(), and ~Table().


The documentation for this class was generated from the following files:
Generated on Sun Nov 21 11:41:18 2010 for DTN Reference Implementation by  doxygen 1.6.3