20 #include "ns3/assert.h"
21 #include "ns3/packet.h"
22 #include "ns3/simulator.h"
23 #include "ns3/uinteger.h"
26 #include "ns3/trace-source-accessor.h"
43 .AddAttribute (
"AliveTimeout",
44 "When this timeout expires, the matching cache entry needs refreshing",
48 .AddAttribute (
"DeadTimeout",
49 "When this timeout expires, a new attempt to resolve the matching entry is made",
53 .AddAttribute (
"WaitReplyTimeout",
54 "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",
58 .AddAttribute (
"MaxRetries",
59 "Number of retransmissions of ArpRequest before marking dead",
62 MakeUintegerChecker<uint32_t> ())
63 .AddAttribute (
"PendingQueueSize",
64 "The size of the queue for packets pending an arp reply.",
67 MakeUintegerChecker<uint32_t> ())
68 .AddTraceSource (
"Drop",
69 "Packet dropped due to ArpCache entry in WaitReply expiring.",
187 bool restartWaitReplyTimer =
false;
197 " expired -- retransmitting arp request since retries = " <<
200 restartWaitReplyTimer =
true;
207 " expired -- drop since max retries exceeded: " <<
221 if (restartWaitReplyTimer)
265 entry->SetIpv4Address (to);
282 return (m_state == DEAD) ?
true :
false;
288 return (m_state == ALIVE) ?
true :
false;
294 return (m_state == WAIT_REPLY) ?
true :
false;
311 m_macAddress = macAddress;
326 if (m_pending.size () >= m_arp->m_pendingQueueSize)
330 m_pending.push_back (waiting);
337 NS_ASSERT (m_state == ALIVE || m_state == DEAD);
339 m_state = WAIT_REPLY;
340 m_pending.push_back (waiting);
342 m_arp->StartWaitReplyTimer ();
356 return m_ipv4Address;
362 m_ipv4Address = destination;
370 return m_arp->GetWaitReplyTimeout ();
372 return m_arp->GetDeadTimeout ();
374 return m_arp->GetAliveTimeout ();
398 if (m_pending.empty ())
405 m_pending.pop_front ();
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
void StartWaitReplyTimer(void)
keep track of time values and allow control of global simulation resolution
void SetArpRequestCallback(Callback< void, Ptr< const ArpCache >, Ipv4Address > arpRequestCallback)
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
ArpCache::Entry * Add(Ipv4Address to)
Add an Ipv4Address to this ARP cache.
virtual void DoDispose(void)
static TypeId GetTypeId(void)
ArpCache::Entry * Lookup(Ipv4Address destination)
Do lookup in the ARP cache against an IP address.
#define NS_ASSERT(condition)
Callback< void, Ptr< const ArpCache >, Ipv4Address > m_arpRequestCallback
#define NS_LOG_COMPONENT_DEFINE(name)
Time GetDeadTimeout(void) const
Ptr< NetDevice > GetDevice(void) const
virtual void DoDispose(void)
bool IsRunning(void) const
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
a polymophic address class
double GetSeconds(void) const
void SetIpv4Address(Ipv4Address destination)
void HandleWaitReplyTimeout(void)
hold objects of type ns3::Time
void MarkWaitReply(Ptr< Packet > waiting)
Hold an unsigned integer type.
NS_OBJECT_ENSURE_REGISTERED(AntennaModel)
uint32_t GetRetries(void) const
Ptr< Ipv4Interface > m_interface
bool IsExpired(void) const
Ipv4Address GetIpv4Address(void) const
#define NS_LOG_LOGIC(msg)
Address GetMacAddress(void) const
void SetDeadTimeout(Time deadTimeout)
void SetAliveTimeout(Time aliveTimeout)
Ptr< Ipv4Interface > GetInterface(void) const
static void Remove(const EventId &id)
void IncrementRetries(void)
Increment the counter of number of retries for an entry.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
void MarkAlive(Address macAddress)
Time GetAliveTimeout(void) const
A record that that holds information about an ArpCache entry.
void Flush(void)
Clear the ArpCache of all entries.
Entry(ArpCache *arp)
Constructor.
Time GetTimeout(void) const
TracedCallback< Ptr< const Packet > > m_dropTrace
bool UpdateWaitReply(Ptr< Packet > waiting)
Ipv4 addresses are stored in host order in this class.
sgi::hash_map< Ipv4Address, ArpCache::Entry *, Ipv4AddressHash >::iterator CacheI
#define NS_LOG_DEBUG(msg)
Ptr< Packet > DequeuePending(void)
Time GetWaitReplyTimeout(void) const
void ClearRetries(void)
Zero the counter of number of retries for an entry.
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range. Both limits are inclusive.
Ptr< NetDevice > m_device
void MarkDead(void)
Changes the state of this entry to dead.
a base class which provides memory management and object aggregation
uint32_t m_pendingQueueSize
void SetWaitReplyTimeout(Time waitReplyTimeout)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)