internet: speedup NdiscCache and make it independent on the Icmpv6L4Protocol variant
This commit is contained in:
@@ -1288,7 +1288,7 @@ Ptr<NdiscCache> Icmpv6L4Protocol::CreateCache (Ptr<NetDevice> device, Ptr<Ipv6In
|
||||
|
||||
Ptr<NdiscCache> cache = CreateObject<NdiscCache> ();
|
||||
|
||||
cache->SetDevice (device, interface);
|
||||
cache->SetDevice (device, interface, this);
|
||||
device->AddLinkChangeCallback (MakeCallback (&NdiscCache::Flush, cache));
|
||||
m_cacheList.push_back (cache);
|
||||
return cache;
|
||||
|
||||
@@ -66,14 +66,16 @@ void NdiscCache::DoDispose ()
|
||||
Flush ();
|
||||
m_device = 0;
|
||||
m_interface = 0;
|
||||
m_icmpv6 = 0;
|
||||
Object::DoDispose ();
|
||||
}
|
||||
|
||||
void NdiscCache::SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface)
|
||||
void NdiscCache::SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface, Ptr<Icmpv6L4Protocol> icmpv6)
|
||||
{
|
||||
NS_LOG_FUNCTION (this << device << interface);
|
||||
m_device = device;
|
||||
m_interface = interface;
|
||||
m_icmpv6 = icmpv6;
|
||||
}
|
||||
|
||||
Ptr<Ipv6Interface> NdiscCache::GetInterface () const
|
||||
@@ -271,7 +273,6 @@ void NdiscCache::Entry::FunctionReachableTimeout ()
|
||||
void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
Ipv6Address addr;
|
||||
|
||||
/* determine source address */
|
||||
@@ -291,11 +292,11 @@ void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
}
|
||||
}
|
||||
|
||||
if (m_nsRetransmit < icmpv6->GetMaxMulticastSolicit ())
|
||||
if (m_nsRetransmit < m_ndCache->m_icmpv6->GetMaxMulticastSolicit ())
|
||||
{
|
||||
m_nsRetransmit++;
|
||||
|
||||
icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
m_ndCache->m_icmpv6->SendNS (addr, Ipv6Address::MakeSolicitedAddress (m_ipv6Address), m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
/* arm the timer again */
|
||||
StartRetransmitTimer ();
|
||||
}
|
||||
@@ -311,7 +312,7 @@ void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
malformedPacket.first->AddHeader (malformedPacket.second);
|
||||
}
|
||||
|
||||
icmpv6->SendErrorDestinationUnreachable (malformedPacket.first, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE);
|
||||
m_ndCache->m_icmpv6->SendErrorDestinationUnreachable (malformedPacket.first, addr, Icmpv6Header::ICMPV6_ADDR_UNREACHABLE);
|
||||
|
||||
/* delete the entry */
|
||||
m_ndCache->Remove (this);
|
||||
@@ -321,8 +322,6 @@ void NdiscCache::Entry::FunctionRetransmitTimeout ()
|
||||
void NdiscCache::Entry::FunctionDelayTimeout ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
Ptr<Ipv6L3Protocol> ipv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Ipv6L3Protocol> ();
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = ipv6->GetIcmpv6 ();
|
||||
Ipv6Address addr;
|
||||
|
||||
this->MarkProbe ();
|
||||
@@ -347,7 +346,7 @@ void NdiscCache::Entry::FunctionDelayTimeout ()
|
||||
return;
|
||||
}
|
||||
|
||||
Ipv6PayloadHeaderPair p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
Ipv6PayloadHeaderPair p = m_ndCache->m_icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
p.first->AddHeader (p.second);
|
||||
m_ndCache->GetDevice ()->Send (p.first, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER);
|
||||
|
||||
@@ -359,9 +358,7 @@ void NdiscCache::Entry::FunctionProbeTimeout ()
|
||||
{
|
||||
NS_LOG_FUNCTION_NOARGS ();
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
if (m_nsRetransmit < icmpv6->GetMaxUnicastSolicit ())
|
||||
if (m_nsRetransmit < m_ndCache->m_icmpv6->GetMaxUnicastSolicit ())
|
||||
{
|
||||
m_nsRetransmit++;
|
||||
|
||||
@@ -388,7 +385,7 @@ void NdiscCache::Entry::FunctionProbeTimeout ()
|
||||
}
|
||||
|
||||
/* icmpv6->SendNS (m_ndCache->GetInterface ()->GetLinkLocalAddress (), m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ()); */
|
||||
Ipv6PayloadHeaderPair p = icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
Ipv6PayloadHeaderPair p = m_ndCache->m_icmpv6->ForgeNS (addr, m_ipv6Address, m_ipv6Address, m_ndCache->GetDevice ()->GetAddress ());
|
||||
p.first->AddHeader (p.second);
|
||||
m_ndCache->GetDevice ()->Send (p.first, this->GetMacAddress (), Ipv6L3Protocol::PROT_NUMBER);
|
||||
|
||||
@@ -422,11 +419,9 @@ void NdiscCache::Entry::StartReachableTimer ()
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_lastReachabilityConfirmation = Simulator::Now ();
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionReachableTimeout, this);
|
||||
m_nudTimer.SetDelay (icmpv6->GetReachableTime ());
|
||||
m_nudTimer.SetDelay (m_ndCache->m_icmpv6->GetReachableTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -453,10 +448,8 @@ void NdiscCache::Entry::StartProbeTimer ()
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionProbeTimeout, this);
|
||||
m_nudTimer.SetDelay (icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.SetDelay (m_ndCache->m_icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -468,10 +461,8 @@ void NdiscCache::Entry::StartDelayTimer ()
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionDelayTimeout, this);
|
||||
m_nudTimer.SetDelay (icmpv6->GetDelayFirstProbe ());
|
||||
m_nudTimer.SetDelay (m_ndCache->m_icmpv6->GetDelayFirstProbe ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
@@ -483,10 +474,8 @@ void NdiscCache::Entry::StartRetransmitTimer ()
|
||||
m_nudTimer.Cancel ();
|
||||
}
|
||||
|
||||
Ptr<Icmpv6L4Protocol> icmpv6 = m_ndCache->GetDevice ()->GetNode ()->GetObject<Icmpv6L4Protocol> ();
|
||||
|
||||
m_nudTimer.SetFunction (&NdiscCache::Entry::FunctionRetransmitTimeout, this);
|
||||
m_nudTimer.SetDelay (icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.SetDelay (m_ndCache->m_icmpv6->GetRetransmissionTime ());
|
||||
m_nudTimer.Schedule ();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace ns3
|
||||
class NetDevice;
|
||||
class Ipv6Interface;
|
||||
class Ipv6Header;
|
||||
class Icmpv6L4Protocol;
|
||||
|
||||
/**
|
||||
* \ingroup ipv6
|
||||
@@ -132,7 +133,7 @@ public:
|
||||
* \param device the device
|
||||
* \param interface the IPv6 interface
|
||||
*/
|
||||
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface);
|
||||
void SetDevice (Ptr<NetDevice> device, Ptr<Ipv6Interface> interface, Ptr<Icmpv6L4Protocol> icmpv6);
|
||||
|
||||
/**
|
||||
* \brief Print the NDISC cache entries
|
||||
@@ -440,6 +441,11 @@ private:
|
||||
*/
|
||||
Ptr<Ipv6Interface> m_interface;
|
||||
|
||||
/**
|
||||
* \brief the icmpv6 L4 protocol for this cache.
|
||||
*/
|
||||
Ptr<Icmpv6L4Protocol> m_icmpv6;
|
||||
|
||||
/**
|
||||
* \brief A list of Entry.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user