A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ns3::ArpCache Class Reference

An ARP cache. More...

#include <arp-cache.h>

+ Inheritance diagram for ns3::ArpCache:
+ Collaboration diagram for ns3::ArpCache:

Classes

class  Entry
 A record that that holds information about an ArpCache entry. More...
 

Public Member Functions

 ArpCache ()
 
 ~ArpCache ()
 
ArpCache::EntryAdd (Ipv4Address to)
 Add an Ipv4Address to this ARP cache. More...
 
void Flush (void)
 Clear the ArpCache of all entries. More...
 
Time GetAliveTimeout (void) const
 
Time GetDeadTimeout (void) const
 
Ptr< NetDeviceGetDevice (void) const
 
Ptr< Ipv4InterfaceGetInterface (void) const
 
Time GetWaitReplyTimeout (void) const
 
ArpCache::EntryLookup (Ipv4Address destination)
 Do lookup in the ARP cache against an IP address. More...
 
void SetAliveTimeout (Time aliveTimeout)
 
void SetArpRequestCallback (Callback< void, Ptr< const ArpCache >, Ipv4Address > arpRequestCallback)
 
void SetDeadTimeout (Time deadTimeout)
 
void SetDevice (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
 
void SetWaitReplyTimeout (Time waitReplyTimeout)
 
void StartWaitReplyTimer (void)
 
- Public Member Functions inherited from ns3::Object
 Object ()
 
virtual ~Object ()
 
void AggregateObject (Ptr< Object > other)
 
void Dispose (void)
 
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)
 
- Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
 SimpleRefCount ()
 
 SimpleRefCount (const SimpleRefCount &o)
 
uint32_t GetReferenceCount (void) const
 
SimpleRefCountoperator= (const SimpleRefCount &o)
 
void Ref (void) const
 
void Unref (void) const
 
- Public Member Functions inherited from ns3::ObjectBase
virtual ~ObjectBase ()
 
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)
 
- Static Public Member Functions inherited from ns3::Object
static TypeId GetTypeId (void)
 
- Static Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter >
static void Cleanup (void)
 
- Static Public Member Functions inherited from ns3::ObjectBase
static TypeId GetTypeId (void)
 

Private Types

typedef sgi::hash_map
< Ipv4Address, ArpCache::Entry
*, Ipv4AddressHash
Cache
 
typedef sgi::hash_map
< Ipv4Address, ArpCache::Entry
*, Ipv4AddressHash >::iterator 
CacheI
 

Private Member Functions

 ArpCache (ArpCache const &)
 
virtual void DoDispose (void)
 
void HandleWaitReplyTimeout (void)
 
ArpCacheoperator= (ArpCache const &)
 

Private Attributes

Time m_aliveTimeout
 
Cache m_arpCache
 
Callback< void, Ptr< const
ArpCache >, Ipv4Address
m_arpRequestCallback
 
Time m_deadTimeout
 
Ptr< NetDevicem_device
 
TracedCallback< Ptr< const
Packet > > 
m_dropTrace
 
Ptr< Ipv4Interfacem_interface
 
uint32_t m_maxRetries
 
uint32_t m_pendingQueueSize
 
Time m_waitReplyTimeout
 
EventId m_waitReplyTimer
 

Additional Inherited Members

- Protected Member Functions inherited from ns3::Object
 Object (const Object &o)
 
virtual void DoInitialize (void)
 
virtual void NotifyNewAggregate (void)
 
- Protected Member Functions inherited from ns3::ObjectBase
void ConstructSelf (const AttributeConstructionList &attributes)
 
virtual void NotifyConstructionCompleted (void)
 

Detailed Description

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

Config Paths

ns3::ArpCache is accessible through the following paths with Config::Set and Config::Connect:

  • /NodeList/[i]/$ns3::ArpL3Protocol/CacheList/[i]
  • /NodeList/[i]/$ns3::Ipv4L3Protocol/InterfaceList/[i]/ArpCache

Attributes

  • AliveTimeout: When this timeout expires, the matching cache entry needs refreshing
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +120000000000.0ns
    • Flags: construct write read
  • DeadTimeout: When this timeout expires, a new attempt to resolve the matching entry is made
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +100000000000.0ns
    • Flags: construct write read
  • WaitReplyTimeout: When this timeout expires, the cache entries will be scanned and entries in WaitReply state will resend ArpRequest unless MaxRetries has been exceeded, in which case the entry is marked dead
    • Set with class: ns3::TimeValue
    • Underlying type: Time -9223372036854775808.0ns:+9223372036854775807.0ns
    • Initial value: +1000000000.0ns
    • Flags: construct write read
  • MaxRetries: Number of retransmissions of ArpRequest before marking dead
  • PendingQueueSize: The size of the queue for packets pending an arp reply.

TraceSources

Definition at line 49 of file arp-cache.h.

Member Typedef Documentation

Definition at line 211 of file arp-cache.h.

typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator ns3::ArpCache::CacheI
private

Definition at line 212 of file arp-cache.h.

Constructor & Destructor Documentation

ns3::ArpCache::ArpCache ( ArpCache const &  )
private
ns3::ArpCache::ArpCache ( )

Definition at line 75 of file arp-cache.cc.

References NS_LOG_FUNCTION.

ns3::ArpCache::~ArpCache ( )

Definition at line 82 of file arp-cache.cc.

References NS_LOG_FUNCTION.

Member Function Documentation

ArpCache::Entry * ns3::ArpCache::Add ( Ipv4Address  to)

Add an Ipv4Address to this ARP cache.

