6#include "traffic-generator-ngmn-gaming.h"
8#include "ns3/address.h"
9#include "ns3/boolean.h"
10#include "ns3/double.h"
13#include "ns3/nstime.h"
14#include "ns3/packet.h"
15#include "ns3/simulator.h"
16#include "ns3/socket-factory.h"
17#include "ns3/socket.h"
18#include "ns3/tcp-socket-factory.h"
19#include "ns3/trace-source-accessor.h"
20#include "ns3/udp-socket-factory.h"
21#include "ns3/uinteger.h"
26NS_LOG_COMPONENT_DEFINE(
"TrafficGeneratorNgmnGaming");
27NS_OBJECT_ENSURE_REGISTERED(TrafficGeneratorNgmnGaming);
33 TypeId(
"ns3::TrafficGeneratorNgmnGaming")
35 .SetGroupName(
"Applications")
37 .AddAttribute(
"IsDownlink",
38 "If set to true the traffic will be generated according to "
39 "parameters and model for gaming downlink, otherwise, if false,"
40 "it will be generated according to parameters and model for uplink.",
42 MakeBooleanAccessor(&TrafficGeneratorNgmnGaming::m_isDownlink),
44 .AddAttribute(
"aParamPacketSizeUl",
45 "The a parameter in number of bytes for the packet size "
46 "calculation in uplink according to the NGMN white paper Annex A. The "
48 "determined using Largest Extreme Value Distribution "
49 "(also known as Fisher-Tippett distribution) random variable.",
51 MakeUintegerAccessor(&TrafficGeneratorNgmnGaming::m_aParamPacketSizeUl),
52 MakeUintegerChecker<uint32_t>())
53 .AddAttribute(
"bParamPacketSizeUl",
54 "The b parameter in number of bytes for the packet size "
55 " calculation in uplink according to the NGMN white paper Annex A. The "
57 "determined using Largest Extreme Value Distribution "
58 "(also known as Fisher-Tippett distribution) random variable.",
60 MakeDoubleAccessor(&TrafficGeneratorNgmnGaming::m_bParamPacketSizeUl),
61 MakeDoubleChecker<double>())
62 .AddAttribute(
"PacketArrivalUl",
63 "Packet arrival time in milliseconds for uplink. "
64 "Packet arrival in uplink is deterministic",
66 MakeUintegerAccessor(&TrafficGeneratorNgmnGaming::m_packetArrivalUl),
67 MakeUintegerChecker<uint32_t>())
70 "The a parameter in number of bytes for the packet size "
71 "calculation in downlink according to NGMN white paper Annex A. The packet size is "
72 "determined using the Largest Extreme Value Distribution "
73 "(also known as Fisher-Tippett distribution) random variable.",
75 MakeUintegerAccessor(&TrafficGeneratorNgmnGaming::m_aParamPacketSizeDl),
76 MakeUintegerChecker<uint32_t>())
79 "The b parameter in number of bytes for the packet size "
80 "calculation in downlink according to NGMN white paper Annex A. The packet size is "
81 "determined using the Largest Extreme Value Distribution "
82 "(also known as Fisher-Tippett distribution) random variable.",
84 MakeDoubleAccessor(&TrafficGeneratorNgmnGaming::m_bParamPacketSizeDl),
85 MakeDoubleChecker<double>())
87 "aParamPacketArrivalDl",
88 "The a parameter for the packet arrival "
89 "calculation in downlink according to NGMN white paper Annex A. The packet arrival "
90 "in downlink is determined using Largest Extreme Value Distribution "
91 "(also known as Fisher-Tippett distribution) random variable.",
93 MakeDoubleAccessor(&TrafficGeneratorNgmnGaming::m_aParamPacketArrivalDl),
94 MakeDoubleChecker<double>())
96 "bParamPacketArrivalDl",
97 "The b parameter for the packet arrival "
98 "calculation in downlink according to NGMN white paper Annex A. The packet arrival"
99 "in downlink is determined using Largest Extreme Value Distribution "
100 "(also known as Fisher-Tippett distribution) random variable.",
102 MakeDoubleAccessor(&TrafficGeneratorNgmnGaming::m_bParamPacketArrivalDl),
103 MakeDoubleChecker<double>())
105 "InitialPacketArrivalMin",
106 "The minimum value in milliseconds for the "
107 "initial packet arrival calculation according to NGMN white paper Annex A. "
108 "The packet arrival in both, downlink and uplink, is determined using the "
109 "Uniform Distribution.",
111 MakeUintegerAccessor(&TrafficGeneratorNgmnGaming::m_initialPacketArrivalMin),
112 MakeUintegerChecker<uint32_t>())
114 "InitialPacketArrivalMax",
115 "The maximum value in milliseconds for the "
116 "initial packet arrival calculation according to NGMN white paper Annex A. "
117 "The packet arrival in both, downlink and uplink, is determined using the "
118 "Uniform Distribution.",
120 MakeUintegerAccessor(&TrafficGeneratorNgmnGaming::m_initialPacketArrivalMax),
121 MakeUintegerChecker<uint32_t>())
122 .AddAttribute(
"Remote",
123 "The address of the destination",
126 MakeAddressChecker())
127 .AddAttribute(
"Protocol",
128 "The type of protocol to use.",
129 TypeIdValue(TcpSocketFactory::GetTypeId()),
132 .AddTraceSource(
"Tx",
133 "A new packet is created and is sent",
134 MakeTraceSourceAccessor(&TrafficGenerator::m_txTrace),
135 "ns3::TrafficGenerator::TxTracedCallback");
139TrafficGeneratorNgmnGaming::TrafficGeneratorNgmnGaming()
142 NS_LOG_FUNCTION(
this);
145TrafficGeneratorNgmnGaming::~TrafficGeneratorNgmnGaming()
147 NS_LOG_FUNCTION(
this);
151TrafficGeneratorNgmnGaming::StartApplication()
153 NS_LOG_FUNCTION(
this);
158TrafficGeneratorNgmnGaming::PacketBurstSent()
160 NS_LOG_FUNCTION(
this);
162 "This function should not be called for the gaming traffic");
169TrafficGeneratorNgmnGaming::GenerateNextPacketBurstSize()
171 NS_LOG_FUNCTION(
this);
172 SetPacketBurstSizeInPackets(1);
176TrafficGeneratorNgmnGaming::GetInitialPacketArrivalTime()
const
178 return MilliSeconds(ceil(m_initPacketArrivalVariable->GetValue()));
182TrafficGeneratorNgmnGaming::GetNextPacketSize()
const
184 NS_LOG_FUNCTION(
this);
191 double y = m_packetSizeRandomVariable->GetValue();
198 a = m_aParamPacketSizeDl;
199 b = m_bParamPacketSizeDl;
203 a = m_aParamPacketSizeUl;
204 b = m_bParamPacketSizeUl;
206 x = a - b * log(-log(y));
213TrafficGeneratorNgmnGaming::GetNextPacketTime()
const
215 NS_LOG_FUNCTION(
this);
223 Time x = MilliSeconds(0);
226 double y = m_packetArrivalVariable->GetValue();
227 double a = m_aParamPacketArrivalDl;
228 double b = m_bParamPacketArrivalDl;
232 x = MilliSeconds(floor(a - b * log(-log(y))));
236 x = MilliSeconds(m_packetArrivalUl);
242TrafficGeneratorNgmnGaming::DoDispose()
244 NS_LOG_FUNCTION(
this);
245 m_initPacketArrivalVariable =
nullptr;
246 m_packetSizeRandomVariable =
nullptr;
247 m_packetArrivalVariable =
nullptr;
250 TrafficGenerator::DoDispose();
254TrafficGeneratorNgmnGaming::DoInitialize()
256 NS_LOG_FUNCTION(
this);
257 m_initPacketArrivalVariable = CreateObject<UniformRandomVariable>();
258 m_initPacketArrivalVariable->SetAttribute(
"Min", DoubleValue(m_initialPacketArrivalMin));
259 m_initPacketArrivalVariable->SetAttribute(
"Max", DoubleValue(m_initialPacketArrivalMax));
260 m_packetSizeRandomVariable = CreateObject<UniformRandomVariable>();
261 m_packetSizeRandomVariable->SetAttribute(
"Min", DoubleValue(0));
262 m_packetSizeRandomVariable->SetAttribute(
"Max", DoubleValue(1));
263 m_packetArrivalVariable = CreateObject<UniformRandomVariable>();
264 m_packetArrivalVariable->SetAttribute(
"Min", DoubleValue(0));
265 m_packetArrivalVariable->SetAttribute(
"Max", DoubleValue(1));
267 TrafficGenerator::DoInitialize();
273 m_initPacketArrivalVariable->SetStream(stream);
274 m_packetSizeRandomVariable->SetStream(stream + 1);
275 m_packetArrivalVariable->SetStream(stream + 2);
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.
int64_t AssignStreams(int64_t stream) override
static TypeId GetTypeId()
Get the type ID.