Generate traffic to a single destination according to an OnOff pattern. More...
#include <onoff-application.h>
Generate traffic to a single destination according to an OnOff pattern.
This traffic generator follows an On/Off pattern: after Application::StartApplication is called, "On" and "Off" states alternate. The duration of each of these states is determined with the onTime and the offTime random variables. During the "Off" state, no traffic is generated. During the "On" state, cbr traffic is generated. This cbr traffic is characterized by the specified "data rate" and "packet size".
Definition at line 68 of file onoff-application.h.
ns3::OnOffApplication::OnOffApplication | ( | ) |
Definition at line 96 of file onoff-application.cc.
References m_connected, m_lastStartTime, m_residualBits, m_socket, m_totBytes, NS_LOG_FUNCTION_NOARGS, and ns3::Seconds().
ns3::OnOffApplication::~OnOffApplication | ( | ) | [virtual] |
Definition at line 106 of file onoff-application.cc.
References NS_LOG_FUNCTION_NOARGS.
void ns3::OnOffApplication::CancelEvents | ( | ) | [private] |
Definition at line 164 of file onoff-application.cc.
References ns3::Simulator::Cancel(), ns3::DataRate::GetBitRate(), ns3::TimeUnit< 0 >::GetDouble(), ns3::EventId::IsRunning(), m_cbrRate, m_lastStartTime, m_residualBits, m_sendEvent, m_startStopEvent, ns3::Simulator::Now(), NS_LOG_FUNCTION_NOARGS, and ns3::Seconds().
Referenced by StartApplication(), StopApplication(), and StopSending().
Definition at line 262 of file onoff-application.cc.
References NS_LOG_FUNCTION_NOARGS.
Definition at line 254 of file onoff-application.cc.
References m_connected, NS_LOG_FUNCTION_NOARGS, and ScheduleStartEvent().
void ns3::OnOffApplication::Construct | ( | Ptr< Node > | n, | |
const Address & | remote, | |||
std::string | tid, | |||
const RandomVariable & | ontime, | |||
const RandomVariable & | offtime, | |||
uint32_t | size | |||
) | [private] |
void ns3::OnOffApplication::DoDispose | ( | void | ) | [protected, virtual] |
This method is called by Object::Dispose or by the object's destructor, whichever comes first.
Subclasses are expected to implement their real destruction code in an overriden version of this method and chain up to their parent's implementation once they are done. i.e., for simplicity, the destructor of every subclass should be empty and its content should be moved to the associated DoDispose method.
Reimplemented from ns3::Application.
Definition at line 120 of file onoff-application.cc.
References m_socket, and NS_LOG_FUNCTION_NOARGS.
TypeId ns3::OnOffApplication::GetTypeId | ( | void | ) | [static] |
This method returns the TypeId associated to ns3::OnOffApplication.
This object is accessible through the following paths with Config::Set and Config::Connect:
Attributes defined for this type:
TraceSources defined for this type:
Reimplemented from ns3::Application.
Definition at line 49 of file onoff-application.cc.
References ns3::TypeId::AddAttribute(), ns3::TypeId::AddTraceSource(), ns3::UdpSocketFactory::GetTypeId(), m_cbrRate, m_jitter, m_maxBytes, m_offTime, m_onTime, m_peer, m_pktSize, m_tid, m_txTrace, ns3::MakeTraceSourceAccessor(), and ns3::TypeId::SetParent().
void ns3::OnOffApplication::ScheduleNextTx | ( | ) | [private] |
Definition at line 197 of file onoff-application.cc.
References ns3::DataRate::GetBitRate(), ns3::RandomVariable::GetValue(), ns3::TimeUnit< 1 >::IsPositive(), m_cbrRate, m_jitter, m_maxBytes, m_pktSize, m_residualBits, m_sendEvent, m_totBytes, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, ns3::Simulator::Schedule(), ns3::Seconds(), SendPacket(), and StopApplication().
Referenced by SendPacket(), and StartSending().
void ns3::OnOffApplication::ScheduleStartEvent | ( | ) | [private] |
Definition at line 221 of file onoff-application.cc.
References ns3::RandomVariable::GetValue(), m_offTime, m_startStopEvent, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, ns3::Simulator::Schedule(), ns3::Seconds(), and StartSending().
Referenced by ConnectionSucceeded(), StartApplication(), and StopSending().
void ns3::OnOffApplication::ScheduleStopEvent | ( | ) | [private] |
Definition at line 230 of file onoff-application.cc.
References ns3::RandomVariable::GetValue(), m_onTime, m_startStopEvent, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, ns3::Simulator::Schedule(), ns3::Seconds(), and StopSending().
Referenced by StartSending().
void ns3::OnOffApplication::SendPacket | ( | ) | [private] |
Definition at line 240 of file onoff-application.cc.
References ns3::EventId::IsExpired(), m_lastStartTime, m_pktSize, m_residualBits, m_sendEvent, m_socket, m_totBytes, m_txTrace, ns3::Now(), ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION_NOARGS, NS_LOG_LOGIC, and ScheduleNextTx().
Referenced by ScheduleNextTx().
void ns3::OnOffApplication::SetMaxBytes | ( | uint32_t | maxBytes | ) |
Definition at line 112 of file onoff-application.cc.
References m_maxBytes, and NS_LOG_FUNCTION.
void ns3::OnOffApplication::StartApplication | ( | void | ) | [private, virtual] |
Application specific startup code.
The StartApplication method is called at the start time specifed by Start This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 130 of file onoff-application.cc.
References CancelEvents(), ns3::Socket::CreateSocket(), ns3::Application::GetNode(), m_peer, m_socket, m_tid, NS_LOG_FUNCTION_NOARGS, and ScheduleStartEvent().
void ns3::OnOffApplication::StartSending | ( | ) | [private] |
Definition at line 180 of file onoff-application.cc.
References NS_LOG_FUNCTION_NOARGS, ScheduleNextTx(), and ScheduleStopEvent().
Referenced by ScheduleStartEvent().
void ns3::OnOffApplication::StopApplication | ( | void | ) | [private, virtual] |
Application specific shutdown code.
The StopApplication method is called at the stop time specifed by Stop This method should be overridden by all or most application subclasses.
Reimplemented from ns3::Application.
Definition at line 149 of file onoff-application.cc.
References CancelEvents(), m_socket, NS_LOG_FUNCTION_NOARGS, and NS_LOG_WARN.
Referenced by ScheduleNextTx().
void ns3::OnOffApplication::StopSending | ( | ) | [private] |
Definition at line 188 of file onoff-application.cc.
References CancelEvents(), NS_LOG_FUNCTION_NOARGS, and ScheduleStartEvent().
Referenced by ScheduleStopEvent().
DataRate ns3::OnOffApplication::m_cbrRate [private] |
Definition at line 107 of file onoff-application.h.
Referenced by CancelEvents(), GetTypeId(), and ScheduleNextTx().
bool ns3::OnOffApplication::m_connected [private] |
Definition at line 104 of file onoff-application.h.
Referenced by ConnectionSucceeded(), and OnOffApplication().
Definition at line 109 of file onoff-application.h.
Referenced by GetTypeId(), and ScheduleNextTx().
Time ns3::OnOffApplication::m_lastStartTime [private] |
Definition at line 111 of file onoff-application.h.
Referenced by CancelEvents(), OnOffApplication(), and SendPacket().
uint32_t ns3::OnOffApplication::m_maxBytes [private] |
Definition at line 112 of file onoff-application.h.
Referenced by GetTypeId(), ScheduleNextTx(), and SetMaxBytes().
Definition at line 106 of file onoff-application.h.
Referenced by GetTypeId(), and ScheduleStartEvent().
Definition at line 105 of file onoff-application.h.
Referenced by GetTypeId(), and ScheduleStopEvent().
Address ns3::OnOffApplication::m_peer [private] |
Definition at line 103 of file onoff-application.h.
Referenced by GetTypeId(), and StartApplication().
uint32_t ns3::OnOffApplication::m_pktSize [private] |
Definition at line 108 of file onoff-application.h.
Referenced by GetTypeId(), ScheduleNextTx(), and SendPacket().
uint32_t ns3::OnOffApplication::m_residualBits [private] |
Definition at line 110 of file onoff-application.h.
Referenced by CancelEvents(), OnOffApplication(), ScheduleNextTx(), and SendPacket().
EventId ns3::OnOffApplication::m_sendEvent [private] |
Definition at line 115 of file onoff-application.h.
Referenced by CancelEvents(), ScheduleNextTx(), and SendPacket().
bool ns3::OnOffApplication::m_sending [private] |
Definition at line 116 of file onoff-application.h.
Ptr<Socket> ns3::OnOffApplication::m_socket [private] |
Definition at line 102 of file onoff-application.h.
Referenced by DoDispose(), OnOffApplication(), SendPacket(), StartApplication(), and StopApplication().
Definition at line 114 of file onoff-application.h.
Referenced by CancelEvents(), ScheduleStartEvent(), and ScheduleStopEvent().
TypeId ns3::OnOffApplication::m_tid [private] |
Identifies the type of this object instance.
Reimplemented from ns3::Object.
Definition at line 117 of file onoff-application.h.
Referenced by GetTypeId(), and StartApplication().
uint32_t ns3::OnOffApplication::m_totBytes [private] |
Definition at line 113 of file onoff-application.h.
Referenced by OnOffApplication(), ScheduleNextTx(), and SendPacket().
TracedCallback<Ptr<const Packet> > ns3::OnOffApplication::m_txTrace [private] |
Definition at line 118 of file onoff-application.h.
Referenced by GetTypeId(), and SendPacket().