A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-routing-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
8
9#ifndef IPV4_ROUTING_HELPER_H
10#define IPV4_ROUTING_HELPER_H
11
12#include "ns3/ipv4-list-routing.h"
13#include "ns3/nstime.h"
14#include "ns3/output-stream-wrapper.h"
15#include "ns3/ptr.h"
16
17namespace ns3
18{
19
20class Ipv4RoutingProtocol;
21class Node;
22
23/**
24 * \ingroup ipv4Helpers
25 *
26 * \brief a factory to create ns3::Ipv4RoutingProtocol objects
27 *
28 * For each new routing protocol created as a subclass of
29 * ns3::Ipv4RoutingProtocol, you need to create a subclass of
30 * ns3::Ipv4RoutingHelper which can be used by
31 * ns3::InternetStackHelper::SetRoutingHelper and
32 * ns3::InternetStackHelper::Install.
33 */
35{
36 public:
37 /*
38 * Destroy an instance of an Ipv4RoutingHelper
39 */
40 virtual ~Ipv4RoutingHelper();
41
42 /**
43 * \brief virtual constructor
44 * \returns pointer to clone of this Ipv4RoutingHelper
45 *
46 * This method is mainly for internal use by the other helpers;
47 * clients are expected to free the dynamic memory allocated by this method
48 */
49 virtual Ipv4RoutingHelper* Copy() const = 0;
50
51 /**
52 * \param node the node within which the new routing protocol will run
53 * \returns a newly-created routing protocol
54 */
55 virtual Ptr<Ipv4RoutingProtocol> Create(Ptr<Node> node) const = 0;
56
57 /**
58 * \brief prints the routing tables of all nodes at a particular time.
59 * \param printTime the time at which the routing table is supposed to be printed.
60 * \param stream The output stream object to use
61 * \param unit The time unit to be used in the report
62 *
63 * This method calls the PrintRoutingTable() method of the
64 * Ipv4RoutingProtocol stored in the Ipv4 object, for all nodes at the
65 * specified time; the output format is routing protocol-specific.
66 */
67 static void PrintRoutingTableAllAt(Time printTime,
69 Time::Unit unit = Time::S);
70
71 /**
72 * \brief prints the routing tables of all nodes at regular intervals specified by user.
73 * \param printInterval the time interval for which the routing table is supposed to be printed.
74 * \param stream The output stream object to use
75 * \param unit The time unit to be used in the report
76 *
77 * This method calls the PrintRoutingTable() method of the
78 * Ipv4RoutingProtocol stored in the Ipv4 object, for all nodes at the
79 * specified time interval; the output format is routing protocol-specific.
80 */
81 static void PrintRoutingTableAllEvery(Time printInterval,
83 Time::Unit unit = Time::S);
84
85 /**
86 * \brief prints the routing tables of a node at a particular time.
87 * \param printTime the time at which the routing table is supposed to be printed.
88 * \param node The node ptr for which we need the routing table to be printed
89 * \param stream The output stream object to use
90 * \param unit The time unit to be used in the report
91 *
92 * This method calls the PrintRoutingTable() method of the
93 * Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
94 * at the specified time; the output format is routing protocol-specific.
95 */
96 static void PrintRoutingTableAt(Time printTime,
97 Ptr<Node> node,
99 Time::Unit unit = Time::S);
100
101 /**
102 * \brief prints the routing tables of a node at regular intervals specified by user.
103 * \param printInterval the time interval for which the routing table is supposed to be printed.
104 * \param node The node ptr for which we need the routing table to be printed
105 * \param stream The output stream object to use
106 * \param unit The time unit to be used in the report
107 *
108 * This method calls the PrintRoutingTable() method of the
109 * Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
110 * at the specified interval; the output format is routing protocol-specific.
111 */
112 static void PrintRoutingTableEvery(Time printInterval,
113 Ptr<Node> node,
115 Time::Unit unit = Time::S);
116
117 /**
118 * \brief prints the neighbor cache of all nodes at a particular time.
119 * \param printTime the time at which the neighbor cache is supposed to be printed.
120 * \param stream The output stream object to use
121 * \param unit The time unit to be used in the report
122 *
123 * This method calls the PrintArpCache() method of the
124 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
125 * specified time. The output format is similar to:
126 * \verbatim
127 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
128 \endverbatim
129 * Note that the MAC address is printed as "type"-"size"-"actual address"
130 */
131 static void PrintNeighborCacheAllAt(Time printTime,
133 Time::Unit unit = Time::S);
134
135 /**
136 * \brief prints the neighbor cache of all nodes at regular intervals specified by user.
137 * \param printInterval the time interval for which the neighbor cache is supposed to be
138 printed.
139 * \param stream The output stream object to use
140 * \param unit The time unit to be used in the report
141 *
142 * This method calls the PrintArpCache() method of the
143 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
144 * specified time. The output format is similar to:
145 * \verbatim
146 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
147 \endverbatim
148 * Note that the MAC address is printed as "type"-"size"-"actual address"
149 */
150 static void PrintNeighborCacheAllEvery(Time printInterval,
152 Time::Unit unit = Time::S);
153
154 /**
155 * \brief prints the neighbor cache of a node at a particular time.
156 * \param printTime the time at which the neighbor cache is supposed to be printed.
157 * \param node The node ptr for which we need the neighbor cache to be printed
158 * \param stream The output stream object to use
159 * \param unit The time unit to be used in the report
160 *
161 * This method calls the PrintArpCache() method of the
162 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
163 * specified time. The output format is similar to:
164 * \verbatim
165 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
166 \endverbatim
167 * Note that the MAC address is printed as "type"-"size"-"actual address"
168 */
169 static void PrintNeighborCacheAt(Time printTime,
170 Ptr<Node> node,
172 Time::Unit unit = Time::S);
173
174 /**
175 * \brief prints the neighbor cache of a node at regular intervals specified by user.
176 * \param printInterval the time interval for which the neighbor cache is supposed to be
177 printed.
178 * \param node The node ptr for which we need the neighbor cache to be printed
179 * \param stream The output stream object to use
180 * \param unit The time unit to be used in the report
181 *
182 * This method calls the PrintArpCache() method of the
183 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
184 * specified time. The output format is similar to:
185 * \verbatim
186 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
187 \endverbatim
188 * Note that the MAC address is printed as "type"-"size"-"actual address"
189 */
190 static void PrintNeighborCacheEvery(Time printInterval,
191 Ptr<Node> node,
193 Time::Unit unit = Time::S);
194
195 /**
196 * \brief Request a specified routing protocol &lt;T&gt; from Ipv4RoutingProtocol protocol
197 *
198 * If protocol is Ipv4ListRouting, then protocol will be searched in the list,
199 * otherwise a simple DynamicCast will be performed
200 *
201 * \param protocol Smart pointer to Ipv4RoutingProtocol object
202 * \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
203 */
204 template <class T>
206
207 private:
208 /**
209 * \brief prints the routing tables of a node.
210 * \param node The node ptr for which we need the routing table to be printed
211 * \param stream The output stream object to use
212 * \param unit The time unit to be used in the report
213 *
214 * This method calls the PrintRoutingTable() method of the
215 * Ipv4RoutingProtocol stored in the Ipv4 object;
216 * the output format is routing protocol-specific.
217 */
218 static void Print(Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
219
220 /**
221 * \brief prints the routing tables of a node at regular intervals specified by user.
222 * \param printInterval the time interval for which the routing table is supposed to be printed.
223 * \param node The node ptr for which we need the routing table to be printed
224 * \param stream The output stream object to use
225 * \param unit The time unit to be used in the report
226 *
227 * This method calls the PrintRoutingTable() method of the
228 * Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
229 * at the specified interval; the output format is routing protocol-specific.
230 */
231 static void PrintEvery(Time printInterval,
232 Ptr<Node> node,
234 Time::Unit unit = Time::S);
235
236 /**
237 * \brief prints the neighbor cache of a node.
238 * \param node The node ptr for which we need the neighbor cache to be printed
239 * \param stream The output stream object to use
240 * \param unit The time unit to be used in the report
241 *
242 * This method calls the PrintArpCache() method of the
243 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
244 * specified time. The output format is similar to:
245 * \verbatim
246 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
247 \endverbatim
248 * Note that the MAC address is printed as "type"-"size"-"actual address"
249 */
250 static void PrintArpCache(Ptr<Node> node,
252 Time::Unit unit = Time::S);
253
254 /**
255 * \brief prints the neighbor cache of a node at regular intervals specified by user.
256 * \param printInterval the time interval for which the neighbor cache is supposed to be
257 printed.
258 * \param node The node ptr for which we need the neighbor cache to be printed
259 * \param stream The output stream object to use
260 * \param unit The time unit to be used in the report
261 *
262 * This method calls the PrintArpCache() method of the
263 * ArpCache associated with each Ipv4Interface stored in the Ipv4 object, for all nodes at the
264 * specified time. The output format is similar to:
265 * \verbatim
266 10.1.1.2 dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
267 \endverbatim
268 * Note that the MAC address is printed as "type"-"size"-"actual address"
269 */
270 static void PrintArpCacheEvery(Time printInterval,
271 Ptr<Node> node,
273 Time::Unit unit = Time::S);
274};
275
276template <class T>
277Ptr<T>
279{
280 Ptr<T> ret = DynamicCast<T>(protocol);
281 if (!ret)
282 {
283 // trying to check if protocol is a list routing
285 if (lrp)
286 {
287 for (uint32_t i = 0; i < lrp->GetNRoutingProtocols(); i++)
288 {
289 int16_t priority;
290 ret = GetRouting<T>(lrp->GetRoutingProtocol(
291 i,
292 priority)); // potential recursion, if inside ListRouting is ListRouting
293 if (ret)
294 {
295 break;
296 }
297 }
298 }
299 }
300
301 return ret;
302}
303
304} // namespace ns3
305
306#endif /* IPV4_ROUTING_HELPER_H */
a factory to create ns3::Ipv4RoutingProtocol objects
static void PrintRoutingTableAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node at a particular time.
static void PrintRoutingTableAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at a particular time.
static void PrintArpCache(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node.
virtual Ipv4RoutingHelper * Copy() const =0
virtual constructor
static void PrintNeighborCacheAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at regular intervals specified by user.
static void PrintEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node at regular intervals specified by user.
static void PrintNeighborCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at regular intervals specified by user.
static void Print(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node.
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const =0
static Ptr< T > GetRouting(Ptr< Ipv4RoutingProtocol > protocol)
Request a specified routing protocol <T> from Ipv4RoutingProtocol protocol.
static void PrintNeighborCacheAt(Time printTime, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at a particular time.
static void PrintArpCacheEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node at regular intervals specified by user.
static void PrintNeighborCacheAllAt(Time printTime, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of all nodes at a particular time.
static void PrintRoutingTableEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of a node at regular intervals specified by user.
static void PrintRoutingTableAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes at regular intervals specified by user.
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Definition ptr.h:580