Internet: Add IPv6 NDISC Static Entries

This commit is contained in:
Saswat K. Mishra
2016-02-14 16:54:05 +01:00
parent b6d49ca37b
commit 7ff01476a3
7 changed files with 68 additions and 9 deletions

View File

@@ -50,6 +50,7 @@ New user-visible features
- (network) ns-3 is now capable of serializing cooked (SLL) headers. This is used
in DCE to allow the generation of pcap directly readable by wireshark.
- (internet) It is now possible to set custom values for RipNg Link Down (standard is 16).
- (internet) permanent (static) NDISC entries can be created for IPv6
Bugs fixed
----------

View File

@@ -14802,6 +14802,11 @@ def register_Ns3NdiscCacheEntry_methods(root_module, cls):
'bool',
[],
is_const=True)
## ndisc-cache.h (module 'internet'): bool ns3::NdiscCache::Entry::IsPermanent() const [member function]
cls.add_method('IsPermanent',
'bool',
[],
is_const=True)
## ndisc-cache.h (module 'internet'): bool ns3::NdiscCache::Entry::IsProbe() const [member function]
cls.add_method('IsProbe',
'bool',
@@ -14830,6 +14835,10 @@ def register_Ns3NdiscCacheEntry_methods(root_module, cls):
cls.add_method('MarkIncomplete',
'void',
[param('ns3::Ptr< ns3::Packet >', 'p')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Entry::MarkPermanent() [member function]
cls.add_method('MarkPermanent',
'void',
[])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Entry::MarkProbe() [member function]
cls.add_method('MarkProbe',
'void',

View File

@@ -14802,6 +14802,11 @@ def register_Ns3NdiscCacheEntry_methods(root_module, cls):
'bool',
[],
is_const=True)
## ndisc-cache.h (module 'internet'): bool ns3::NdiscCache::Entry::IsPermanent() const [member function]
cls.add_method('IsPermanent',
'bool',
[],
is_const=True)
## ndisc-cache.h (module 'internet'): bool ns3::NdiscCache::Entry::IsProbe() const [member function]
cls.add_method('IsProbe',
'bool',
@@ -14830,6 +14835,10 @@ def register_Ns3NdiscCacheEntry_methods(root_module, cls):
cls.add_method('MarkIncomplete',
'void',
[param('ns3::Ptr< ns3::Packet >', 'p')])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Entry::MarkPermanent() [member function]
cls.add_method('MarkPermanent',
'void',
[])
## ndisc-cache.h (module 'internet'): void ns3::NdiscCache::Entry::MarkProbe() [member function]
cls.add_method('MarkProbe',
'void',

View File

@@ -392,8 +392,9 @@ ArpCache::Entry::MarkAlive (Address macAddress)
void
ArpCache::Entry::MarkPermanent (void)
{
NS_LOG_FUNCTION (this);
NS_LOG_FUNCTION (this << m_macAddress);
NS_ASSERT (!m_macAddress.IsInvalid ());
m_state = PERMANENT;
ClearRetries ();
UpdateSeen ();

View File

@@ -401,7 +401,7 @@ void Icmpv6L4Protocol::ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address
}
else
{
if (!entry->IsReachable ())
if (!entry->IsReachable () || !entry->IsPermanent ())
{
entry->StopNudTimer ();
waiting = entry->MarkReachable (lla.GetAddress ());
@@ -412,7 +412,10 @@ void Icmpv6L4Protocol::ReceiveLLA (Icmpv6OptionLinkLayerAddress lla, Ipv6Address
cache->GetInterface ()->Send (*it, src);
}
}
entry->StartReachableTimer ();
if (!entry->IsPermanent ())
{
entry->StartReachableTimer ();
}
}
}
}
@@ -708,7 +711,7 @@ void Icmpv6L4Protocol::HandleNA (Ptr<Packet> packet, Ipv6Address const &src, Ipv
if (naHeader.GetFlagS ())
{
if (!entry->IsReachable ())
if (!entry->IsReachable () || !entry->IsPermanent ())
{
if (entry->IsProbe ())
{
@@ -724,7 +727,10 @@ void Icmpv6L4Protocol::HandleNA (Ptr<Packet> packet, Ipv6Address const &src, Ipv
entry->MarkReachable (lla.GetAddress ());
}
}
entry->StartReachableTimer ();
if (!entry->IsPermanent ())
{
entry->StartReachableTimer ();
}
}
else if (lla.GetAddress () != entry->GetMacAddress ())
{
@@ -1295,7 +1301,7 @@ bool Icmpv6L4Protocol::Lookup (Ipv6Address dst, Ptr<NetDevice> device, Ptr<Ndisc
NdiscCache::Entry* entry = cache->Lookup (dst);
if (entry)
{
if (entry->IsReachable () || entry->IsDelay ())
if (entry->IsReachable () || entry->IsDelay () || entry->IsPermanent ())
{
*hardwareDestination = entry->GetMacAddress ();
return true;
@@ -1329,7 +1335,7 @@ bool Icmpv6L4Protocol::Lookup (Ptr<Packet> p, Ipv6Address dst, Ptr<NetDevice> de
NdiscCache::Entry* entry = cache->Lookup (dst);
if (entry)
{
if (entry->IsReachable () || entry->IsDelay ())
if (entry->IsReachable () || entry->IsDelay () || entry->IsPermanent ())
{
/* XXX check reachability time */
/* send packet */

View File

@@ -187,10 +187,18 @@ void NdiscCache::PrintNdiscCache (Ptr<OutputStreamWrapper> stream)
{
*os << " PROBE\n";
}
else
else if (i->second->IsStale ())
{
*os << " STALE\n";
}
else if (i->second->IsPermanent ())
{
*os << " PERMANENT\n";
}
else
{
NS_FATAL_ERROR ("Test for possibly unreachable code-- please file a bug report, with a test case, if this is ever hit");
}
}
}
@@ -495,6 +503,13 @@ void NdiscCache::Entry::MarkDelay ()
m_state = DELAY;
}
void NdiscCache::Entry::MarkPermanent ()
{
NS_LOG_FUNCTION_NOARGS ();
StopNudTimer ();
m_state = PERMANENT;
}
bool NdiscCache::Entry::IsStale () const
{
NS_LOG_FUNCTION_NOARGS ();
@@ -525,6 +540,12 @@ bool NdiscCache::Entry::IsProbe () const
return (m_state == PROBE);
}
bool NdiscCache::Entry::IsPermanent () const
{
NS_LOG_FUNCTION_NOARGS ();
return (m_state == PERMANENT);
}
Address NdiscCache::Entry::GetMacAddress () const
{
NS_LOG_FUNCTION_NOARGS ();

View File

@@ -184,6 +184,11 @@ public:
*/
void MarkDelay ();
/**
* \brief Change the state to this entry to PERMANENT.
*/
void MarkPermanent ();
/**
* \brief Add a packet (or replace old value) in the queue.
* \param p packet to add
@@ -225,6 +230,12 @@ public:
*/
bool IsProbe () const;
/**
* \brief Is the entry PERMANENT
* \return true if the entry is in PERMANENT state, false otherwise
*/
bool IsPermanent () const;
/**
* \brief Get the MAC address of this entry.
* \return the L2 address
@@ -328,7 +339,8 @@ private:
REACHABLE, /**< Mapping exists between IPv6 and L2 addresses */
STALE, /**< Mapping is stale */
DELAY, /**< Try to wait contact from remote host */
PROBE /**< Try to contact IPv6 address to know again its L2 address */
PROBE, /**< Try to contact IPv6 address to know again its L2 address */
PERMANENT /**< Permanent Mapping exists between IPv6 and L2 addresses */
};
/**