A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
nix-vector-helper.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-helper.h.
8 *
9 * Authors: Josh Pelkey <jpelkey@gatech.edu>
10 *
11 * Modified by: Ameya Deshpande <ameyanrd@outlook.com>
12 */
13
14#ifndef NIX_VECTOR_HELPER_H
15#define NIX_VECTOR_HELPER_H
16
17#include "ns3/ipv4-routing-helper.h"
18#include "ns3/ipv6-routing-helper.h"
19#include "ns3/object-factory.h"
20
21namespace ns3
22{
23
24/**
25 * \ingroup nix-vector-routing
26 *
27 * \brief Helper class that adds Nix-vector routing to nodes.
28 *
29 * This class is expected to be used in conjunction with
30 * ns3::InternetStackHelper::SetRoutingHelper
31 *
32 * \internal
33 * Since this class is meant to be specialized only by Ipv4RoutingHelper or
34 * Ipv6RoutingHelper the implementation of this class doesn't need to be
35 * exposed here; it is in nix-vector-helper.cc.
36
37 */
38template <typename T>
39class NixVectorHelper : public std::enable_if_t<std::is_same_v<Ipv4RoutingHelper, T> ||
40 std::is_same_v<Ipv6RoutingHelper, T>,
41 T>
42{
43 /// Alias for determining whether the parent is Ipv4RoutingHelper or Ipv6RoutingHelper
44 static constexpr bool IsIpv4 = std::is_same_v<Ipv4RoutingHelper, T>;
45 /// Alias for Ipv4 and Ipv6 classes
46 using Ip = typename std::conditional_t<IsIpv4, Ipv4, Ipv6>;
47 /// Alias for Ipv4Address and Ipv6Address classes
48 using IpAddress = typename std::conditional_t<IsIpv4, Ipv4Address, Ipv6Address>;
49 /// Alias for Ipv4RoutingProtocol and Ipv6RoutingProtocol classes
51 typename std::conditional_t<IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol>;
52
53 public:
54 /**
55 * Construct an NixVectorHelper to make life easier while adding Nix-vector
56 * routing to nodes.
57 */
59
60 /**
61 * \brief Construct an NixVectorHelper from another previously
62 * initialized instance (Copy Constructor).
63 *
64 * \param o object to copy
65 */
67
68 // Delete assignment operator to avoid misuse
70
71 /**
72 * \returns pointer to clone of this NixVectorHelper
73 *
74 * This method is mainly for internal use by the other helpers;
75 * clients are expected to free the dynamic memory allocated by this method
76 */
77 NixVectorHelper<T>* Copy() const override;
78
79 /**
80 * \param node the node on which the routing protocol will run
81 * \returns a newly-created routing protocol
82 *
83 * This method will be called by ns3::InternetStackHelper::Install
84 */
85 Ptr<IpRoutingProtocol> Create(Ptr<Node> node) const override;
86
87 /**
88 * \brief prints the routing path for a source and destination at a particular time.
89 * If the routing path does not exist, it prints that the path does not exist between
90 * the nodes in the ostream.
91 * \param printTime the time at which the routing path is supposed to be printed.
92 * \param source the source node pointer to start traversing
93 * \param dest the IP destination address
94 * \param stream the output stream object to use
95 * \param unit the time unit to be used in the report
96 *
97 * This method calls the PrintRoutingPath() method of the
98 * NixVectorRouting for the source and destination to provide
99 * the routing path at the specified time.
100 */
101 void PrintRoutingPathAt(Time printTime,
102 Ptr<Node> source,
103 IpAddress dest,
105 Time::Unit unit = Time::S);
106
107 private:
108 ObjectFactory m_agentFactory; //!< Object factory
109
110 /**
111 * \brief prints the routing path for the source and destination. If the routing path
112 * does not exist, it prints that the path does not exist between the nodes in the ostream.
113 * \param source the source node pointer to start traversing
114 * \param dest the IP destination address
115 * \param stream the output stream object to use
116 * \param unit the time unit to be used in the report
117 *
118 * This method calls the PrintRoutingPath() method of the
119 * NixVectorRouting for the source and destination to provide
120 * the routing path.
121 */
122 static void PrintRoute(Ptr<Node> source,
123 IpAddress dest,
125 Time::Unit unit = Time::S);
126};
127
128/**
129 * \ingroup nix-vector-routing
130 * Create the typedef Ipv4NixVectorHelper with T as Ipv4RoutingHelper
131 *
132 * Note: This typedef enables also backwards compatibility with original Ipv4RoutingHelper.
133 */
135
136/**
137 * \ingroup nix-vector-routing
138 * Create the typedef Ipv6NixVectorHelper with T as Ipv6RoutingHelper
139 */
141} // namespace ns3
142
143#endif /* NIX_VECTOR_HELPER_H */
Helper class that adds Nix-vector routing to nodes.
static void PrintRoute(Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for the source and destination.
NixVectorHelper< T > * Copy() const override
typename std::conditional_t< IsIpv4, Ipv4, Ipv6 > Ip
Alias for Ipv4 and Ipv6 classes.
ObjectFactory m_agentFactory
Object factory.
NixVectorHelper & operator=(const NixVectorHelper &)=delete
static constexpr bool IsIpv4
Alias for determining whether the parent is Ipv4RoutingHelper or Ipv6RoutingHelper.
void PrintRoutingPathAt(Time printTime, Ptr< Node > source, IpAddress dest, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing path for a source and destination at a particular time.
typename std::conditional_t< IsIpv4, Ipv4RoutingProtocol, Ipv6RoutingProtocol > IpRoutingProtocol
Alias for Ipv4RoutingProtocol and Ipv6RoutingProtocol classes.
NixVectorHelper()
Construct an NixVectorHelper to make life easier while adding Nix-vector routing to nodes.
Ptr< IpRoutingProtocol > Create(Ptr< Node > node) const override
typename std::conditional_t< IsIpv4, Ipv4Address, Ipv6Address > IpAddress
Alias for Ipv4Address and Ipv6Address classes.
Instantiate subclasses of ns3::Object.
Smart pointer class similar to boost::intrusive_ptr.
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
Unit
The unit to use to interpret a number representing time.
Definition nstime.h:100
@ S
second
Definition nstime.h:105
NixVectorHelper< Ipv6RoutingHelper > Ipv6NixVectorHelper
Create the typedef Ipv6NixVectorHelper with T as Ipv6RoutingHelper.
NixVectorHelper< Ipv4RoutingHelper > Ipv4NixVectorHelper
Create the typedef Ipv4NixVectorHelper with T as Ipv4RoutingHelper.
Every class exported by the ns3 library is enclosed in the ns3 namespace.