PingCache Class Reference

#include <PingCache.h>

List of all members.

Public Member Functions

void setAddressPinged (const TransportAddress &handle)
void insertAddressRtt (const NodeHandle &add, simtime_t time)
void addressTimeout (const TransportAddress &handle)
simtime_t getAddressRtt (const TransportAddress &add)
NodeHandle getNodeHandle (const TransportAddress &add)

Protected Member Functions

void initialize ()

Protected Attributes

std::map
< TransportAddress,
PingCacheEntry
pingCache

Friends

std::ostream & operator<< (std::ostream &os, const PingCacheEntry &)

Classes

struct  PingCacheEntry


Member Function Documentation

void PingCache::initialize (  )  [protected]

00038 {
00039     WATCH_MAP(pingCache);
00040 }

void PingCache::setAddressPinged ( const TransportAddress handle  ) 

00043 {
00044     PingCacheEntry entry;
00045     
00046     entry.insertTime = simulation.simTime();
00047     entry.rtt = PINGSTATE_WAITING;
00048     entry.nodeRef = NodeHandle::UNSPECIFIED_NODE;
00049     
00050     pingCache[handle] = entry;
00051 }

void PingCache::insertAddressRtt ( const NodeHandle add,
simtime_t  time 
)

00066 {
00067     PingCacheEntry entry;
00068     
00069     entry.insertTime = simulation.simTime();
00070     entry.rtt = rtt;
00071     entry.nodeRef = add;
00072     
00073     TransportAddress ta = add;
00074     pingCache[ta] = entry;
00075 }

void PingCache::addressTimeout ( const TransportAddress handle  ) 

00054 {
00055     PingCacheEntry entry;
00056     
00057     entry.insertTime = simulation.simTime();
00058     entry.rtt = PINGSTATE_TIMEOUT;
00059     entry.nodeRef = NodeHandle::UNSPECIFIED_NODE;
00060     
00061     pingCache[handle] = entry;
00062 }

simtime_t PingCache::getAddressRtt ( const TransportAddress add  ) 

00078 {
00079     if (par("disablePingCache")) return PINGSTATE_UNKNOWN;  /* cache disabled */
00080     
00081     if (pingCache.count(add) == 0) return PINGSTATE_UNKNOWN; /* entry not there */
00082     
00083     PingCacheEntry entry = pingCache[add];
00084     
00085     if (simulation.simTime() - entry.rtt >= (simtime_t)par("pingExpirationTime")) 
00086         return PINGSTATE_UNKNOWN;   /* entry expired */
00087     else 
00088         return entry.rtt;
00089 }

NodeHandle PingCache::getNodeHandle ( const TransportAddress add  ) 

00092 {
00093     if (pingCache.count(add) == 0) opp_error("PingCache.cc: getNodeHandle was asked for a non-existant node reference.");
00094     return pingCache[add].nodeRef;
00095 }


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const PingCacheEntry p 
) [friend]

00029 {
00030     os << p.rtt << " (i=" << p.insertTime << ")";
00031     return os;
00032 }


Member Data Documentation

std::map<TransportAddress, PingCacheEntry> PingCache::pingCache [protected]


The documentation for this class was generated from the following files:
Generated on Thu Apr 17 13:19:30 2008 for ITM OverSim by  doxygen 1.5.3