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/data-rate.h"
15#include "ns3/event-id.h"
16#include "ns3/traced-callback.h"
17
18#include <deque>
19#include <map>
20#include <optional>
21
22namespace ns3
23{
24
27
28/**
29 * @ingroup applications
30 * @brief Generate video traffic.
31 *
32 * This video traffic generator implements the Buffered Video Steaming model from IEEE
33 * 802.11-14/0571r12 - 11ax Evaluation Methodology (see applications documentation for
34 * full citation).
35 */
37{
38 public:
39 /**
40 * @brief Get the type ID.
41 * @return the object TypeId
42 */
43 static TypeId GetTypeId();
44
46 ~TgaxVideoTraffic() override;
47
48 /// TrafficModelClassIdentifier enumeration
49 enum class TrafficModelClassIdentifier : uint8_t
50 {
51 CUSTOM = 0, //< Custom traffic model (by default, load parameters of Buffered Video Model 1)
52 BUFFERED_VIDEO_1, //< Buffered Video Model 1
53 BUFFERED_VIDEO_2, //< Buffered Video Model 2
54 BUFFERED_VIDEO_3, //< Buffered Video Model 3
55 BUFFERED_VIDEO_4, //< Buffered Video Model 4
56 BUFFERED_VIDEO_5, //< Buffered Video Model 5
57 BUFFERED_VIDEO_6, //< Buffered Video Model 6
58 MULTICAST_VIDEO_1, //< Multicast Video Model 1
59 MULTICAST_VIDEO_2 //< Multicast Video Model 2
60 };
61
62 /// List of parameters for a given traffic model
64 {
65 DataRate bitRate; //!< video bit rate
66 double frameSizeBytesScale; //!< scale parameter for the Weibull distribution used to
67 //!< generate size of video frames in bytes (corresponds to
68 //!< lambda parameter in table 5 from IEEE 802.11-14/0571r12 -
69 //!< 11ax Evaluation Methodology)
70 double frameSizeBytesShape; //!< shape parameter for the Weibull distribution used to
71 //!< generate size of video frames in bytes (corresponds to k
72 //!< parameter in table 5 from IEEE 802.11-14/0571r12 - 11ax
73 //!< Evaluation Methodology)
74 };
75
76 /// Parameters for each traffic model
77 using TrafficModels = std::map<TrafficModelClassIdentifier, TrafficModelParameters>;
78
79 static const TrafficModels m_trafficModels; //!< Traffic models as defined in Table 5 from IEEE
80 //!< 802.11-14/0571r12 - 11ax Evaluation Methodology
81
82 int64_t AssignStreams(int64_t stream) override;
83
84 protected:
85 void DoInitialize() override;
86
87 private:
88 void DoStartApplication() override;
89 void DoConnectionSucceeded(Ptr<Socket> socket) override;
90 void CancelEvents() override;
91
92 /**
93 * Schedule send of a packet with a random latency
94 */
95 void SendWithLatency();
96
97 /**
98 * Effectively send a packet once the latency has elapsed
99 * @param eventId the event ID
100 * @param size the size of the packet to send (in bytes)
101 * @param latency the latency applied to that packet
102 */
103 void Send(uint64_t eventId, uint32_t size, Time latency);
104
105 /**
106 * Schedule the next frame generation
107 */
108 void ScheduleNextFrame();
109
110 /**
111 * Generate new video frame
112 */
113 void GenerateVideoFrame();
114
115 /**
116 * @return the payload size of the next packet to transmit (in bytes)
117 */
119
120 /**
121 * Handle a Data Sent event
122 *
123 * @param socket the connected socket
124 * @param size the amount of transmitted bytes
125 */
126 void TxDone(Ptr<Socket> socket, uint32_t size);
127
128 /**
129 * Handle a Send event
130 *
131 * @param socket the connected socket
132 * @param available the amount of available bytes for transmission
133 */
134 void TxAvailable(Ptr<Socket> socket, uint32_t available);
135
136 TrafficModelClassIdentifier m_trafficModelClassId; //!< The Traffic Model Class Identifier
137 DataRate m_bitRate; //!< Video bit rate (if model is custom)
138 double m_frameSizeBytesScale; //!< Scale parameter for the Weibull distribution used to generate
139 //!< size of video frames (if model is custom)
140 double m_frameSizeBytesShape; //!< Shape parameter for the Weibull distribution used to generate
141 //!< size of video frames (if model is custom)
142 double
143 m_latencyMsScale; //!< Scale parameter for the Gamma distribution used to generate latency
144 double
145 m_latencyMsShape; //!< Shape parameter for the Gamma distribution used to generate latency
146
148 m_frameSizeBytes; //!< Weibull random variable to generate size of video frames (in bytes)
150 m_latencyMs; //!< Gamma random variable to generate latency (in milliseconds)
151
152 std::optional<uint32_t> m_maxSize; //!< Limit on the number of bytes that can be sent at once
153 //!< over the network, hence we limit at application level to
154 //!< apply the latency to each transmitted packet
155 uint32_t m_remainingSize{0}; //!< Number of bytes to send directly to the socket because current
156 //!< video frame is too large to be sent at once
157 Time m_interArrival; //!< Calculated inter arrival duration between two generated packets
158
159 EventId m_generateFrameEvent; //!< Event ID of pending frame generation event
160 std::deque<uint32_t> m_generatedFrames; //!< Hold size of generated video frames
161
162 std::map<uint64_t, EventId> m_sendEvents; //!< Event IDs of pending TX events
163 uint64_t m_nextEventId{0}; //!< The next event ID
164
165 /// Structure to store information about packets that are not successfully transmitted
167 {
168 uint64_t id; //!< the associated TX event ID
169 Ptr<Packet> packet; //!< the packet to transmit
170 Time latency; //!< the networking latency applied to the first transmission attempt
171 };
172
173 std::deque<UnsentPacketInfo> m_unsentPackets; //!< Hold unsent packet for later attempt
174
175 /**
176 * TracedCallback signature for packet and latency.
177 *
178 * @param [in] packet The packet.
179 * @param [in] latency The networking latency.
180 */
181 typedef void (*TxTracedCallback)(Ptr<const Packet> packet, Time latency);
182
183 /// Traced Callback: transmitted packets and their latencies.
185
186 /// Traced Callback: generated frames (amount of payload bytes).
188};
189
190} // namespace ns3
191
192#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.
void Send(uint64_t eventId, uint32_t size, Time latency)
Effectively send a packet once the latency has elapsed.
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...
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