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 () | |
void | SetDevice (Ptr< NetDevice > device, Ptr< Ipv4Interface > interface) |
Ptr< NetDevice > | GetDevice (void) const |
Ptr< Ipv4Interface > | GetInterface (void) const |
void | SetAliveTimeout (Time aliveTimeout) |
void | SetDeadTimeout (Time deadTimeout) |
void | SetWaitReplyTimeout (Time waitReplyTimeout) |
Time | GetAliveTimeout (void) const |
Time | GetDeadTimeout (void) const |
Time | GetWaitReplyTimeout (void) const |
void | SetArpRequestCallback (Callback< void, Ptr< const ArpCache >, Ipv4Address > arpRequestCallback) |
void | StartWaitReplyTimer (void) |
ArpCache::Entry * | Lookup (Ipv4Address destination) |
Do lookup in the ARP cache against an IP address. | |
ArpCache::Entry * | Add (Ipv4Address to) |
Add an Ipv4Address to this ARP cache. | |
void | Flush (void) |
Clear the ArpCache of all entries. | |
Static Public Member Functions | |
static TypeId | GetTypeId (void) |
This method returns the TypeId associated to ns3::ArpCache. | |
Private Types | |
typedef sgi::hash_map < Ipv4Address, ArpCache::Entry *, Ipv4AddressHash > | Cache |
typedef sgi::hash_map < Ipv4Address, ArpCache::Entry *, Ipv4AddressHash >::iterator | CacheI |
Private Member Functions | |
virtual void | DoDispose (void) |
void | HandleWaitReplyTimeout (void) |
Private Attributes | |
Ptr< NetDevice > | m_device |
Ptr< Ipv4Interface > | m_interface |
Time | m_aliveTimeout |
Time | m_deadTimeout |
Time | m_waitReplyTimeout |
EventId | m_waitReplyTimer |
Callback< void, Ptr< const ArpCache >, Ipv4Address > | m_arpRequestCallback |
uint32_t | m_maxRetries |
uint32_t | m_pendingQueueSize |
Cache | m_arpCache |
TracedCallback< Ptr< const Packet > > | m_dropTrace |
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 49 of file arp-cache.h.
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash> ns3::ArpCache::Cache [private] |
Definition at line 204 of file arp-cache.h.
typedef sgi::hash_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator ns3::ArpCache::CacheI [private] |
Definition at line 205 of file arp-cache.h.
ns3::ArpCache::ArpCache | ( | ) |
Definition at line 73 of file arp-cache.cc.
References NS_LOG_FUNCTION.
ns3::ArpCache::~ArpCache | ( | ) |
Definition at line 80 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 255 of file arp-cache.cc.
References m_arpCache, NS_ASSERT, and NS_LOG_FUNCTION_NOARGS.
void ns3::ArpCache::DoDispose | ( | void | ) | [private, virtual] |
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.
Reimplemented from ns3::Object.
Definition at line 86 of file arp-cache.cc.
References 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 227 of file arp-cache.cc.
References ns3::EventId::Cancel(), ns3::EventId::IsRunning(), m_arpCache, m_waitReplyTimer, ns3::Simulator::Now(), NS_LOG_FUNCTION_NOARGS, and NS_LOG_LOGIC.
Referenced by ns3::ArpL3Protocol::CreateCache(), and DoDispose().
Time ns3::ArpCache::GetAliveTimeout | ( | void | ) | const |
Definition at line 141 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::ArpCache::Entry::IsExpired().
Time ns3::ArpCache::GetDeadTimeout | ( | void | ) | const |
Definition at line 147 of file arp-cache.cc.
References m_deadTimeout, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::ArpCache::Entry::IsExpired().
Definition at line 108 of file arp-cache.cc.
References m_device, and NS_LOG_FUNCTION_NOARGS.
Ptr< Ipv4Interface > ns3::ArpCache::GetInterface | ( | void | ) | const |
Definition at line 115 of file arp-cache.cc.
References m_interface, and NS_LOG_FUNCTION_NOARGS.
TypeId ns3::ArpCache::GetTypeId | ( | void | ) | [static] |
This method returns the TypeId associated to ns3::ArpCache.
This object is accessible through the following paths with Config::Set and Config::Connect:
Attributes defined for this type:
TraceSources defined for this type:
Reimplemented from ns3::Object.
Definition at line 37 of file arp-cache.cc.
References ns3::TypeId::AddAttribute(), ns3::TypeId::AddTraceSource(), m_aliveTimeout, m_deadTimeout, m_dropTrace, m_maxRetries, m_pendingQueueSize, m_waitReplyTimeout, ns3::MakeTraceSourceAccessor(), ns3::Seconds(), and ns3::TypeId::SetParent().
Time ns3::ArpCache::GetWaitReplyTimeout | ( | void | ) | const |
Definition at line 153 of file arp-cache.cc.
References m_waitReplyTimeout, and NS_LOG_FUNCTION_NOARGS.
Referenced by ns3::ArpCache::Entry::IsExpired().
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 180 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::IsExpired(), 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_NOARGS, 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 243 of file arp-cache.cc.
References m_arpCache, and NS_LOG_FUNCTION_NOARGS.
void ns3::ArpCache::SetAliveTimeout | ( | Time | aliveTimeout | ) |
Definition at line 122 of file arp-cache.cc.
References m_aliveTimeout, and NS_LOG_FUNCTION_NOARGS.
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 160 of file arp-cache.cc.
References m_arpRequestCallback, and NS_LOG_FUNCTION_NOARGS.
void ns3::ArpCache::SetDeadTimeout | ( | Time | deadTimeout | ) |
Definition at line 128 of file arp-cache.cc.
References m_deadTimeout, and NS_LOG_FUNCTION_NOARGS.
void ns3::ArpCache::SetDevice | ( | Ptr< NetDevice > | device, | |
Ptr< Ipv4Interface > | interface | |||
) |
device | The hardware NetDevice associated with this ARP chache | |
interface | the Ipv4Interface associated with this ARP chache |
Definition at line 100 of file arp-cache.cc.
References m_device, m_interface, and NS_LOG_FUNCTION_NOARGS.
void ns3::ArpCache::SetWaitReplyTimeout | ( | Time | waitReplyTimeout | ) |
Definition at line 134 of file arp-cache.cc.
References m_waitReplyTimeout, and NS_LOG_FUNCTION_NOARGS.
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 168 of file arp-cache.cc.
References HandleWaitReplyTimeout(), ns3::EventId::IsRunning(), m_waitReplyTimeout, m_waitReplyTimer, ns3::Simulator::Now(), NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, and ns3::Simulator::Schedule().
Referenced by ns3::ArpCache::Entry::MarkWaitReply().
Time ns3::ArpCache::m_aliveTimeout [private] |
Definition at line 211 of file arp-cache.h.
Referenced by GetAliveTimeout(), GetTypeId(), and SetAliveTimeout().
Cache ns3::ArpCache::m_arpCache [private] |
Definition at line 224 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 215 of file arp-cache.h.
Referenced by HandleWaitReplyTimeout(), and SetArpRequestCallback().
Time ns3::ArpCache::m_deadTimeout [private] |
Definition at line 212 of file arp-cache.h.
Referenced by GetDeadTimeout(), GetTypeId(), and SetDeadTimeout().
Ptr<NetDevice> ns3::ArpCache::m_device [private] |
Definition at line 209 of file arp-cache.h.
Referenced by DoDispose(), GetDevice(), HandleWaitReplyTimeout(), and SetDevice().
TracedCallback<Ptr<const Packet> > ns3::ArpCache::m_dropTrace [private] |
Definition at line 225 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
Ptr<Ipv4Interface> ns3::ArpCache::m_interface [private] |
Definition at line 210 of file arp-cache.h.
Referenced by DoDispose(), GetInterface(), and SetDevice().
uint32_t ns3::ArpCache::m_maxRetries [private] |
Definition at line 216 of file arp-cache.h.
Referenced by GetTypeId(), and HandleWaitReplyTimeout().
uint32_t ns3::ArpCache::m_pendingQueueSize [private] |
Definition at line 223 of file arp-cache.h.
Referenced by GetTypeId(), and ns3::ArpCache::Entry::UpdateWaitReply().
Time ns3::ArpCache::m_waitReplyTimeout [private] |
Definition at line 213 of file arp-cache.h.
Referenced by GetTypeId(), GetWaitReplyTimeout(), HandleWaitReplyTimeout(), SetWaitReplyTimeout(), and StartWaitReplyTimer().
EventId ns3::ArpCache::m_waitReplyTimer [private] |
Definition at line 214 of file arp-cache.h.
Referenced by DoDispose(), Flush(), HandleWaitReplyTimeout(), and StartWaitReplyTimer().