A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
nix-vector-routing.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2009 The Georgia Institute of Technology
3 * Copyright (c) 2021 NITK Surathkal
4 *
5 * SPDX-License-Identifier: GPL-2.0-only
6 *
7 * This file is adapted from the old ipv4-nix-vector-routing.h.
8 *
9 * Authors: Josh Pelkey <jpelkey@gatech.edu>
10 *
11 * Modified by: Ameya Deshpande <ameyanrd@outlook.com>
12 */
13
14#ifndef NIX_VECTOR_ROUTING_H
15#define NIX_VECTOR_ROUTING_H
16
17#include "ns3/bridge-net-device.h"
18#include "ns3/channel.h"
19#include "ns3/ipv4-interface.h"
20#include "ns3/ipv4-l3-protocol.h"
21#include "ns3/ipv4-route.h"
22#include "ns3/ipv4-routing-protocol.h"
23#include "ns3/ipv6-interface.h"
24#include "ns3/ipv6-l3-protocol.h"
25#include "ns3/ipv6-route.h"
26#include "ns3/ipv6-routing-protocol.h"
27#include "ns3/net-device-container.h"
28#include "ns3/nix-vector.h"
29#include "ns3/node-container.h"
30#include "ns3/node-list.h"
31#include "ns3/nstime.h"
32
33#include <map>
34#include <unordered_map>
35
36// NOLINTBEGIN(modernize-use-override)
37
38namespace ns3
39{
40
41/**
42 * \defgroup nix-vector-routing Nix-Vector Routing
43 *
44 * Nix-vector routing is a simulation specific routing protocol and is
45 * intended for large network topologies.
46 */
47
48/**
49 * \ingroup nix-vector-routing
50 * Nix-vector routing protocol
51 *
52 * \internal
53 * Since this class is meant to be specialized only by Ipv4RoutingProtocol or
54 * Ipv6RoutingProtocol the implementation of this class doesn't need to be
55 * exposed here; it is in nix-vector-routing.cc.
56 */
57template <typename T>
58class NixVectorRouting : public std::enable_if_t<std::is_same_v<Ipv4RoutingProtocol, T> ||
59 std::is_same_v<Ipv6RoutingProtocol, T>,
60 T>
61{
62 /// Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol
63 static constexpr bool IsIpv4 = std::is_same_v<Ipv4RoutingProtocol, T>;
64
65 /// Alias for Ipv4 and Ipv6 classes
66 using Ip = typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
67
68 /// Alias for Ipv4Address and Ipv6Address classes
69 using IpAddress = typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
70
71 /// Alias for Ipv4Route and Ipv6Route classes
72 using IpRoute = typename std::conditional_t<IsIpv4, Ipv4Route, Ipv6Route>;
73
74 /// Alias for Ipv4AddressHash and Ipv6AddressHash classes
75 using IpAddressHash = typename std::conditional_t<IsIpv4, Ipv4AddressHash, Ipv6AddressHash>;
76
77 /// Alias for Ipv4Header and Ipv6Header classes
78 using IpHeader = typename std::conditional_t<IsIpv4, Ipv4Header, Ipv6Header>;
79
80 /// Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes
82 typename std::conditional_t<IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress>;
83
84 /// Alias for Ipv4Interface and Ipv6Interface classes
85 using IpInterface = typename std::conditional_t<IsIpv4, Ipv4Interface, Ipv6Interface>;
86
87 /// Alias for Ipv4L3Protocol and Ipv4L3Protocol classes
88 using IpL3Protocol = typename std::conditional_t<IsIpv4, Ipv4L3Protocol, Ipv6L3Protocol>;
89
90 public:
93 /**
94 * @brief The Interface ID of the Global Router interface.
95 * @return The Interface ID
96 * @see Object::GetObject ()
97 */
98 static TypeId GetTypeId();
99 /**
100 * @brief Set the Node pointer of the node for which this
101 * routing protocol is to be placed
102 *
103 * @param node Node pointer
104 */
105 void SetNode(Ptr<Node> node);
106
107 /**
108 * @brief Called when run-time link topology change occurs
109 * which iterates through the node list and flushes any
110 * nix vector caches
111 *
112 * \internal
113 * \c const is used here due to need to potentially flush the cache
114 * in const methods such as PrintRoutingTable. Caches are stored in
115 * mutable variables and flushed in const methods.
116 */
117 void FlushGlobalNixRoutingCache() const;
118
119 /**
120 * @brief Print the Routing Path according to Nix Routing
121 * \param source Source node
122 * \param dest Destination node address
123 * \param stream The ostream the Routing path is printed to
124 * \param unit the time unit to be used in the report
125 *
126 * \note IpAddress is alias for either Ipv4Address or Ipv6Address
127 * depending on on whether the network is IPv4 or IPv6 respectively.
128 */
129 void PrintRoutingPath(Ptr<Node> source,
130 IpAddress dest,
132 Time::Unit unit) const;
133
134 private:
135 /**
136 * Flushes the cache which stores nix-vector based on
137 * destination IP
138 */
139 void FlushNixCache() const;
140
141 /**
142 * Flushes the cache which stores the Ip route
143 * based on the destination IP
144 */
145 void FlushIpRouteCache() const;
146
147 /**
148 * Upon a run-time topology change caches are
149 * flushed and the total number of neighbors is
150 * reset to zero
151 */
153
154 /**
155 * Takes in the source node and dest IP and calls GetNodeByIp,
156 * BFS, accounting for any output interface specified, and finally
157 * BuildNixVector to return the built nix-vector
158 *
159 * \param source Source node
160 * \param dest Destination node address
161 * \param oif Preferred output interface
162 * \returns The NixVector to be used in routing.
163 */
165
166 /**
167 * Checks the cache based on dest IP for the nix-vector
168 * \param address Address to check
169 * \param foundInCache Address found in cache
170 * \returns The NixVector to be used in routing.
171 */
172 Ptr<NixVector> GetNixVectorInCache(const IpAddress& address, bool& foundInCache) const;
173
174 /**
175 * Checks the cache based on dest IP for the IpRoute
176 * \param address Address to check
177 * \returns The cached route.
178 */
180
181 /**
182 * Given a net-device returns all the adjacent net-devices,
183 * essentially getting the neighbors on that channel
184 * \param [in] netDevice the NetDevice attached to the channel.
185 * \param [in] channel the channel to check
186 * \param [out] netDeviceContainer the NetDeviceContainer of the NetDevices in the channel.
187 */
189 Ptr<Channel> channel,
190 NetDeviceContainer& netDeviceContainer) const;
191
192 /**
193 * Iterates through the node list and finds the one
194 * corresponding to the given IpAddress
195 * \param dest destination node IP
196 * \return The node with the specified IP.
197 */
198 Ptr<Node> GetNodeByIp(IpAddress dest) const;
199
200 /**
201 * Iterates through the node list and finds the one
202 * corresponding to the given IpAddress
203 * \param netDevice NetDevice pointer
204 * \return The node with the specified IP.
205 */
207
208 /**
209 * Recurses the T vector, created by BFS and actually builds the nixvector
210 * \param [in] parentVector Parent vector for retracing routes
211 * \param [in] source Source Node index
212 * \param [in] dest Destination Node index
213 * \param [out] nixVector the NixVector to be used for routing
214 * \returns true on success, false otherwise.
215 */
216 bool BuildNixVector(const std::vector<Ptr<Node>>& parentVector,
217 uint32_t source,
218 uint32_t dest,
219 Ptr<NixVector> nixVector) const;
220
221 /**
222 * Simply iterates through the nodes net-devices and determines
223 * how many neighbors the node has.
224 * \param [in] node node pointer
225 * \returns the number of neighbors of m_node.
226 */
228
229 /**
230 * Determine if the NetDevice is bridged
231 * \param nd the NetDevice to check
232 * \returns the bridging NetDevice (or null if the NetDevice is not bridged)
233 */
235
236 /**
237 * Nix index is with respect to the neighbors. The net-device index must be
238 * derived from this
239 * \param [in] node the current node under consideration
240 * \param [in] nodeIndex Nix Node index
241 * \param [out] gatewayIp IP address of the gateway
242 * \returns the index of the NetDevice in the node.
243 */
245 uint32_t nodeIndex,
246 IpAddress& gatewayIp) const;
247
248 /**
249 * \brief Breadth first search algorithm.
250 * \param [in] numberOfNodes total number of nodes
251 * \param [in] source Source Node
252 * \param [in] dest Destination Node
253 * \param [out] parentVector Parent vector for retracing routes
254 * \param [in] oif specific output interface to use from source node, if not null
255 * \returns false if dest not found, true o.w.
256 */
257 bool BFS(uint32_t numberOfNodes,
258 Ptr<Node> source,
259 Ptr<Node> dest,
260 std::vector<Ptr<Node>>& parentVector,
261 Ptr<NetDevice> oif) const;
262
263 /**
264 * \sa Ipv4RoutingProtocol::DoInitialize
265 * \sa Ipv6RoutingProtocol::DoInitialize
266 */
267 void DoInitialize();
268
269 /**
270 * \sa Ipv4RoutingProtocol::DoDispose
271 * \sa Ipv6RoutingProtocol::DoDispose
272 */
273 void DoDispose();
274
275 /// Map of IpAddress to NixVector
276 typedef std::map<IpAddress, Ptr<NixVector>> NixMap_t;
277 /// Map of IpAddress to IpRoute
278 typedef std::map<IpAddress, Ptr<IpRoute>> IpRouteMap_t;
279
280 /// Callback for IPv4 unicast packets to be forwarded
283
284 /// Callback for IPv6 unicast packets to be forwarded
287
288 /// Callback for unicast packets to be forwarded
289 typedef typename std::conditional_t<IsIpv4, UnicastForwardCallbackv4, UnicastForwardCallbackv6>
291
292 /// Callback for IPv4 multicast packets to be forwarded
295
296 /// Callback for IPv6 multicast packets to be forwarded
297 typedef Callback<void,
301 const IpHeader&>
303
304 /// Callback for multicast packets to be forwarded
305 typedef
306 typename std::conditional_t<IsIpv4, MulticastForwardCallbackv4, MulticastForwardCallbackv6>
308
309 /// Callback for packets to be locally delivered
311
312 /// Callback for routing errors (e.g., no route found)
314
315 /* From Ipv4RoutingProtocol and Ipv6RoutingProtocol */
316 /**
317 * \brief Query routing cache for an existing route, for an outbound packet
318 * \param p packet to be routed. Note that this method may modify the packet.
319 * Callers may also pass in a null pointer.
320 * \param header input parameter (used to form key to search for the route)
321 * \param oif Output interface Netdevice. May be zero, or may be bound via
322 * socket options to a particular output interface.
323 * \param sockerr Output parameter; socket errno
324 *
325 * \returns a code that indicates what happened in the lookup
326 *
327 * \sa Ipv4RoutingProtocol::RouteOutput
328 * \sa Ipv6RoutingProtocol::RouteOutput
329 */
331 const IpHeader& header,
332 Ptr<NetDevice> oif,
333 Socket::SocketErrno& sockerr);
334
335 /**
336 * \brief Route an input packet (to be forwarded or locally delivered)
337 * \param p received packet
338 * \param header input parameter used to form a search key for a route
339 * \param idev Pointer to ingress network device
340 * \param ucb Callback for the case in which the packet is to be forwarded
341 * as unicast
342 * \param mcb Callback for the case in which the packet is to be forwarded
343 * as multicast
344 * \param lcb Callback for the case in which the packet is to be locally
345 * delivered
346 * \param ecb Callback to call if there is an error in forwarding
347 *
348 * \returns true if NixVectorRouting class takes responsibility for
349 * forwarding or delivering the packet, false otherwise
350 *
351 * \sa Ipv4RoutingProtocol::RouteInput
352 * \sa Ipv6RoutingProtocol::RouteInput
353 */
354 virtual bool RouteInput(Ptr<const Packet> p,
355 const IpHeader& header,
357 const UnicastForwardCallback& ucb,
358 const MulticastForwardCallback& mcb,
359 const LocalDeliverCallback& lcb,
360 const ErrorCallback& ecb);
361
362 /**
363 * \param interface the index of the interface we are being notified about
364 *
365 * \sa Ipv4RoutingProtocol::NotifyInterfaceUp
366 * \sa Ipv6RoutingProtocol::NotifyInterfaceUp
367 */
368 virtual void NotifyInterfaceUp(uint32_t interface);
369
370 /**
371 * \param interface the index of the interface we are being notified about
372 *
373 * \sa Ipv4RoutingProtocol::NotifyInterfaceDown
374 * \sa Ipv6RoutingProtocol::NotifyInterfaceDown
375 */
376 virtual void NotifyInterfaceDown(uint32_t interface);
377
378 /**
379 * \param interface the index of the interface we are being notified about
380 * \param address a new address being added to an interface
381 *
382 * \sa Ipv4RoutingProtocol::NotifyAddAddress
383 * \sa Ipv6RoutingProtocol::NotifyAddAddress
384 */
385 virtual void NotifyAddAddress(uint32_t interface, IpInterfaceAddress address);
386
387 /**
388 * \param interface the index of the interface we are being notified about
389 * \param address a new address being added to an interface
390 *
391 * \sa Ipv4RoutingProtocol::NotifyRemoveAddress
392 * \sa Ipv6RoutingProtocol::NotifyRemoveAddress
393 */
394 virtual void NotifyRemoveAddress(uint32_t interface, IpInterfaceAddress address);
395
396 /**
397 * \brief Print the Routing Table entries
398 *
399 * \param stream The ostream the Routing table is printed to
400 * \param unit The time unit to be used in the report
401 *
402 * \sa Ipv4RoutingProtocol::PrintRoutingTable
403 * \sa Ipv6RoutingProtocol::PrintRoutingTable
404 */
406 Time::Unit unit = Time::S) const;
407
408 /* From IPv4RoutingProtocol */
409 /**
410 * \brief Typically, invoked directly or indirectly from ns3::Ipv4::SetRoutingProtocol
411 *
412 * \param ipv4 the ipv4 object this routing protocol is being associated with
413 *
414 * \sa Ipv4RoutingProtocol::SetIpv4
415 */
416 virtual void SetIpv4(Ptr<Ip> ipv4);
417
418 /* From IPv6RoutingProtocol */
419 /**
420 * \brief Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol
421 *
422 * \param ipv6 the ipv6 object this routing protocol is being associated with
423 *
424 * \sa Ipv6RoutingProtocol::SetIpv6
425 */
426 virtual void SetIpv6(Ptr<Ip> ipv6);
427
428 /**
429 * \brief Notify a new route.
430 *
431 * \param dst destination address
432 * \param mask destination mask
433 * \param nextHop nextHop for this destination
434 * \param interface output interface
435 * \param prefixToUse prefix to use as source with this route
436 *
437 * \sa Ipv6RoutingProtocol::NotifyAddRoute
438 */
439 virtual void NotifyAddRoute(IpAddress dst,
440 Ipv6Prefix mask,
441 IpAddress nextHop,
442 uint32_t interface,
443 IpAddress prefixToUse = IpAddress::GetZero());
444
445 /**
446 * \brief Notify route removing.
447 *
448 * \param dst destination address
449 * \param mask destination mask
450 * \param nextHop nextHop for this destination
451 * \param interface output interface
452 * \param prefixToUse prefix to use as source with this route
453 *
454 * \sa Ipv6RoutingProtocol::NotifyRemoveRoute
455 */
456 virtual void NotifyRemoveRoute(IpAddress dst,
457 Ipv6Prefix mask,
458 IpAddress nextHop,
459 uint32_t interface,
460 IpAddress prefixToUse = IpAddress::GetZero());
461
462 /**
463 * Flushes routing caches if required.
464 */
465 void CheckCacheStateAndFlush() const;
466
467 /**
468 * Build map from IP Address to Node for faster lookup.
469 */
470 void BuildIpAddressToNodeMap() const;
471
472 /**
473 * Flag to mark when caches are dirty and need to be flushed.
474 * Used for lazy cleanup of caches when there are many topology changes.
475 */
476 static bool g_isCacheDirty;
477
478 /**
479 * Nix Epoch, incremented each time a flush is performed.
480 */
482
483 /** Cache stores nix-vectors based on destination ip */
485
486 /** Cache stores IpRoutes based on destination ip */
488
489 Ptr<Ip> m_ip; //!< IP object
490 Ptr<Node> m_node; //!< Node object
491
492 /** Total neighbors used for nix-vector to determine number of bits */
494
495 /**
496 * Mapping of IP address to ns-3 node.
497 *
498 * Used to avoid linear searching of nodes/devices to find a node in
499 * GetNodeByIp() method. NIX vector routing assumes IP addresses
500 * are unique so mapping can be done without duplication.
501 **/
502 typedef std::unordered_map<IpAddress, ns3::Ptr<ns3::Node>, IpAddressHash> IpAddressToNodeMap;
503 static IpAddressToNodeMap g_ipAddressToNodeMap; //!< Address to node map.
504
505 /// Mapping of Ptr<NetDevice> to Ptr<IpInterface>.
506 typedef std::unordered_map<Ptr<NetDevice>, Ptr<IpInterface>> NetDeviceToIpInterfaceMap;
508 g_netdeviceToIpInterfaceMap; //!< NetDevice pointer to IpInterface pointer map
509};
510
511/**
512 * \ingroup nix-vector-routing
513 * Create the typedef Ipv4NixVectorRouting with T as Ipv4RoutingProtocol
514 *
515 * Note: This typedef enables also backwards compatibility with original Ipv4NixVectorRouting.
516 */
518
519/**
520 * \ingroup nix-vector-routing
521 * Create the typedef Ipv6NixVectorRouting with T as Ipv6RoutingProtocol
522 */
524} // namespace ns3
525
526// NOLINTEND(modernize-use-override)
527
528#endif /* NIX_VECTOR_ROUTING_H */
Callback template class.
Definition callback.h:422
Describes an IPv6 prefix.
holds a vector of ns3::NetDevice pointers
Nix-vector routing protocol.
Callback< void, Ptr< IpRoute >, Ptr< const Packet >, const IpHeader & > UnicastForwardCallbackv4
Callback for IPv4 unicast packets to be forwarded.
std::map< IpAddress, Ptr< IpRoute > > IpRouteMap_t
Map of IpAddress to IpRoute.
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.
typename std::conditional_t< IsIpv4, Ipv4InterfaceAddress, Ipv6InterfaceAddress > IpInterfaceAddress
Alias for Ipv4InterfaceAddress and Ipv6InterfaceAddress classes.
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 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.
typename std::conditional_t< IsIpv4, Ipv4AddressHash, Ipv6AddressHash > IpAddressHash
Alias for Ipv4AddressHash and Ipv6AddressHash classes.
std::map< IpAddress, Ptr< NixVector > > NixMap_t
Map of IpAddress to NixVector.
NixMap_t m_nixCache
Cache stores nix-vectors based on destination ip.
typename std::conditional_t< IsIpv4, Ipv4Route, Ipv6Route > IpRoute
Alias for Ipv4Route and Ipv6Route classes.
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...
Callback< void, Ptr< Ipv4MulticastRoute >, Ptr< const Packet >, const IpHeader & > MulticastForwardCallbackv4
Callback for IPv4 multicast packets to be forwarded.
virtual void SetIpv6(Ptr< Ip > ipv6)
Typically, invoked directly or indirectly from ns3::Ipv6::SetRoutingProtocol.
Callback< void, Ptr< const Packet >, const IpHeader &, Socket::SocketErrno > ErrorCallback
Callback for routing errors (e.g., no route found)
uint32_t m_totalNeighbors
Total neighbors used for nix-vector to determine number of bits.
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< Ip > m_ip
IP object.
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, Ipv4Interface, Ipv6Interface > IpInterface
Alias for Ipv4Interface and Ipv6Interface classes.
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
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.
Callback< void, Ptr< const NetDevice >, Ptr< Ipv6MulticastRoute >, Ptr< const Packet >, const IpHeader & > MulticastForwardCallbackv6
Callback for IPv6 multicast packets to be forwarded.
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.
void ResetTotalNeighbors()
Upon a run-time topology change caches are flushed and the total number of neighbors is reset to zero...
virtual void NotifyRemoveAddress(uint32_t interface, IpInterfaceAddress address)
Callback< void, Ptr< const Packet >, const IpHeader &, uint32_t > LocalDeliverCallback
Callback for packets to be locally delivered.
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.
Ptr< Node > m_node
Node object.
void CheckCacheStateAndFlush() const
Flushes routing caches if required.
Callback< void, Ptr< const NetDevice >, Ptr< IpRoute >, Ptr< const Packet >, const IpHeader & > UnicastForwardCallbackv6
Callback for IPv6 unicast packets to be forwarded.
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.
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingProtocol or Ipv6RoutingProtocol.
IpRouteMap_t m_ipRouteCache
Cache stores IpRoutes based on destination ip.
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.
Smart pointer class similar to boost::intrusive_ptr.
SocketErrno
Enumeration of the possible errors returned by a socket.
Definition socket.h:73
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:100
@ S
second
Definition nstime.h:105
a unique identifier for an interface.
Definition type-id.h:48
NixVectorRouting< Ipv6RoutingProtocol > Ipv6NixVectorRouting
Create the typedef Ipv6NixVectorRouting with T as Ipv6RoutingProtocol.
NixVectorRouting< Ipv4RoutingProtocol > Ipv4NixVectorRouting
Create the typedef Ipv4NixVectorRouting with T as Ipv4RoutingProtocol.
Every class exported by the ns3 library is enclosed in the ns3 namespace.