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