A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
tgax-video-traffic.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 DERONNE SOFTWARE ENGINEERING
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Sébastien Deronne <sebastien.deronne@gmail.com>
7 */
8
9#ifndef TGAX_VIDEO_TRAFFIC_H
10#define TGAX_VIDEO_TRAFFIC_H
11
12#include "source-application.h"
13
14#include "ns3/applications-export.h"
15#include "ns3/data-rate.h"
16#include "ns3/event-id.h"
17#include "ns3/traced-callback.h"
18
19#include <deque>
20#include <map>
21#include <optional>
22
23namespace ns3
24{
25
28
29/**
30 * @ingroup applications
31 * @brief Generate video traffic.
32 *
33 * This video traffic generator implements the Buffered Video Steaming model from IEEE
34 * 802.11-14/0571r12 - 11ax Evaluation Methodology (see applications documentation for
35 * full citation).
36 */
37class APPLICATIONS_EXPORT TgaxVideoTraffic : public SourceApplication
38{
39 public:
40 /**
41 * @brief Get the type ID.
42 * @return the object TypeId
43 */
44 static TypeId GetTypeId();
45
47 ~TgaxVideoTraffic() override;
48
49 /// TrafficModelClassIdentifier enumeration
50 enum class TrafficModelClassIdentifier : uint8_t
51 {
52 CUSTOM = 0, //< Custom traffic model (by default, load parameters of Buffered Video Model 1)
53 BUFFERED_VIDEO_1, //< Buffered Video Model 1
54 BUFFERED_VIDEO_2, //< Buffered Video Model 2
55 BUFFERED_VIDEO_3, //< Buffered Video Model 3
56 BUFFERED_VIDEO_4, //< Buffered Video Model 4
57 BUFFERED_VIDEO_5, //< Buffered Video Model 5
58 BUFFERED_VIDEO_6, //< Buffered Video Model 6
59 MULTICAST_VIDEO_1, //< Multicast Video Model 1
60 MULTICAST_VIDEO_2 //< Multicast Video Model 2
61 };
62
63 /// List of parameters for a given traffic model
65 {
66 DataRate bitRate; //!< video bit rate
67 double frameSizeBytesScale; //!< scale parameter for the Weibull distribution used to
68 //!< generate size of video frames in bytes (corresponds to
69 //!< lambda parameter in table 5 from IEEE 802.11-14/0571r12 -
70 //!< 11ax Evaluation Methodology)
71 double frameSizeBytesShape; //!< shape parameter for the Weibull distribution used to
72 //!< generate size of video frames in bytes (corresponds to k
73 //!< parameter in table 5 from IEEE 802.11-14/0571r12 - 11ax
74 //!< Evaluation Methodology)
75 };
76
77 /// Parameters for each traffic model
78 using TrafficModels = std::map<TrafficModelClassIdentifier, TrafficModelParameters>;
79
80 static const TrafficModels m_trafficModels; //!< Traffic models as defined in Table 5 from IEEE
81 //!< 802.11-14/0571r12 - 11ax Evaluation Methodology
82
83 int64_t AssignStreams(int64_t stream) override;
84
85 protected:
86 void DoInitialize() override;
87
88 private:
89 void DoStartApplication() override;
90 void DoConnectionSucceeded(Ptr<Socket> socket) override;
91 void CancelEvents() override;
92
93 /**
94 * Schedule send of a packet with a random latency
95 */
96 void SendWithLatency();
97
98 /**
99 * Effectively send a packet once the latency has elapsed
100 * @param eventId the event ID
101 * @param size the size of the packet to send (in bytes)
102 * @param latency the latency applied to that packet
103 */
104 void Send(uint64_t eventId, uint32_t size, Time latency);
105
106 /**
107 * Schedule the next frame generation
108 */
109 void ScheduleNextFrame();
110
111 /**
112 * Generate new video frame
113 */
114 void GenerateVideoFrame();
115
116 /**
117 * @return the payload size of the next packet to transmit (in bytes)
118 */
120
121 /**
122 * Handle a Data Sent event
123 *
124 * @param socket the connected socket
125 * @param size the amount of transmitted bytes
126 */
127 void TxDone(Ptr<Socket> socket, uint32_t size);
128
129 /**
130 * Handle a Send event
131 *
132 * @param socket the connected socket
133 * @param available the amount of available bytes for transmission
134 */
135 void TxAvailable(Ptr<Socket> socket, uint32_t available);
136
137 TrafficModelClassIdentifier m_trafficModelClassId; //!< The Traffic Model Class Identifier
138 DataRate m_bitRate; //!< Video bit rate (if model is custom)
139 double m_frameSizeBytesScale; //!< Scale parameter for the Weibull distribution used to generate
140 //!< size of video frames (if model is custom)
141 double m_frameSizeBytesShape; //!< Shape parameter for the Weibull distribution used to generate
142 //!< size of video frames (if model is custom)
143 double
144 m_latencyMsScale; //!< Scale parameter for the Gamma distribution used to generate latency
145 double
146 m_latencyMsShape; //!< Shape parameter for the Gamma distribution used to generate latency
147
149 m_frameSizeBytes; //!< Weibull random variable to generate size of video frames (in bytes)
151 m_latencyMs; //!< Gamma random variable to generate latency (in milliseconds)
152
153 std::optional<uint32_t> m_maxSize; //!< Limit on the number of bytes that can be sent at once
154 //!< over the network, hence we limit at application level to
155 //!< apply the latency to each transmitted packet
156 uint32_t m_remainingSize{0}; //!< Number of bytes to send directly to the socket because current
157 //!< video frame is too large to be sent at once
158 Time m_interArrival; //!< Calculated inter arrival duration between two generated packets
159
160 EventId m_generateFrameEvent; //!< Event ID of pending frame generation event
161 std::deque<uint32_t> m_generatedFrames; //!< Hold size of generated video frames
162
163 std::map<uint64_t, EventId> m_sendEvents; //!< Event IDs of pending TX events
164 uint64_t m_nextEventId{0}; //!< The next event ID
165
166 /// Structure to store information about packets that are not successfully transmitted
168 {
169 uint64_t id; //!< the associated TX event ID
170 Ptr<Packet> packet; //!< the packet to transmit
171 Time latency; //!< the networking latency applied to the first transmission attempt
172 };
173
174 std::deque<UnsentPacketInfo> m_unsentPackets; //!< Hold unsent packet for later attempt
175
176 /**
177 * TracedCallback signature for packet and latency.
178 *
179 * @param [in] packet The packet.
180 * @param [in] latency The networking latency.
181 */
182 typedef void (*TxTracedCallback)(Ptr<const Packet> packet, Time latency);
183
184 /// Traced Callback: transmitted packets and their latencies.
186
187 /// Traced Callback: generated frames (amount of payload bytes).
189};
190
191} // namespace ns3
192
193#endif /* TGAX_VIDEO_TRAFFIC_H */
Class for representing data rates.
Definition data-rate.h:78
An identifier for simulation events.
Definition event-id.h:45
The gamma distribution Random Number Generator (RNG) that allows stream numbers to be set determinist...
Smart pointer class similar to boost::intrusive_ptr.
Definition ptr.h:70
SourceApplication(bool allowPacketSocket=true)
Constructor.
static const TrafficModels m_trafficModels
Traffic models as defined in Table 5 from IEEE 802.11-14/0571r12 - 11ax Evaluation Methodology.
void TxAvailable(Ptr< Socket > socket, uint32_t available)
Handle a Send event.
std::map< uint64_t, EventId > m_sendEvents
Event IDs of pending TX events.
Ptr< GammaRandomVariable > m_latencyMs
Gamma random variable to generate latency (in milliseconds).
std::deque< UnsentPacketInfo > m_unsentPackets
Hold unsent packet for later attempt.
void SendWithLatency()
Schedule send of a packet with a random latency.
void CancelEvents() override
Cancel all pending events.
double m_frameSizeBytesShape
Shape parameter for the Weibull distribution used to generate size of video frames (if model is custo...
void DoStartApplication() override
Application specific startup code for child subclasses.
DataRate m_bitRate
Video bit rate (if model is custom).
TracedCallback< Ptr< const Packet >, Time > m_txLatencyTrace
Traced Callback: transmitted packets and their latencies.
EventId m_generateFrameEvent
Event ID of pending frame generation event.
Ptr< WeibullRandomVariable > m_frameSizeBytes
Weibull random variable to generate size of video frames (in bytes).
double m_latencyMsShape
Shape parameter for the Gamma distribution used to generate latency.
Time m_interArrival
Calculated inter arrival duration between two generated packets.
std::deque< uint32_t > m_generatedFrames
Hold size of generated video frames.
static TypeId GetTypeId()
Get the type ID.
void DoInitialize() override
Initialize() implementation.
std::map< TrafficModelClassIdentifier, TrafficModelParameters > TrafficModels
Parameters for each traffic model.
void DoConnectionSucceeded(Ptr< Socket > socket) override
Application specific code for child subclasses upon a Connection Succeed event.
uint32_t m_remainingSize
Number of bytes to send directly to the socket because current video frame is too large to be sent at...
void(* TxTracedCallback)(Ptr< const Packet > packet, Time latency)
TracedCallback signature for packet and latency.
double m_latencyMsScale
Scale parameter for the Gamma distribution used to generate latency.
double m_frameSizeBytesScale
Scale parameter for the Weibull distribution used to generate size of video frames (if model is custo...
void ScheduleNextFrame()
Schedule the next frame generation.
uint64_t m_nextEventId
The next event ID.
void GenerateVideoFrame()
Generate new video frame.
std::optional< uint32_t > m_maxSize
Limit on the number of bytes that can be sent at once over the network, hence we limit at application...
TrafficModelClassIdentifier m_trafficModelClassId
The Traffic Model Class Identifier.
TrafficModelClassIdentifier
TrafficModelClassIdentifier enumeration.
void TxDone(Ptr< Socket > socket, uint32_t size)
Handle a Data Sent event.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this Application object.
TracedCallback< uint32_t > m_frameGeneratedTrace
Traced Callback: generated frames (amount of payload bytes).
Simulation virtual time values and global simulation resolution.
Definition nstime.h:95
Forward calls to a chain of Callback.
a unique identifier for an interface.
Definition type-id.h:50
The Weibull distribution Random Number Generator (RNG) which allows stream numbers to be set determin...
static void Send(Ptr< NetDevice > dev, int level, std::string emuMode)
Every class exported by the ns3 library is enclosed in the ns3 namespace.
List of parameters for a given traffic model.
double frameSizeBytesScale
scale parameter for the Weibull distribution used to generate size of video frames in bytes (correspo...
double frameSizeBytesShape
shape parameter for the Weibull distribution used to generate size of video frames in bytes (correspo...
Structure to store information about packets that are not successfully transmitted.
uint64_t id
the associated TX event ID
Time latency
the networking latency applied to the first transmission attempt
Ptr< Packet > packet
the packet to transmit