A Discrete-Event Network Simulator
API
ns3::CsmaHelper Class Reference

build a set of CsmaNetDevice objects More...

#include "csma-helper.h"

+ Inheritance diagram for ns3::CsmaHelper:
+ Collaboration diagram for ns3::CsmaHelper:

Public Member Functions

 CsmaHelper ()
 Construct a CsmaHelper. More...
 
 ~CsmaHelper () override
 
int64_t AssignStreams (NetDeviceContainer c, int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. More...
 
void DisableFlowControl ()
 Disable flow control only if you know what you are doing. More...
 
NetDeviceContainer Install (const NodeContainer &c) const
 This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute. More...
 
NetDeviceContainer Install (const NodeContainer &c, Ptr< CsmaChannel > channel) const
 For each Ptr<node> in the provided container, this method creates an ns3::CsmaNetDevice (with the attributes configured by CsmaHelper::SetDeviceAttribute); adds the device to the node; and attaches the provided channel to the device. More...
 
NetDeviceContainer Install (const NodeContainer &c, std::string channelName) const
 For each Ptr<node> in the provided container, this method creates an ns3::CsmaNetDevice (with the attributes configured by CsmaHelper::SetDeviceAttribute); adds the device to the node; and attaches the provided channel to the device. More...
 
NetDeviceContainer Install (Ptr< Node > node) const
 This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute, an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the channel to the device. More...
 
NetDeviceContainer Install (Ptr< Node > node, Ptr< CsmaChannel > channel) const
 This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device. More...
 
NetDeviceContainer Install (Ptr< Node > node, std::string channelName) const
 This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device. More...
 
NetDeviceContainer Install (std::string name) const
 This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute, an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the channel to the device. More...
 
NetDeviceContainer Install (std::string nodeName, Ptr< CsmaChannel > channel) const
 This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device. More...
 
NetDeviceContainer Install (std::string nodeName, std::string channelName) const
 This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device. More...
 
void SetChannelAttribute (std::string n1, const AttributeValue &v1)
 
void SetDeviceAttribute (std::string n1, const AttributeValue &v1)
 
template<typename... Ts>
void SetQueue (std::string type, Ts &&... args)
 
- Public Member Functions inherited from ns3::PcapHelperForDevice
 PcapHelperForDevice ()
 Construct a PcapHelperForDevice. More...
 
virtual ~PcapHelperForDevice ()
 Destroy a PcapHelperForDevice. More...
 
void EnablePcap (std::string prefix, NetDeviceContainer d, bool promiscuous=false)
 Enable pcap output on each device in the container which is of the appropriate type. More...
 
void EnablePcap (std::string prefix, NodeContainer n, bool promiscuous=false)
 Enable pcap output on each device (which is of the appropriate type) in the nodes provided in the container. More...
 
void EnablePcap (std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
 Enable pcap output the indicated net device. More...
 
void EnablePcap (std::string prefix, std::string ndName, bool promiscuous=false, bool explicitFilename=false)
 Enable pcap output the indicated net device using a device previously named using the ns-3 object name service. More...
 
void EnablePcap (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool promiscuous=false)
 Enable pcap output on the device specified by a global node-id (of a previously created node) and associated device-id. More...
 
void EnablePcapAll (std::string prefix, bool promiscuous=false)
 Enable pcap output on each device (which is of the appropriate type) in the set of all nodes created in the simulation. More...
 
- Public Member Functions inherited from ns3::AsciiTraceHelperForDevice
 AsciiTraceHelperForDevice ()
 Construct an AsciiTraceHelperForDevice. More...
 
virtual ~AsciiTraceHelperForDevice ()
 Destroy an AsciiTraceHelperForDevice. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, NetDeviceContainer d)
 Enable ascii trace output on each device in the container which is of the appropriate type. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, NodeContainer n)
 Enable ascii trace output on each device (which is of the appropriate type) in the nodes provided in the container. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, Ptr< NetDevice > nd)
 Enable ascii trace output on the indicated net device. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, std::string ndName)
 Enable ascii trace output the indicated net device using a device previously named using the ns-3 object name service. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, uint32_t nodeid, uint32_t deviceid)
 Enable ascii trace output on the device specified by a global node-id (of a previously created node) and associated device-id. More...
 
void EnableAscii (std::string prefix, NetDeviceContainer d)
 Enable ascii trace output on each device in the container which is of the appropriate type. More...
 
void EnableAscii (std::string prefix, NodeContainer n)
 Enable ascii trace output on each device (which is of the appropriate type) in the nodes provided in the container. More...
 
