A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
click-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 * Author: Lalith Suresh <suresh.lalith@gmail.com>
8 */
9
10#ifndef CLICK_INTERNET_STACK_HELPER_H
11#define CLICK_INTERNET_STACK_HELPER_H
12
13#include "ns3/internet-trace-helper.h"
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
22#include <map>
23
24namespace ns3
25{
26
27class Node;
28class Ipv4RoutingHelper;
29
30/**
31 * \brief aggregate Click/IP/TCP/UDP functionality to existing Nodes.
32 *
33 * This helper has been adapted from the InternetStackHelper class and
34 * nodes will not be able to use Ipv6 functionalities.
35 *
36 */
38{
39 public:
40 /**
41 * Create a new ClickInternetStackHelper which uses Ipv4ClickRouting for routing
42 */
44
45 /**
46 * Destroy the ClickInternetStackHelper
47 */
49
50 /**
51 * Copy constructor.
52 *
53 * \param o Object to copy from.
54 */
56
57 /**
58 * Assignment operator.
59 *
60 * \param o Object to copy from.
61 * \return Reference to updated object.
62 */
64
65 /**
66 * Return helper internal state to that of a newly constructed one
67 */
68 void Reset();
69
70 /**
71 * Aggregate implementations of the ns3::Ipv4L3ClickProtocol, ns3::ArpL3Protocol,
72 * ns3::Udp, and ns3::Tcp classes onto the provided node. This method will
73 * assert if called on a node that already has an Ipv4 object aggregated to it.
74 *
75 * \param nodeName The name of the node on which to install the stack.
76 */
77 void Install(std::string nodeName) const;
78
79 /**
80 * Aggregate implementations of the ns3::Ipv4L3ClickProtocol, ns3::ArpL3Protocol,
81 * ns3::Udp, and ns3::Tcp classes onto the provided node. This method will
82 * assert if called on a node that already has an Ipv4 object aggregated to it.
83 *
84 * \param node The node on which to install the stack.
85 */
86 void Install(Ptr<Node> node) const;
87
88 /**
89 * For each node in the input container, aggregate implementations of the
90 * ns3::Ipv4L3ClickProtocol, ns3::ArpL3Protocol, ns3::Udp, and, ns3::Tcp classes.
91 * The program will assert if this method is called on a container with a
92 * node that already has an Ipv4 object aggregated to it.
93 *
94 * \param c NodeContainer that holds the set of nodes on which to install the
95 * new stacks.
96 */
97 void Install(NodeContainer c) const;
98
99 /**
100 * Aggregate IPv4, UDP, and TCP stacks to all nodes in the simulation
101 */
102 void InstallAll() const;
103
104 /**
105 * \brief Set a Click file to be used for a group of nodes.
106 * \param c NodeContainer of nodes
107 * \param clickfile Click file to be used
108 */
109 void SetClickFile(NodeContainer c, std::string clickfile);
110
111 /**
112 * \brief Set a Click file to be used for a node.
113 * \param node Node for which Click file is to be set
114 * \param clickfile Click file to be used
115 */
116 void SetClickFile(Ptr<Node> node, std::string clickfile);
117
118 /**
119 * \brief Set defines to be used for a group of nodes.
120 * \param c NodeContainer of nodes
121 * \param defines Defines mapping to be used
122 */
123 void SetDefines(NodeContainer c, std::map<std::string, std::string> defines);
124
125 /**
126 * \brief Set defines to be used for a node.
127 * \param node Node for which the defines are to be set
128 * \param defines Defines mapping to be used
129 */
130 void SetDefines(Ptr<Node> node, std::map<std::string, std::string> defines);
131
132 /**
133 * \brief Set a Click routing table element for a group of nodes.
134 * \param c NodeContainer of nodes
135 * \param rt Click Routing Table element name
136 */
137 void SetRoutingTableElement(NodeContainer c, std::string rt);
138
139 /**
140 * \brief Set a Click routing table element for a node.
141 * \param node Node for which Click file is to be set
142 * \param rt Click Routing Table element name
143 */
144 void SetRoutingTableElement(Ptr<Node> node, std::string rt);
145
146 private:
147 /**
148 * \brief Enable pcap output the indicated Ipv4 and interface pair.
149 *
150 * \param prefix Filename prefix to use for pcap files.
151 * \param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
152 * \param interface Interface ID on the Ipv4 on which you want to enable tracing.
153 * \param explicitFilename Whether the filename is explicit or not.
154 */
155 void EnablePcapIpv4Internal(std::string prefix,
156 Ptr<Ipv4> ipv4,
157 uint32_t interface,
158 bool explicitFilename) override;
159
160 /**
161 * \brief Enable ascii trace output on the indicated Ipv4 and interface pair.
162 *
163 * \param stream An OutputStreamWrapper representing an existing file to use
164 * when writing trace data.
165 * \param prefix Filename prefix to use for ascii trace files.
166 * \param ipv4 Ptr to the Ipv4 interface on which you want to enable tracing.
167 * \param interface Interface ID on the Ipv4 on which you want to enable tracing.
168 * \param explicitFilename Whether the filename is explicit or not.
169 */
171 std::string prefix,
172 Ptr<Ipv4> ipv4,
173 uint32_t interface,
174 bool explicitFilename) override;
175
176 /**
177 * Initialize stack helper.
178 * Called by both constructor and Reset().
179 */
180 void Initialize();
181
182 /**
183 * Create and aggregate object from type ID.
184 *
185 * \param node Node.
186 * \param typeId Type ID.
187 */
188 static void CreateAndAggregateObjectFromTypeId(Ptr<Node> node, const std::string typeId);
189
190 /**
191 * Check if PCAP is hooked.
192 *
193 * \param ipv4 IPv4 stack.
194 * \return True if PCAP is hooked.
195 */
196 bool PcapHooked(Ptr<Ipv4> ipv4);
197
198 /**
199 * Check if ASCII is hooked.
200 *
201 * \param ipv4 IPv4 stack.
202 * \return True if ASCII is hooked.
203 */
204 bool AsciiHooked(Ptr<Ipv4> ipv4);
205
206 /**
207 * \brief IPv4 install state (enabled/disabled) ?
208 */
210
211 /**
212 * \brief Node to Click file mapping
213 */
214 std::map<Ptr<Node>, std::string> m_nodeToClickFileMap;
215
216 /**
217 * \brief Node to Click defines mapping
218 */
219 std::map<Ptr<Node>, std::map<std::string, std::string>> m_nodeToDefinesMap;
220
221 /**
222 * \brief Node to Routing Table Element mapping
223 */
224 std::map<Ptr<Node>, std::string> m_nodeToRoutingTableElementMap;
225};
226
227} // namespace ns3
228
229#endif /* CLICK_INTERNET_STACK_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing IPv4 protocols...
aggregate Click/IP/TCP/UDP functionality to existing Nodes.
std::map< Ptr< Node >, std::string > m_nodeToClickFileMap
Node to Click file mapping.
~ClickInternetStackHelper() override
Destroy the ClickInternetStackHelper.
ClickInternetStackHelper & operator=(const ClickInternetStackHelper &o)
Assignment operator.
bool PcapHooked(Ptr< Ipv4 > ipv4)
Check if PCAP is hooked.
void SetDefines(NodeContainer c, std::map< std::string, std::string > defines)
Set defines to be used for a group of nodes.
static void CreateAndAggregateObjectFromTypeId(Ptr< Node > node, const std::string typeId)
Create and aggregate object from type ID.
std::map< Ptr< Node >, std::string > m_nodeToRoutingTableElementMap
Node to Routing Table Element mapping.
void Initialize()
Initialize stack helper.
bool m_ipv4Enabled
IPv4 install state (enabled/disabled) ?
void SetClickFile(NodeContainer c, std::string clickfile)
Set a Click file to be used for a group of nodes.
bool AsciiHooked(Ptr< Ipv4 > ipv4)
Check if ASCII is hooked.
ClickInternetStackHelper()
Create a new ClickInternetStackHelper which uses Ipv4ClickRouting for routing.
void SetRoutingTableElement(NodeContainer c, std::string rt)
Set a Click routing table element for a group of nodes.
void InstallAll() const
Aggregate IPv4, UDP, and TCP stacks to all nodes in the simulation.
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4L3ClickProtocol, ns3::ArpL3Protocol, ns3::Udp,...
void EnablePcapIpv4Internal(std::string prefix, Ptr< Ipv4 > ipv4, uint32_t interface, bool explicitFilename) override
Enable pcap output the indicated Ipv4 and interface pair.
void Reset()
Return helper internal state to that of a newly constructed one.
std::map< Ptr< Node >, std::map< std::string, std::string > > m_nodeToDefinesMap
Node to Click defines mapping.
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.
keep track of a set of node pointers.
Base class providing common user-level pcap operations for helpers representing IPv4 protocols .
Smart pointer class similar to boost::intrusive_ptr.
Every class exported by the ns3 library is enclosed in the ns3 namespace.