Definition at line 258 of file arp-cache.cc.

References m_arpCache, NS_ASSERT, and NS_LOG_FUNCTION.

Referenced by ns3::EpcS1uUlTestCase::DoRun(), and ns3::ArpL3Protocol::Lookup().

+ Here is the caller graph for this function:

void ns3::ArpCache::DoDispose ( void  )
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 88 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().

+ Here is the call graph for this function:

void ns3::ArpCache::Flush ( void  )

Clear the ArpCache of all entries.

Definition at line 230 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Time ns3::ArpCache::GetAliveTimeout ( void  ) const

Definition at line 143 of file arp-cache.cc.

References m_aliveTimeout, and NS_LOG_FUNCTION.

Time ns3::ArpCache::GetDeadTimeout ( void  ) const

Definition at line 149 of file arp-cache.cc.

References m_deadTimeout, and NS_LOG_FUNCTION.

Ptr< NetDevice > ns3::ArpCache::GetDevice ( void  ) const
Returns
The NetDevice that this ARP cache is associated with

Definition at line 110 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 117 of file arp-cache.cc.

References m_interface, and NS_LOG_FUNCTION.

TypeId ns3::ArpCache::GetTypeId ( void  )
static
Time ns3::ArpCache::GetWaitReplyTimeout ( void  ) const

Definition at line 155 of file arp-cache.cc.

References m_waitReplyTimeout, and NS_LOG_FUNCTION.

void ns3::ArpCache::HandleWaitReplyTimeout ( void  )
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 183 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().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ArpCache::Entry * ns3::ArpCache::Lookup ( Ipv4Address  destination)

Do lookup in the ARP cache against an IP address.

Parameters
destinationThe destination IPv4 address to lookup the MAC address of
Returns
An ArpCache::Entry with info about layer 2

Definition at line 246 of file arp-cache.cc.

References m_arpCache, and NS_LOG_FUNCTION.

Referenced by ns3::ArpL3Protocol::Lookup().

+ Here is the caller graph for this function:

ArpCache& ns3::ArpCache::operator= ( ArpCache const &  )
private
void ns3::ArpCache::SetAliveTimeout ( Time  aliveTimeout)

Definition at line 124 of file arp-cache.cc.

References m_aliveTimeout, and NS_LOG_FUNCTION.

Referenced by ns3::EpcS1uUlTestCase::DoRun().

+ Here is the caller graph for this function:

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

Parameters
arpRequestCallbackCallback for transmitting an Arp request.

Definition at line 162 of file arp-cache.cc.

References m_arpRequestCallback, and NS_LOG_FUNCTION.

void ns3::ArpCache::SetDeadTimeout ( Time  deadTimeout)

Definition at line 130 of file arp-cache.cc.

References m_deadTimeout, and NS_LOG_FUNCTION.

void ns3::ArpCache::SetDevice ( Ptr< NetDevice device,
Ptr< Ipv4Interface interface 
)
Parameters
deviceThe hardware NetDevice associated with this ARP chache
interfacethe Ipv4Interface associated with this ARP chache

Definition at line 102 of file arp-cache.cc.

References m_device, m_interface, and NS_LOG_FUNCTION.

Referenced by ns3::ArpL3Protocol::CreateCache().

+ Here is the caller graph for this function:

void ns3::ArpCache::SetWaitReplyTimeout ( Time  waitReplyTimeout)

Definition at line 136 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 170 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().

+ Here is the call graph for this function:

Member Data Documentation

Time ns3::ArpCache::m_aliveTimeout
private

Definition at line 218 of file arp-cache.h.

Referenced by GetAliveTimeout(), GetTypeId(), and SetAliveTimeout().

Cache ns3::ArpCache::m_arpCache
private

Definition at line 231 of file arp-cache.h.

Referenced by Add(), Flush(), HandleWaitReplyTimeout(), and Lookup().

Callback<void, Ptr<const ArpCache>, Ipv4Address> ns3::ArpCache::m_arpRequestCallback
private

Definition at line 222 of file arp-cache.h.

Referenced by HandleWaitReplyTimeout(), and SetArpRequestCallback().

Time ns3::ArpCache::m_deadTimeout
private

Definition at line 219 of file arp-cache.h.

Referenced by GetDeadTimeout(), GetTypeId(), and SetDeadTimeout().

Ptr<NetDevice> ns3::ArpCache::m_device
private

Definition at line 216 of file arp-cache.h.

Referenced by DoDispose(), GetDevice(), HandleWaitReplyTimeout(), and SetDevice().

TracedCallback<Ptr<const Packet> > ns3::ArpCache::m_dropTrace
private

Definition at line 232 of file arp-cache.h.

Referenced by GetTypeId(), and HandleWaitReplyTimeout().

Ptr<Ipv4Interface> ns3::ArpCache::m_interface
private

Definition at line 217 of file arp-cache.h.

Referenced by DoDispose(), GetInterface(), and SetDevice().

uint32_t ns3::ArpCache::m_maxRetries
private

Definition at line 223 of file arp-cache.h.

Referenced by GetTypeId(), and HandleWaitReplyTimeout().

uint32_t ns3::ArpCache::m_pendingQueueSize
private

Definition at line 230 of file arp-cache.h.

Referenced by GetTypeId().

Time ns3::ArpCache::m_waitReplyTimeout
private
EventId ns3::ArpCache::m_waitReplyTimer
private

Definition at line 221 of file arp-cache.h.

Referenced by DoDispose(), Flush(), HandleWaitReplyTimeout(), and StartWaitReplyTimer().


The documentation for this class was generated from the following files: