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