6#include "traffic-generator-3gpp-audio-data.h"
10#include "ns3/nstime.h"
11#include "ns3/tcp-socket-factory.h"
12#include "ns3/trace-source-accessor.h"
13#include "ns3/uinteger.h"
18NS_LOG_COMPONENT_DEFINE(
"TrafficGenerator3gppAudioData");
19NS_OBJECT_ENSURE_REGISTERED(TrafficGenerator3gppAudioData);
25 TypeId(
"ns3::TrafficGenerator3gppAudioData")
27 .SetGroupName(
"Applications")
31 "The desired data rate in Mbps. Typical values are 0.756 Mbps and 1.12 Mbps.",
33 MakeDoubleAccessor(&TrafficGenerator3gppAudioData::SetDataRate),
34 MakeDoubleChecker<double>())
35 .AddAttribute(
"Periodicity",
36 "The periodicity in milliseconds.",
38 MakeUintegerAccessor(&TrafficGenerator3gppAudioData::m_periodicity),
39 MakeUintegerChecker<uint32_t>())
40 .AddAttribute(
"Remote",
41 "The address of the destination",
45 .AddAttribute(
"Protocol",
46 "The type of protocol to use.",
47 TypeIdValue(TcpSocketFactory::GetTypeId()),
51 "A new packet is created and is sent",
52 MakeTraceSourceAccessor(&TrafficGenerator::m_txTrace),
53 "ns3::TrafficGenerator::TxTracedCallback");
57TrafficGenerator3gppAudioData::TrafficGenerator3gppAudioData()
60 NS_LOG_FUNCTION(
this);
63TrafficGenerator3gppAudioData::~TrafficGenerator3gppAudioData()
65 NS_LOG_FUNCTION(
this);
69TrafficGenerator3gppAudioData::DoInitialize()
71 m_packetSize = (m_dataRate * 1e6 * m_periodicity * 1e-3) / 8;
72 NS_ASSERT(m_packetSize);
73 TrafficGenerator::DoInitialize();
77TrafficGenerator3gppAudioData::StartApplication()
79 NS_LOG_FUNCTION(
this);
84TrafficGenerator3gppAudioData::SetDataRate(
double dataRate)
86 NS_LOG_FUNCTION(
this);
87 m_dataRate = dataRate;
91TrafficGenerator3gppAudioData::PacketBurstSent()
93 NS_LOG_FUNCTION(
this);
96 NS_ABORT_MSG(
"This function should not be called for the video + audio/data traffic");
100TrafficGenerator3gppAudioData::GenerateNextPacketBurstSize()
102 NS_LOG_FUNCTION(
this);
103 SetPacketBurstSizeInPackets(1);
107TrafficGenerator3gppAudioData::GetNextPacketSize()
const
109 NS_LOG_FUNCTION(
this);
114TrafficGenerator3gppAudioData::GetNextPacketTime()
const
116 NS_LOG_FUNCTION(
this);
117 NS_ASSERT(m_periodicity);
118 NS_LOG_DEBUG(
"Next packet time in Milliseconds: " << m_periodicity);
119 return MilliSeconds(m_periodicity);
int64_t AssignStreams(int64_t stream) override
static TypeId GetTypeId()
Get the type ID.
void SetRemote(Address remote)
Sets the remote address.
bool SendPacketBurst()
Send another packet burst, which can be e.g., a file, or a video frame.
void SetProtocol(TypeId protocol)
Sets the protocol.