Generate VoIP traffic. More...
#include "tgax-voip-traffic.h"
Public Types | |
| enum class | VoiceActivityState : uint8_t { INACTIVE_SILENCE = 0 , ACTIVE_TALKING = 1 } |
| Voice activity states. More... | |
| Public Types inherited from ns3::Application | |
| typedef void(* | DelayAddressCallback) (const Time &delay, const Address &from) |
| Common callback signature for packet delay and address. | |
| typedef void(* | StateTransitionCallback) (const std::string &oldState, const std::string &newState) |
| Common signature used by callbacks to application's state transition trace source. | |
Public Member Functions | |
| TgaxVoipTraffic () | |
| ~TgaxVoipTraffic () override | |
| int64_t | AssignStreams (int64_t stream) override |
| Assign a fixed random variable stream number to the random variables used by this Application object. | |
| Public Member Functions inherited from ns3::SourceApplication | |
| SourceApplication (bool allowPacketSocket=true) | |
| Constructor. | |
| ~SourceApplication () override | |
| Address | GetRemote () const |
| get the remote address | |
| Ptr< Socket > | GetSocket () const |
| Get the socket this application is attached to. | |
| virtual void | SetRemote (const Address &addr) |
| set the remote address | |
| Public Member Functions inherited from ns3::Application | |
| Application () | |
| ~Application () override | |
| Ptr< Node > | GetNode () const |
| void | SetNode (Ptr< Node > node) |
| void | SetStartTime (Time start) |
| Specify application start time. | |
| void | SetStopTime (Time stop) |
| Specify application stop time. | |
| Public Member Functions inherited from ns3::Object | |
| Object () | |
| Caller graph was not generated because of its size. | |
| ~Object () override | |
| Destructor. | |
| void | AggregateObject (Ptr< Object > other) |
| Aggregate two Objects together. | |
| void | Dispose () |
| Dispose of this Object. | |
| AggregateIterator | GetAggregateIterator () const |
| Get an iterator to the Objects aggregated to this one. | |
| TypeId | GetInstanceTypeId () const final |
| Get the most derived TypeId for this Object. | |
| template<> | |
| Ptr< Object > | GetObject () const |
| Specialization of () for objects of type ns3::Object. | |
| template<typename T> | |
| Ptr< T > | GetObject () const |
| Get a pointer to the requested aggregated Object. | |
| template<> | |
| Ptr< Object > | GetObject (TypeId tid) const |
| Specialization of (TypeId tid) for objects of type ns3::Object. | |
| template<typename T> | |
| Ptr< T > | GetObject (TypeId tid) const |
| Get a pointer to the requested aggregated Object by TypeId. | |
| void | Initialize () |
| Invoke DoInitialize on all Objects aggregated to this one. | |
| bool | IsInitialized () const |
| Check if the object has been initialized. | |
| void | UnidirectionalAggregateObject (Ptr< Object > other) |
| Aggregate an Object to another Object. | |
| Public Member Functions inherited from ns3::SimpleRefCount< Object, ObjectBase, ObjectDeleter > | |
| SimpleRefCount () | |
| Default constructor. | |
| uint32_t | GetReferenceCount () const |
| Get the reference count of the object. | |
| SimpleRefCount & | operator= (const SimpleRefCount &o) |
| Assignment operator. | |
| void | Ref () const |
| Increment the reference count. | |
| void | Unref () const |
| Decrement the reference count. | |
| Public Member Functions inherited from ns3::ObjectBase | |
| virtual | ~ObjectBase () |
| Virtual destructor. | |
| void | GetAttribute (std::string name, AttributeValue &value, bool permissive=false) const |
| Get the value of an attribute, raising fatal errors if unsuccessful. | |
| bool | GetAttributeFailSafe (std::string name, AttributeValue &value) const |
| Get the value of an attribute without raising errors. | |
| void | SetAttribute (std::string name, const AttributeValue &value) |
| Set a single attribute, raising fatal errors if unsuccessful. | |
| bool | SetAttributeFailSafe (std::string name, const AttributeValue &value) |
| Set a single attribute without raising errors. | |
| bool | TraceConnect (std::string name, std::string context, const CallbackBase &cb) |
| Connect a TraceSource to a Callback with a context. | |
| bool | TraceConnectWithoutContext (std::string name, const CallbackBase &cb) |
| Connect a TraceSource to a Callback without a context. | |
| bool | TraceDisconnect (std::string name, std::string context, const CallbackBase &cb) |
| Disconnect from a TraceSource a Callback previously connected with a context. | |
| bool | TraceDisconnectWithoutContext (std::string name, const CallbackBase &cb) |
| Disconnect from a TraceSource a Callback previously connected without a context. | |
Static Public Member Functions | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
| Static Public Member Functions inherited from ns3::SourceApplication | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
| Static Public Member Functions inherited from ns3::Application | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
| Static Public Member Functions inherited from ns3::Object | |
| static TypeId | GetTypeId () |
| Register this type. | |
| Static Public Member Functions inherited from ns3::ObjectBase | |
| static TypeId | GetTypeId () |
| Get the type ID. | |
Protected Member Functions | |
| void | DoInitialize () override |
| Initialize() implementation. | |
| Protected Member Functions inherited from ns3::SourceApplication | |
| bool | CloseSocket () |
| Close the socket. | |
| void | DoDispose () override |
| Destructor implementation. | |
| Protected Member Functions inherited from ns3::Object | |
| Object (const Object &o) | |
| Copy an Object. | |
| virtual void | NotifyNewAggregate () |
| Notify all Objects aggregated to this one of a new Object being aggregated. | |
| Protected Member Functions inherited from ns3::ObjectBase | |
| void | ConstructSelf (const AttributeConstructionList &attributes) |
| Complete construction of ObjectBase; invoked by derived classes. | |
| virtual void | NotifyConstructionCompleted () |
| Notifier called once the ObjectBase is fully constructed. | |
Private Types | |
| typedef void(* | StateUpdatedCallback) (VoiceActivityState state, Time duration) |
| TracedCallback signature for state change. | |
| typedef void(* | TxTracedCallback) (Ptr< const Packet > packet, Time jitter) |
| TracedCallback signature for packet and jitter. | |
Private Member Functions | |
| void | CancelEvents () override |
| Cancel all pending events. | |
| void | DoConnectionSucceeded (Ptr< Socket > socket) override |
| Application specific code for child subclasses upon a Connection Succeed event. | |
| void | DoStartApplication () override |
| Application specific startup code for child subclasses. | |
| Time | GetEncoderFrameDuration () const |
| Get the duration to encode a frame based on the current state. | |
| Time | GetStateUpdateInterval () const |
| Get the interval between two state updates. | |
| void | ScheduleNext () |
| Schedule the next state update. | |
| void | SendPacket (uint64_t eventId, Ptr< Packet > packet, Time jitter) |
| Transmit one VoIP packet. | |
| void | SetActiveExponentialMean (Time mean) |
| Set the mean of the exponential distribution used to calculate durations of active/talking state. | |
| void | SetInactiveExponentialMean (Time mean) |
| Set the mean of the exponential distribution used to calculate durations of inactive/silent state. | |
| void | UpdateState () |
| Update voice activity state. | |
Private Attributes | |
| Ptr< ExponentialRandomVariable > | m_activeExponential |
| Exponential random variable to generate active/talking state durations. | |
| uint32_t | m_activePacketSize |
| Size in bytes for payload of active packets. | |
| double | m_activeToInactive |
| Probability to transition from active/talking state to inactive/silence state. | |
| Ptr< UniformRandomVariable > | m_activeUniform |
| Uniform random variable to generate state transitions from active state. | |
| VoiceActivityState | m_currentState |
| Hold the current voice activity state. | |
| Time | m_delayJitterBound |
| Bound of laplacian distribution used to calculate delay jitter. | |
| Ptr< LaplacianRandomVariable > | m_delayJitterLaplacian |
| Laplacian random variable to generate delay jitter. | |
| Time | m_delayJitterScale |
| Scale of laplacian distribution used to calculate delay jitter. | |
| Ptr< ExponentialRandomVariable > | m_inactiveExponential |
| Exponential random variable to generate inactive/silent state durations. | |
| double | m_inactiveToActive |
| Probability to transition from inactive/silence state to active/talking state. | |
| Ptr< UniformRandomVariable > | m_inactiveUniform |
| Uniform random variable to generate state transitions from inactive state. | |
| uint64_t | m_nextEventId {0} |
| The next event ID. | |
| bool | m_pendingStateTransition {false} |
| Flag whether a state transition should once duration of current state has elapsed. | |
| Time | m_remainingEncodingDuration |
| The remaining duration to encode the current frame. | |
| Time | m_remainingStateDuration |
| The remaining duration in the current state. | |
| Time | m_silenceInterval |
| Interval between generation of silence packets. | |
| uint32_t | m_silencePacketSize |
| Size in bytes for payload of silence packets. | |
| TracedCallback< VoiceActivityState, Time > | m_stateUpdate |
| Traced Callback: voice activity state updated. | |
| EventId | m_stateUpdateEvent |
| Event ID of pending state update event scheduling. | |
| TracedCallback< Ptr< const Packet >, Time > | m_txJitterTrace |
| Traced Callback: transmitted packets and their jitters. | |
| std::map< uint64_t, EventId > | m_txPacketEvents |
| Event IDs of pending TX events. | |
| Time | m_voiceInterval |
| Interval between generation of voice packets. | |
Additional Inherited Members | |
| Protected Types inherited from ns3::SourceApplication | |
| typedef void(* | ConnectionEventCallback) (Ptr< Socket > socket, const Address &local, const Address &remote) |
| TracedCallback signature for connection success/failure event. | |
| Protected Attributes inherited from ns3::SourceApplication | |
| bool | m_connected {false} |
| flag whether socket is connected | |
| TracedCallback< Ptr< Socket >, const Address &, const Address & > | m_connectionFailure |
| Traced Callback: connection failure event. | |
| TracedCallback< Ptr< Socket >, const Address &, const Address & > | m_connectionSuccess |
| Traced Callback: connection success event. | |
| Address | m_local |
| Local address to bind to. | |
| Address | m_peer |
| Peer address. | |
| TypeId | m_protocolTid |
| Protocol TypeId value. | |
| Ptr< Socket > | m_socket |
| Socket. | |
| uint8_t | m_tos |
| The packets Type of Service. | |
| TracedCallback< Ptr< const Packet > > | m_txTrace |
| Traced Callback: transmitted packets. | |
| Protected Attributes inherited from ns3::Application | |
| Ptr< Node > | m_node |
| The node that this application is installed on. | |
| EventId | m_startEvent |
| The event that will fire at m_startTime to start the application. | |
| Time | m_startTime |
| The simulation time that the application will start. | |
| EventId | m_stopEvent |
| The event that will fire at m_stopTime to end the application. | |
| Time | m_stopTime |
| The simulation time that the application will end. | |
| Related Symbols inherited from ns3::ObjectBase | |
| static TypeId | GetObjectIid () |
| Ensure the TypeId for ObjectBase gets fully configured to anchor the inheritance tree properly. | |
Generate VoIP traffic.
This voip traffic generator follows requirements from IEEE 802.11-14/0571r12 - 11ax Evaluation Methodology (see applications documentation for full citation).
The VoIP traffic alternates between periods of active talking and silence, with given probabilities to transition from one state to another. These state updates are assumed to be done at the speech encoder frame rate.
Fixed-size VoIP packets are generated at every encoder frame interval, plus a random network packet arrival delay jitter (if BoundDelayJitter is non-zero). The size of these packets also depend on the current state.
The VoIP model from the reference relies on UDP with compressed protocol headers. Since compressed protocol headers are not supported in the simulator, a packet socket is used instead, allowing user to tune payload sizes by adding up the size of the compressed headers.
This model can also be used with usual UDP or TCP sockets. For the later, user should be warned that the model does not provide any mechanism when TX buffer is full.
ns3::TgaxVoipTraffic is accessible through the following paths with Config::Set and Config::Connect:
Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns TypeId Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns Address Address Time -9.22337e+18ns:+9.22337e+18ns Time -9.22337e+18ns:+9.22337e+18ns Group: Applications
Size of this type is 512 bytes (on a 64-bit architecture).
Definition at line 50 of file tgax-voip-traffic.h.
|
private |
TracedCallback signature for state change.
| [in] | state | The new state. |
| [in] | duration | The duration of the state. |
Definition at line 176 of file tgax-voip-traffic.h.
|
private |
TracedCallback signature for packet and jitter.
| [in] | packet | The packet. |
| [in] | jitter | The networking jitter. |
Definition at line 168 of file tgax-voip-traffic.h.
|
strong |
Voice activity states.
| Enumerator | |
|---|---|
| INACTIVE_SILENCE | |
| ACTIVE_TALKING | |
Definition at line 65 of file tgax-voip-traffic.h.
| ns3::TgaxVoipTraffic::TgaxVoipTraffic | ( | ) |
Definition at line 117 of file tgax-voip-traffic.cc.
References ns3::CreateObject(), m_activeExponential, m_activeUniform, m_delayJitterLaplacian, m_inactiveExponential, m_inactiveUniform, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
override |
Definition at line 127 of file tgax-voip-traffic.cc.
References NS_LOG_FUNCTION.
|
overridevirtual |
Assign a fixed random variable stream number to the random variables used by this Application object.
| stream | first stream index to use |
Reimplemented from ns3::Application.
Definition at line 133 of file tgax-voip-traffic.cc.
References m_activeExponential, m_activeUniform, m_delayJitterLaplacian, m_inactiveExponential, m_inactiveUniform, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Cancel all pending events.
Implements ns3::SourceApplication.
Definition at line 185 of file tgax-voip-traffic.cc.
References GetEncoderFrameDuration(), m_remainingEncodingDuration, m_stateUpdateEvent, m_txPacketEvents, and NS_LOG_FUNCTION.
Application specific code for child subclasses upon a Connection Succeed event.
| socket | the connected socket |
Reimplemented from ns3::SourceApplication.
Definition at line 339 of file tgax-voip-traffic.cc.
References NS_LOG_FUNCTION, and ScheduleNext().
|
overrideprotectedvirtual |
Initialize() implementation.
This method is called only once by Initialize(). If the user calls Initialize() multiple times, DoInitialize() is called only the first time.
Subclasses are expected to override this method and chain up to their parent's implementation once they are done. It is safe to call GetObject() and AggregateObject() from within this method.
Reimplemented from ns3::Application.
Definition at line 146 of file tgax-voip-traffic.cc.
References ns3::Object::DoInitialize(), m_delayJitterBound, m_delayJitterLaplacian, m_delayJitterScale, and NS_LOG_FUNCTION.
|
overrideprivatevirtual |
Application specific startup code for child subclasses.
Reimplemented from ns3::SourceApplication.
Definition at line 171 of file tgax-voip-traffic.cc.
References ns3::SourceApplication::m_connected, ns3::SourceApplication::m_socket, NS_LOG_FUNCTION, and ScheduleNext().
|
private |
Get the duration to encode a frame based on the current state.
Definition at line 198 of file tgax-voip-traffic.cc.
References ACTIVE_TALKING, m_currentState, m_silenceInterval, and m_voiceInterval.
Referenced by CancelEvents(), and UpdateState().
|
private |
Get the interval between two state updates.
Definition at line 205 of file tgax-voip-traffic.cc.
References m_silenceInterval, m_voiceInterval, and NS_ABORT_MSG_IF.
Referenced by ScheduleNext(), and UpdateState().
|
static |
Get the type ID.
Definition at line 33 of file tgax-voip-traffic.cc.
References ns3::SourceApplication::SourceApplication(), TgaxVoipTraffic(), ns3::TypeId::ATTR_CONSTRUCT, ns3::TypeId::ATTR_GET, ns3::TypeId::LookupByName(), m_activePacketSize, m_activeToInactive, m_delayJitterBound, m_delayJitterScale, m_inactiveToActive, ns3::SourceApplication::m_protocolTid, m_silenceInterval, m_silencePacketSize, m_stateUpdate, m_txJitterTrace, m_voiceInterval, ns3::MakeDoubleAccessor(), ns3::MakeDoubleChecker(), ns3::MakeTimeAccessor(), ns3::MakeTimeChecker(), ns3::MakeTraceSourceAccessor(), ns3::MakeTypeIdAccessor(), ns3::MakeTypeIdChecker(), ns3::MakeUintegerAccessor(), ns3::MakeUintegerChecker(), ns3::MicroSeconds(), ns3::MilliSeconds(), SetActiveExponentialMean(), SetInactiveExponentialMean(), and ns3::TypeId::SetParent().
Referenced by TgaxVoipTrafficTestCase::DoSetup().
|
private |
Schedule the next state update.
Definition at line 214 of file tgax-voip-traffic.cc.
References GetStateUpdateInterval(), m_stateUpdateEvent, NS_ASSERT, NS_LOG_FUNCTION, ns3::Simulator::Schedule(), and UpdateState().
Referenced by DoConnectionSucceeded(), DoStartApplication(), and UpdateState().
|
private |
Transmit one VoIP packet.
| eventId | the event ID |
| packet | the packet to transmit |
| jitter | the delay jitter applied to that packet |
Definition at line 223 of file tgax-voip-traffic.cc.
References ns3::Inet6SocketAddress::ConvertFrom(), ns3::InetSocketAddress::ConvertFrom(), ns3::Inet6SocketAddress::IsMatchingType(), ns3::InetSocketAddress::IsMatchingType(), ns3::SourceApplication::m_peer, ns3::SourceApplication::m_socket, m_txJitterTrace, m_txPacketEvents, ns3::SourceApplication::m_txTrace, ns3::Simulator::Now(), NS_ABORT_IF, NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_INFO, and ns3::Time::S.
Referenced by UpdateState().
|
private |
Set the mean of the exponential distribution used to calculate durations of active/talking state.
| mean | the mean value |
Definition at line 157 of file tgax-voip-traffic.cc.
References ns3::Time::GetMilliSeconds(), m_activeExponential, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
private |
Set the mean of the exponential distribution used to calculate durations of inactive/silent state.
| mean | the mean value |
Definition at line 164 of file tgax-voip-traffic.cc.
References ns3::Time::GetMilliSeconds(), m_inactiveExponential, and NS_LOG_FUNCTION.
Referenced by GetTypeId().
|
private |
Update voice activity state.
Definition at line 256 of file tgax-voip-traffic.cc.
References ACTIVE_TALKING, ns3::Create(), GetEncoderFrameDuration(), GetStateUpdateInterval(), INACTIVE_SILENCE, m_activeExponential, m_activePacketSize, m_activeToInactive, m_activeUniform, m_currentState, m_delayJitterBound, m_delayJitterLaplacian, m_inactiveExponential, m_inactiveToActive, m_inactiveUniform, m_nextEventId, m_pendingStateTransition, m_remainingEncodingDuration, m_remainingStateDuration, m_silencePacketSize, m_stateUpdate, m_txPacketEvents, ns3::MicroSeconds(), ns3::MilliSeconds(), ns3::Time::MS, ns3::Simulator::Now(), NS_ASSERT, NS_LOG_FUNCTION, NS_LOG_INFO, ns3::Time::S, ns3::Simulator::Schedule(), ScheduleNext(), and SendPacket().
Referenced by ScheduleNext().
|
private |
Exponential random variable to generate active/talking state durations.
Definition at line 141 of file tgax-voip-traffic.h.
Referenced by TgaxVoipTraffic(), AssignStreams(), SetActiveExponentialMean(), and UpdateState().
|
private |
Size in bytes for payload of active packets.
Definition at line 127 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and UpdateState().
|
private |
Probability to transition from active/talking state to inactive/silence state.
Definition at line 131 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and UpdateState().
|
private |
Uniform random variable to generate state transitions from active state.
Definition at line 145 of file tgax-voip-traffic.h.
Referenced by TgaxVoipTraffic(), AssignStreams(), and UpdateState().
|
private |
Hold the current voice activity state.
Definition at line 150 of file tgax-voip-traffic.h.
Referenced by GetEncoderFrameDuration(), and UpdateState().
|
private |
Bound of laplacian distribution used to calculate delay jitter.
Definition at line 136 of file tgax-voip-traffic.h.
Referenced by DoInitialize(), GetTypeId(), and UpdateState().
|
private |
Laplacian random variable to generate delay jitter.
Definition at line 148 of file tgax-voip-traffic.h.
Referenced by TgaxVoipTraffic(), AssignStreams(), DoInitialize(), and UpdateState().
|
private |
Scale of laplacian distribution used to calculate delay jitter.
Definition at line 135 of file tgax-voip-traffic.h.
Referenced by DoInitialize(), and GetTypeId().
|
private |
Exponential random variable to generate inactive/silent state durations.
Definition at line 139 of file tgax-voip-traffic.h.
Referenced by TgaxVoipTraffic(), AssignStreams(), SetInactiveExponentialMean(), and UpdateState().
|
private |
Probability to transition from inactive/silence state to active/talking state.
Definition at line 133 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and UpdateState().
|
private |
Uniform random variable to generate state transitions from inactive state.
Definition at line 143 of file tgax-voip-traffic.h.
Referenced by TgaxVoipTraffic(), AssignStreams(), and UpdateState().
|
private |
|
private |
Flag whether a state transition should once duration of current state has elapsed.
Definition at line 152 of file tgax-voip-traffic.h.
Referenced by UpdateState().
|
private |
The remaining duration to encode the current frame.
Definition at line 155 of file tgax-voip-traffic.h.
Referenced by CancelEvents(), and UpdateState().
|
private |
The remaining duration in the current state.
Definition at line 154 of file tgax-voip-traffic.h.
Referenced by UpdateState().
|
private |
Interval between generation of silence packets.
Definition at line 130 of file tgax-voip-traffic.h.
Referenced by GetEncoderFrameDuration(), GetStateUpdateInterval(), and GetTypeId().
|
private |
Size in bytes for payload of silence packets.
Definition at line 128 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and UpdateState().
|
private |
Traced Callback: voice activity state updated.
Definition at line 182 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and UpdateState().
|
private |
Event ID of pending state update event scheduling.
Definition at line 157 of file tgax-voip-traffic.h.
Referenced by CancelEvents(), and ScheduleNext().
|
private |
Traced Callback: transmitted packets and their jitters.
Definition at line 179 of file tgax-voip-traffic.h.
Referenced by GetTypeId(), and SendPacket().
|
private |
Event IDs of pending TX events.
Definition at line 159 of file tgax-voip-traffic.h.
Referenced by CancelEvents(), SendPacket(), and UpdateState().
|
private |
Interval between generation of voice packets.
Definition at line 129 of file tgax-voip-traffic.h.
Referenced by GetEncoderFrameDuration(), GetStateUpdateInterval(), and GetTypeId().