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