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