#include <PingCache.h>
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 |
void PingCache::initialize | ( | ) | [protected] |
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 | ) |
std::ostream& operator<< | ( | std::ostream & | os, | |
const PingCacheEntry & | p | |||
) | [friend] |
std::map<TransportAddress, PingCacheEntry> PingCache::pingCache [protected] |