28#include "ns3/ipv4-list-routing.h"
30#include "ns3/loopback-net-device.h"
63 if constexpr (std::is_same_v<T, Ipv4RoutingProtocol>)
71 static TypeId tid =
TypeId((
"ns3::" + name +
"NixVectorRouting"))
73 .SetGroupName(
"NixVectorRouting")
74 .template AddConstructor<NixVectorRouting<T>>();
119 for (
uint32_t i = 0; i < m_ip->GetNInterfaces(); i++)
121 m_ip->SetForwarding(i,
true);
165 rp->FlushIpRouteCache();
166 rp->m_totalNeighbors = 0;
171 g_ipAddressToNodeMap.clear();
187 m_ipRouteCache.clear();
197 nixVector->SetEpoch(g_epoch);
212 if (source == destNode)
221 std::vector<Ptr<Node>> parentVector;
225 if (BuildNixVector(parentVector, source->GetId(), destNode->GetId(), nixVector))
249 CheckCacheStateAndFlush();
251 typename NixMap_t::iterator iter = m_nixCache.find(address);
252 if (iter != m_nixCache.end())
260 foundInCache =
false;
270 CheckCacheStateAndFlush();
272 typename IpRouteMap_t::iterator iter = m_ipRouteCache.find(address);
273 if (iter != m_ipRouteCache.end())
297 if (!parentVector.at(dest))
302 Ptr<Node> parentNode = parentVector.at(dest);
304 uint32_t numberOfDevices = parentNode->GetNDevices();
310 for (
uint32_t i = 0; i < numberOfDevices; i++)
316 if (localNetDevice->IsBridge())
329 GetAdjacentNetDevices(localNetDevice, channel, netDeviceContainer);
338 iter != netDeviceContainer.
End();
341 Ptr<Node> remoteNode = (*iter)->GetNode();
343 if (remoteNode->GetId() == dest)
345 destId = totalNeighbors + offset;
350 totalNeighbors += netDeviceContainer.
GetN();
352 NS_LOG_LOGIC(
"Adding Nix: " << destId <<
" with " << nixVector->BitCount(totalNeighbors)
353 <<
" bits, for node " << parentNode->GetId());
354 nixVector->AddNeighborIndex(destId, nixVector->BitCount(totalNeighbors));
358 BuildNixVector(parentVector, source, (parentVector.at(dest))->GetId(), nixVector);
371 if (!netDeviceInterface || !netDeviceInterface->IsUp())
373 NS_LOG_LOGIC(
"IpInterface either doesn't exist or is down");
377 uint32_t netDeviceAddresses = netDeviceInterface->GetNAddresses();
379 for (std::size_t i = 0; i < channel->GetNDevices(); i++)
382 if (remoteDevice != netDevice)
385 Ptr<IpInterface> remoteDeviceInterface = GetInterfaceByNetDevice(remoteDevice);
386 if (!remoteDeviceInterface || !remoteDeviceInterface->IsUp())
388 NS_LOG_LOGIC(
"IpInterface either doesn't exist or is down");
392 uint32_t remoteDeviceAddresses = remoteDeviceInterface->GetNAddresses();
393 bool commonSubnetFound =
false;
395 for (
uint32_t j = 0; j < netDeviceAddresses; ++j)
398 if constexpr (!IsIpv4)
405 for (
uint32_t k = 0; k < remoteDeviceAddresses; ++k)
408 if constexpr (!IsIpv4)
415 if (netDeviceIfAddr.IsInSameSubnet(remoteDeviceIfAddr.GetAddress()))
417 commonSubnetFound =
true;
422 if (commonSubnetFound)
428 if (!commonSubnetFound)
438 NS_LOG_LOGIC(
"Looking through bridge ports of bridge net device " << bd);
439 for (
uint32_t j = 0; j < bd->GetNBridgePorts(); ++j)
442 if (ndBridged == remoteDevice)
444 NS_LOG_LOGIC(
"That bridge port is me, don't walk backward");
452 GetAdjacentNetDevices(ndBridged, chBridged, netDeviceContainer);
457 netDeviceContainer.
Add(channel->GetDevice(i));
476 uint32_t numberOfDevices = node->GetNDevices();
478 for (
uint32_t deviceId = 0; deviceId < numberOfDevices; deviceId++)
483 if (!DynamicCast<LoopbackNetDevice>(device))
485 int32_t interfaceIndex = (ip)->GetInterfaceForDevice(node->GetDevice(deviceId));
486 if (interfaceIndex != -1)
488 g_netdeviceToIpInterfaceMap[device] = (ip)->GetInterface(interfaceIndex);
490 uint32_t numberOfAddresses = ip->GetNAddresses(interfaceIndex);
491 for (
uint32_t addressIndex = 0; addressIndex < numberOfAddresses;
495 ip->GetAddress(interfaceIndex, addressIndex);
499 g_ipAddressToNodeMap.count(addr),
500 "Duplicate IP address ("
502 <<
") found during NIX Vector map construction for node "
506 << addr <<
" for node " << node->GetId()
507 <<
" to NIX Vector IP address to node map");
508 g_ipAddressToNodeMap[addr] = node;
524 if (g_ipAddressToNodeMap.empty())
526 BuildIpAddressToNodeMap();
531 typename IpAddressToNodeMap::iterator iter = g_ipAddressToNodeMap.find(dest);
533 if (iter == g_ipAddressToNodeMap.end())
535 NS_LOG_ERROR(
"Couldn't find dest node given the IP" << dest);
540 destNode = iter->second;
551 if (g_netdeviceToIpInterfaceMap.empty())
553 BuildIpAddressToNodeMap();
558 typename NetDeviceToIpInterfaceMap::iterator iter = g_netdeviceToIpInterfaceMap.find(netDevice);
560 if (iter == g_netdeviceToIpInterfaceMap.end())
562 NS_LOG_ERROR(
"Couldn't find IpInterface node given the NetDevice" << netDevice);
563 ipInterface =
nullptr;
567 ipInterface = iter->second;
579 uint32_t numberOfDevices = node->GetNDevices();
584 for (
uint32_t i = 0; i < numberOfDevices; i++)
599 GetAdjacentNetDevices(localNetDevice, channel, netDeviceContainer);
601 totalNeighbors += netDeviceContainer.
GetN();
604 return totalNeighbors;
614 uint32_t nDevices = node->GetNDevices();
622 for (
uint32_t i = 0; i < nDevices; ++i)
627 if (ndTest->IsBridge())
629 NS_LOG_LOGIC(
"device " << i <<
" is a bridge net device");
633 "NixVectorRouting::NetDeviceIsBridged (): GetObject for <BridgeNetDevice> failed");
635 for (
uint32_t j = 0; j < bnd->GetNBridgePorts(); ++j)
637 NS_LOG_LOGIC(
"Examine bridge port " << j <<
" " << bnd->GetBridgePort(j));
638 if (bnd->GetBridgePort(j) == nd)
640 NS_LOG_LOGIC(
"Net device " << nd <<
" is bridged by " << bnd);
658 uint32_t numberOfDevices = node->GetNDevices();
664 for (
uint32_t i = 0; i < numberOfDevices; i++)
679 GetAdjacentNetDevices(localNetDevice, channel, netDeviceContainer);
682 if (nodeIndex < (totalNeighbors + netDeviceContainer.
GetN()))
686 Ptr<NetDevice> gatewayDevice = netDeviceContainer.
Get(nodeIndex - totalNeighbors);
689 gatewayIp = ifAddr.GetAddress();
692 totalNeighbors += netDeviceContainer.
GetN();
711 CheckCacheStateAndFlush();
713 IpAddress destAddress = header.GetDestination();
717 if (destAddress.IsLocalhost())
719 rtentry = Create<IpRoute>();
720 rtentry->SetSource(IpAddress::GetLoopback());
721 rtentry->SetDestination(destAddress);
722 rtentry->SetGateway(IpAddress::GetZero());
723 for (
uint32_t i = 0; i < m_ip->GetNInterfaces(); i++)
726 DynamicCast<LoopbackNetDevice>(m_ip->GetNetDevice(i));
729 rtentry->SetOutputDevice(loNetDevice);
736 if constexpr (!IsIpv4)
739 if (destAddress.IsLinkLocalMulticast())
743 "Try to send on link-local multicast address, and no interface index is given!");
744 rtentry = Create<IpRoute>();
746 m_ip->SourceAddressSelection(m_ip->GetInterfaceForDevice(oif), destAddress));
747 rtentry->SetDestination(destAddress);
749 rtentry->SetOutputDevice(oif);
754 bool foundInCache =
false;
755 nixVectorInCache = GetNixVectorInCache(destAddress, foundInCache);
763 nixVectorInCache = GetNixVector(m_node, destAddress, oif);
764 if (nixVectorInCache)
767 m_nixCache.insert(
typename NixMap_t::value_type(destAddress, nixVectorInCache));
772 if (nixVectorInCache)
774 NS_LOG_LOGIC(
"Nix-vector contents: " << *nixVectorInCache);
778 nixVectorForPacket = nixVectorInCache->Copy();
782 if (m_totalNeighbors == 0)
784 m_totalNeighbors = FindTotalNeighbors(m_node);
789 uint32_t numberOfBits = nixVectorForPacket->BitCount(m_totalNeighbors);
790 uint32_t nodeIndex = nixVectorForPacket->ExtractNeighborIndex(numberOfBits);
794 rtentry = GetIpRouteInCache(destAddress);
796 if (!rtentry || !(rtentry->GetOutputDevice() == oif))
805 m_ipRouteCache.erase(destAddress);
810 uint32_t index = FindNetDeviceForNixIndex(m_node, nodeIndex, gatewayIp);
815 interfaceIndex = (m_ip)->GetInterfaceForDevice(m_node->GetDevice(index));
819 interfaceIndex = (m_ip)->GetInterfaceForDevice(oif);
822 NS_ASSERT_MSG(interfaceIndex != -1,
"Interface index not found for device");
824 IpAddress sourceIPAddr = m_ip->SourceAddressSelection(interfaceIndex, destAddress);
827 rtentry = Create<IpRoute>();
828 rtentry->SetSource(sourceIPAddr);
830 rtentry->SetGateway(gatewayIp);
831 rtentry->SetDestination(destAddress);
835 rtentry->SetOutputDevice(m_ip->GetNetDevice(interfaceIndex));
839 rtentry->SetOutputDevice(oif);
845 m_ipRouteCache.insert(
typename IpRouteMap_t::value_type(destAddress, rtentry));
848 NS_LOG_LOGIC(
"Nix-vector contents: " << *nixVectorInCache <<
" : Remaining bits: "
849 << nixVectorForPacket->GetRemainingBits());
855 NS_LOG_LOGIC(
"Adding Nix-vector to packet: " << *nixVectorForPacket);
856 p->SetNixVector(nixVectorForPacket);
878 NS_LOG_FUNCTION(
this << p << header << header.GetSource() << header.GetDestination() << idev);
880 CheckCacheStateAndFlush();
884 NS_ASSERT(m_ip->GetInterfaceForDevice(idev) >= 0);
885 uint32_t iif = m_ip->GetInterfaceForDevice(idev);
889 IpAddress destAddress = header.GetDestination();
891 if constexpr (IsIpv4)
894 if (m_ip->IsDestinationAddress(destAddress, iif))
899 p->SetNixVector(
nullptr);
916 if (destAddress.IsMulticast())
918 NS_LOG_LOGIC(
"Multicast route not supported by Nix-Vector routing " << destAddress);
923 if (m_ip->IsForwarding(iif) ==
false)
942 if (nixVector->GetEpoch() != g_epoch)
944 NS_LOG_LOGIC(
"NixVector epoch mismatch (" << nixVector->GetEpoch() <<
" Vs " << g_epoch
945 <<
") - rebuilding it");
946 nixVector = GetNixVector(m_node, destAddress,
nullptr);
947 p->SetNixVector(nixVector);
952 if (m_totalNeighbors == 0)
954 m_totalNeighbors = FindTotalNeighbors(m_node);
956 uint32_t numberOfBits = nixVector->BitCount(m_totalNeighbors);
957 uint32_t nodeIndex = nixVector->ExtractNeighborIndex(numberOfBits);
959 rtentry = GetIpRouteInCache(destAddress);
965 uint32_t index = FindNetDeviceForNixIndex(m_node, nodeIndex, gatewayIp);
966 uint32_t interfaceIndex = (m_ip)->GetInterfaceForDevice(m_node->GetDevice(index));
970 rtentry = Create<IpRoute>();
971 rtentry->SetSource(ifAddr.GetAddress());
973 rtentry->SetGateway(gatewayIp);
974 rtentry->SetDestination(destAddress);
975 rtentry->SetOutputDevice(m_ip->GetNetDevice(interfaceIndex));
978 m_ipRouteCache.insert(
typename IpRouteMap_t::value_type(destAddress, rtentry));
981 NS_LOG_LOGIC(
"At Node " << m_node->GetId() <<
", Extracting " << numberOfBits
982 <<
" bits from Nix-vector: " << nixVector <<
" : " << *nixVector);
988 if constexpr (IsIpv4)
990 ucb(rtentry, p, header);
994 ucb(idev, rtentry, p, header);
1000template <
typename T>
1006 CheckCacheStateAndFlush();
1008 std::ostream* os = stream->GetStream();
1010 std::ios oldState(
nullptr);
1011 oldState.copyfmt(*os);
1013 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
1015 *os <<
"Node: " << m_ip->template GetObject<Node>()->GetId() <<
", Time: " <<
Now().
As(unit)
1016 <<
", Local time: " << m_ip->template GetObject<Node>()->GetLocalTime().As(unit)
1017 <<
", Nix Routing" << std::endl;
1019 *os <<
"NixCache:" << std::endl;
1020 if (m_nixCache.size() > 0)
1022 *os << std::setw(30) <<
"Destination";
1023 *os <<
"NixVector" << std::endl;
1024 for (
typename NixMap_t::const_iterator it = m_nixCache.begin(); it != m_nixCache.end();
1027 std::ostringstream dest;
1029 *os << std::setw(30) << dest.str();
1032 *os << *(it->second) << std::endl;
1036 *os <<
"-" << std::endl;
1041 *os <<
"IpRouteCache:" << std::endl;
1042 if (m_ipRouteCache.size() > 0)
1044 *os << std::setw(30) <<
"Destination";
1045 *os << std::setw(30) <<
"Gateway";
1046 *os << std::setw(30) <<
"Source";
1047 *os <<
"OutputDevice" << std::endl;
1048 for (
typename IpRouteMap_t::const_iterator it = m_ipRouteCache.begin();
1049 it != m_ipRouteCache.end();
1052 std::ostringstream dest;
1053 std::ostringstream gw;
1054 std::ostringstream src;
1055 dest << it->second->GetDestination();
1056 *os << std::setw(30) << dest.str();
1057 gw << it->second->GetGateway();
1058 *os << std::setw(30) << gw.str();
1059 src << it->second->GetSource();
1060 *os << std::setw(30) << src.str();
1068 *os << it->second->GetOutputDevice()->GetIfIndex();
1075 (*os).copyfmt(oldState);
1079template <
typename T>
1083 g_isCacheDirty =
true;
1086template <
typename T>
1090 g_isCacheDirty =
true;
1093template <
typename T>
1097 g_isCacheDirty =
true;
1100template <
typename T>
1104 g_isCacheDirty =
true;
1107template <
typename T>
1115 g_isCacheDirty =
true;
1118template <
typename T>
1126 g_isCacheDirty =
true;
1129template <
typename T>
1137 NS_LOG_FUNCTION(
this << numberOfNodes << source << dest << parentVector << oif);
1139 NS_LOG_LOGIC(
"Going from Node " << source->GetId() <<
" to Node " << dest->GetId());
1140 std::queue<Ptr<Node>> greyNodeList;
1143 parentVector.assign(numberOfNodes,
nullptr);
1146 greyNodeList.push(source);
1147 parentVector.at(source->GetId()) = source;
1150 while (!greyNodeList.empty())
1152 Ptr<Node> currNode = greyNodeList.front();
1155 if (currNode == dest)
1164 if (currNode == source && oif)
1169 uint32_t interfaceIndex = (ip)->GetInterfaceForDevice(oif);
1170 if (!(ip->IsUp(interfaceIndex)))
1176 if (!(oif->IsLinkUp()))
1190 GetAdjacentNetDevices(oif, channel, netDeviceContainer);
1197 iter != netDeviceContainer.
End();
1200 Ptr<Node> remoteNode = (*iter)->GetNode();
1202 if (!remoteIpInterface || !(remoteIpInterface->IsUp()))
1204 NS_LOG_LOGIC(
"IpInterface either doesn't exist or is down");
1212 if (!parentVector.at(remoteNode->GetId()))
1214 parentVector.at(remoteNode->GetId()) = currNode;
1215 greyNodeList.push(remoteNode);
1223 for (
uint32_t i = 0; i < (currNode->GetNDevices()); i++)
1233 uint32_t interfaceIndex = (ip)->GetInterfaceForDevice(currNode->GetDevice(i));
1234 if (!(ip->IsUp(interfaceIndex)))
1240 if (!(localNetDevice->IsLinkUp()))
1254 GetAdjacentNetDevices(localNetDevice, channel, netDeviceContainer);
1261 iter != netDeviceContainer.
End();
1264 Ptr<Node> remoteNode = (*iter)->GetNode();
1266 if (!remoteIpInterface || !(remoteIpInterface->IsUp()))
1268 NS_LOG_LOGIC(
"IpInterface either doesn't exist or is down");
1276 if (!parentVector.at(remoteNode->GetId()))
1278 parentVector.at(remoteNode->GetId()) = currNode;
1279 greyNodeList.push(remoteNode);
1294template <
typename T>
1307 CheckCacheStateAndFlush();
1316 std::ostream* os = stream->GetStream();
1318 std::ios oldState(
nullptr);
1319 oldState.copyfmt(*os);
1321 *os << std::resetiosflags(std::ios::adjustfield) << std::setiosflags(std::ios::left);
1322 *os <<
"Time: " <<
Now().
As(unit) <<
", Nix Routing" << std::endl;
1323 *os <<
"Route path from ";
1324 *os <<
"Node " << source->GetId() <<
" to Node " << destNode->GetId() <<
", ";
1325 *os <<
"Nix Vector: ";
1328 bool foundInCache =
true;
1329 nixVectorInCache = GetNixVectorInCache(dest, foundInCache);
1337 nixVectorInCache = GetNixVector(source, dest,
nullptr);
1340 if (nixVectorInCache || (!nixVectorInCache && source == destNode))
1345 if (nixVectorInCache)
1350 nixVector = nixVectorInCache->Copy();
1356 if (source == destNode)
1358 std::ostringstream addr;
1359 std::ostringstream node;
1361 node <<
"(Node " << destNode->GetId() <<
")";
1362 *os << std::setw(25) << addr.str();
1363 *os << std::setw(10) << node.str();
1365 *os << std::setw(25) << addr.str();
1366 *os << node.str() << std::endl;
1369 while (curr != destNode)
1371 totalNeighbors = FindTotalNeighbors(curr);
1374 uint32_t numberOfBits = nixVector->BitCount(totalNeighbors);
1376 uint32_t nixIndex = nixVector->ExtractNeighborIndex(numberOfBits);
1381 uint32_t netDeviceIndex = FindNetDeviceForNixIndex(curr, nixIndex, gatewayIp);
1387 uint32_t interfaceIndex = ip->GetInterfaceForDevice(outDevice);
1391 sourceIPAddr = ip->SourceAddressSelection(interfaceIndex, dest);
1397 sourceIPAddr = ip->GetAddress(interfaceIndex, 0).GetAddress();
1400 std::ostringstream currAddr;
1401 std::ostringstream currNode;
1402 std::ostringstream nextAddr;
1403 std::ostringstream nextNode;
1404 currAddr << sourceIPAddr;
1405 currNode <<
"(Node " << curr->GetId() <<
")";
1406 *os << std::setw(25) << currAddr.str();
1407 *os << std::setw(10) << currNode.str();
1409 curr = GetNodeByIp(gatewayIp);
1410 nextAddr << ((curr == destNode) ? dest : gatewayIp);
1411 nextNode <<
"(Node " << curr->GetId() <<
")";
1413 *os << std::setw(25) << nextAddr.str();
1414 *os << nextNode.str() << std::endl;
1420 *os <<
")" << std::endl;
1422 *os <<
"There does not exist a path from Node " << source->GetId() <<
" to Node "
1423 << destNode->GetId() <<
"." << std::endl;
1426 (*os).copyfmt(oldState);
1429template <
typename T>
1435 FlushGlobalNixRoutingCache();
1437 g_isCacheDirty =
false;
a virtual net device that bridges multiple LAN segments
bool IsNull() const
Check for null implementation.
static Ipv6Address GetZero()
Get the 0 (::) Ipv6Address.
@ LINKLOCAL
Link-local address (fe80::/64)
Describes an IPv6 prefix.
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,...
holds a vector of ns3::NetDevice pointers
uint32_t GetN() const
Get the number of Ptr<NetDevice> stored in this container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin() const
Get an iterator which refers to the first NetDevice in the container.
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
Iterator End() const
Get an iterator which indicates past-the-last NetDevice in the container.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
Nix-vector routing protocol.
void PrintRoutingPath(Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit) const
Print the Routing Path according to Nix Routing.
void BuildIpAddressToNodeMap() const
Build map from IP Address to Node for faster lookup.
Ptr< IpRoute > GetIpRouteInCache(IpAddress address)
Checks the cache based on dest IP for the IpRoute.
virtual void NotifyRemoveRoute(IpAddress dst, Ipv6Prefix mask, IpAddress nextHop, uint32_t interface, IpAddress prefixToUse=IpAddress::GetZero())
Notify route removing.
virtual void NotifyAddRoute(IpAddress dst, Ipv6Prefix mask, IpAddress nextHop, uint32_t interface, IpAddress prefixToUse=IpAddress::GetZero())
Notify a new route.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
bool BFS(uint32_t numberOfNodes, Ptr< Node > source, Ptr< Node > dest, std::vector< Ptr< Node > > &parentVector, Ptr< NetDevice > oif) const
Breadth first search algorithm.
static uint32_t g_epoch
Nix Epoch, incremented each time a flush is performed.
virtual void NotifyInterfaceUp(uint32_t interface)
void GetAdjacentNetDevices(Ptr< NetDevice > netDevice, Ptr< Channel > channel, NetDeviceContainer &netDeviceContainer) const
Given a net-device returns all the adjacent net-devices, essentially getting the neighbors on that ch...
std::conditional_t< IsIpv4, UnicastForwardCallbackv4, UnicastForwardCallbackv6 > UnicastForwardCallback
Callback for unicast packets to be forwarded.
virtual void NotifyInterfaceDown(uint32_t interface)
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
static IpAddressToNodeMap g_ipAddressToNodeMap
Address to node map.
void FlushGlobalNixRoutingCache() const
Called when run-time link topology change occurs which iterates through the node list and flushes any...
virtual void SetIpv6(Ptr< Ip > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
virtual Ptr< IpRoute > RouteOutput(Ptr< Packet > p, const IpHeader &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
virtual void SetIpv4(Ptr< Ip > ipv4)
Typically, invoked directly or indirectly from ns3::Ipv4::SetRoutingProtocol.
Ptr< IpInterface > GetInterfaceByNetDevice(Ptr< NetDevice > netDevice) const
Iterates through the node list and finds the one corresponding to the given IpAddress.
uint32_t FindTotalNeighbors(Ptr< Node > node) const
Simply iterates through the nodes net-devices and determines how many neighbors the node has.
virtual void NotifyAddAddress(uint32_t interface, IpInterfaceAddress address)
std::conditional_t< IsIpv4, MulticastForwardCallbackv4, MulticastForwardCallbackv6 > MulticastForwardCallback
Callback for multicast packets to be forwarded.
void FlushIpRouteCache() const
Flushes the cache which stores the Ip route based on the destination IP.
virtual bool RouteInput(Ptr< const Packet > p, const IpHeader &header, Ptr< const NetDevice > idev, const UnicastForwardCallback &ucb, const MulticastForwardCallback &mcb, const LocalDeliverCallback &lcb, const ErrorCallback &ecb)
Route an input packet (to be forwarded or locally delivered)
Ptr< NixVector > GetNixVector(Ptr< Node > source, IpAddress dest, Ptr< NetDevice > oif) const
Takes in the source node and dest IP and calls GetNodeByIp, BFS, accounting for any output interface ...
typename std::conditional_t< IsIpv4, Ipv4Header, Ipv6Header > IpHeader
Alias for Ipv4Header and Ipv6Header classes.
bool BuildNixVector(const std::vector< Ptr< Node > > &parentVector, uint32_t source, uint32_t dest, Ptr< NixVector > nixVector) const
Recurses the T vector, created by BFS and actually builds the nixvector.
Ptr< NixVector > GetNixVectorInCache(const IpAddress &address, bool &foundInCache) const
Checks the cache based on dest IP for the nix-vector.
uint32_t FindNetDeviceForNixIndex(Ptr< Node > node, uint32_t nodeIndex, IpAddress &gatewayIp) const
Nix index is with respect to the neighbors.
static NetDeviceToIpInterfaceMap g_netdeviceToIpInterfaceMap
NetDevice pointer to IpInterface pointer map.
void SetNode(Ptr< Node > node)
Set the Node pointer of the node for which this routing protocol is to be placed.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
typename std::conditional_t< IsIpv4, Ipv4L3Protocol, Ipv6L3Protocol > IpL3Protocol
Alias for Ipv4L3Protocol and Ipv4L3Protocol classes.
virtual void NotifyRemoveAddress(uint32_t interface, IpInterfaceAddress address)
static TypeId GetTypeId()
The Interface ID of the Global Router interface.
static bool g_isCacheDirty
Flag to mark when caches are dirty and need to be flushed.
void CheckCacheStateAndFlush() const
Flushes routing caches if required.
std::unordered_map< IpAddress, ns3::Ptr< ns3::Node >, IpAddressHash > IpAddressToNodeMap
Mapping of IP address to ns-3 node.
std::unordered_map< Ptr< NetDevice >, Ptr< IpInterface > > NetDeviceToIpInterfaceMap
Mapping of Ptr<NetDevice> to Ptr<IpInterface>.
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Determine if the NetDevice is bridged.
void FlushNixCache() const
Flushes the cache which stores nix-vector based on destination IP.
Ptr< Node > GetNodeByIp(IpAddress dest) const
Iterates through the node list and finds the one corresponding to the given IpAddress.
static uint32_t GetNNodes()
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Smart pointer class similar to boost::intrusive_ptr.
SocketErrno
Enumeration of the possible errors returned by a socket.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
Unit
The unit to use to interpret a number representing time.
a unique identifier for an interface.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
#define NS_ASSERT_MSG(condition, message)
At runtime, in debugging builds, if this condition is not true, the program prints the message to out...
#define NS_ABORT_MSG_UNLESS(cond, msg)
Abnormal program termination if a condition is false, with a message.
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_LOGIC(msg)
Use NS_LOG to output a message of level LOG_LOGIC.
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_OBJECT_TEMPLATE_CLASS_DEFINE(type, param)
Explicitly instantiate a template class with one template parameter and register the resulting instan...
Time Now()
create an ns3::Time instance which contains the current simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.