An ARP cache. More...
#include "arp-cache.h"
Classes | |
class | Entry |
A record that that holds information about an ArpCache entry. More... | |
Public Types | |
typedef std::pair< Ptr< Packet >, Ipv4Header > | Ipv4PayloadHeaderPair |
Pair of a packet and an Ipv4 header. More... | |
Public Member Functions | |
ArpCache () | |
ArpCache (const ArpCache &)=delete | |
~ArpCache () override | |
ArpCache::Entry * | Add (Ipv4Address to) |
Add an Ipv4Address to this ARP cache. More... | |
void | Flush () |
Clear the ArpCache of all entries. More... | |
Time | GetAliveTimeout () const |
Get the time the entry will be in ALIVE state (unless refreshed) More... | |
Time | GetDeadTimeout () const |
Get the time the entry will be in DEAD state before being removed. More... | |
Ptr< NetDevice > | GetDevice () const |
Returns the NetDevice that this ARP cache is associated with. More... | |
Ptr< Ipv4Interface > | GetInterface () const |
Returns the Ipv4Interface that this ARP cache is associated with. More... | |
Time | GetWaitReplyTimeout () 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... | |
std::list< ArpCache::Entry * > | LookupInverse (Address destination) |
Do lookup in the ARP cache against a MAC address. More... | |
ArpCache & | operator= (const ArpCache &)=delete |
void | PrintArpCache (Ptr< OutputStreamWrapper > stream) |
Print the ARP cache entries. More... | |
void | Remove (ArpCache::Entry *entry) |
Remove an entry. More... | |
void | RemoveAutoGeneratedEntries () |
Clear the ArpCache of all Auto-Generated entries. 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 () |
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 () | |
Constructor. More... | |
~Object () override | |
Destructor. More... | |
void | AggregateObject (Ptr< Object > other) |
Aggregate two Objects together. More... | |
void | Dispose () |
Dispose of this Object. More... | |
AggregateIterator | GetAggregateIterator () const |
Get an iterator to the Objects aggregated to this one. More... | |
TypeId | GetInstanceTypeId () const override |
Get the most derived TypeId for this Object. More... | |
template<typename T > | |
Ptr< T > | GetObject () const |
Get a pointer to the requested aggregated Object. More... | |
template<> | |
Ptr< Object > | GetObject () const |
Specialization of () for objects of type ns3::Object. More... | |
template<typename T > | |
Ptr< T > | GetObject (TypeId tid) const |
Get a pointer to the requested aggregated Object by TypeId. More... | |
template<> | |
Ptr< Object > | GetObject (TypeId tid) const |
Specialization of (TypeId tid) for objects of type ns3::Object. More... | |
void | Initialize () |
Invoke DoInitialize on all Objects aggregated to this one. More... | |
bool | IsInitialized () const |
Check if the object has been initialized. More... | |
Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
SimpleRefCount () | |
Default constructor. More... | |
SimpleRefCount (const SimpleRefCount &o[[maybe_unused]]) | |
Copy constructor. More... | |
uint32_t | GetReferenceCount () const |
Get the reference count of the object. More... | |
SimpleRefCount & | operator= (const SimpleRefCount &o[[maybe_unused]]) |
Assignment operator. More... | |
void | Ref () const |
Increment the reference count. More... | |
void | Unref () 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 |
Get the value of an attribute, raising fatal errors if unsuccessful. More... | |
bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
Get the value of an attribute without raising errors. More... | |
void | SetAttribute (std::string name, const AttributeValue &value) |
Set a single attribute, raising fatal errors if unsuccessful. More... | |
bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
Set a single attribute without raising errors. More... | |
bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
Connect a TraceSource to a Callback with a context. More... | |
bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
Connect a TraceSource to a Callback without a context. More... | |
bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected with a context. More... | |
bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
Disconnect from a TraceSource a Callback previously connected without a context. More... | |
Static Public Member Functions | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Static Public Member Functions inherited from ns3::Object | |
static TypeId | GetTypeId () |
Register this type. More... | |
Static Public Member Functions inherited from ns3::ObjectBase | |
static TypeId | GetTypeId () |
Get the type ID. More... | |
Private Types | |
typedef std::map< Ipv4Address, ArpCache::Entry * > | Cache |
ARP Cache container. More... | |
typedef std::map< Ipv4Address, ArpCache::Entry * >::iterator | CacheI |
ARP Cache container iterator. More... | |
Private Member Functions | |
void | DoDispose () override |
Destructor implementation. More... | |
void | HandleWaitReplyTimeout () |
This function is an event handler for the event that the ArpCache wants to check whether it must retry any Arp requests. 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) | |
Copy an Object. More... | |
virtual void | DoInitialize () |
Initialize() implementation. More... | |
virtual void | NotifyNewAggregate () |
Notify all Objects aggregated to this one of a new Object being aggregated. More... | |
Protected Member Functions inherited from ns3::ObjectBase | |
void | ConstructSelf (const AttributeConstructionList &attributes) |
Complete construction of ObjectBase; invoked by derived classes. More... | |
virtual void | NotifyConstructionCompleted () |
Notifier called once the ObjectBase is fully constructed. More... | |
Related Functions inherited from ns3::ObjectBase | |
static TypeId | GetObjectIid () |
Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. 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
Definition at line 52 of file arp-cache.h.
|
private |
ARP Cache container.
Definition at line 324 of file arp-cache.h.
|
private |
ARP Cache container iterator.
Definition at line 328 of file arp-cache.h.
typedef std::pair<Ptr<Packet>, Ipv4Header> ns3::ArpCache::Ipv4PayloadHeaderPair |
Pair of a packet and an Ipv4 header.
Definition at line 178 of file arp-cache.h.
ns3::ArpCache::ArpCache | ( | ) |
Definition at line 86 of file arp-cache.cc.
References NS_LOG_FUNCTION.
|
override |
Definition at line 93 of file arp-cache.cc.
References NS_LOG_FUNCTION.
|
delete |
ArpCache::Entry * ns3::ArpCache::Add | ( | Ipv4Address | to | ) |
Add an Ipv4Address to this ARP cache.
to | the destination address of the ARP entry. |
Definition at line 352 of file arp-cache.cc.
References m_arpCache, NS_ASSERT, and NS_LOG_FUNCTION.
Referenced by ns3::NeighborCacheHelper::AddEntry(), FlushTest::DoRun(), EpcS1uUlTestCase::DoRun(), and ns3::ArpL3Protocol::Lookup().
|
overrideprivatevirtual |
Destructor implementation.
This method is called by Dispose() or by the Object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overridden 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 99 of file arp-cache.cc.
References ns3::EventId::Cancel(), ns3::Object::DoDispose(), Flush(), ns3::EventId::IsRunning(), m_device, m_interface, m_waitReplyTimer, and NS_LOG_FUNCTION.
void ns3::ArpCache::Flush | ( | ) |
Clear the ArpCache of all entries.
Definition at line 245 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 | ( | ) | const |
Get the time the entry will be in ALIVE state (unless refreshed)
Definition at line 156 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION.
Time ns3::ArpCache::GetDeadTimeout | ( | ) | const |
Get the time the entry will be in DEAD state before being removed.
Definition at line 163 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 121 of file arp-cache.cc.
References m_device, and NS_LOG_FUNCTION.
Ptr< Ipv4Interface > ns3::ArpCache::GetInterface | ( | ) | const |
Returns the Ipv4Interface that this ARP cache is associated with.
Definition at line 128 of file arp-cache.cc.
References m_interface, and NS_LOG_FUNCTION.
Referenced by ns3::ArpL3Protocol::Receive().
|
static |
Get the type ID.
Definition at line 41 of file arp-cache.cc.
References m_aliveTimeout, m_deadTimeout, m_dropTrace, m_maxRetries, m_pendingQueueSize, m_waitReplyTimeout, ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeUintegerAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().
Time ns3::ArpCache::GetWaitReplyTimeout | ( | ) | const |
Get the time the entry will be in WAIT_REPLY state.
Definition at line 170 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 197 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 340 of file arp-cache.cc.
References m_arpCache, and NS_LOG_FUNCTION.
Referenced by ns3::NeighborCacheHelper::AddEntry(), ns3::ArpL3Protocol::Lookup(), ns3::ArpL3Protocol::Receive(), ns3::Ipv4L3Protocol::Receive(), and ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressRemoved().
std::list< ArpCache::Entry * > ns3::ArpCache::LookupInverse | ( | Address | destination | ) |
Do lookup in the ARP cache against a MAC address.
destination | The destination MAC address to lookup of |
Definition at line 323 of file arp-cache.cc.
References ns3::ArpCache::Entry::GetMacAddress(), m_arpCache, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4L3Protocol::Receive().
void ns3::ArpCache::PrintArpCache | ( | Ptr< OutputStreamWrapper > | stream | ) |
Print the ARP cache entries.
stream | the ostream the ARP cache entries is printed to |
Definition at line 262 of file arp-cache.cc.
References ns3::Names::FindName(), ns3::OutputStreamWrapper::GetStream(), m_arpCache, m_device, and NS_LOG_FUNCTION.
Referenced by ns3::Ipv4RoutingHelper::PrintArpCache(), and ns3::Ipv4RoutingHelper::PrintArpCacheEvery().
void ns3::ArpCache::Remove | ( | ArpCache::Entry * | entry | ) |
Remove an entry.
entry | pointer to delete it from the list |
Definition at line 364 of file arp-cache.cc.
References ns3::ArpCache::Entry::ClearPendingPacket(), m_arpCache, NS_LOG_FUNCTION, and NS_LOG_WARN.
Referenced by ns3::NeighborCacheHelper::UpdateCacheByIpv4AddressRemoved().
void ns3::ArpCache::RemoveAutoGeneratedEntries | ( | ) |
Clear the ArpCache of all Auto-Generated entries.
Definition at line 306 of file arp-cache.cc.
References m_arpCache, and NS_LOG_FUNCTION.
Referenced by ns3::NeighborCacheHelper::FlushAutoGenerated().
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 135 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION.
Referenced by 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 177 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 142 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 cache |
interface | the Ipv4Interface associated with this ARP cache |
Definition at line 113 of file arp-cache.cc.
References m_device, m_interface, and NS_LOG_FUNCTION.
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 149 of file arp-cache.cc.
References m_waitReplyTimeout, and NS_LOG_FUNCTION.
void ns3::ArpCache::StartWaitReplyTimer | ( | ) |
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 184 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 334 of file arp-cache.h.
Referenced by GetAliveTimeout(), GetTypeId(), and SetAliveTimeout().
|
private |
the ARP cache
Definition at line 349 of file arp-cache.h.
Referenced by Add(), Flush(), HandleWaitReplyTimeout(), Lookup(), LookupInverse(), PrintArpCache(), Remove(), and RemoveAutoGeneratedEntries().
|
private |
reply timeout callback
Definition at line 339 of file arp-cache.h.
Referenced by HandleWaitReplyTimeout(), and SetArpRequestCallback().
|
private |
cache dead state timeout
Definition at line 335 of file arp-cache.h.
Referenced by GetDeadTimeout(), GetTypeId(), and SetDeadTimeout().
NetDevice associated with the cache.
Definition at line 332 of file arp-cache.h.
Referenced by DoDispose(), GetDevice(), HandleWaitReplyTimeout(), PrintArpCache(), and SetDevice().
|
private |
trace for packets dropped by the ARP cache queue
Definition at line 351 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
|
private |
Ipv4Interface associated with the cache.
Definition at line 333 of file arp-cache.h.
Referenced by DoDispose(), GetInterface(), and SetDevice().
|
private |
max retries for a resolution
Definition at line 340 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
|
private |
number of packets waiting for a resolution
Definition at line 348 of file arp-cache.h.
Referenced by GetTypeId().
|
private |
cache reply state timeout
Definition at line 336 of file arp-cache.h.
Referenced by GetTypeId(), GetWaitReplyTimeout(), HandleWaitReplyTimeout(), SetWaitReplyTimeout(), and StartWaitReplyTimer().
|
private |
cache alive state timer
Definition at line 337 of file arp-cache.h.
Referenced by DoDispose(), Flush(), HandleWaitReplyTimeout(), and StartWaitReplyTimer().