|
A Discrete-Event Network Simulator
|
API
|
Go to the documentation of this file.
22 #include "ns3/uinteger.h"
24 #include "ns3/names.h"
42 .SetGroupName (
"Internet")
43 .AddAttribute (
"UnresolvedQueueSize",
44 "Size of the queue for packets pending an NA reply.",
47 MakeUintegerChecker<uint32_t> ())
112 std::list<NdiscCache::Entry *> entryList;
119 entryList.push_back (entry);
143 if ((*i).second == entry)
184 *os << i->first <<
" dev ";
195 *os <<
" lladdr " << i->second->GetMacAddress ();
197 if (i->second->IsReachable ())
199 *os <<
" REACHABLE\n";
201 else if (i->second->IsDelay ())
205 else if (i->second->IsIncomplete ())
207 *os <<
" INCOMPLETE\n";
209 else if (i->second->IsProbe ())
213 else if (i->second->IsStale ())
217 else if (i->second->IsPermanent ())
219 *os <<
" PERMANENT\n";
223 NS_FATAL_ERROR (
"Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit");
232 m_nudTimer (
Timer::CANCEL_ON_DESTROY),
233 m_lastReachabilityConfirmation (
Seconds (0.0)),
255 if (m_waiting.size () >=
m_ndCache->GetUnresQlen ())
259 m_waiting.pop_front ();
261 m_waiting.push_back (p);
283 if (m_ipv6Address.IsLinkLocal ())
285 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
287 else if (!m_ipv6Address.IsAny ())
289 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
299 if (m_nsRetransmit < m_ndCache->
m_icmpv6->GetMaxMulticastSolicit ())
305 StartRetransmitTimer ();
310 if (malformedPacket.first == 0)
312 malformedPacket.first = Create<Packet> ();
316 malformedPacket.first->AddHeader (malformedPacket.second);
333 if (m_ipv6Address.IsLinkLocal ())
335 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
337 else if (!m_ipv6Address.IsAny ())
339 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
354 p.first->AddHeader (p.second);
365 if (m_nsRetransmit < m_ndCache->
m_icmpv6->GetMaxUnicastSolicit ())
371 if (m_ipv6Address.IsLinkLocal ())
373 addr =
m_ndCache->GetInterface ()->GetLinkLocalAddress ().GetAddress ();
375 else if (!m_ipv6Address.IsAny ())
377 addr =
m_ndCache->GetInterface ()->GetAddressMatchingDestination (m_ipv6Address).GetAddress ();
393 p.first->AddHeader (p.second);
409 m_ipv6Address = ipv6Address;
415 return m_ipv6Address;
421 return m_lastReachabilityConfirmation;
427 if (m_nudTimer.IsRunning ())
429 m_nudTimer.Cancel ();
434 m_nudTimer.SetDelay (
m_ndCache->m_icmpv6->GetReachableTime ());
435 m_nudTimer.Schedule ();
442 if (m_state == REACHABLE)
445 if (m_nudTimer.IsRunning ())
447 m_nudTimer.Cancel ();
449 m_nudTimer.Schedule ();
456 if (m_nudTimer.IsRunning ())
458 m_nudTimer.Cancel ();
462 m_nudTimer.SetDelay (
m_ndCache->m_icmpv6->GetRetransmissionTime ());
463 m_nudTimer.Schedule ();
469 if (m_nudTimer.IsRunning ())
471 m_nudTimer.Cancel ();
475 m_nudTimer.SetDelay (
m_ndCache->m_icmpv6->GetDelayFirstProbe ());
476 m_nudTimer.Schedule ();
482 if (m_nudTimer.IsRunning ())
484 m_nudTimer.Cancel ();
488 m_nudTimer.SetDelay (
m_ndCache->m_icmpv6->GetRetransmissionTime ());
489 m_nudTimer.Schedule ();
495 m_nudTimer.Cancel ();
502 m_state = INCOMPLETE;
506 m_waiting.push_back (p);
560 return (m_state == STALE);
566 return (m_state == REACHABLE);
572 return (m_state ==
DELAY);
578 return (m_state == INCOMPLETE);
584 return (m_state == PROBE);
590 return (m_state == PERMANENT);
607 os << m_ipv6Address <<
" lladdr " << m_macAddress <<
" state ";
void SetUnresQlen(uint32_t unresQlen)
Set the max number of waiting packet.
a unique identifier for an interface.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
void SetIpv6Address(Ipv6Address ipv6Address)
Set the IPv6 address.
Ptr< Ipv6Interface > GetInterface() const
Get the Ipv6Interface associated with this cache.
bool IsStale() const
Is the entry STALE.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
void Flush()
Flush the cache.
void MarkPermanent()
Change the state to this entry to PERMANENT.
std::list< NdiscCache::Entry * > LookupInverse(Address dst)
Lookup in the cache for a MAC address.
void MarkProbe()
Changes the state to this entry to PROBE.
static Time Now(void)
Return the current simulation virtual time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ipv6Address MakeSolicitedAddress(Ipv6Address addr)
Make the solicited IPv6 address.
bool IsReachable() const
Is the entry REACHABLE.
void ClearWaitingPacket()
Clear the waiting packet list.
void MarkIncomplete(Ipv6PayloadHeaderPair p)
Changes the state to this entry to INCOMPLETE.
A record that holds information about a NdiscCache entry.
virtual NdiscCache::Entry * Add(Ipv6Address to)
Add an entry.
IPv6 Neighbor Discovery cache.
void FunctionProbeTimeout()
Function called when probe timer timeout.
Entry(NdiscCache *nd)
Constructor.
void SetRouter(bool router)
Set the node type.
Describes an IPv6 address.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void StartDelayTimer()
Start delay timer.
void FunctionDelayTimeout()
Function called when delay timer timeout.
Ptr< Icmpv6L4Protocol > m_icmpv6
the icmpv6 L4 protocol for this cache.
void MarkReachable()
Changes the state to this entry to REACHABLE.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
bool IsDelay() const
Is the entry DELAY.
Ptr< NetDevice > m_device
The NetDevice.
A simple virtual Timer class.
void AddWaitingPacket(Ipv6PayloadHeaderPair p)
Add a packet (or replace old value) in the queue.
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
void SetDevice(Ptr< NetDevice > device, Ptr< Ipv6Interface > interface, Ptr< Icmpv6L4Protocol > icmpv6)
Set the device and interface.
void MarkStale()
Changes the state to this entry to STALE.
bool IsPermanent() const
Is the entry PERMANENT.
uint32_t m_unresQlen
Max number of packet stored in m_waiting.
std::unordered_map< Ipv6Address, NdiscCache::Entry *, Ipv6AddressHash >::iterator CacheI
Neighbor Discovery Cache container iterator.
void SetMacAddress(Address mac)
Set the MAC address of this entry.
void StopNudTimer()
Stop NUD timer and reset the NUD retransmission counter.
void Remove(NdiscCache::Entry *entry)
Delete an entry.
a polymophic address class
A base class which provides memory management and object aggregation.
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,...
void StartRetransmitTimer()
Start retransmit timer.
bool IsRouter() const
If the entry is a host or a router.
void StartReachableTimer()
Start the reachable timer.
Simulation virtual time values and global simulation resolution.
static TypeId GetTypeId()
Get the type ID.
Cache m_ndCache
A list of Entry.
Time GetLastReachabilityConfirmation() const
Get the time of last reachability confirmation.
bool IsProbe() const
Is the entry PROBE.
static const uint16_t PROT_NUMBER
The protocol number for IPv6 (0x86DD).
void DoDispose()
Dispose this object.
void Print(std::ostream &os) const
Print this entry to the given output stream.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
uint32_t GetUnresQlen()
Get the max number of waiting packet.
virtual NdiscCache::Entry * Lookup(Ipv6Address dst)
Lookup in the cache.
void MarkDelay()
Change the state to this entry to DELAY.
void FunctionRetransmitTimeout()
Function called when retransmit timer timeout.
std::pair< Ptr< Packet >, Ipv6Header > Ipv6PayloadHeaderPair
Pair of a packet and an Ipv4 header.
Time Seconds(double value)
Construct a Time in the indicated unit.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
static const uint32_t DEFAULT_UNRES_QLEN
Default value for unres qlen.
Hold an unsigned integer type.
Ptr< Ipv6Interface > m_interface
the interface.
Ipv6Address GetIpv6Address(void) const
Get the IPv6 address.
bool IsAny() const
If the IPv6 address is the "Any" address.
Ptr< const AttributeAccessor > MakeUintegerAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
std::ostream & operator<<(std::ostream &os, const Angles &a)
bool IsIncomplete() const
Is the entry INCOMPLETE.
virtual uint32_t GetIfIndex(void) const =0
void UpdateReachableTimer()
Update the reachable timer.
virtual void DoDispose(void)
Destructor implementation.
#define DELAY(time)
Gets the delay between a given time and the current time.
void FunctionReachableTimeout()
Function called when reachable timer timeout.
Ptr< NetDevice > GetDevice() const
Get the NetDevice associated with this cache.
void StartProbeTimer()
Start probe timer.
Address GetMacAddress() const
Get the MAC address of this entry.
void PrintNdiscCache(Ptr< OutputStreamWrapper > stream)
Print the NDISC cache entries.