void EnableAscii (std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
 Enable ascii trace output on the indicated net device. More...
 
void EnableAscii (std::string prefix, std::string ndName, bool explicitFilename=false)
 Enable ascii trace output the indicated net device using a device previously named using the ns-3 object name service. More...
 
void EnableAscii (std::string prefix, uint32_t nodeid, uint32_t deviceid, bool explicitFilename)
 Enable ascii trace output on the device specified by a global node-id (of a previously created node) and associated device-id. More...
 
void EnableAsciiAll (Ptr< OutputStreamWrapper > stream)
 Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes created in the simulation. More...
 
void EnableAsciiAll (std::string prefix)
 Enable ascii trace output on each device (which is of the appropriate type) in the set of all nodes created in the simulation. More...
 

Private Member Functions

void EnableAsciiInternal (Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename) override
 Enable ascii trace output on the indicated net device. More...
 
void EnablePcapInternal (std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
 Enable pcap output on the indicated net device. More...
 
Ptr< NetDeviceInstallPriv (Ptr< Node > node, Ptr< CsmaChannel > channel) const
 This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device. More...
 

Private Attributes

ObjectFactory m_channelFactory
 factory for the channel More...
 
ObjectFactory m_deviceFactory
 factory for the NetDevices More...
 
bool m_enableFlowControl
 whether to enable flow control More...
 
ObjectFactory m_queueFactory
 factory for the queues More...
 

Detailed Description

build a set of CsmaNetDevice objects

Normally we eschew multiple inheritance, however, the classes PcapUserHelperForDevice and AsciiTraceUserHelperForDevice are treated as "mixins". A mixin is a self-contained class that encapsulates a general attribute or a set of functionality that may be of interest to many other classes.

Definition at line 47 of file csma-helper.h.

Constructor & Destructor Documentation

◆ CsmaHelper()

ns3::CsmaHelper::CsmaHelper ( )

Construct a CsmaHelper.

Definition at line 41 of file csma-helper.cc.

References m_channelFactory, m_deviceFactory, m_enableFlowControl, m_queueFactory, and ns3::ObjectFactory::SetTypeId().

+ Here is the call graph for this function:

◆ ~CsmaHelper()

ns3::CsmaHelper::~CsmaHelper ( )
inlineoverride

Definition at line 55 of file csma-helper.h.

Member Function Documentation

◆ AssignStreams()

int64_t ns3::CsmaHelper::AssignStreams ( NetDeviceContainer  c,
int64_t  stream 
)

Assign a fixed random variable stream number to the random variables used by this model.

Return the number of streams (possibly zero) that have been assigned. The Install() method should have previously been called by the user.

Parameters
cNetDeviceContainer of the set of net devices for which the CsmaNetDevice should be modified to use a fixed stream
streamfirst stream index to use
Returns
the number of stream indices assigned by this helper

Definition at line 296 of file csma-helper.cc.

References ns3::NetDeviceContainer::Begin(), second::csma, and ns3::NetDeviceContainer::End().

+ Here is the call graph for this function:

◆ DisableFlowControl()

void ns3::CsmaHelper::DisableFlowControl ( )

Disable flow control only if you know what you are doing.

By disabling flow control, this NetDevice will be sent packets even if there is no room for them (such packets will be likely dropped by this NetDevice). Also, any queue disc installed on this NetDevice will have no effect, as every packet enqueued to the traffic control layer queue disc will be immediately dequeued.

Definition at line 62 of file csma-helper.cc.

References m_enableFlowControl.

◆ EnableAsciiInternal()

void ns3::CsmaHelper::EnableAsciiInternal ( Ptr< OutputStreamWrapper stream,
std::string  prefix,
Ptr< NetDevice nd,
bool  explicitFilename 
)
overrideprivatevirtual

Enable ascii trace output on the indicated net device.

NetDevice-specific implementation mechanism for hooking the trace and writing to the trace file.

Parameters
streamThe output stream object to use when logging ascii traces.
prefixFilename prefix to use for ascii trace files.
ndNet device for which you want to enable tracing.
explicitFilenameTreat the prefix as an explicit filename if true

Implements ns3::AsciiTraceHelperForDevice.

Definition at line 111 of file csma-helper.cc.

References ns3::Config::Connect(), ns3::AsciiTraceHelper::CreateFileStream(), ns3::AsciiTraceHelper::DefaultDequeueSinkWithContext(), ns3::AsciiTraceHelper::DefaultDropSinkWithContext(), ns3::AsciiTraceHelper::DefaultEnqueueSinkWithContext(), ns3::AsciiTraceHelper::DefaultReceiveSinkWithContext(), ns3::Packet::EnablePrinting(), ns3::AsciiTraceHelper::GetFilenameFromDevice(), ns3::CsmaNetDevice::GetQueue(), ns3::AsciiTraceHelper::HookDefaultDequeueSinkWithoutContext(), ns3::AsciiTraceHelper::HookDefaultDropSinkWithoutContext(), ns3::AsciiTraceHelper::HookDefaultEnqueueSinkWithoutContext(), ns3::AsciiTraceHelper::HookDefaultReceiveSinkWithoutContext(), ns3::MakeBoundCallback(), and NS_LOG_INFO.

+ Here is the call graph for this function:

◆ EnablePcapInternal()

void ns3::CsmaHelper::EnablePcapInternal ( std::string  prefix,
Ptr< NetDevice nd,
bool  promiscuous,
bool  explicitFilename 
)
overrideprivatevirtual

Enable pcap output on the indicated net device.

NetDevice-specific implementation mechanism for hooking the trace and writing to the trace file.

Parameters
prefixFilename prefix to use for pcap files.
ndNet device for which you want to enable tracing.
promiscuousIf true capture all possible packets available at the device.
explicitFilenameTreat the prefix as an explicit filename if true

Implements ns3::PcapHelperForDevice.

Definition at line 68 of file csma-helper.cc.

References ns3::PcapHelper::CreateFile(), ns3::PcapHelper::DLT_EN10MB, create-module::file, ns3::PcapHelper::GetFilenameFromDevice(), ns3::PcapHelper::HookDefaultSink(), and NS_LOG_INFO.

+ Here is the call graph for this function:

◆ Install() [1/9]

NetDeviceContainer ns3::CsmaHelper::Install ( const NodeContainer c) const

This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute.

For each Ptr<node> in the provided container: it creates an ns3::CsmaNetDevice (with the attributes configured by CsmaHelper::SetDeviceAttribute); adds the device to the node; and attaches the channel to the device.

Parameters
cThe NodeContainer holding the nodes to be changed.
Returns
A container holding the added net devices.

Definition at line 268 of file csma-helper.cc.

References third::channel, ns3::ObjectFactory::Create(), ns3::Object::GetObject(), Install(), and m_channelFactory.

+ Here is the call graph for this function:

◆ Install() [2/9]

NetDeviceContainer ns3::CsmaHelper::Install ( const NodeContainer c,
Ptr< CsmaChannel channel 
) const

For each Ptr<node> in the provided container, this method creates an ns3::CsmaNetDevice (with the attributes configured by CsmaHelper::SetDeviceAttribute); adds the device to the node; and attaches the provided channel to the device.

Parameters
cThe NodeContainer holding the nodes to be changed.
channelThe channel to attach to the devices.
Returns
A container holding the added net devices.

Definition at line 276 of file csma-helper.cc.

References ns3::NetDeviceContainer::Add(), ns3::NodeContainer::Begin(), third::channel, ns3::NodeContainer::End(), and InstallPriv().

+ Here is the call graph for this function:

◆ Install() [3/9]

NetDeviceContainer ns3::CsmaHelper::Install ( const NodeContainer c,
std::string  channelName 
) const

For each Ptr<node> in the provided container, this method creates an ns3::CsmaNetDevice (with the attributes configured by CsmaHelper::SetDeviceAttribute); adds the device to the node; and attaches the provided channel to the device.

Parameters
cThe NodeContainer holding the nodes to be changed.
channelNameThe name of the channel to attach to the devices.
Returns
A container holding the added net devices.

Definition at line 289 of file csma-helper.cc.

References third::channel, and Install().

+ Here is the call graph for this function:

◆ Install() [4/9]

NetDeviceContainer ns3::CsmaHelper::Install ( Ptr< Node node) const

This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute, an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the channel to the device.

Parameters
nodeThe node to install the device in
Returns
A container holding the added net device.

Definition at line 226 of file csma-helper.cc.

References third::channel, ns3::ObjectFactory::Create(), ns3::Object::GetObject(), and m_channelFactory.

Referenced by ns3::CsmaStarHelper::CsmaStarHelper(), EpcS1uDlTestCase::DoRun(), EpcS1uUlTestCase::DoRun(), Install(), and NeighborCacheExample::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Install() [5/9]

NetDeviceContainer ns3::CsmaHelper::Install ( Ptr< Node node,
Ptr< CsmaChannel channel 
) const

This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device.

Parameters
nodeThe node to install the device in
channelThe channel to attach to the device.
Returns
A container holding the added net device.

Definition at line 240 of file csma-helper.cc.

References third::channel, and InstallPriv().

+ Here is the call graph for this function:

◆ Install() [6/9]

NetDeviceContainer ns3::CsmaHelper::Install ( Ptr< Node node,
std::string  channelName 
) const

This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device.

Parameters
nodeThe node to install the device in
channelNameThe name of the channel to attach to the device.
Returns
A container holding the added net device.

Definition at line 246 of file csma-helper.cc.

References third::channel, and InstallPriv().

+ Here is the call graph for this function:

◆ Install() [7/9]

NetDeviceContainer ns3::CsmaHelper::Install ( std::string  name) const

This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute, an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the channel to the device.

Parameters
nameThe name of the node to install the device in
Returns
A container holding the added net device.

Definition at line 233 of file csma-helper.cc.

References Install().

+ Here is the call graph for this function:

◆ Install() [8/9]

NetDeviceContainer ns3::CsmaHelper::Install ( std::string  nodeName,
Ptr< CsmaChannel channel 
) const

This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device.

Parameters
nodeNameThe name of the node to install the device in
channelThe channel to attach to the device.
Returns
A container holding the added net device.

Definition at line 253 of file csma-helper.cc.

References third::channel, and InstallPriv().

+ Here is the call graph for this function:

◆ Install() [9/9]

NetDeviceContainer ns3::CsmaHelper::Install ( std::string  nodeName,
std::string  channelName 
) const

This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device.

Parameters
nodeNameThe name of the node to install the device in
channelNameThe name of the channel to attach to the device.
Returns
A container holding the added net device.

Definition at line 260 of file csma-helper.cc.

References third::channel, and InstallPriv().

+ Here is the call graph for this function:

◆ InstallPriv()

Ptr< NetDevice > ns3::CsmaHelper::InstallPriv ( Ptr< Node node,
Ptr< CsmaChannel channel 
) const
private

This method creates an ns3::CsmaNetDevice with the attributes configured by CsmaHelper::SetDeviceAttribute and then adds the device to the node and attaches the provided channel to the device.

Parameters
nodeThe node to install the device in
channelThe channel to attach to the device.
Returns
A container holding the added net device.

Definition at line 313 of file csma-helper.cc.

References ns3::Node::AddDevice(), ns3::Mac48Address::Allocate(), third::channel, ns3::ObjectFactory::Create(), m_deviceFactory, m_enableFlowControl, and m_queueFactory.

Referenced by Install().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetChannelAttribute()

void ns3::CsmaHelper::SetChannelAttribute ( std::string  n1,
const AttributeValue v1 
)
Parameters
n1the name of the attribute to set
v1the value of the attribute to set

Set these attributes on each ns3::CsmaChannel created by CsmaHelper::Install

Definition at line 56 of file csma-helper.cc.

References m_channelFactory, and ns3::ObjectFactory::Set().

Referenced by NeighborCacheExample::Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ SetDeviceAttribute()

void ns3::CsmaHelper::SetDeviceAttribute ( std::string  n1,
const AttributeValue v1 
)
Parameters
n1the name of the attribute to set
v1the value of the attribute to set

Set these attributes on each ns3::CsmaNetDevice created by CsmaHelper::Install

Definition at line 50 of file csma-helper.cc.

References m_deviceFactory, and ns3::ObjectFactory::Set().

+ Here is the call graph for this function:

◆ SetQueue()

template<typename... Ts>
void ns3::CsmaHelper::SetQueue ( std::string  type,
Ts &&...  args 
)
Template Parameters
Ts[deduced] Argument types
Parameters
typethe type of queue
[in]argsName and AttributeValue pairs to set.

Set the type of queue to create and associated to each CsmaNetDevice created through CsmaHelper::Install.

Definition at line 269 of file csma-helper.h.

References ns3::QueueBase::AppendItemTypeIfNotPresent(), check-style-clang-format::args, m_queueFactory, ns3::ObjectFactory::Set(), ns3::ObjectFactory::SetTypeId(), and check-style-clang-format::type.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_channelFactory

ObjectFactory ns3::CsmaHelper::m_channelFactory
private

factory for the channel

Definition at line 259 of file csma-helper.h.

Referenced by CsmaHelper(), Install(), and SetChannelAttribute().

◆ m_deviceFactory

ObjectFactory ns3::CsmaHelper::m_deviceFactory
private

factory for the NetDevices

Definition at line 258 of file csma-helper.h.

Referenced by CsmaHelper(), InstallPriv(), and SetDeviceAttribute().

◆ m_enableFlowControl

bool ns3::CsmaHelper::m_enableFlowControl
private

whether to enable flow control

Definition at line 260 of file csma-helper.h.

Referenced by CsmaHelper(), DisableFlowControl(), and InstallPriv().

◆ m_queueFactory

ObjectFactory ns3::CsmaHelper::m_queueFactory
private

factory for the queues

Definition at line 257 of file csma-helper.h.

Referenced by CsmaHelper(), InstallPriv(), and SetQueue().


The documentation for this class was generated from the following files: