A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
point-to-point-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#ifndef POINT_TO_POINT_HELPER_H
20#define POINT_TO_POINT_HELPER_H
21
22#include "ns3/net-device-container.h"
23#include "ns3/node-container.h"
24#include "ns3/object-factory.h"
25#include "ns3/queue.h"
26#include "ns3/trace-helper.h"
27
28#include <string>
29
30namespace ns3
31{
32
33class NetDevice;
34class Node;
35
36/**
37 * \brief Build a set of PointToPointNetDevice objects
38 *
39 * Normally we eschew multiple inheritance, however, the classes
40 * PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are
41 * "mixins".
42 */
44{
45 public:
46 /**
47 * Create a PointToPointHelper to make life easier when creating point to
48 * point networks.
49 */
51
53 {
54 }
55
56 /**
57 * Each point to point net device must have a queue to pass packets through.
58 * This method allows one to set the type of the queue that is automatically
59 * created when the device is created and attached to a node.
60 *
61 * \tparam Ts \deduced Argument types
62 * \param type the type of queue
63 * \param [in] args Name and AttributeValue pairs to set.
64 *
65 * Set the type of queue to create and associated to each
66 * PointToPointNetDevice created through PointToPointHelper::Install.
67 */
68 template <typename... Ts>
69 void SetQueue(std::string type, Ts&&... args);
70
71 /**
72 * Set an attribute value to be propagated to each NetDevice created by the
73 * helper.
74 *
75 * \param name the name of the attribute to set
76 * \param value the value of the attribute to set
77 *
78 * Set these attributes on each ns3::PointToPointNetDevice created
79 * by PointToPointHelper::Install
80 */
81 void SetDeviceAttribute(std::string name, const AttributeValue& value);
82
83 /**
84 * Set an attribute value to be propagated to each Channel created by the
85 * helper.
86 *
87 * \param name the name of the attribute to set
88 * \param value the value of the attribute to set
89 *
90 * Set these attribute on each ns3::PointToPointChannel created
91 * by PointToPointHelper::Install
92 */
93 void SetChannelAttribute(std::string name, const AttributeValue& value);
94
95 /**
96 * Disable flow control only if you know what you are doing. By disabling
97 * flow control, this NetDevice will be sent packets even if there is no
98 * room for them (such packets will be likely dropped by this NetDevice).
99 * Also, any queue disc installed on this NetDevice will have no effect,
100 * as every packet enqueued to the traffic control layer queue disc will
101 * be immediately dequeued.
102 */
103 void DisableFlowControl();
104
105 /**
106 * \param c a set of nodes
107 * \return a NetDeviceContainer for nodes
108 *
109 * This method creates a ns3::PointToPointChannel with the
110 * attributes configured by PointToPointHelper::SetChannelAttribute,
111 * then, for each node in the input container, we create a
112 * ns3::PointToPointNetDevice with the requested attributes,
113 * a queue for this ns3::NetDevice, and associate the resulting
114 * ns3::NetDevice with the ns3::Node and ns3::PointToPointChannel.
115 */
117
118 /**
119 * \param a first node
120 * \param b second node
121 * \return a NetDeviceContainer for nodes
122 *
123 * Saves you from having to construct a temporary NodeContainer.
124 * Also, if MPI is enabled, for distributed simulations,
125 * appropriate remote point-to-point channels are created.
126 */
128
129 /**
130 * \param a first node
131 * \param bName name of second node
132 * \return a NetDeviceContainer for nodes
133 *
134 * Saves you from having to construct a temporary NodeContainer.
135 */
136 NetDeviceContainer Install(Ptr<Node> a, std::string bName);
137
138 /**
139 * \param aName Name of first node
140 * \param b second node
141 * \return a NetDeviceContainer for nodes
142 *
143 * Saves you from having to construct a temporary NodeContainer.
144 */
145 NetDeviceContainer Install(std::string aName, Ptr<Node> b);
146
147 /**
148 * \param aNode Name of first node
149 * \param bNode Name of second node
150 * \return a NetDeviceContainer for nodes
151 *
152 * Saves you from having to construct a temporary NodeContainer.
153 */
154 NetDeviceContainer Install(std::string aNode, std::string bNode);
155
156 private:
157 /**
158 * \brief Enable pcap output the indicated net device.
159 *
160 * NetDevice-specific implementation mechanism for hooking the trace and
161 * writing to the trace file.
162 *
163 * \param prefix Filename prefix to use for pcap files.
164 * \param nd Net device for which you want to enable tracing.
165 * \param promiscuous If true capture all possible packets available at the device.
166 * \param explicitFilename Treat the prefix as an explicit filename if true
167 */
168 void EnablePcapInternal(std::string prefix,
170 bool promiscuous,
171 bool explicitFilename) override;
172
173 /**
174 * \brief Enable ascii trace output on the indicated net device.
175 *
176 * NetDevice-specific implementation mechanism for hooking the trace and
177 * writing to the trace file.
178 *
179 * \param stream The output stream object to use when logging ascii traces.
180 * \param prefix Filename prefix to use for ascii trace files.
181 * \param nd Net device for which you want to enable tracing.
182 * \param explicitFilename Treat the prefix as an explicit filename if true
183 */
185 std::string prefix,
187 bool explicitFilename) override;
188
189 ObjectFactory m_queueFactory; //!< Queue Factory
190 ObjectFactory m_channelFactory; //!< Channel Factory
191 ObjectFactory m_deviceFactory; //!< Device Factory
192 bool m_enableFlowControl; //!< whether to enable flow control
193};
194
195/***************************************************************
196 * Implementation of the templates declared above.
197 ***************************************************************/
198
199template <typename... Ts>
200void
201PointToPointHelper::SetQueue(std::string type, Ts&&... args)
202{
204
206 m_queueFactory.Set(std::forward<Ts>(args)...);
207}
208
209} // namespace ns3
210
211#endif /* POINT_TO_POINT_HELPER_H */
Base class providing common user-level ascii trace operations for helpers representing net devices.
Definition: trace-helper.h:729
Hold a value for an Attribute.
Definition: attribute.h:70
holds a vector of ns3::NetDevice pointers
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Base class providing common user-level pcap operations for helpers representing net devices.
Definition: trace-helper.h:624
Build a set of PointToPointNetDevice objects.
ObjectFactory m_channelFactory
Channel Factory.
PointToPointHelper()
Create a PointToPointHelper to make life easier when creating point to point networks.
bool m_enableFlowControl
whether to enable flow control
void SetDeviceAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each NetDevice created by the helper.
void DisableFlowControl()
Disable flow control only if you know what you are doing.
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output the indicated net device.
void SetChannelAttribute(std::string name, const AttributeValue &value)
Set an attribute value to be propagated to each Channel created by the helper.
ObjectFactory m_queueFactory
Queue Factory.
void SetQueue(std::string type, Ts &&... args)
Each point to point net device must have a queue to pass packets through.
ObjectFactory m_deviceFactory
Device Factory.
NetDeviceContainer Install(NodeContainer c)
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
static void AppendItemTypeIfNotPresent(std::string &typeId, const std::string &itemType)
Append the item type to the provided type ID if the latter does not end with '>'.
Definition: queue.cc:73
Every class exported by the ns3 library is enclosed in the ns3 namespace.