From fded01ad4faaf3a09a9d00a6f5878b2115ffc208 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Sun, 9 May 2021 12:09:42 +0200 Subject: [PATCH] internet: (partially fix #384) add IPv6 reachability hint function --- src/internet/model/ipv6-l3-protocol.cc | 49 ++++++++++++++++++++++++++ src/internet/model/ipv6-l3-protocol.h | 2 ++ 2 files changed, 51 insertions(+) diff --git a/src/internet/model/ipv6-l3-protocol.cc b/src/internet/model/ipv6-l3-protocol.cc index 922d01381..984552d52 100644 --- a/src/internet/model/ipv6-l3-protocol.cc +++ b/src/internet/model/ipv6-l3-protocol.cc @@ -1601,5 +1601,54 @@ bool Ipv6L3Protocol::IsRegisteredMulticastAddress (Ipv6Address address) const return true; } +bool Ipv6L3Protocol::ReachabilityHint (uint32_t ipInterfaceIndex, Ipv6Address address) +{ + if (ipInterfaceIndex >= m_interfaces.size ()) + { + return false; + } + + Ptr ndiscCache = m_interfaces[ipInterfaceIndex]->GetNdiscCache (); + if (!ndiscCache) + { + return false; + } + + NdiscCache::Entry* entry = ndiscCache->Lookup (address); + if (!entry || entry->IsIncomplete ()) + { + return false; + } + + + if (entry->IsReachable ()) + { + entry->UpdateReachableTimer (); + } + else if (entry->IsPermanent ()) + { + return true; + } + else if (entry->IsProbe ()) + { + // we just confirm the entry's MAC address to get the waiting packets (if any) + std::list waiting = entry->MarkReachable (entry->GetMacAddress ()); + for (std::list::const_iterator it = waiting.begin (); it != waiting.end (); it++) + { + ndiscCache->GetInterface ()->Send (it->first, it->second, it->second.GetSourceAddress ()); + } + entry->ClearWaitingPacket (); + entry->StartReachableTimer (); + } + else // STALE OR DELAY + { + entry->MarkReachable (); + entry->StartReachableTimer (); + } + + + return true; +} + } /* namespace ns3 */ diff --git a/src/internet/model/ipv6-l3-protocol.h b/src/internet/model/ipv6-l3-protocol.h index da00bd7ca..815f23196 100644 --- a/src/internet/model/ipv6-l3-protocol.h +++ b/src/internet/model/ipv6-l3-protocol.h @@ -449,6 +449,8 @@ public: */ bool IsRegisteredMulticastAddress (Ipv6Address address, uint32_t interface) const; + bool ReachabilityHint (uint32_t ipInterfaceIndex, Ipv6Address address); + protected: /** * \brief Dispose object.