A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv6-routing-helper.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19
20#ifndef IPV6_ROUTING_HELPER_H
21#define IPV6_ROUTING_HELPER_H
22
23#include "ns3/ipv6-list-routing.h"
24#include "ns3/nstime.h"
25#include "ns3/output-stream-wrapper.h"
26#include "ns3/ptr.h"
27
28namespace ns3
29{
30
31class Ipv6RoutingProtocol;
32class Node;
33
34/**
35 * \ingroup ipv6Helpers
36 *
37 * \brief A factory to create ns3::Ipv6RoutingProtocol objects
38 *
39 * For each new routing protocol created as a subclass of
40 * ns3::Ipv6RoutingProtocol, you need to create a subclass of
41 * ns3::Ipv6RoutingHelper which can be used by
42 * ns3::InternetStackHelper::SetRoutingHelper and
43 * ns3::InternetStackHelper::Install.
44 */
46{
47 public:
48 /**
49 * \brief Destroy an Ipv6 Ipv6RoutingHelper.
50 */
51 virtual ~Ipv6RoutingHelper();
52
53 /**
54 * \brief virtual constructor
55 * \returns pointer to clone of this Ipv6RoutingHelper
56 *
57 * This method is mainly for internal use by the other helpers;
58 * clients are expected to free the dynamic memory allocated by this method
59 */
60 virtual Ipv6RoutingHelper* Copy() const = 0;
61
62 /**
63 * \param node the node within which the new routing protocol will run
64 * \returns a newly-created routing protocol
65 */
66 virtual Ptr<Ipv6RoutingProtocol> Create(Ptr<Node> node) const = 0;
67
68 /**
69 * \brief prints the routing tables of all nodes at a particular time.
70 * \param printTime the time at which the routing table is supposed to be printed.
71 * \param stream The output stream object to use
72 * \param unit The time unit to be used in the report
73 *
74 * This method calls the PrintRoutingTable() method of the
75 * Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
76 * specified time; the output format is routing protocol-specific.
77 */
78 static void PrintRoutingTableAllAt(Time printTime,
80 Time::Unit unit = Time::S);
81
82 /**
83 * \brief prints the routing tables of all nodes at regular intervals specified by user.
84 * \param printInterval the time interval for which the routing table is supposed to be printed.
85 * \param stream The output stream object to use
86 * \param unit The time unit to be used in the report
87 *
88 * This method calls the PrintRoutingTable() method of the
89 * Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
90 * specified time interval; the output format is routing protocol-specific.
91 */
92 static void PrintRoutingTableAllEvery(Time printInterval,
94 Time::Unit unit = Time::S);
95
96 /**
97 * \brief prints the routing tables of a node at a particular time.
98 * \param printTime the time at which the routing table is supposed to be printed.
99 * \param node The node ptr for which we need the routing table to be printed
100 * \param stream The output stream object to use
101 * \param unit The time unit to be used in the report
102 *
103 * This method calls the PrintRoutingTable() method of the
104 * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
105 * at the specified time; the output format is routing protocol-specific.
106 */
107 static void PrintRoutingTableAt(Time printTime,
108 Ptr<Node> node,
110 Time::Unit unit = Time::S);
111
112 /**
113 * \brief prints the routing tables of a node at regular intervals specified by user.
114 * \param printInterval the time interval for which the routing table is supposed to be printed.
115 * \param node The node ptr for which we need the routing table to be printed
116 * \param stream The output stream object to use
117 * \param unit The time unit to be used in the report
118 *
119 * This method calls the PrintRoutingTable() method of the
120 * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
121 * at the specified interval; the output format is routing protocol-specific.
122 */
123 static void PrintRoutingTableEvery(Time printInterval,
124 Ptr<Node> node,
126 Time::Unit unit = Time::S);
127
128 /**
129 * \brief prints the neighbor cache of all nodes at a particular time.
130 * \param printTime the time at which the neighbor cache is supposed to be printed.
131 * \param stream The output stream object to use
132 * \param unit The time unit to be used in the report
133 *
134 * This method calls the PrintNdiscCache() method of the
135 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
136 * specified time. The output format is similar to:
137 * \verbatim
138 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
139 \endverbatim
140 * Note that the MAC address is printed as "type"-"size"-"actual address"
141 */
142 static void PrintNeighborCacheAllAt(Time printTime,
144 Time::Unit unit = Time::S);
145
146 /**
147 * \brief prints the neighbor cache of all nodes at regular intervals specified by user.
148 * \param printInterval the time interval for which the neighbor cache is supposed to be
149 printed.
150 * \param stream The output stream object to use
151 * \param unit The time unit to be used in the report
152 *
153 * This method calls the PrintNdiscCache() method of the
154 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
155 * specified time. The output format is similar to:
156 * \verbatim
157 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
158 \endverbatim
159 * Note that the MAC address is printed as "type"-"size"-"actual address"
160 */
161 static void PrintNeighborCacheAllEvery(Time printInterval,
163 Time::Unit unit = Time::S);
164
165 /**
166 * \brief prints the neighbor cache of a node at a particular time.
167 * \param printTime the time at which the neighbor cache is supposed to be printed.
168 * \param node The node ptr for which we need the neighbor cache to be printed
169 * \param stream The output stream object to use
170 * \param unit The time unit to be used in the report
171 *
172 * This method calls the PrintNdiscCache() method of the
173 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
174 * specified time. The output format is similar to:
175 * \verbatim
176 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
177 \endverbatim
178 * Note that the MAC address is printed as "type"-"size"-"actual address"
179 */
180 static void PrintNeighborCacheAt(Time printTime,
181 Ptr<Node> node,
183 Time::Unit unit = Time::S);
184
185 /**
186 * \brief prints the neighbor cache of a node at regular intervals specified by user.
187 * \param printInterval the time interval for which the neighbor cache is supposed to be
188 printed.
189 * \param node The node ptr for which we need the neighbor cache to be printed
190 * \param stream The output stream object to use
191 * \param unit The time unit to be used in the report
192 *
193 * This method calls the PrintNdiscCache() method of the
194 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
195 * specified time. The output format is similar to:
196 * \verbatim
197 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
198 \endverbatim
199 * Note that the MAC address is printed as "type"-"size"-"actual address"
200 */
201 static void PrintNeighborCacheEvery(Time printInterval,
202 Ptr<Node> node,
204 Time::Unit unit = Time::S);
205
206 /**
207 * \brief Request a specified routing protocol &lt;T&gt; from Ipv6RoutingProtocol protocol
208 *
209 * If protocol is Ipv6ListRouting, then protocol will be searched in the list,
210 * otherwise a simple DynamicCast will be performed
211 *
212 * \param protocol Smart pointer to Ipv6RoutingProtocol object
213 * \return a Smart Pointer to the requested protocol (zero if the protocol can't be found)
214 */
215 template <class T>
217
218 private:
219 /**
220 * \brief prints the routing tables of a node.
221 * \param node The node ptr for which we need the routing table to be printed
222 * \param stream The output stream object to use
223 * \param unit The time unit to be used in the report
224 *
225 * This method calls the PrintRoutingTable() method of the
226 * Ipv6RoutingProtocol stored in the Ipv6 object;
227 * the output format is routing protocol-specific.
228 */
229 static void Print(Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit);
230
231 /**
232 * \brief prints the routing tables of a node at regular intervals specified by user.
233 * \param printInterval the time interval for which the routing table is supposed to be printed.
234 * \param node The node ptr for which we need the routing table to be printed
235 * \param stream The output stream object to use
236 * \param unit The time unit to be used in the report
237 *
238 * This method calls the PrintRoutingTable() method of the
239 * Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
240 * at the specified interval; the output format is routing protocol-specific.
241 */
242 static void PrintEvery(Time printInterval,
243 Ptr<Node> node,
245 Time::Unit unit);
246
247 /**
248 * \brief prints the neighbor cache of a node.
249 * \param node The node ptr for which we need the neighbor cache to be printed
250 * \param stream The output stream object to use
251 * \param unit The time unit to be used in the report
252 *
253 * This method calls the PrintNdiscCache() method of the
254 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
255 * specified time. The output format is similar to:
256 * \verbatim
257 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
258 \endverbatim
259 * Note that the MAC address is printed as "type"-"size"-"actual address"
260 */
261 static void PrintNdiscCache(Ptr<Node> node,
263 Time::Unit unit = Time::S);
264
265 /**
266 * \brief prints the neighbor cache of a node at regular intervals specified by user.
267 * \param printInterval the time interval for which the neighbor cache is supposed to be
268 printed.
269 * \param node The node ptr for which we need the neighbor cache to be printed
270 * \param stream The output stream object to use
271 * \param unit The time unit to be used in the report
272 *
273 * This method calls the PrintNdiscCache() method of the
274 * NdiscCache associated with each Ipv6Interface stored in the Ipv6 object, for all nodes at the
275 * specified time. The output format is similar to:
276 * \verbatim
277 2001:db8::f00d:beef:cafe dev 1 lladdr 00-06-00:00:00:00:00:02 REACHABLE
278 \endverbatim
279 * Note that the MAC address is printed as "type"-"size"-"actual address"
280 */
281 static void PrintNdiscCacheEvery(Time printInterval,
282 Ptr<Node> node,
284 Time::Unit unit = Time::S);
285};
286
287template <class T>
288Ptr<T>
290{
291 Ptr<T> ret = DynamicCast<T>(protocol);
292 if (!ret)
293 {
294 // trying to check if protocol is a list routing
295 Ptr<Ipv6ListRouting> lrp = DynamicCast<Ipv6ListRouting>(protocol);
296 if (lrp)
297 {
298 for (uint32_t i = 0; i < lrp->GetNRoutingProtocols(); i++)
299 {
300 int16_t priority;
301 ret = GetRouting<T>(lrp->GetRoutingProtocol(
302 i,
303 priority)); // potential recursion, if inside ListRouting is ListRouting
304 if (ret)
305 {
306 break;
307 }
308 }
309 }
310 }
311
312 return ret;
313}
314
315} // namespace ns3
316
317#endif /* IPV6_ROUTING_HELPER_H */
A factory to create ns3::Ipv6RoutingProtocol objects.
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 PrintNdiscCacheEvery(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.
virtual Ptr< Ipv6RoutingProtocol > Create(Ptr< Node > node) const =0
static void PrintNdiscCache(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the neighbor cache of a node.
static Ptr< T > GetRouting(Ptr< Ipv6RoutingProtocol > protocol)
Request a specified routing protocol <T> from Ipv6RoutingProtocol protocol.
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 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 PrintRoutingTableAllEvery(Time printInterval, Ptr< OutputStreamWrapper > stream, Time::Unit unit=Time::S)
prints the routing tables of all nodes 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 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.
virtual ~Ipv6RoutingHelper()
Destroy an Ipv6 Ipv6RoutingHelper.
static void Print(Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit)
prints the routing tables of a node.
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.
virtual Ipv6RoutingHelper * Copy() const =0
virtual constructor
static void PrintEvery(Time printInterval, Ptr< Node > node, Ptr< OutputStreamWrapper > stream, Time::Unit unit)
prints the routing tables of a node at regular intervals specified by user.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
Unit
The unit to use to interpret a number representing time.
Definition: nstime.h:111
@ S
second
Definition: nstime.h:116
Every class exported by the ns3 library is enclosed in the ns3 namespace.