22 #include "ns3/address.h"
23 #include "ns3/callback.h"
24 #include "ns3/ipv4-address.h"
25 #include "ns3/net-device.h"
26 #include "ns3/nstime.h"
27 #include "ns3/object.h"
28 #include "ns3/output-stream-wrapper.h"
29 #include "ns3/packet.h"
31 #include "ns3/simulator.h"
32 #include "ns3/traced-callback.h"
324 typedef std::map<Ipv4Address, ArpCache::Entry*>
Cache;
328 typedef std::map<Ipv4Address, ArpCache::Entry*>::iterator
CacheI;
a polymophic address class
A record that that holds information about an ArpCache entry.
void SetIpv4Address(Ipv4Address destination)
void MarkAutoGenerated()
Changes the state of this entry to auto-generated.
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
Ipv4Address m_ipv4Address
entry's IP address
Time m_lastSeen
last moment a packet from that address has been seen
bool UpdateWaitReply(Ipv4PayloadHeaderPair waiting)
Address m_macAddress
entry's MAC address
Address GetMacAddress() const
void ClearPendingPacket()
Clear the pending packet list.
void MarkPermanent()
Changes the state of this entry to Permanent.
void ClearRetries()
Zero the counter of number of retries for an entry.
ArpCacheEntryState_e
ARP cache entry states.
uint32_t GetRetries() const
void UpdateSeen()
Update the entry when seeing a packet.
uint32_t m_retries
rerty counter
void IncrementRetries()
Increment the counter of number of retries for an entry.
void MarkAlive(Address macAddress)
void MarkDead()
Changes the state of this entry to dead.
void SetMacAddress(Address macAddress)
void MarkWaitReply(Ipv4PayloadHeaderPair waiting)
Ipv4PayloadHeaderPair DequeuePending()
ArpCacheEntryState_e m_state
state of the entry
Ipv4Address GetIpv4Address() const
Time GetTimeout() const
Returns the entry timeout.
Entry(ArpCache *arp)
Constructor.
Time GetWaitReplyTimeout() const
Get the time the entry will be in WAIT_REPLY state.
void Remove(ArpCache::Entry *entry)
Remove an entry.
void SetWaitReplyTimeout(Time waitReplyTimeout)
Set the time the entry will be in WAIT_REPLY state.
void HandleWaitReplyTimeout()
This function is an event handler for the event that the ArpCache wants to check whether it must retr...
Time GetAliveTimeout() const
Get the time the entry will be in ALIVE state (unless refreshed)
std::map< Ipv4Address, ArpCache::Entry * > Cache
ARP Cache container.
uint32_t m_maxRetries
max retries for a resolution
EventId m_waitReplyTimer
cache alive state timer
Time m_aliveTimeout
cache alive state timeout
void DoDispose() override
Destructor implementation.
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...
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 Flush()
Clear the ArpCache of all 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
ArpCache & operator=(const ArpCache &)=delete
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 SetDevice(Ptr< NetDevice > device, Ptr< Ipv4Interface > interface)
Set the NetDevice and Ipv4Interface associated with the ArpCache.
Ptr< Ipv4Interface > GetInterface() const
Returns the Ipv4Interface that this ARP cache is associated with.
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
ArpCache::Entry * Lookup(Ipv4Address destination)
Do lookup in the ARP cache against an IP address.
Cache m_arpCache
the ARP cache
void RemoveAutoGeneratedEntries()
Clear the ArpCache of all Auto-Generated entries.
Ptr< NetDevice > m_device
NetDevice associated with the cache.
void StartWaitReplyTimer()
This method will schedule a timeout at WaitReplyTimeout interval in the future, unless a timer is alr...
Time GetDeadTimeout() const
Get the time the entry will be in DEAD state before being removed.
static TypeId GetTypeId()
Get the type ID.
std::pair< Ptr< Packet >, Ipv4Header > Ipv4PayloadHeaderPair
Pair of a packet and an Ipv4 header.
void SetDeadTimeout(Time deadTimeout)
Set the time the entry will be in DEAD state before being removed.
Ptr< NetDevice > GetDevice() const
Returns the NetDevice that this ARP cache is associated with.
ArpCache(const ArpCache &)=delete
std::map< Ipv4Address, ArpCache::Entry * >::iterator CacheI
ARP Cache container iterator.
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.
Smart pointer class similar to boost::intrusive_ptr.
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.