A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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...
 
virtual ~CsmaHelper ()
 
int64_t AssignStreams (NetDeviceContainer c, int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. 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 (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 (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 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...
 
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...
 
void SetChannelAttribute (std::string n1, const AttributeValue &v1)
 
void SetDeviceAttribute (std::string n1, const AttributeValue &v1)
 
void SetQueue (std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue())
 
- Public Member Functions inherited from ns3::PcapHelperForDevice
 PcapHelperForDevice ()
 Construct a PcapHelperForDevice. More...
 
virtual ~PcapHelperForDevice ()
 Destroy a PcapHelperForDevice. 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, 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, 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 (std::string prefix, Ptr< NetDevice > nd, bool explicitFilename=false)
 Enable ascii trace output on the indicated net device. More...
 
void EnableAscii (Ptr< OutputStreamWrapper > stream, Ptr< NetDevice > nd)
 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 (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 (std::string prefix, NetDeviceContainer d)
 Enable ascii trace output on each device in the container which is of the appropriate type. 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 (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 (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 (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 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 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...
 
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...
 

Private Member Functions

virtual void EnableAsciiInternal (Ptr< OutputStreamWrapper > stream, std::string prefix, Ptr< NetDevice > nd, bool explicitFilename)
 Enable ascii trace output on the indicated net device. More...
 
virtual void EnablePcapInternal (std::string prefix, Ptr< NetDevice > nd, bool promiscuous, bool explicitFilename)
 Enable pcap output on the indicated net device. More...
 
Ptr< NetDeviceInstallPriv (Ptr< Node > node, Ptr< CsmaChannel > channel) const
 

Private Attributes

ObjectFactory m_channelFactory
 
ObjectFactory m_deviceFactory
 
ObjectFactory m_queueFactory
 

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

Constructor & Destructor Documentation

ns3::CsmaHelper::CsmaHelper ( )

Construct a CsmaHelper.

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

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

+ Here is the call graph for this function:

virtual ns3::CsmaHelper::~CsmaHelper ( )
inlinevirtual

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

Member Function Documentation

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(), and ns3::NetDeviceContainer::End().

+ Here is the call graph for this function:

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

Enable ascii trace output on the indicated net device.

Internal:

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 114 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:

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

Enable pcap output on the indicated net device.

Internal:

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 75 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:

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(), and m_channelFactory.

Referenced by ns3::CsmaStarHelper::CsmaStarHelper(), DynamicGlobalRoutingTestCase::DoRun(), CsmaBridgeTestCase::DoRun(), ns3::EpcS1uDlTestCase::DoRun(), Ns3TcpSocketTestCase2::DoRun(), ns3::EpcS1uUlTestCase::DoRun(), CsmaOneSubnetTestCase::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), Install(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 Install().

+ Here is the call graph for this function:

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:

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 InstallPriv().

+ Here is the call graph for this function:

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 InstallPriv().

+ Here is the call graph for this function:

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 InstallPriv().

+ Here is the call graph for this function:

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:

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:

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 Install().

+ Here is the call graph for this function:

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

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

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

Referenced by Install().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by DynamicGlobalRoutingTestCase::DoRun(), CsmaBridgeTestCase::DoRun(), Ns3TcpSocketTestCase2::DoRun(), CsmaBroadcastTestCase::DoRun(), CsmaMulticastTestCase::DoRun(), CsmaOneSubnetTestCase::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

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

Referenced by CsmaPacketSocketTestCase::DoRun(), CsmaPingTestCase::DoRun(), CsmaRawIpSocketTestCase::DoRun(), and main().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ns3::CsmaHelper::SetQueue ( std::string  type,
std::string  n1 = "",
const AttributeValue v1 = EmptyAttributeValue (),
std::string  n2 = "",
const AttributeValue v2 = EmptyAttributeValue (),
std::string  n3 = "",
const AttributeValue v3 = EmptyAttributeValue (),
std::string  n4 = "",
const AttributeValue v4 = EmptyAttributeValue () 
)
Parameters
typethe type of queue
n1the name of the attribute to set on the queue
v1the value of the attribute to set on the queue
n2the name of the attribute to set on the queue
v2the value of the attribute to set on the queue
n3the name of the attribute to set on the queue
v3the value of the attribute to set on the queue
n4the name of the attribute to set on the queue
v4the value of the attribute to set on the queue

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

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

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

+ Here is the call graph for this function:

Member Data Documentation

ObjectFactory ns3::CsmaHelper::m_channelFactory
private

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

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

ObjectFactory ns3::CsmaHelper::m_deviceFactory
private

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

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

ObjectFactory ns3::CsmaHelper::m_queueFactory
private

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

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


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