22 #include "ns3/uinteger.h"
24 #include "ns3/names.h"
42 .AddAttribute (
"UnresolvedQueueSize",
43 "Size of the queue for packets pending an NA reply.",
46 MakeUintegerChecker<uint32_t> ())
108 entry->SetIpv6Address (to);
119 if ((*i).second == entry)
160 *os << i->first <<
" dev ";
168 *os << static_cast<int> (
m_device->GetIfIndex ());
171 *os <<
" lladdr " << i->second->GetMacAddress ();
173 if (i->second->IsReachable ())
175 *os <<
" REACHABLE\n";
177 else if (i->second->IsDelay ())
181 else if (i->second->IsIncomplete ())
183 *os <<
" INCOMPLETE\n";
185 else if (i->second->IsProbe ())
200 m_reachableTimer (
Timer::CANCEL_ON_DESTROY),
201 m_retransTimer (
Timer::CANCEL_ON_DESTROY),
202 m_probeTimer (
Timer::CANCEL_ON_DESTROY),
203 m_delayTimer (
Timer::CANCEL_ON_DESTROY),
204 m_lastReachabilityConfirmation (
Seconds (0.0)),
226 if (m_waiting.size () >=
m_ndCache->GetUnresQlen ())
230 m_waiting.remove (0);
232 m_waiting.push_back (p);
255 if (m_ipv6Address.IsLinkLocal ())
257 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();;
259 else if (!m_ipv6Address.IsAny ())
261 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
271 if (GetNSRetransmit () < icmpv6->MAX_MULTICAST_SOLICIT)
277 StartRetransmitTimer ();
282 if (malformedPacket == 0)
284 malformedPacket = Create<Packet> ();
303 if (m_ipv6Address.IsLinkLocal ())
305 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
307 else if (!m_ipv6Address.IsAny ())
309 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
323 Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address,
m_ndCache->GetDevice ()->GetAddress ());
326 ResetNSRetransmit ();
337 if (GetNSRetransmit () < icmpv6->MAX_UNICAST_SOLICIT)
341 if (m_ipv6Address.IsLinkLocal ())
343 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
345 else if (!m_ipv6Address.IsAny ())
347 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
363 Ptr<Packet> p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address,
m_ndCache->GetDevice ()->GetAddress ());
379 m_ipv6Address = ipv6Address;
385 return m_nsRetransmit;
403 return m_lastReachabilityConfirmation;
414 if (m_reachableTimer.IsRunning ())
416 m_reachableTimer.Cancel ();
420 m_reachableTimer.Schedule ();
426 m_reachableTimer.Cancel ();
432 if (m_probeTimer.IsRunning ())
434 m_probeTimer.Cancel ();
438 m_probeTimer.Schedule ();
444 m_probeTimer.Cancel ();
445 ResetNSRetransmit ();
452 if (m_delayTimer.IsRunning ())
454 m_delayTimer.Cancel ();
458 m_delayTimer.Schedule ();
464 m_delayTimer.Cancel ();
465 ResetNSRetransmit ();
471 if (m_retransTimer.IsRunning ())
473 m_retransTimer.Cancel ();
477 m_retransTimer.Schedule ();
483 m_retransTimer.Cancel ();
484 ResetNSRetransmit ();
490 m_state = INCOMPLETE;
494 m_waiting.push_back (p);
541 return (m_state == STALE);
547 return (m_state == REACHABLE);
553 return (m_state ==
DELAY);
559 return (m_state == INCOMPLETE);
565 return (m_state == PROBE);
bool IsAny() const
If the IPv6 address is the "Any" address.
void FunctionDelayTimeout()
Function called when delay timer timeout.
static TypeId GetTypeId()
Get the type ID.
Simulation virtual time values and global simulation resolution.
Time GetLastReachabilityConfirmation() const
Get the time of last reachability confirmation.
Smart pointer class similar to boost::intrusive_ptr.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void MarkIncomplete(Ptr< Packet > p)
Changes the state to this entry to INCOMPLETE.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Address GetMacAddress() const
Get the MAC address of this entry.
NdiscCache::Entry * Add(Ipv6Address to)
Add an entry.
void SetUnresQlen(uint32_t unresQlen)
Set the max number of waiting packet.
IPv6 layer implementation.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
void StopReachableTimer()
Stop the reachable timer.
virtual void DoDispose(void)
Destructor implementation.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
a polymophic address class
uint32_t GetUnresQlen()
Get the max number of waiting packet.
Ptr< Ipv6Interface > GetInterface() const
Get the Ipv6Interface associated with this cache.
bool IsDelay() const
Is the entry DELAY.
Ptr< Ipv6Interface > m_interface
the interface.
void FunctionRetransmitTimeout()
Function called when retransmit timer timeout.
void MarkReachable()
Changes the state to this entry to REACHABLE.
void Flush()
Flush the cache.
Hold an unsigned integer type.
#define DELAY(time)
Gets the delay between a given time and the current time.
Introspection did not find any typical Config paths.
static const uint32_t REACHABLE_TIME
Neighbor Discovery node constants : reachable time.
void PrintNdiscCache(Ptr< OutputStreamWrapper > stream)
Print the NDISC cache entries.
void StopProbeTimer()
Stop probe timer.
void StartRetransmitTimer()
Start retransmit timer.
void ClearWaitingPacket()
Clear the waiting packet list.
Entry(NdiscCache *nd)
Constructor.
bool IsProbe() const
Is the entry PROBE.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void AddWaitingPacket(Ptr< Packet > p)
Add a packet (or replace old value) in the queue.
void StartDelayTimer()
Start delay timer.
void StartReachableTimer()
Start the reachable timer.
bool IsIncomplete() const
Is the entry INCOMPLETE.
void FunctionReachableTimeout()
Function called when reachable timer timeout.
void StartProbeTimer()
Start probe timer.
static const uint32_t DEFAULT_UNRES_QLEN
Default value for unres qlen.
void Remove(NdiscCache::Entry *entry)
Delete an entry.
void FunctionProbeTimeout()
Function called when probe timer timeout.
uint32_t m_unresQlen
Max number of packet stored in m_waiting.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
Describes an IPv6 address.
NdiscCache::Entry * Lookup(Ipv6Address dst)
Lookup in the cache.
void MarkStale()
Changes the state to this entry to STALE.
void IncNSRetransmit()
Increment NS retransmit.
void DoDispose()
Dispose this object.
void SetIpv6Address(Ipv6Address ipv6Address)
Set the IPv6 address.
void MarkDelay()
Change the state to this entry to DELAY.
static const uint32_t RETRANS_TIMER
Neighbor Discovery node constants : retransmission timer.
void StopRetransmitTimer()
Stop retransmit timer.
Time Seconds(double value)
Construct a Time in the indicated unit.
void UpdateLastReachabilityconfirmation()
Update the time of last reachability confirmation.
void StopDelayTimer()
Stop delay timer.
static std::string FindName(Ptr< Object > object)
Given a pointer to an object, look to see if that object has a name associated with it and...
bool IsRouter() const
If the entry is a host or a router.
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv6Interface > interface)
Set the device and interface.
Cache m_ndCache
A list of Entry.
A record that holds information about an NdiscCache entry.
void SetRouter(bool router)
Set the node type.
static const uint8_t DELAY_FIRST_PROBE_TIME
Neighbor Discovery node constants : delay for the first probe.
A base class which provides memory management and object aggregation.
sgi::hash_map< Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash >::iterator CacheI
Neighbor Discovery Cache container iterator.
bool IsReachable() const
Is the entry REACHABLE.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method...
a unique identifier for an interface.
void ResetNSRetransmit()
Reset NS retransmit (=0).
Ptr< NetDevice > GetDevice() const
Get the NetDevice associated with this cache.
TypeId SetParent(TypeId tid)
void MarkProbe()
Changes the state to this entry to PROBE.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
bool IsStale() const
Is the entry STALE.
static Ipv6Address MakeSolicitedAddress(Ipv6Address addr)
Make the solicited IPv6 address.
Ptr< NetDevice > m_device
The NetDevice.
uint8_t GetNSRetransmit() const
Get the number of NS retransmit.