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

A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes. More...

#include "on-off-helper.h"

+ Collaboration diagram for ns3::OnOffHelper:

Public Member Functions

 OnOffHelper (std::string protocol, Address address)
 Create an OnOffHelper to make it easier to work with OnOffApplications. More...
 
int64_t AssignStreams (NodeContainer c, int64_t stream)
 Assign a fixed random variable stream number to the random variables used by this model. More...
 
ApplicationContainer Install (NodeContainer c) const
 Install an ns3::OnOffApplication on each node of the input container configured with all the attributes set with SetAttribute. More...
 
ApplicationContainer Install (Ptr< Node > node) const
 Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute. More...
 
ApplicationContainer Install (std::string nodeName) const
 Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute. More...
 
void SetAttribute (std::string name, const AttributeValue &value)
 Helper function used to set the underlying application attributes. More...
 
void SetConstantRate (DataRate dataRate, uint32_t packetSize=512)
 Helper function to set a constant rate source. More...
 

Private Member Functions

Ptr< ApplicationInstallPriv (Ptr< Node > node) const
 Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute. More...
 

Private Attributes

ObjectFactory m_factory
 Object factory. More...
 

Detailed Description

A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.

Definition at line 42 of file on-off-helper.h.

Constructor & Destructor Documentation

◆ OnOffHelper()

ns3::OnOffHelper::OnOffHelper ( std::string  protocol,
Address  address 
)

Create an OnOffHelper to make it easier to work with OnOffApplications.

Parameters
protocolthe name of the protocol to use to send traffic by the applications. This string identifies the socket factory type used to create sockets for the applications. A typical value would be ns3::UdpSocketFactory.
addressthe address of the remote node to send traffic to.

Definition at line 32 of file on-off-helper.cc.

References first::address, m_factory, ns3::ObjectFactory::Set(), and ns3::ObjectFactory::SetTypeId().

+ Here is the call graph for this function:

Member Function Documentation

◆ AssignStreams()

int64_t ns3::OnOffHelper::AssignStreams ( NodeContainer  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
streamfirst stream index to use
cNodeContainer of the set of nodes for which the OnOffApplication should be modified to use a fixed stream
Returns
the number of stream indices assigned by this helper

Definition at line 80 of file on-off-helper.cc.

References ns3::NodeContainer::Begin(), ns3::NodeContainer::End(), ns3::Node::GetApplication(), and ns3::Node::GetNApplications().

+ Here is the call graph for this function:

◆ Install() [1/3]

ApplicationContainer ns3::OnOffHelper::Install ( NodeContainer  c) const

Install an ns3::OnOffApplication on each node of the input container configured with all the attributes set with SetAttribute.

Parameters
cNodeContainer of the set of nodes on which an OnOffApplication will be installed.
Returns
Container of Ptr to the applications installed.

Definition at line 59 of file on-off-helper.cc.

References ns3::ApplicationContainer::Add(), ns3::NodeContainer::Begin(), ns3::NodeContainer::End(), and InstallPriv().

Referenced by Experiment::ApplicationSetup(), BuildAppsTest(), CreateOnOffFlow(), WifiMsduAggregatorThroughputTest::DoRun(), WifiAcMappingTest::DoRun(), CsmaBridgeTestCase::DoRun(), Ns3TcpInteroperabilityTestCase::DoRun(), CsmaBroadcastTestCase::DoRun(), CsmaMulticastTestCase::DoRun(), CsmaPacketSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), experiment(), NetAnimExperiment::Run(), Experiment::Run(), RoutingExperiment::Run(), and RoutingHelper::SetupRoutingMessages().

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

◆ Install() [2/3]

ApplicationContainer ns3::OnOffHelper::Install ( Ptr< Node node) const

Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute.

Parameters
nodeThe node on which an OnOffApplication will be installed.
Returns
Container of Ptr to the applications installed.

Definition at line 46 of file on-off-helper.cc.

References InstallPriv().

+ Here is the call graph for this function:

◆ Install() [3/3]

ApplicationContainer ns3::OnOffHelper::Install ( std::string  nodeName) const

Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute.

Parameters
nodeNameThe node on which an OnOffApplication will be installed.
Returns
Container of Ptr to the applications installed.

Definition at line 52 of file on-off-helper.cc.

References InstallPriv().

+ Here is the call graph for this function:

◆ InstallPriv()

Ptr< Application > ns3::OnOffHelper::InstallPriv ( Ptr< Node node) const
private

Install an ns3::OnOffApplication on the node configured with all the attributes set with SetAttribute.

Parameters
nodeThe node on which an OnOffApplication will be installed.
Returns
Ptr to the application installed.

Definition at line 71 of file on-off-helper.cc.

References ns3::Node::AddApplication(), ns3::ObjectFactory::Create(), and m_factory.

Referenced by Install().

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

◆ SetAttribute()

void ns3::OnOffHelper::SetAttribute ( std::string  name,
const AttributeValue value 
)

Helper function used to set the underlying application attributes.

Parameters
namethe name of the application attribute to set
valuethe value of the application attribute to set

Definition at line 40 of file on-off-helper.cc.

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

Referenced by Experiment::ApplicationSetup(), BuildAppsTest(), CreateOnOffFlow(), WifiMsduAggregatorThroughputTest::DoRun(), BriteTopologyFunctionTestCase::DoRun(), Ns3TcpInteroperabilityTestCase::DoRun(), CsmaPacketSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), experiment(), DsdvManetExample::InstallApplications(), NetAnimExperiment::Run(), Experiment::Run(), RoutingExperiment::Run(), and RoutingHelper::SetupRoutingMessages().

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

◆ SetConstantRate()

void ns3::OnOffHelper::SetConstantRate ( DataRate  dataRate,
uint32_t  packetSize = 512 
)

Helper function to set a constant rate source.

Equivalent to setting the attributes OnTime to constant 1000 seconds, OffTime to constant 0 seconds, and the DataRate and PacketSize set accordingly

Parameters
dataRateDataRate object for the sending rate
packetSizesize in bytes of the packet payloads generated

Definition at line 100 of file on-off-helper.cc.

References m_factory, packetSize, and ns3::ObjectFactory::Set().

Referenced by Experiment::ApplicationSetup(), WifiMsduAggregatorThroughputTest::DoRun(), WifiAcMappingTest::DoRun(), CsmaBridgeTestCase::DoRun(), CsmaBroadcastTestCase::DoRun(), CsmaMulticastTestCase::DoRun(), CsmaOneSubnetTestCase::DoRun(), CsmaPacketSocketTestCase::DoRun(), CsmaStarTestCase::DoRun(), and Experiment::Run().

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

Member Data Documentation

◆ m_factory

ObjectFactory ns3::OnOffHelper::m_factory
private

Object factory.

Definition at line 126 of file on-off-helper.h.

Referenced by InstallPriv(), OnOffHelper(), SetAttribute(), and SetConstantRate().


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