A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
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.
 
 ~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.
 
void DisableFlowControl ()
 Disable flow control only if you know what you are doing.
 
NetDeviceContainer Install (const NodeContainer &c) const
 This method creates an ns3::CsmaChannel with the attributes configured by CsmaHelper::SetChannelAttribute.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
virtual ~PcapHelperForDevice ()
 Destroy a PcapHelperForDevice.
 
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.
 
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.
 
void EnablePcap (std::string prefix, Ptr< NetDevice > nd, bool promiscuous=false, bool explicitFilename=false)
 Enable pcap output the indicated net device.
 
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.
 
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.
 
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.
 
- Public Member Functions inherited from ns3::AsciiTraceHelperForDevice
 AsciiTraceHelperForDevice ()
 Construct an AsciiTraceHelperForDevice.
 
virtual ~AsciiTraceHelperForDevice ()
 Destroy an AsciiTraceHelperForDevice.
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, NetDeviceContainer d)
 Enable ascii trace output on each device in the container which is of the appropriate type.
 
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.
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, Ptr< NetDevice > nd)
 Enable ascii trace output on the indicated net device.
 
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.
 
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.
 
void EnableAscii (std::string prefix, NetDeviceContainer d)
 Enable ascii trace output on each device in the container which is of the appropriate type.
 
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.
 
void EnableAscii (std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
 Enable ascii trace output on the indicated net device.
 
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.
 
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.
 
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.
 
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.
 

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.
 
void EnablePcapInternal (std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename) override
 Enable pcap output on the indicated net device.
 
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.
 

Private Attributes

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

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 36 of file csma-helper.h.

Constructor & Destructor Documentation

◆ CsmaHelper()

ns3::CsmaHelper::CsmaHelper ( )

Construct a CsmaHelper.

Definition at line 30 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 44 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 285 of file csma-helper.cc.

References ns3::NetDeviceContainer::Begin(), ns3::DynamicCast(), 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 51 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 100 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 57 of file csma-helper.cc.

References ns3::PcapHelper::CreateFile(), ns3::PcapHelper::DLT_EN10MB, 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 257 of file csma-helper.cc.

References 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 265 of file csma-helper.cc.

References ns3::NetDeviceContainer::Add(), ns3::NodeContainer::Begin(), 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 278 of file csma-helper.cc.

References ns3::Names::Find(), 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 215 of file csma-helper.cc.

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

Referenced by ns3::CsmaStarHelper::CsmaStarHelper(), EpcS1uDlTestCase::DoRun(), EpcS1uUlTestCase::DoRun(), Install(), Install(), Install(), 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 229 of file csma-helper.cc.

References 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 235 of file csma-helper.cc.

References ns3::Names::Find(), 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 222 of file csma-helper.cc.

References ns3::Names::Find(), and 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 242 of file csma-helper.cc.

References ns3::Names::Find(), 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 249 of file csma-helper.cc.

References ns3::Names::Find(), 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 302 of file csma-helper.cc.

References ns3::Mac48Address::Allocate(), ns3::ObjectFactory::Create(), ns3::CreateObject(), m_deviceFactory, m_enableFlowControl, and m_queueFactory.

Referenced by Install(), Install(), Install(), Install(), and 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 45 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 39 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 258 of file csma-helper.h.

References ns3::QueueBase::AppendItemTypeIfNotPresent(), m_queueFactory, ns3::ObjectFactory::Set(), and ns3::ObjectFactory::SetTypeId().

+ 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 248 of file csma-helper.h.

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

◆ m_deviceFactory

ObjectFactory ns3::CsmaHelper::m_deviceFactory
private

factory for the NetDevices

Definition at line 247 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 249 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 246 of file csma-helper.h.

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


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