An ARP cache. More...
#include <arp-cache.h>
Classes | |
class | Entry |
A record that that holds information about an ArpCache entry. More... | |
Public Member Functions | |
ArpCache () | |
~ArpCache () | |
ArpCache::Entry * | Add (Ipv4Address to) |
Add an Ipv4Address to this ARP cache. More... | |
void | Flush (void) |
Clear the ArpCache of all entries. More... | |
Time | GetAliveTimeout (void) const |
Get the time the entry will be in ALIVE state (unless refreshed) More... | |
Time | GetDeadTimeout (void) const |
Get the time the entry will be in DEAD state before being removed. More... | |
Ptr< NetDevice > | GetDevice (void) const |
Returns the NetDevice that this ARP cache is associated with. More... | |
Ptr< Ipv4Interface > | GetInterface (void) const |
Returns the Ipv4Interface that this ARP cache is associated with. More... | |
Time | GetWaitReplyTimeout (void) const |
Get the time the entry will be in WAIT_REPLY state. More... | |
ArpCache::Entry * | Lookup (Ipv4Address destination) |
Do lookup in the ARP cache against an IP address. More... | |
void | SetAliveTimeout (Time aliveTimeout) |
Set the time the entry will be in ALIVE state (unless refreshed) More... | |
void | SetArpRequestCallback (Callback< void, Ptr< const ArpCache >, Ipv4Address > arpRequestCallback) |
This callback is set when the ArpCache is set up and allows the cache to generate an Arp request when the WaitReply time expires and a retransmission must be sent. More... | |
void | SetDeadTimeout (Time deadTimeout) |
Set the time the entry will be in DEAD state before being removed. More... | |
void | SetDevice (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface) |
Set the NetDevice and Ipv4Interface associated with the ArpCache. More... | |
void | SetWaitReplyTimeout (Time waitReplyTimeout) |
Set the time the entry will be in WAIT_REPLY state. More... | |
void | StartWaitReplyTimer (void) |
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is already running for the cache, in which case this method does nothing. More... | |
Public Member Functions inherited from ns3::Object | |
Object () | |
virtual | ~Object () |
void | AggregateObject (Ptr< Object > other) |
void | Dispose (void) |
Run the DoDispose methods of this object and all the objects aggregated to it. More... | |
AggregateIterator | GetAggregateIterator (void) const |
virtual TypeId | GetInstanceTypeId (void) const |
template<typename T > | |
Ptr< T > | GetObject (void) const |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
void | Initialize (void) |
This method calls the virtual DoInitialize method on all the objects aggregated to this object. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Constructor. More... | |
SimpleRefCount (const SimpleRefCount &o) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount (void) const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o) |
Assignment. More... | |
void | Ref (void) const |
Increment the reference count. More... | |
void | Unref (void) const |
Decrement the reference count. More... | |
Public Member Functions inherited from ns3::ObjectBase | |
virtual | ~ObjectBase () |
Virtual destructor. More... | |
void | GetAttribute (std::string name, AttributeValue &value) const |
bool | GetAttributeFailSafe (std::string name, AttributeValue &attribute) const |
void | SetAttribute (std::string name, const AttributeValue &value) |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId (void) |
Register this type. More... | |
Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
static void | Cleanup (void) |
Noop. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId (void) |
Get the type ID. More... | |
Private Types | |
typedef sgi::hash_map < Ipv4Address, ArpCache::Entry *, Ipv4AddressHash > | Cache |
ARP Cache container. More... | |
typedef sgi::hash_map < Ipv4Address, ArpCache::Entry *, Ipv4AddressHash >::iterator | CacheI |
ARP Cache container iterator. More... | |
Private Member Functions | |
ArpCache (ArpCache const &) | |
Copy constructor. More... | |
virtual void | DoDispose (void) |
This method is called by Object::Dispose or by the object's destructor, whichever comes first. More... | |
void | HandleWaitReplyTimeout (void) |
This function is an event handler for the event that the ArpCache wants to check whether it must retry any Arp requests. More... | |
ArpCache & | operator= (ArpCache const &) |
Copy constructor. More... | |
Private Attributes | |
Time | m_aliveTimeout |
cache alive state timeout More... | |
Cache | m_arpCache |
the ARP cache More... | |
Callback< void, Ptr< const ArpCache >, Ipv4Address > | m_arpRequestCallback |
reply timeout callback More... | |
Time | m_deadTimeout |
cache dead state timeout More... | |
Ptr< NetDevice > | m_device |
NetDevice associated with the cache. More... | |
TracedCallback< Ptr< const Packet > > | m_dropTrace |
trace for packets dropped by the ARP cache queue More... | |
Ptr< Ipv4Interface > | m_interface |
Ipv4Interface associated with the cache. More... | |
uint32_t | m_maxRetries |
max retries for a resolution More... | |
uint32_t | m_pendingQueueSize |
number of packets waiting for a resolution More... | |
Time | m_waitReplyTimeout |
cache reply state timeout More... | |
EventId | m_waitReplyTimer |
cache alive state timer More... | |
Additional Inherited Members | |
Protected Member Functions inherited from ns3::Object | |
Object (const Object &o) | |
virtual void | DoInitialize (void) |
This method is called only once by Object::Initialize. More... | |
virtual void | NotifyNewAggregate (void) |
This method is invoked whenever two sets of objects are aggregated together. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
virtual void | NotifyConstructionCompleted (void) |
This method is invoked once all member attributes have been initialized. More... | |
An ARP cache.
A cached lookup table for translating layer 3 addresses to layer 2. This implementation does lookups from IPv4 to a MAC address
ns3::ArpCache is accessible through the following paths with Config::Set and Config::Connect:
Definition at line 49 of file arp-cache.h.
|
private |
ARP Cache container.
Definition at line 270 of file arp-cache.h.
|
private |
ARP Cache container iterator.
Definition at line 274 of file arp-cache.h.
|
private |
Copy constructor.
Defined and unimplemented to avoid misuse
ns3::ArpCache::ArpCache | ( | ) |
Definition at line 76 of file arp-cache.cc.
References NS_LOG_FUNCTION.
ns3::ArpCache::~ArpCache | ( | ) |
Definition at line 83 of file arp-cache.cc.
References NS_LOG_FUNCTION.
ArpCache::Entry * ns3::ArpCache::Add | ( | Ipv4Address | to | ) |
Add an Ipv4Address to this ARP cache.
Definition at line 259 of file arp-cache.cc.
References m_arpCache, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::EpcS1uUlTestCase::DoRun(), and ns3::ArpL3Protocol::Lookup().
|
privatevirtual |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
It is safe to call GetObject from within this method.
Reimplemented from ns3::Object.
Definition at line 89 of file arp-cache.cc.
References ns3::Object::DoDispose(), Flush(), ns3::EventId::IsRunning(), m_device, m_interface, m_waitReplyTimer, NS_LOG_FUNCTION, and ns3::Simulator::Remove().
void ns3::ArpCache::Flush | ( | void | ) |
Clear the ArpCache of all entries.
Definition at line 231 of file arp-cache.cc.
References ns3::EventId::Cancel(), ns3::EventId::IsRunning(), m_arpCache, m_waitReplyTimer, ns3::Simulator::Now(), NS_LOG_FUNCTION, and NS_LOG_LOGIC.
Referenced by ns3::ArpL3Protocol::CreateCache(), and DoDispose().
Time ns3::ArpCache::GetAliveTimeout | ( | void | ) | const |
Get the time the entry will be in ALIVE state (unless refreshed)
Definition at line 144 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION.
Time ns3::ArpCache::GetDeadTimeout | ( | void | ) | const |
Get the time the entry will be in DEAD state before being removed.
Definition at line 150 of file arp-cache.cc.
References m_deadTimeout, and NS_LOG_FUNCTION.
Returns the NetDevice that this ARP cache is associated with.
Definition at line 111 of file arp-cache.cc.
References m_device, and NS_LOG_FUNCTION.
Ptr< Ipv4Interface > ns3::ArpCache::GetInterface | ( | void | ) | const |
Returns the Ipv4Interface that this ARP cache is associated with.
Definition at line 118 of file arp-cache.cc.
References m_interface, and NS_LOG_FUNCTION.
|
static |
Get the type ID.
Definition at line 40 of file arp-cache.cc.
References m_aliveTimeout, m_deadTimeout, m_dropTrace, m_maxRetries, m_pendingQueueSize, m_waitReplyTimeout, ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
Time ns3::ArpCache::GetWaitReplyTimeout | ( | void | ) | const |
Get the time the entry will be in WAIT_REPLY state.
Definition at line 156 of file arp-cache.cc.
References m_waitReplyTimeout, and NS_LOG_FUNCTION.
|
private |
This function is an event handler for the event that the ArpCache wants to check whether it must retry any Arp requests.
If there are no Arp requests pending, this event is not scheduled.
Definition at line 184 of file arp-cache.cc.
References ns3::ArpCache::Entry::ClearRetries(), ns3::ArpCache::Entry::DequeuePending(), ns3::ArpCache::Entry::GetIpv4Address(), ns3::ArpCache::Entry::GetRetries(), ns3::ArpCache::Entry::IncrementRetries(), ns3::ArpCache::Entry::IsWaitReply(), m_arpCache, m_arpRequestCallback, m_device, m_dropTrace, m_maxRetries, m_waitReplyTimeout, m_waitReplyTimer, ns3::ArpCache::Entry::MarkDead(), ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Simulator::Schedule().
Referenced by StartWaitReplyTimer().
ArpCache::Entry * ns3::ArpCache::Lookup | ( | Ipv4Address | destination | ) |
Do lookup in the ARP cache against an IP address.
destination | The destination IPv4 address to lookup the MAC address of |
Definition at line 247 of file arp-cache.cc.
References m_arpCache, and NS_LOG_FUNCTION.
Referenced by ns3::ArpL3Protocol::Lookup().
Copy constructor.
Defined and unimplemented to avoid misuse
void ns3::ArpCache::SetAliveTimeout | ( | Time | aliveTimeout | ) |
Set the time the entry will be in ALIVE state (unless refreshed)
aliveTimeout | the Alive state timeout |
Definition at line 125 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION.
Referenced by ns3::EpcS1uUlTestCase::DoRun().
void ns3::ArpCache::SetArpRequestCallback | ( | Callback< void, Ptr< const ArpCache >, Ipv4Address > | arpRequestCallback | ) |
This callback is set when the ArpCache is set up and allows the cache to generate an Arp request when the WaitReply time expires and a retransmission must be sent.
arpRequestCallback | Callback for transmitting an Arp request. |
Definition at line 163 of file arp-cache.cc.
References m_arpRequestCallback, and NS_LOG_FUNCTION.
void ns3::ArpCache::SetDeadTimeout | ( | Time | deadTimeout | ) |
Set the time the entry will be in DEAD state before being removed.
deadTimeout | the Dead state timeout |
Definition at line 131 of file arp-cache.cc.
References m_deadTimeout, and NS_LOG_FUNCTION.
void ns3::ArpCache::SetDevice | ( | Ptr< NetDevice > | device, |
Ptr< Ipv4Interface > | interface | ||
) |
Set the NetDevice and Ipv4Interface associated with the ArpCache.
device | The hardware NetDevice associated with this ARP chache |
interface | the Ipv4Interface associated with this ARP chache |
Definition at line 103 of file arp-cache.cc.
References m_device, m_interface, and NS_LOG_FUNCTION.
Referenced by ns3::ArpL3Protocol::CreateCache().
void ns3::ArpCache::SetWaitReplyTimeout | ( | Time | waitReplyTimeout | ) |
Set the time the entry will be in WAIT_REPLY state.
waitReplyTimeout | the WAIT_REPLY state timeout |
Definition at line 137 of file arp-cache.cc.
References m_waitReplyTimeout, and NS_LOG_FUNCTION.
void ns3::ArpCache::StartWaitReplyTimer | ( | void | ) |
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is already running for the cache, in which case this method does nothing.
Definition at line 171 of file arp-cache.cc.
References HandleWaitReplyTimeout(), ns3::EventId::IsRunning(), m_waitReplyTimeout, m_waitReplyTimer, ns3::Simulator::Now(), NS_LOG_FUNCTION, NS_LOG_LOGIC, and ns3::Simulator::Schedule().
|
private |
cache alive state timeout
Definition at line 280 of file arp-cache.h.
Referenced by GetAliveTimeout(), GetTypeId(), and SetAliveTimeout().
|
private |
the ARP cache
Definition at line 294 of file arp-cache.h.
Referenced by Add(), Flush(), HandleWaitReplyTimeout(), and Lookup().
|
private |
reply timeout callback
Definition at line 284 of file arp-cache.h.
Referenced by HandleWaitReplyTimeout(), and SetArpRequestCallback().
|
private |
cache dead state timeout
Definition at line 281 of file arp-cache.h.
Referenced by GetDeadTimeout(), GetTypeId(), and SetDeadTimeout().
NetDevice associated with the cache.
Definition at line 278 of file arp-cache.h.
Referenced by DoDispose(), GetDevice(), HandleWaitReplyTimeout(), and SetDevice().
|
private |
trace for packets dropped by the ARP cache queue
Definition at line 295 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
|
private |
Ipv4Interface associated with the cache.
Definition at line 279 of file arp-cache.h.
Referenced by DoDispose(), GetInterface(), and SetDevice().
|
private |
max retries for a resolution
Definition at line 285 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
|
private |
number of packets waiting for a resolution
Definition at line 293 of file arp-cache.h.
Referenced by GetTypeId().
|
private |
cache reply state timeout
Definition at line 282 of file arp-cache.h.
Referenced by GetTypeId(), GetWaitReplyTimeout(), HandleWaitReplyTimeout(), SetWaitReplyTimeout(), and StartWaitReplyTimer().
|
private |
cache alive state timer
Definition at line 283 of file arp-cache.h.
Referenced by DoDispose(), Flush(), HandleWaitReplyTimeout(), and StartWaitReplyTimer().