A Discrete-Event Network Simulator
API
csma-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 CSMA_HELPER_H
20 #define CSMA_HELPER_H
21 
22 #include "ns3/attribute.h"
23 #include "ns3/csma-channel.h"
24 #include "ns3/net-device-container.h"
25 #include "ns3/node-container.h"
26 #include "ns3/object-factory.h"
27 #include "ns3/queue.h"
28 #include "ns3/trace-helper.h"
29 
30 #include <string>
31 
32 namespace ns3
33 {
34 
35 class Packet;
36 
48 {
49  public:
53  CsmaHelper();
54 
55  ~CsmaHelper() override
56  {
57  }
58 
67  template <typename... Ts>
68  void SetQueue(std::string type, Ts&&... args);
69 
77  void SetDeviceAttribute(std::string n1, const AttributeValue& v1);
78 
86  void SetChannelAttribute(std::string n1, const AttributeValue& v1);
87 
96  void DisableFlowControl();
97 
108 
118  NetDeviceContainer Install(std::string name) const;
119 
130 
140  NetDeviceContainer Install(Ptr<Node> node, std::string channelName) const;
141 
151  NetDeviceContainer Install(std::string nodeName, Ptr<CsmaChannel> channel) const;
152 
162  NetDeviceContainer Install(std::string nodeName, std::string channelName) const;
163 
174  NetDeviceContainer Install(const NodeContainer& c) const;
175 
187 
198  NetDeviceContainer Install(const NodeContainer& c, std::string channelName) const;
199 
211  int64_t AssignStreams(NetDeviceContainer c, int64_t stream);
212 
213  private:
224 
236  void EnablePcapInternal(std::string prefix,
237  Ptr<NetDevice> nd,
238  bool promiscuous,
239  bool explicitFilename) override;
240 
253  std::string prefix,
254  Ptr<NetDevice> nd,
255  bool explicitFilename) override;
256 
261 };
262 
263 /***************************************************************
264  * Implementation of the templates declared above.
265  ***************************************************************/
266 
267 template <typename... Ts>
268 void
269 CsmaHelper::SetQueue(std::string type, Ts&&... args)
270 {
272 
274  m_queueFactory.Set(std::forward<Ts>(args)...);
275 }
276 
277 } // namespace ns3
278 
279 #endif /* CSMA_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
build a set of CsmaNetDevice objects
Definition: csma-helper.h:48
void SetQueue(std::string type, Ts &&... args)
Definition: csma-helper.h:269
ObjectFactory m_channelFactory
factory for the channel
Definition: csma-helper.h:259
void SetDeviceAttribute(std::string n1, const AttributeValue &v1)
Definition: csma-helper.cc:50
void EnableAsciiInternal(Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
Enable ascii trace output on the indicated net device.
Definition: csma-helper.cc:111
bool m_enableFlowControl
whether to enable flow control
Definition: csma-helper.h:260
Ptr< NetDevice > InstallPriv(Ptr< Node > node, Ptr< CsmaChannel > channel) const
This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttr...
Definition: csma-helper.cc:313
void SetChannelAttribute(std::string n1, const AttributeValue &v1)
Definition: csma-helper.cc:56
CsmaHelper()
Construct a CsmaHelper.
Definition: csma-helper.cc:41
int64_t AssignStreams(NetDeviceContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Definition: csma-helper.cc:296
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttri...
Definition: csma-helper.cc:226
void DisableFlowControl()
Disable flow control only if you know what you are doing.
Definition: csma-helper.cc:62
ObjectFactory m_queueFactory
factory for the queues
Definition: csma-helper.h:257
void EnablePcapInternal(std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
Enable pcap output on the indicated net device.
Definition: csma-helper.cc:68
ObjectFactory m_deviceFactory
factory for the NetDevices
Definition: csma-helper.h:258
~CsmaHelper() override
Definition: csma-helper.h:55
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
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.
channel
Definition: third.py:88