6#include "traffic-generator-ngmn-video.h"
8#include "ns3/address.h"
12#include "ns3/nstime.h"
13#include "ns3/packet.h"
14#include "ns3/simulator.h"
15#include "ns3/socket-factory.h"
16#include "ns3/socket.h"
17#include "ns3/tcp-socket-factory.h"
18#include "ns3/trace-source-accessor.h"
19#include "ns3/udp-socket-factory.h"
20#include "ns3/uinteger.h"
25NS_LOG_COMPONENT_DEFINE(
"TrafficGeneratorNgmnVideo");
26NS_OBJECT_ENSURE_REGISTERED(TrafficGeneratorNgmnVideo);
28uint32_t TrafficGeneratorNgmnVideo::m_flowIdCounter = 0;
34 TypeId(
"ns3::TrafficGeneratorNgmnVideo")
36 .SetGroupName(
"Applications")
39 "NumberOfPacketsInFrame",
40 "Number of packets in frame",
42 MakeUintegerAccessor(&TrafficGeneratorNgmnVideo::m_numberOfPacketsInFrame),
43 MakeUintegerChecker<uint32_t>(8))
44 .AddAttribute(
"InterframeIntervalTime",
45 "Interframe interval time ",
46 TimeValue(MilliSeconds(100)),
47 MakeTimeAccessor(&TrafficGeneratorNgmnVideo::m_interframeIntervalTime),
49 .AddAttribute(
"PacketSizeScale",
50 "The scale parameter for the Pareto distribution "
51 "for the packet size generation",
53 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetSizeScale),
54 MakeDoubleChecker<double>())
55 .AddAttribute(
"PacketSizeShape",
56 "The shape parameter for the Pareto distribution "
57 "for the packet size generation",
59 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetSizeShape),
60 MakeDoubleChecker<double>())
61 .AddAttribute(
"PacketSizeBound",
62 "The bound parameter for the Pareto distribution "
63 "for the packet size generation",
65 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetSizeBound),
66 MakeDoubleChecker<double>())
67 .AddAttribute(
"PacketTimeScale",
68 "The scale parameter for the Pareto distribution "
69 "for the packet time generation",
71 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetTimeScale),
72 MakeDoubleChecker<double>())
73 .AddAttribute(
"PacketTimeShape",
74 "The shape parameter for the Pareto distribution "
75 "for the packet timee generation",
77 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetTimeShape),
78 MakeDoubleChecker<double>())
79 .AddAttribute(
"PacketTimeBound",
80 "The bound parameter for the Pareto distribution "
81 "for the packet time generation",
83 MakeDoubleAccessor(&TrafficGeneratorNgmnVideo::m_packetTimeBound),
84 MakeDoubleChecker<double>())
85 .AddAttribute(
"Remote",
86 "The address of the destination",
90 .AddAttribute(
"Protocol",
91 "The type of protocol to use.",
92 TypeIdValue(TcpSocketFactory::GetTypeId()),
96 "A new packet is created and is sent",
97 MakeTraceSourceAccessor(&TrafficGenerator::m_txTrace),
98 "ns3::TrafficGenerator::TxTracedCallback");
102TrafficGeneratorNgmnVideo::TrafficGeneratorNgmnVideo()
105 NS_LOG_FUNCTION(
this);
106 m_flowId = m_flowIdCounter++;
109TrafficGeneratorNgmnVideo::~TrafficGeneratorNgmnVideo()
111 NS_LOG_FUNCTION(
this);
115TrafficGeneratorNgmnVideo::StartApplication()
117 NS_LOG_FUNCTION(
this);
122TrafficGeneratorNgmnVideo::GetNextPacketSize()
const
124 NS_LOG_FUNCTION(
this);
130 uint32_t packetSize = floor(std::min(m_packetSizeGenerator->GetValue(), m_packetSizeBound));
131 NS_LOG_DEBUG(
" Next packet size :" << packetSize);
136TrafficGeneratorNgmnVideo::GetNextPacketTime()
const
138 NS_LOG_FUNCTION(
this);
143 Seconds(std::min(m_packetTimeGenerator->GetValue(), m_packetTimeBound) * 0.001);
144 NS_LOG_DEBUG(
"Next packet time :" << packetTime.As(Time::MS));
149TrafficGeneratorNgmnVideo::PacketBurstSent()
151 NS_LOG_FUNCTION(
this);
152 m_packetFrameCounter++;
153 NS_LOG_INFO(
"Next frame to send: " << m_packetFrameCounter);
159TrafficGeneratorNgmnVideo::GenerateNextPacketBurstSize()
161 NS_LOG_FUNCTION(
this);
162 SetPacketBurstSizeInPackets(m_numberOfPacketsInFrame);
166TrafficGeneratorNgmnVideo::DoDispose()
168 NS_LOG_FUNCTION(
this);
169 m_packetSizeGenerator =
nullptr;
170 m_packetTimeGenerator =
nullptr;
172 TrafficGenerator::DoDispose();
176TrafficGeneratorNgmnVideo::DoInitialize()
178 NS_LOG_FUNCTION(
this);
179 m_packetSizeGenerator = CreateObject<ParetoRandomVariable>();
180 m_packetSizeGenerator->SetAttribute(
"Scale", DoubleValue(m_packetSizeScale));
181 m_packetSizeGenerator->SetAttribute(
"Shape", DoubleValue(m_packetSizeShape));
182 m_packetTimeGenerator = CreateObject<ParetoRandomVariable>();
183 m_packetTimeGenerator->SetAttribute(
"Scale", DoubleValue(m_packetTimeScale));
184 m_packetTimeGenerator->SetAttribute(
"Shape", DoubleValue(m_packetTimeShape));
186 TrafficGenerator::DoInitialize();
192 m_packetSizeGenerator->SetStream(stream);
193 m_packetTimeGenerator->SetStream(stream + 1);
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.
static TypeId GetTypeId()
Get the type ID.
int64_t AssignStreams(int64_t stream) override