18#include "ns3/uinteger.h"
32 .SetGroupName(
"Internet")
33 .AddAttribute(
"UnresolvedQueueSize",
34 "Size of the queue for packets pending an NA reply.",
104std::list<NdiscCache::Entry*>
109 std::list<NdiscCache::Entry*> entryList;
116 entryList.push_back(entry);
129 entry->SetIpv6Address(to);
141 if ((*i).second == entry)
182 std::ostream* os = stream->GetStream();
186 *os << i->first <<
" dev ";
194 *os << static_cast<int>(
m_device->GetIfIndex());
197 *os <<
" lladdr " << i->second->GetMacAddress();
199 if (i->second->IsReachable())
201 *os <<
" REACHABLE\n";
203 else if (i->second->IsDelay())
207 else if (i->second->IsIncomplete())
209 *os <<
" INCOMPLETE\n";
211 else if (i->second->IsProbe())
215 else if (i->second->IsStale())
219 else if (i->second->IsPermanent())
221 *os <<
" PERMANENT\n";
223 else if (i->second->IsAutoGenerated())
225 *os <<
" STATIC_AUTOGENERATED\n";
229 NS_FATAL_ERROR(
"Test for possibly unreachable code-- please file a bug report, with a "
230 "test case, if this is ever hit");
239 m_nudTimer(
Timer::CANCEL_ON_DESTROY),
240 m_lastReachabilityConfirmation(
Seconds(0.0)),
265 if (m_waiting.size() >=
m_ndCache->GetUnresQlen())
269 m_waiting.pop_front();
271 m_waiting.push_back(p);
296 if (m_ipv6Address.IsLinkLocal())
298 addr =
m_ndCache->GetInterface()->GetLinkLocalAddress().GetAddress();
300 else if (!m_ipv6Address.IsAny())
302 addr =
m_ndCache->GetInterface()->GetAddressMatchingDestination(m_ipv6Address).GetAddress();
312 if (m_nsRetransmit < m_ndCache->
m_icmpv6->GetMaxMulticastSolicit())
321 StartRetransmitTimer();
326 if (!malformedPacket.first)
332 malformedPacket.first->AddHeader(malformedPacket.second);
335 m_ndCache->m_icmpv6->SendErrorDestinationUnreachable(malformedPacket.first,
352 if (m_ipv6Address.IsLinkLocal())
354 addr =
m_ndCache->GetInterface()->GetLinkLocalAddress().GetAddress();
356 else if (!m_ipv6Address.IsAny())
358 addr =
m_ndCache->GetInterface()->GetAddressMatchingDestination(m_ipv6Address).GetAddress();
376 p.first->AddHeader(p.second);
388 if (m_nsRetransmit < m_ndCache->
m_icmpv6->GetMaxUnicastSolicit())
394 if (m_ipv6Address.IsLinkLocal())
396 addr =
m_ndCache->GetInterface()->GetLinkLocalAddress().GetAddress();
398 else if (!m_ipv6Address.IsAny())
401 ->GetAddressMatchingDestination(m_ipv6Address)
423 p.first->AddHeader(p.second);
440 m_ipv6Address = ipv6Address;
447 return m_ipv6Address;
454 return m_lastReachabilityConfirmation;
461 if (m_nudTimer.IsRunning())
468 m_nudTimer.SetDelay(
m_ndCache->m_icmpv6->GetReachableTime());
469 m_nudTimer.Schedule();
477 if (m_state == REACHABLE)
480 if (m_nudTimer.IsRunning())
484 m_nudTimer.Schedule();
492 if (m_nudTimer.IsRunning())
498 m_nudTimer.SetDelay(
m_ndCache->m_icmpv6->GetRetransmissionTime());
499 m_nudTimer.Schedule();
506 if (m_nudTimer.IsRunning())
512 m_nudTimer.SetDelay(
m_ndCache->m_icmpv6->GetDelayFirstProbe());
513 m_nudTimer.Schedule();
520 if (m_nudTimer.IsRunning())
526 m_nudTimer.SetDelay(
m_ndCache->m_icmpv6->GetRetransmissionTime());
527 m_nudTimer.Schedule();
542 m_state = INCOMPLETE;
546 m_waiting.push_back(p);
550std::list<NdiscCache::Ipv6PayloadHeaderPair>
580std::list<NdiscCache::Ipv6PayloadHeaderPair>
609 m_state = STATIC_AUTOGENERATED;
616 return (m_state == STALE);
623 return (m_state == REACHABLE);
630 return (m_state ==
DELAY);
637 return (m_state == INCOMPLETE);
644 return (m_state == PROBE);
651 return (m_state == PERMANENT);
658 return (m_state == STATIC_AUTOGENERATED);
678 os << m_ipv6Address <<
" lladdr " << m_macAddress <<
" state ";
699 case STATIC_AUTOGENERATED:
700 os <<
"STATIC_AUTOGENERATED";
711 if (i->second->IsAutoGenerated())
713 i->second->ClearWaitingPacket();
a polymophic address class
Describes an IPv6 address.
static Ipv6Address MakeSolicitedAddress(Ipv6Address addr)
Make the solicited IPv6 address.
bool IsAny() const
If the IPv6 address is the "Any" address.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
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,...
A record that holds information about a NdiscCache entry.
void MarkProbe()
Changes the state to this entry to PROBE.
bool IsPermanent() const
Is the entry PERMANENT.
void MarkPermanent()
Change the state to this entry to PERMANENT.
void ClearWaitingPacket()
Clear the waiting packet list.
void StartProbeTimer()
Start probe timer.
void MarkReachable()
Changes the state to this entry to REACHABLE.
void StartReachableTimer()
Start the reachable timer.
void Print(std::ostream &os) const
Print this entry to the given output stream.
void UpdateReachableTimer()
Update the reachable timer.
void FunctionProbeTimeout()
Function called when probe timer timeout.
void MarkStale()
Changes the state to this entry to STALE.
Address GetMacAddress() const
Get the MAC address of this entry.
Ipv6Address GetIpv6Address() const
Get the IPv6 address.
void StartDelayTimer()
Start delay timer.
void MarkAutoGenerated()
Changes the state of this entry to auto-generated.
bool IsIncomplete() const
Is the entry INCOMPLETE.
void FunctionDelayTimeout()
Function called when delay timer timeout.
bool IsDelay() const
Is the entry DELAY.
void StartRetransmitTimer()
Start retransmit timer.
void SetIpv6Address(Ipv6Address ipv6Address)
Set the IPv6 address.
void MarkIncomplete(Ipv6PayloadHeaderPair p)
Changes the state to this entry to INCOMPLETE.
bool IsStale() const
Is the entry STALE.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
bool IsProbe() const
Is the entry PROBE.
Time GetLastReachabilityConfirmation() const
Get the time of last reachability confirmation.
void FunctionRetransmitTimeout()
Function called when retransmit timer timeout.
void MarkDelay()
Change the state to this entry to DELAY.
Entry(NdiscCache *nd)
Constructor.
bool IsRouter() const
If the entry is a host or a router.
void SetRouter(bool router)
Set the node type.
void FunctionReachableTimeout()
Function called when reachable timer timeout.
bool IsAutoGenerated() const
Is the entry STATIC_AUTOGENERATED.
void AddWaitingPacket(Ipv6PayloadHeaderPair p)
Add a packet (or replace old value) in the queue.
bool IsReachable() const
Is the entry REACHABLE.
void StopNudTimer()
Stop NUD timer and reset the NUD retransmission counter.
IPv6 Neighbor Discovery cache.
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv6Interface > interface, Ptr< Icmpv6L4Protocol > icmpv6)
Set the device and interface.
std::pair< Ptr< Packet >, Ipv6Header > Ipv6PayloadHeaderPair
Pair of a packet and an Ipv4 header.
virtual NdiscCache::Entry * Add(Ipv6Address to)
Add an entry.
void Flush()
Flush the cache.
Ptr< Ipv6Interface > m_interface
the interface.
void Remove(NdiscCache::Entry *entry)
Delete an entry.
void PrintNdiscCache(Ptr< OutputStreamWrapper > stream)
Print the NDISC cache entries.
~NdiscCache() override
Destructor.
Ptr< NetDevice > m_device
The NetDevice.
uint32_t GetUnresQlen()
Get the max number of waiting packet.
virtual NdiscCache::Entry * Lookup(Ipv6Address dst)
Lookup in the cache.
void RemoveAutoGeneratedEntries()
Clear the NDISC cache of all Auto-Generated entries.
void DoDispose() override
Dispose this object.
Ptr< NetDevice > GetDevice() const
Get the NetDevice associated with this cache.
static const uint32_t DEFAULT_UNRES_QLEN
Default value for unres qlen.
static TypeId GetTypeId()
Get the type ID.
Cache m_ndCache
A list of Entry.
std::list< NdiscCache::Entry * > LookupInverse(Address dst)
Lookup in the cache for a MAC address.
void SetUnresQlen(uint32_t unresQlen)
Set the max number of waiting packet.
Ptr< Icmpv6L4Protocol > m_icmpv6
the icmpv6 L4 protocol for this cache.
Ptr< Ipv6Interface > GetInterface() const
Get the Ipv6Interface associated with this cache.
uint32_t m_unresQlen
Max number of packet stored in m_waiting.
A base class which provides memory management and object aggregation.
virtual void DoDispose()
Destructor implementation.
Smart pointer class similar to boost::intrusive_ptr.
static Time Now()
Return the current simulation virtual time.
Simulation virtual time values and global simulation resolution.
A simple virtual Timer class.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Hold an unsigned integer type.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeUintegerChecker()
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
std::ostream & operator<<(std::ostream &os, const Angles &a)
#define DELAY(time)
Gets the delay between a given time and the current time.