25 #include <unordered_map>
26 #include "ns3/simulator.h"
27 #include "ns3/callback.h"
28 #include "ns3/packet.h"
29 #include "ns3/nstime.h"
30 #include "ns3/net-device.h"
31 #include "ns3/ipv4-address.h"
32 #include "ns3/address.h"
34 #include "ns3/object.h"
35 #include "ns3/traced-callback.h"
36 #include "ns3/output-stream-wrapper.h"
306 typedef std::unordered_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>
Cache;
310 typedef std::unordered_map<Ipv4Address, ArpCache::Entry *, Ipv4AddressHash>::iterator
CacheI;
a polymophic address class
A record that that holds information about an ArpCache entry.
void SetIpv4Address(Ipv4Address destination)
std::list< Ipv4PayloadHeaderPair > m_pending
list of pending packets for the entry's IP
ArpCache * m_arp
pointer to the ARP cache owning the entry
void ClearRetries(void)
Zero the counter of number of retries for an entry.
Ipv4Address m_ipv4Address
entry's IP address
Time m_lastSeen
last moment a packet from that address has been seen
bool UpdateWaitReply(Ipv4PayloadHeaderPair waiting)
Time GetTimeout(void) const
Returns the entry timeout.
Address m_macAddress
entry's MAC address
Ipv4PayloadHeaderPair DequeuePending(void)
void MarkPermanent(void)
Changes the state of this entry to Permanent.
void ClearPendingPacket(void)
Clear the pending packet list.
ArpCacheEntryState_e
ARP cache entry states.
uint32_t m_retries
rerty counter
void MarkDead(void)
Changes the state of this entry to dead.
void IncrementRetries(void)
Increment the counter of number of retries for an entry.
void MarkAlive(Address macAddress)
void SetMacAddress(Address macAddress)
Ipv4Address GetIpv4Address(void) const
void MarkWaitReply(Ipv4PayloadHeaderPair waiting)
void UpdateSeen(void)
Update the entry when seeing a packet.
uint32_t GetRetries(void) const
ArpCacheEntryState_e m_state
state of the entry
Address GetMacAddress(void) const
bool IsExpired(void) const
Entry(ArpCache *arp)
Constructor.
void Remove(ArpCache::Entry *entry)
Remove an entry.
void SetWaitReplyTimeout(Time waitReplyTimeout)
Set the time the entry will be in WAIT_REPLY state.
uint32_t m_maxRetries
max retries for a resolution
EventId m_waitReplyTimer
cache alive state timer
Time m_aliveTimeout
cache alive state timeout
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...
ArpCache & operator=(ArpCache const &)=delete
Time m_deadTimeout
cache dead state timeout
Time m_waitReplyTimeout
cache reply state timeout
Ptr< Ipv4Interface > m_interface
Ipv4Interface associated with the cache.
void PrintArpCache(Ptr< OutputStreamWrapper > stream)
Print the ARP cache entries.
void SetAliveTimeout(Time aliveTimeout)
Set the time the entry will be in ALIVE state (unless refreshed)
uint32_t m_pendingQueueSize
number of packets waiting for a resolution
std::unordered_map< Ipv4Address, ArpCache::Entry *, Ipv4AddressHash > Cache
ARP Cache container.
Ptr< Ipv4Interface > GetInterface(void) const
Returns the Ipv4Interface that this ARP cache is associated with.
Time GetAliveTimeout(void) const
Get the time the entry will be in ALIVE state (unless refreshed)
TracedCallback< Ptr< const Packet > > m_dropTrace
trace for packets dropped by the ARP cache queue
ArpCache::Entry * Add(Ipv4Address to)
Add an Ipv4Address to this ARP cache.
void Flush(void)
Clear the ArpCache of all entries.
virtual void DoDispose(void)
Destructor implementation.
void HandleWaitReplyTimeout(void)
This function is an event handler for the event that the ArpCache wants to check whether it must retr...
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
Set the NetDevice and Ipv4Interface associated with the ArpCache.
std::list< ArpCache::Entry * > LookupInverse(Address destination)
Do lookup in the ARP cache against a MAC address.
Callback< void, Ptr< const ArpCache >, Ipv4Address > m_arpRequestCallback
reply timeout callback
Time GetDeadTimeout(void) const
Get the time the entry will be in DEAD state before being removed.
ArpCache::Entry * Lookup(Ipv4Address destination)
Do lookup in the ARP cache against an IP address.
Cache m_arpCache
the ARP cache
Ptr< NetDevice > GetDevice(void) const
Returns the NetDevice that this ARP cache is associated with.
std::unordered_map< Ipv4Address, ArpCache::Entry *, Ipv4AddressHash >::iterator CacheI
ARP Cache container iterator.
Ptr< NetDevice > m_device
NetDevice associated with the cache.
std::pair< Ptr< Packet >, Ipv4Header > Ipv4PayloadHeaderPair
Pair of a packet and an Ipv4 header.
void StartWaitReplyTimer(void)
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is alr...
Time GetWaitReplyTimeout(void) const
Get the time the entry will be in WAIT_REPLY state.
static TypeId GetTypeId(void)
Get the type ID.
void SetDeadTimeout(Time deadTimeout)
Set the time the entry will be in DEAD state before being removed.
ArpCache(ArpCache const &)=delete
An identifier for simulation events.
Ipv4 addresses are stored in host order in this class.
A base class which provides memory management and object aggregation.
Simulation virtual time values and global simulation resolution.
Forward calls to a chain of Callback.
a unique identifier for an interface.
Every class exported by the ns3 library is enclosed in the ns3 namespace.