30 #include "ns3/abort.h"
31 #include "ns3/names.h"
32 #include "ns3/ipv4-list-routing.h"
33 #include "ns3/loopback-net-device.h"
61 std::string Tname = GetTypeParamName<NixVectorRouting<T> > ();
62 std::string name = (Tname ==
"Ipv4RoutingProtocol" ?
"Ipv4" :
"Ipv6");
63 static TypeId tid =
TypeId (
"ns3::" + name +
"NixVectorRouting")
65 .SetGroupName (
"NixVectorRouting")
66 .template AddConstructor<NixVectorRouting<T> > ()
73 : m_totalNeighbors (0)
106 template <
typename T>
112 for (uint32_t i = 0 ; i < m_ip->GetNInterfaces (); i++)
114 m_ip->SetForwarding (i,
true);
120 template <
typename T>
132 template <
typename T>
141 template <
typename T>
157 rp->FlushNixCache ();
158 rp->FlushIpRouteCache ();
159 rp->m_totalNeighbors = 0;
164 g_ipAddressToNodeMap.clear ();
167 template <
typename T>
175 template <
typename T>
180 m_ipRouteCache.clear ();
183 template <
typename T>
205 if (source == destNode)
214 std::vector< Ptr<Node> > parentVector;
218 if (BuildNixVector (parentVector, source->
GetId (), destNode->
GetId (), nixVector))
237 template <
typename T>
243 CheckCacheStateAndFlush ();
245 typename NixMap_t::iterator iter = m_nixCache.find (
address);
246 if (iter != m_nixCache.end ())
254 foundInCache =
false;
258 template <
typename T>
264 CheckCacheStateAndFlush ();
266 typename IpRouteMap_t::iterator iter = m_ipRouteCache.find (
address);
267 if (iter != m_ipRouteCache.end ())
277 template <
typename T>
288 if (parentVector.at (dest) == 0)
293 Ptr<Node> parentNode = parentVector.at (dest);
295 uint32_t numberOfDevices = parentNode->
GetNDevices ();
297 uint32_t totalNeighbors = 0;
301 for (uint32_t i = 0; i < numberOfDevices; i++)
320 GetAdjacentNetDevices (localNetDevice,
channel, netDeviceContainer);
330 Ptr<Node> remoteNode = (*iter)->GetNode ();
332 if (remoteNode->
GetId () == dest)
334 destId = totalNeighbors + offset;
339 totalNeighbors += netDeviceContainer.
GetN ();
342 << nixVector->
BitCount (totalNeighbors) <<
" bits, for node " << parentNode->
GetId ());
347 BuildNixVector (parentVector, source, (parentVector.at (dest))->GetId (), nixVector);
351 template <
typename T>
358 if (netDeviceInterface == 0 || !netDeviceInterface->IsUp ())
360 NS_LOG_LOGIC (
"IpInterface either doesn't exist or is down");
364 uint32_t netDeviceAddresses = netDeviceInterface->GetNAddresses ();
366 for (std::size_t i = 0; i <
channel->GetNDevices (); i++)
369 if (remoteDevice != netDevice)
372 Ptr<IpInterface> remoteDeviceInterface = GetInterfaceByNetDevice (remoteDevice);
373 if (remoteDeviceInterface == 0 || !remoteDeviceInterface->IsUp ())
375 NS_LOG_LOGIC (
"IpInterface either doesn't exist or is down");
379 uint32_t remoteDeviceAddresses = remoteDeviceInterface->GetNAddresses ();
380 bool commonSubnetFound =
false;
382 for (uint32_t j = 0; j < netDeviceAddresses; ++j)
385 if constexpr (!IsIpv4::value)
392 for (uint32_t
k = 0;
k < remoteDeviceAddresses; ++
k)
395 if constexpr (!IsIpv4::value)
402 if (netDeviceIfAddr.IsInSameSubnet (remoteDeviceIfAddr.GetAddress ()))
404 commonSubnetFound =
true;
409 if (commonSubnetFound)
415 if (!commonSubnetFound)
425 NS_LOG_LOGIC (
"Looking through bridge ports of bridge net device " << bd);
426 for (uint32_t j = 0; j < bd->GetNBridgePorts (); ++j)
429 if (ndBridged == remoteDevice)
431 NS_LOG_LOGIC (
"That bridge port is me, don't walk backward");
439 GetAdjacentNetDevices (ndBridged, chBridged, netDeviceContainer);
444 netDeviceContainer.
Add (
channel->GetDevice (i));
450 template <
typename T>
465 for (uint32_t deviceId = 0; deviceId < numberOfDevices; deviceId++)
470 if ( !DynamicCast<LoopbackNetDevice>(device) )
472 int32_t interfaceIndex = (ip)->GetInterfaceForDevice (node->
GetDevice (deviceId));
473 if (interfaceIndex != -1)
475 g_netdeviceToIpInterfaceMap[device] = (ip)->GetInterface (interfaceIndex);
477 uint32_t numberOfAddresses = ip->GetNAddresses (interfaceIndex);
478 for (uint32_t addressIndex = 0; addressIndex < numberOfAddresses; addressIndex++)
484 "Duplicate IP address (" << addr <<
") found during NIX Vector map construction for node " << node->
GetId ());
486 NS_LOG_LOGIC (
"Adding IP address " << addr <<
" for node " << node->
GetId () <<
" to NIX Vector IP address to node map");
487 g_ipAddressToNodeMap[addr] = node;
496 template <
typename T>
503 if ( g_ipAddressToNodeMap.empty () )
505 BuildIpAddressToNodeMap ();
510 typename IpAddressToNodeMap::iterator iter = g_ipAddressToNodeMap.find(dest);
512 if(iter == g_ipAddressToNodeMap.end ())
514 NS_LOG_ERROR (
"Couldn't find dest node given the IP" << dest);
519 destNode = iter ->
second;
525 template <
typename T>
530 if ( g_netdeviceToIpInterfaceMap.empty () )
532 BuildIpAddressToNodeMap ();
537 typename NetDeviceToIpInterfaceMap::iterator iter = g_netdeviceToIpInterfaceMap.find(netDevice);
539 if(iter == g_netdeviceToIpInterfaceMap.end ())
541 NS_LOG_ERROR (
"Couldn't find IpInterface node given the NetDevice" << netDevice);
546 ipInterface = iter ->
second;
552 template <
typename T>
559 uint32_t totalNeighbors = 0;
563 for (uint32_t i = 0; i < numberOfDevices; i++)
578 GetAdjacentNetDevices (localNetDevice,
channel, netDeviceContainer);
580 totalNeighbors += netDeviceContainer.
GetN ();
583 return totalNeighbors;
586 template <
typename T>
601 for (uint32_t i = 0; i < nDevices; ++i)
608 NS_LOG_LOGIC (
"device " << i <<
" is a bridge net device");
610 NS_ABORT_MSG_UNLESS (bnd,
"NixVectorRouting::NetDeviceIsBridged (): GetObject for <BridgeNetDevice> failed");
612 for (uint32_t j = 0; j < bnd->GetNBridgePorts (); ++j)
614 NS_LOG_LOGIC (
"Examine bridge port " << j <<
" " << bnd->GetBridgePort (j));
615 if (bnd->GetBridgePort (j) == nd)
617 NS_LOG_LOGIC (
"Net device " << nd <<
" is bridged by " << bnd);
623 NS_LOG_LOGIC (
"Net device " << nd <<
" is not bridged");
627 template <
typename T>
635 uint32_t totalNeighbors = 0;
639 for (uint32_t i = 0; i < numberOfDevices; i++)
654 GetAdjacentNetDevices (localNetDevice,
channel, netDeviceContainer);
657 if (nodeIndex < (totalNeighbors + netDeviceContainer.
GetN ()))
661 Ptr<NetDevice> gatewayDevice = netDeviceContainer.
Get (nodeIndex-totalNeighbors);
662 Ptr<IpInterface> gatewayInterface = GetInterfaceByNetDevice (gatewayDevice);
664 gatewayIp = ifAddr.GetAddress ();
667 totalNeighbors += netDeviceContainer.
GetN ();
673 template <
typename T>
683 CheckCacheStateAndFlush ();
685 IpAddress destAddress = header.GetDestination ();
689 if (destAddress.IsLocalhost ())
691 rtentry = Create<IpRoute> ();
692 rtentry->SetSource (IpAddress::GetLoopback ());
693 rtentry->SetDestination (destAddress);
694 rtentry->SetGateway (IpAddress::GetZero ());
695 for (uint32_t i = 0 ; i < m_ip->GetNInterfaces (); i++)
700 rtentry->SetOutputDevice (loNetDevice);
707 if constexpr (!IsIpv4::value)
710 if (destAddress.IsLinkLocalMulticast ())
712 NS_ASSERT_MSG (oif,
"Try to send on link-local multicast address, and no interface index is given!");
713 rtentry = Create<IpRoute> ();
714 rtentry->SetSource (m_ip->SourceAddressSelection (m_ip->GetInterfaceForDevice (oif), destAddress));
715 rtentry->SetDestination (destAddress);
717 rtentry->SetOutputDevice (oif);
722 bool foundInCache =
false;
723 nixVectorInCache = GetNixVectorInCache (destAddress, foundInCache);
731 nixVectorInCache = GetNixVector (m_node, destAddress, oif);
732 if (nixVectorInCache)
735 m_nixCache.insert (
typename NixMap_t::value_type (destAddress, nixVectorInCache));
740 if (nixVectorInCache)
742 NS_LOG_LOGIC (
"Nix-vector contents: " << *nixVectorInCache);
746 nixVectorForPacket = nixVectorInCache->
Copy ();
750 if (m_totalNeighbors == 0)
752 m_totalNeighbors = FindTotalNeighbors (m_node);
757 uint32_t numberOfBits = nixVectorForPacket->
BitCount (m_totalNeighbors);
762 rtentry = GetIpRouteInCache (destAddress);
764 if (!rtentry || !(rtentry->GetOutputDevice () == oif))
773 m_ipRouteCache.erase (destAddress);
778 uint32_t index = FindNetDeviceForNixIndex (m_node, nodeIndex, gatewayIp);
779 int32_t interfaceIndex = 0;
783 interfaceIndex = (m_ip)->GetInterfaceForDevice (m_node->GetDevice (index));
787 interfaceIndex = (m_ip)->GetInterfaceForDevice (oif);
790 NS_ASSERT_MSG (interfaceIndex != -1,
"Interface index not found for device");
792 IpAddress sourceIPAddr = m_ip->SourceAddressSelection (interfaceIndex, destAddress);
795 rtentry = Create<IpRoute> ();
796 rtentry->SetSource (sourceIPAddr);
798 rtentry->SetGateway (gatewayIp);
799 rtentry->SetDestination (destAddress);
803 rtentry->SetOutputDevice (m_ip->GetNetDevice (interfaceIndex));
807 rtentry->SetOutputDevice (oif);
813 m_ipRouteCache.insert (
typename IpRouteMap_t::value_type (destAddress, rtentry));
822 NS_LOG_LOGIC (
"Adding Nix-vector to packet: " << *nixVectorForPacket);
835 template <
typename T>
841 NS_LOG_FUNCTION (
this << p << header << header.GetSource () << header.GetDestination () << idev);
843 CheckCacheStateAndFlush ();
847 NS_ASSERT (m_ip->GetInterfaceForDevice (idev) >= 0);
848 uint32_t iif = m_ip->GetInterfaceForDevice (idev);
852 IpAddress destAddress = header.GetDestination ();
854 if constexpr (IsIpv4::value)
857 if (m_ip->IsDestinationAddress (destAddress, iif))
863 lcb (p, header, iif);
879 if (destAddress.IsMulticast ())
881 NS_LOG_LOGIC (
"Multicast route not supported by Nix-Vector routing " << destAddress);
886 if (m_ip->IsForwarding (iif) ==
false)
888 NS_LOG_LOGIC (
"Forwarding disabled for this interface");
905 if (nixVector->
GetEpoch () != g_epoch)
908 <<
") - rebuilding it");
909 nixVector = GetNixVector (m_node, destAddress, 0);
915 if (m_totalNeighbors == 0)
917 m_totalNeighbors = FindTotalNeighbors (m_node);
919 uint32_t numberOfBits = nixVector->
BitCount (m_totalNeighbors);
922 rtentry = GetIpRouteInCache (destAddress);
928 uint32_t index = FindNetDeviceForNixIndex (m_node, nodeIndex, gatewayIp);
929 uint32_t interfaceIndex = (m_ip)->GetInterfaceForDevice (m_node->GetDevice (index));
933 rtentry = Create<IpRoute> ();
934 rtentry->SetSource (ifAddr.GetAddress ());
936 rtentry->SetGateway (gatewayIp);
937 rtentry->SetDestination (destAddress);
938 rtentry->SetOutputDevice (m_ip->GetNetDevice (interfaceIndex));
941 m_ipRouteCache.insert (
typename IpRouteMap_t::value_type (destAddress, rtentry));
944 NS_LOG_LOGIC (
"At Node " << m_node->GetId () <<
", Extracting " << numberOfBits <<
945 " bits from Nix-vector: " << nixVector <<
" : " << *nixVector);
951 if constexpr (IsIpv4::value)
953 ucb (rtentry, p, header);
957 ucb (idev, rtentry, p, header);
963 template <
typename T>
969 CheckCacheStateAndFlush ();
973 std::ios oldState (
nullptr);
974 oldState.copyfmt (*os);
976 *os << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left);
978 *os <<
"Node: " << m_ip->template GetObject<Node> ()->GetId ()
979 <<
", Time: " <<
Now().
As (unit)
980 <<
", Local time: " << m_ip->template GetObject<Node> ()->GetLocalTime ().As (unit)
981 <<
", Nix Routing" << std::endl;
983 *os <<
"NixCache:" << std::endl;
984 if (m_nixCache.size () > 0)
986 *os << std::setw (30) <<
"Destination";
987 *os <<
"NixVector" << std::endl;
988 for (
typename NixMap_t::const_iterator it = m_nixCache.begin (); it != m_nixCache.end (); it++)
990 std::ostringstream dest;
992 *os << std::setw (30) << dest.str ();
995 *os << *(it->second) << std::endl;
999 *os <<
"-" << std::endl;
1004 *os <<
"IpRouteCache:" << std::endl;
1005 if (m_ipRouteCache.size () > 0)
1007 *os << std::setw (30) <<
"Destination";
1008 *os << std::setw (30) <<
"Gateway";
1009 *os << std::setw (30) <<
"Source";
1010 *os <<
"OutputDevice" << std::endl;
1011 for (
typename IpRouteMap_t::const_iterator it = m_ipRouteCache.begin (); it != m_ipRouteCache.end (); it++)
1013 std::ostringstream dest, gw, src;
1014 dest << it->second->GetDestination ();
1015 *os << std::setw (30) << dest.str ();
1016 gw << it->second->GetGateway ();
1017 *os << std::setw (30) << gw.str ();
1018 src << it->second->GetSource ();
1019 *os << std::setw (30) << src.str ();
1027 *os << it->second->GetOutputDevice ()->GetIfIndex ();
1034 (*os).copyfmt (oldState);
1038 template <
typename T>
1042 g_isCacheDirty =
true;
1044 template <
typename T>
1048 g_isCacheDirty =
true;
1050 template <
typename T>
1054 g_isCacheDirty =
true;
1056 template <
typename T>
1060 g_isCacheDirty =
true;
1062 template <
typename T>
1066 g_isCacheDirty =
true;
1068 template <
typename T>
1072 g_isCacheDirty =
true;
1075 template <
typename T>
1081 NS_LOG_FUNCTION (
this << numberOfNodes << source << dest << parentVector << oif);
1084 std::queue< Ptr<Node> > greyNodeList;
1087 parentVector.assign (numberOfNodes, 0);
1090 greyNodeList.push (source);
1091 parentVector.at (source->
GetId ()) = source;
1094 while (greyNodeList.size () != 0)
1096 Ptr<Node> currNode = greyNodeList.front ();
1099 if (currNode == dest)
1108 if (currNode == source && oif)
1113 uint32_t interfaceIndex = (ip)->GetInterfaceForDevice (oif);
1114 if (!(ip->IsUp (interfaceIndex)))
1134 GetAdjacentNetDevices (oif,
channel, netDeviceContainer);
1142 Ptr<Node> remoteNode = (*iter)->GetNode ();
1144 if (remoteIpInterface == 0 || !(remoteIpInterface->IsUp ()))
1146 NS_LOG_LOGIC (
"IpInterface either doesn't exist or is down");
1154 if (parentVector.at (remoteNode->
GetId ()) == 0)
1156 parentVector.at (remoteNode->
GetId ()) = currNode;
1157 greyNodeList.push (remoteNode);
1165 for (uint32_t i = 0; i < (currNode->
GetNDevices ()); i++)
1175 uint32_t interfaceIndex = (ip)->GetInterfaceForDevice (currNode->
GetDevice (i));
1176 if (!(ip->IsUp (interfaceIndex)))
1182 if (!(localNetDevice->
IsLinkUp ()))
1196 GetAdjacentNetDevices (localNetDevice,
channel, netDeviceContainer);
1204 Ptr<Node> remoteNode = (*iter)->GetNode ();
1206 if (remoteIpInterface == 0 || !(remoteIpInterface->IsUp ()))
1208 NS_LOG_LOGIC (
"IpInterface either doesn't exist or is down");
1216 if (parentVector.at (remoteNode->
GetId ()) == 0)
1218 parentVector.at (remoteNode->
GetId ()) = currNode;
1219 greyNodeList.push (remoteNode);
1227 greyNodeList.pop ();
1234 template <
typename T>
1245 CheckCacheStateAndFlush ();
1247 Ptr<Node> destNode = GetNodeByIp (dest);
1254 std::ostream* os = stream->
GetStream ();
1256 std::ios oldState (
nullptr);
1257 oldState.copyfmt (*os);
1259 *os << std::resetiosflags (std::ios::adjustfield) << std::setiosflags (std::ios::left);
1260 *os <<
"Time: " <<
Now().
As (unit)
1261 <<
", Nix Routing" << std::endl;
1262 *os <<
"Route path from ";
1263 *os <<
"Node " << source->
GetId () <<
" to Node " << destNode->
GetId () <<
", ";
1264 *os <<
"Nix Vector: ";
1267 bool foundInCache =
true;
1268 nixVectorInCache = GetNixVectorInCache (dest, foundInCache);
1276 nixVectorInCache = GetNixVector (source, dest,
nullptr);
1279 if (nixVectorInCache || (!nixVectorInCache && source == destNode))
1282 uint32_t totalNeighbors = 0;
1284 if (nixVectorInCache)
1289 nixVector = nixVectorInCache->
Copy ();
1295 if (source == destNode)
1297 std::ostringstream addr, node;
1299 node <<
"(Node " << destNode->
GetId () <<
")";
1300 *os << std::setw (25) << addr.str ();
1301 *os << std::setw (10) << node.str ();
1303 *os << std::setw (25) << addr.str ();
1304 *os << node.str () << std::endl;
1307 while (curr != destNode)
1309 totalNeighbors = FindTotalNeighbors (curr);
1312 uint32_t numberOfBits = nixVector->
BitCount (totalNeighbors);
1319 uint32_t netDeviceIndex = FindNetDeviceForNixIndex (curr, nixIndex, gatewayIp);
1325 uint32_t interfaceIndex = ip->GetInterfaceForDevice (outDevice);
1329 sourceIPAddr = ip->SourceAddressSelection (interfaceIndex, dest);
1335 sourceIPAddr = ip->GetAddress (interfaceIndex, 0).GetAddress ();
1338 std::ostringstream currAddr, currNode, nextAddr, nextNode;
1339 currAddr << sourceIPAddr;
1340 currNode <<
"(Node " << curr->
GetId () <<
")";
1341 *os << std::setw (25) << currAddr.str ();
1342 *os << std::setw (10) << currNode.str ();
1344 curr = GetNodeByIp (gatewayIp);
1345 nextAddr << ((curr == destNode) ? dest : gatewayIp);
1346 nextNode <<
"(Node " << curr->GetId () <<
")";
1348 *os << std::setw (25) << nextAddr.str ();
1349 *os << nextNode.str () << std::endl;
1355 *os <<
")" << std::endl;
1357 *os <<
"There does not exist a path from Node " << source->
GetId ()
1358 <<
" to Node " << destNode->
GetId () <<
"." << std::endl;
1361 (*os).copyfmt (oldState);
1364 template <
typename T>
1370 FlushGlobalNixRoutingCache ();
1372 g_isCacheDirty =
false;
a virtual net device that bridges multiple LAN segments
bool IsNull(void) 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
Iterator End(void) const
Get an iterator which indicates past-the-last NetDevice in the container.
uint32_t GetN(void) const
Get the number of Ptr<NetDevice> stored in this container.
std::vector< Ptr< NetDevice > >::const_iterator Iterator
NetDevice container iterator.
Iterator Begin(void) 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.
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
virtual Ptr< Node > GetNode(void) const =0
virtual Ptr< Channel > GetChannel(void) const =0
virtual bool IsBridge(void) const =0
Return true if the net device is acting as a bridge.
virtual bool IsLinkUp(void) const =0
void AddNeighborIndex(uint32_t newBits, uint32_t numberOfBits)
Ptr< NixVector > Copy(void) const
uint32_t GetRemainingBits(void) const
uint32_t ExtractNeighborIndex(uint32_t numberOfBits)
void SetEpoch(uint32_t epoch)
Set the NixVector Epoch.
uint32_t BitCount(uint32_t numberOfNeighbors) const
uint32_t GetEpoch() const
Get the NixVector Epoch.
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.
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.
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 perfomed.
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...
virtual void NotifyInterfaceDown(uint32_t interface)
void FlushIpRouteCache(void) const
Flushes the cache which stores the Ip route based on the destination IP.
static IpAddressToNodeMap g_ipAddressToNodeMap
Address to node map.
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.
typename std::conditional< IsIpv4::value, Ipv4L3Protocol, Ipv6L3Protocol >::type IpL3Protocol
Alias for Ipv4L3Protocol and Ipv4L3Protocol classes.
virtual void NotifyAddAddress(uint32_t interface, IpInterfaceAddress address)
typename std::conditional< IsIpv4::value, Ipv4Address, Ipv6Address >::type IpAddress
Alias for Ipv4Address and Ipv6Address classes.
typename std::conditional< IsIpv4::value, Ipv4InterfaceAddress, Ipv6InterfaceAddress >::type IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
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 ...
std::unordered_map< IpAddress, ns3::Ptr< ns3::Node >, IpAddressHash > IpAddressToNodeMap
Mapping of IP address to ns-3 node.
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.
static TypeId GetTypeId(void)
The Interface ID of the Global Router interface.
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.
virtual void NotifyRemoveAddress(uint32_t interface, IpInterfaceAddress address)
void FlushNixCache(void) const
Flushes the cache which stores nix-vector based on destination IP.
static bool g_isCacheDirty
Flag to mark when caches are dirty and need to be flushed.
void CheckCacheStateAndFlush(void) const
Flushes routing caches if required.
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.
std::conditional< IsIpv4::value, MulticastForwardCallbackv4, MulticastForwardCallbackv6 >::type MulticastForwardCallback
Callback for multicast packets to be forwarded.
virtual bool RouteInput(Ptr< const Packet > p, const IpHeader &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
void FlushGlobalNixRoutingCache(void) const
Called when run-time link topology change occurs which iterates through the node list and flushes any...
std::conditional< IsIpv4::value, UnicastForwardCallbackv4, UnicastForwardCallbackv6 >::type UnicastForwardCallback
Callback for unicast packets to be forwarded.
typename std::conditional< IsIpv4::value, Ipv4Header, Ipv6Header >::type IpHeader
Alias for Ipv4Header and Ipv6Header classes.
Ptr< Node > GetNodeByIp(IpAddress dest) const
Iterates through the node list and finds the one corresponding to the given IpAddress.
void BuildIpAddressToNodeMap(void) const
Build map from IP Address to Node for faster lookup.
uint32_t GetId(void) const
uint32_t GetNDevices(void) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
static Iterator End(void)
static uint32_t GetNNodes(void)
static Iterator Begin(void)
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
std::ostream * GetStream(void)
Return a pointer to an ostream previously set in the wrapper.
void SetNixVector(Ptr< NixVector > nixVector) const
Set the packet nix-vector.
Ptr< NixVector > GetNixVector(void) const
Get the packet nix-vector.
SocketErrno
Enumeration of the possible errors returned by a socket.
Unit
The unit to use to interpret a number representing time.
TimeWithUnit As(const enum Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
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 and register the resulting instance with the TypeId system.
Time Now(void)
create an ns3::Time instance which contains the current simulation time.
Every class exported by the ns3 library is enclosed in the ns3 namespace.