A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
internet-stack-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 INTERNET_STACK_HELPER_H
21#define INTERNET_STACK_HELPER_H
22
24
25#include "ns3/ipv4-l3-protocol.h"
26#include "ns3/ipv6-l3-protocol.h"
27#include "ns3/net-device-container.h"
28#include "ns3/node-container.h"
29#include "ns3/object-factory.h"
30#include "ns3/packet.h"
31#include "ns3/ptr.h"
32
33namespace ns3
34{
35
36class Node;
37class Ipv4RoutingHelper;
38class Ipv6RoutingHelper;
39
40/**
41 * \defgroup internet Internet
42 *
43 * This section documents the API of the ns-3 internet module. For a generic functional description,
44 * please refer to the ns-3 manual.
45 */
46
47/**
48 * \ingroup internet
49 * \defgroup ipv4Helpers IPv4 Helper classes
50 */
51
52/**
53 * \ingroup internet
54 * \defgroup ipv6Helpers IPv6 Helper classes
55 */
56
57/**
58 * \ingroup internet
59 *
60 * \brief aggregate IP/TCP/UDP functionality to existing Nodes.
61 *
62 * This helper enables pcap and ascii tracing of events in the internet stack
63 * associated with a node. This is substantially similar to the tracing
64 * that happens in device helpers, but the important difference is that, well,
65 * there is no device. This means that the creation of output file names will
66 * change, and also the user-visible methods will not reference devices and
67 * therefore the number of trace enable methods is reduced.
68 *
69 * Normally we avoid multiple inheritance in ns-3, however, the classes
70 * PcapUserHelperForIpv4 and AsciiTraceUserHelperForIpv4 are
71 * treated as "mixins". A mixin is a self-contained class that
72 * encapsulates a general attribute or a set of functionality that
73 * may be of interest to many other classes.
74 *
75 * This class aggregates instances of these objects, by default, to each node:
76 * - ns3::ArpL3Protocol
77 * - ns3::Ipv4L3Protocol
78 * - ns3::Icmpv4L4Protocol
79 * - ns3::Ipv6L3Protocol
80 * - ns3::Icmpv6L4Protocol
81 * - ns3::UdpL4Protocol
82 * - ns3::TrafficControlLayer
83 * - a TCP based on the TCP factory provided
84 * - a PacketSocketFactory
85 * - Ipv4 routing (a list routing object, a global routing object, and a static routing object)
86 * - Ipv6 routing (a static routing object)
87 */
89 public PcapHelperForIpv6,
92{
93 public:
94 /**
95 * Create a new InternetStackHelper which uses a mix of static routing
96 * and global routing by default. The static routing protocol
97 * (ns3::Ipv4StaticRouting) and the global routing protocol are
98 * stored in an ns3::Ipv4ListRouting protocol with priorities 0, and -10
99 * by default. If you wish to use different priorites and different
100 * routing protocols, you need to use an adhoc ns3::Ipv4RoutingHelper,
101 * such as ns3::OlsrHelper
102 */
104
105 /**
106 * Destroy the InternetStackHelper
107 */
108 ~InternetStackHelper() override;
109
110 /**
111 * \brief Copy constructor
112 * \param o Object to copy from.
113 */
115
116 /**
117 * \brief Copy constructor
118 * \param o Object to copy from.
119 * \returns A copy of the InternetStackHelper.
120 */
122
123 /**
124 * Return helper internal state to that of a newly constructed one
125 */
126 void Reset();
127
128 /**
129 * \param routing a new routing helper
130 *
131 * Set the routing helper to use during Install. The routing
132 * helper is really an object factory which is used to create
133 * an object of type ns3::Ipv4RoutingProtocol per node. This routing
134 * object is then associated to a single ns3::Ipv4 object through its
135 * ns3::Ipv4::SetRoutingProtocol.
136 */
137 void SetRoutingHelper(const Ipv4RoutingHelper& routing);
138
139 /**
140 * \brief Set IPv6 routing helper.
141 * \param routing IPv6 routing helper
142 */
143 void SetRoutingHelper(const Ipv6RoutingHelper& routing);
144
145 /**
146 * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes
147 * onto the provided node. This method will do nothing if the stacks are already installed,
148 * and will not overwrite existing stacks parameters.
149 *
150 * \param nodeName The name of the node on which to install the stack.
151 */
152 void Install(std::string nodeName) const;
153
154 /**
155 * Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes
156 * onto the provided node. This method will do nothing if the stacks are already installed,
157 * and will not overwrite existing stacks parameters.
158 *
159 * \param node The node on which to install the stack.
160 */
161 void Install(Ptr<Node> node) const;
162
163 /**
164 * For each node in the input container, aggregate implementations of the
165 * ns3::Ipv4, ns3::Ipv6, ns3::Udp, and, ns3::Tcp classes. This method will do nothing if the
166 * stacks are already installed, and will not overwrite existing stacks parameters.
167 *
168 * \param c NodeContainer that holds the set of nodes on which to install the
169 * new stacks.
170 */
171 void Install(NodeContainer c) const;
172
173 /**
174 * Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation
175 */
176 void InstallAll() const;
177
178 /**
179 * \brief Enable/disable IPv4 stack install.
180 * \param enable enable state
181 */
182 void SetIpv4StackInstall(bool enable);
183
184 /**
185 * \brief Enable/disable IPv6 stack install.
186 * \param enable enable state
187 */
188 void SetIpv6StackInstall(bool enable);
189
190 /**
191 * \brief Enable/disable IPv4 ARP Jitter.
192 * \param enable enable state
193 */
194 void SetIpv4ArpJitter(bool enable);
195
196 /**
197 * \brief Enable/disable IPv6 NS and RS Jitter.
198 * \param enable enable state
199 */
200 void SetIpv6NsRsJitter(bool enable);
201
202 /**
203 * Assign a fixed random variable stream number to the random variables
204 * used by this model. Return the number of streams (possibly zero) that
205 * have been assigned. The Install() method should have previously been
206 * called by the user.
207 *
208 * \param stream first stream index to use
209 * \param c NodeContainer of the set of nodes for which the internet models
210 * should be modified to use a fixed stream
211 * \return the number of stream indices assigned by this helper
212 */
213 int64_t AssignStreams(NodeContainer c, int64_t stream);
214
215 private:
216 /**
217 * @brief Enable pcap output the indicated Ipv4 and interface pair.
218 *
219 * @param prefix Filename prefix to use for pcap files.
220 * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
221 * @param interface Interface ID on the Ipv4 on which you want to enable tracing.
222 * @param explicitFilename Treat the prefix as an explicit filename if true
223 */
224 void EnablePcapIpv4Internal(std::string prefix,
225 Ptr<Ipv4> ipv4,
226 uint32_t interface,
227 bool explicitFilename) override;
228
229 /**
230 * @brief Enable ascii trace output on the indicated Ipv4 and interface pair.
231 *
232 * @param stream An OutputStreamWrapper representing an existing file to use
233 * when writing trace data.
234 * @param prefix Filename prefix to use for ascii trace files.
235 * @param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
236 * @param interface Interface ID on the Ipv4 on which you want to enable tracing.
237 * @param explicitFilename Treat the prefix as an explicit filename if true
238 */
240 std::string prefix,
241 Ptr<Ipv4> ipv4,
242 uint32_t interface,
243 bool explicitFilename) override;
244
245 /**
246 * @brief Enable pcap output the indicated Ipv6 and interface pair.
247 *
248 * @param prefix Filename prefix to use for pcap files.
249 * @param ipv6 Ptr to the Ipv6 interface on which you want to enable tracing.
250 * @param interface Interface ID on the Ipv6 on which you want to enable tracing.
251 * @param explicitFilename Treat the prefix as an explicit filename if true
252 */
253 void EnablePcapIpv6Internal(std::string prefix,
254 Ptr<Ipv6> ipv6,
255 uint32_t interface,
256 bool explicitFilename) override;
257
258 /**
259 * @brief Enable ascii trace output on the indicated Ipv6 and interface pair.
260 *
261 * @param stream An OutputStreamWrapper representing an existing file to use
262 * when writing trace data.
263 * @param prefix Filename prefix to use for ascii trace files.
264 * @param ipv6 Ptr to the Ipv6 interface on which you want to enable tracing.
265 * @param interface Interface ID on the Ipv6 on which you want to enable tracing.
266 * @param explicitFilename Treat the prefix as an explicit filename if true
267 */
269 std::string prefix,
270 Ptr<Ipv6> ipv6,
271 uint32_t interface,
272 bool explicitFilename) override;
273
274 /**
275 * \brief Initialize the helper to its default values
276 */
277 void Initialize();
278
279 /**
280 * \brief IPv4 routing helper.
281 */
283
284 /**
285 * \brief IPv6 routing helper.
286 */
288
289 /**
290 * \brief create an object from its TypeId and aggregates it to the node. Does nothing if
291 * an object of the same type is already aggregated to the node.
292 * \param node the node
293 * \param typeId the object TypeId
294 */
295 static void CreateAndAggregateObjectFromTypeId(Ptr<Node> node, const std::string typeId);
296
297 /**
298 * \brief checks if there is an hook to a Pcap wrapper
299 * \param ipv4 pointer to the IPv4 object
300 * \returns true if a hook is found
301 */
302 bool PcapHooked(Ptr<Ipv4> ipv4);
303
304 /**
305 * \brief checks if there is an hook to an ascii output stream
306 * \param ipv4 pointer to the IPv4 object
307 * \returns true if a hook is found
308 */
309 bool AsciiHooked(Ptr<Ipv4> ipv4);
310
311 /**
312 * \brief checks if there is an hook to a Pcap wrapper
313 * \param ipv6 pointer to the IPv6 object
314 * \returns true if a hook is found
315 */
316 bool PcapHooked(Ptr<Ipv6> ipv6);
317
318 /**
319 * \brief checks if there is an hook to an ascii output stream
320 * \param ipv6 pointer to the IPv6 object
321 * \returns true if a hook is found
322 */
323 bool AsciiHooked(Ptr<Ipv6> ipv6);
324
325 /**
326 * \brief IPv4 install state (enabled/disabled) ?
327 */
329
330 /**
331 * \brief IPv6 install state (enabled/disabled) ?
332 */
334
335 /**
336 * \brief IPv4 ARP Jitter state (enabled/disabled) ?
337 */
339
340 /**
341 * \brief IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
342 */
344};
345
346} // namespace ns3
347
348#endif /* INTERNET_STACK_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing IPv4 protocols...
Base class providing common user-level ascii trace operations for helpers representing IPv6 protocols...
aggregate IP/TCP/UDP functionality to existing Nodes.
void EnablePcapIpv6Internal(std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename) override
Enable pcap output the indicated Ipv6 and interface pair.
void SetIpv4StackInstall(bool enable)
Enable/disable IPv4 stack install.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
void SetIpv4ArpJitter(bool enable)
Enable/disable IPv4 ARP Jitter.
void EnableAsciiIpv4Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename) override
Enable ascii trace output on the indicated Ipv4 and interface pair.
bool m_ipv6Enabled
IPv6 install state (enabled/disabled) ?
void SetRoutingHelper(const Ipv4RoutingHelper &routing)
bool m_ipv6NsRsJitterEnabled
IPv6 IPv6 NS and RS Jitter state (enabled/disabled) ?
bool AsciiHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to an ascii output stream
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
const Ipv4RoutingHelper * m_routing
IPv4 routing helper.
void InstallAll() const
Aggregate IPv4, IPv6, UDP, and TCP stacks to all nodes in the simulation.
void SetIpv6StackInstall(bool enable)
Enable/disable IPv6 stack install.
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
create an object from its TypeId and aggregates it to the node.
void Initialize()
Initialize the helper to its default values.
void SetIpv6NsRsJitter(bool enable)
Enable/disable IPv6 NS and RS Jitter.
bool PcapHooked(Ptr< Ipv4 > ipv4)
checks if there is an hook to a Pcap wrapper
void EnablePcapIpv4Internal(std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename) override
Enable pcap output the indicated Ipv4 and interface pair.
bool m_ipv4ArpJitterEnabled
IPv4 ARP Jitter state (enabled/disabled) ?
const Ipv6RoutingHelper * m_routingv6
IPv6 routing helper.
InternetStackHelper & operator=(const InternetStackHelper &o)
Copy constructor.
InternetStackHelper()
Create a new InternetStackHelper which uses a mix of static routing and global routing by default.
void Reset()
Return helper internal state to that of a newly constructed one.
~InternetStackHelper() override
Destroy the InternetStackHelper.
void EnableAsciiIpv6Internal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< Ipv6 > ipv6, uint32_t interface, bool explicitFilename) override
Enable ascii trace output on the indicated Ipv6 and interface pair.
a factory to create ns3::Ipv4RoutingProtocol objects
A factory to create ns3::Ipv6RoutingProtocol objects.
keep track of a set of node pointers.
Base class providing common user-level pcap operations for helpers representing IPv4 protocols .
Base class providing common user-level pcap operations for helpers representing IPv6 protocols .
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.