21 #ifndef IPV4_NIX_VECTOR_ROUTING_H 22 #define IPV4_NIX_VECTOR_ROUTING_H 24 #include "ns3/channel.h" 25 #include "ns3/node-container.h" 26 #include "ns3/node-list.h" 27 #include "ns3/net-device-container.h" 28 #include "ns3/ipv4-routing-protocol.h" 29 #include "ns3/ipv4-route.h" 30 #include "ns3/nix-vector.h" 31 #include "ns3/bridge-net-device.h" 32 #include "ns3/nstime.h" 35 #include <unordered_map> 50 typedef std::map<Ipv4Address, Ptr<NixVector> >
NixMap_t;
219 bool BFS (uint32_t numberOfNodes,
void FlushGlobalNixRoutingCache(void) const
Called when run-time link topology change occurs which iterates through the node list and flushes any...
void BuildIpv4AddressToNodeMap(void) const
Build map from IPv4 Address to Node for faster lookup.
bool BuildNixVectorLocal(Ptr< NixVector > nixVector)
Special variation of BuildNixVector for when a node is sending to itself.
Ptr< Node > GetNodeByIp(Ipv4Address dest) const
Iterates through the node list and finds the one corresponding to the given Ipv4Address.
virtual void PrintRoutingTable(Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S) const
Print the Routing Table entries.
void DoDispose(void)
Destructor implementation.
Ptr< Ipv4 > m_ipv4
IPv4 object.
void FlushIpv4RouteCache(void) const
Flushes the cache which stores the Ipv4 route based on the destination IP.
std::map< Ipv4Address, Ptr< NixVector > > NixMap_t
Map of Ipv4Address to NixVector.
Ptr< NixVector > GetNixVector(Ptr< Node > source, Ipv4Address dest, Ptr< NetDevice > oif) const
Takes in the source node and dest IP and calls GetNodeByIp, BFS, accounting for any output interface ...
uint32_t FindTotalNeighbors(Ptr< Node > node) const
Simply iterates through the nodes net-devices and determines how many neighbors the node has...
SocketErrno
Enumeration of the possible errors returned by a socket.
bool BuildNixVector(const std::vector< Ptr< Node > > &parentVector, uint32_t source, uint32_t dest, Ptr< NixVector > nixVector) const
Recurses the parent vector, created by BFS and actually builds the nixvector.
bool BFS(uint32_t numberOfNodes, Ptr< Node > source, Ptr< Node > dest, std::vector< Ptr< Node > > &parentVector, Ptr< NetDevice > oif) const
Breadth first search algorithm.
void FlushNixCache(void) const
Flushes the cache which stores nix-vector based on destination IP.
Ptr< Node > m_node
Node object.
void SetNode(Ptr< Node > node)
Set the Node pointer of the node for which this routing protocol is to be placed. ...
Nix-vector routing protocol.
Unit
The unit to use to interpret a number representing time.
holds a vector of ns3::NetDevice pointers
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::unordered_map< Ipv4Address, ns3::Ptr< ns3::Node >, Ipv4AddressHash > Ipv4AddressToNodeMap
Mapping of IPv4 address to ns-3 node.
Ptr< Ipv4Route > GetIpv4RouteInCache(Ipv4Address address)
Checks the cache based on dest IP for the Ipv4Route.
static TypeId GetTypeId(void)
The Interface ID of the Global Router interface.
Ptr< BridgeNetDevice > NetDeviceIsBridged(Ptr< NetDevice > nd) const
Determine if the NetDevice is bridged.
virtual void NotifyInterfaceDown(uint32_t interface)
virtual void NotifyInterfaceUp(uint32_t interface)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< NixVector > GetNixVectorInCache(Ipv4Address address) const
Checks the cache based on dest IP for the nix-vector.
NixMap_t m_nixCache
Cache stores nix-vectors based on destination ip.
static bool g_isCacheDirty
Flag to mark when caches are dirty and need to be flushed.
void ResetTotalNeighbors(void)
Upon a run-time topology change caches are flushed and the total number of neighbors is reset to zero...
void PrintRoutingPath(Ptr< Node > source, Ipv4Address dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit) const
Print the Routing Path according to Nix Routing.
virtual void NotifyRemoveAddress(uint32_t interface, Ipv4InterfaceAddress address)
virtual Ptr< Ipv4Route > RouteOutput(Ptr< Packet > p, const Ipv4Header &header, Ptr< NetDevice > oif, Socket::SocketErrno &sockerr)
Query routing cache for an existing route, for an outbound packet.
virtual void SetIpv4(Ptr< Ipv4 > ipv4)
uint32_t m_totalNeighbors
Total neighbors used for nix-vector to determine number of bits.
Ipv4 addresses are stored in host order in this class.
a class to store IPv4 address information on an interface
Ipv4RouteMap_t m_ipv4RouteCache
Cache stores Ipv4Routes based on destination ip.
virtual bool RouteInput(Ptr< const Packet > p, const Ipv4Header &header, Ptr< const NetDevice > idev, UnicastForwardCallback ucb, MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb)
Route an input packet (to be forwarded or locally delivered)
Abstract base class for IPv4 routing protocols.
void CheckCacheStateAndFlush(void) const
Flushes routing caches if required.
std::map< Ipv4Address, Ptr< Ipv4Route > > Ipv4RouteMap_t
Map of Ipv4Address to Ipv4Route.
virtual void NotifyAddAddress(uint32_t interface, Ipv4InterfaceAddress address)
uint32_t FindNetDeviceForNixIndex(Ptr< Node > node, uint32_t nodeIndex, Ipv4Address &gatewayIp) const
Nix index is with respect to the neighbors.
a unique identifier for an interface.
static Ipv4AddressToNodeMap g_ipv4AddressToNodeMap
Address to node map.
Class providing an hash for IPv4 addresses.