11#include "ns3/double.h"
13#include "ns3/inet-socket-address.h"
14#include "ns3/inet6-socket-address.h"
17#include "ns3/nstime.h"
18#include "ns3/packet-socket-address.h"
19#include "ns3/packet.h"
20#include "ns3/random-variable-stream.h"
21#include "ns3/simulator.h"
22#include "ns3/socket-factory.h"
23#include "ns3/socket.h"
24#include "ns3/tcp-socket-factory.h"
25#include "ns3/udp-socket-factory.h"
26#include "ns3/uinteger.h"
40 {TrafficModelClassIdentifier::BUFFERED_VIDEO_1, {{
"2Mbps"}, 6950, 0.8099}},
41 {TrafficModelClassIdentifier::BUFFERED_VIDEO_2, {{
"4Mbps"}, 13900, 0.8099}},
42 {TrafficModelClassIdentifier::BUFFERED_VIDEO_3, {{
"6Mbps"}, 20850, 0.8099}},
43 {TrafficModelClassIdentifier::BUFFERED_VIDEO_4, {{
"8Mbps"}, 27800, 0.8099}},
44 {TrafficModelClassIdentifier::BUFFERED_VIDEO_5, {{
"10Mbps"}, 34750, 0.8099}},
45 {TrafficModelClassIdentifier::BUFFERED_VIDEO_6, {{
"15600Kbps"}, 54210, 0.8099}},
46 {TrafficModelClassIdentifier::MULTICAST_VIDEO_1, {{
"3Mbps"}, 10425, 0.8099}},
47 {TrafficModelClassIdentifier::MULTICAST_VIDEO_2, {{
"6Mbps"}, 20850, 0.8099}}
57 TypeId(
"ns3::TgaxVideoTraffic")
59 .SetGroupName(
"Applications")
62 "TrafficModelClassIdentifier",
63 "The Traffic Model Class Identifier to use (use Custom for custom settings)",
88 "The type of protocol to use. This should be a subclass of ns3::SocketFactory",
93 .AddAttribute(
"CustomVideoBitRate",
94 "The video bit rate (if TrafficModelClassIdentifier is Custom).",
100 .AddAttribute(
"CustomFrameSizeScale",
101 "Scale parameter for the Weibull distribution to calculate the video "
102 "frame size in bytes (if TrafficModelClassIdentifier is Custom).",
108 .AddAttribute(
"CustomFrameSizeShape",
109 "Shape parameter for the Weibull distribution to calculate the video "
110 "frame size in bytes (if TrafficModelClassIdentifier is Custom).",
116 .AddAttribute(
"LatencyShape",
117 "Shape parameter for the Gamma distribution to calculate the network "
118 "latency in milliseconds.",
124 .AddAttribute(
"LatencyScale",
125 "Rate parameter for the Gamma distribution to calculate the network "
126 "latency in milliseconds. If set to 0 (default), no latency is added."
127 "In the reference model, this is set to 60.227ms because it uses a link "
128 "simulator that doesn't actually have queues and TCP models.",
136 "A video packet is sent, this trace also reports the latency applied to the packet",
138 "ns3::TgaxVideoTraffic::TxTracedCallback")
139 .AddTraceSource(
"VideoFrameGenerated",
140 "A video frame is generated, this trace reports the amount of payload "
141 "bytes in the generated frame",
143 "ns3::TracedValueCallback::Uint32");
163 auto currentStream = stream;
166 return (currentStream - stream);
183 "Cannot use TCP protocol with multicast video traffic model");
206 m_socket->GetAttribute(
"SegmentSize", uintegerValue);
228 sendEvent.second.Cancel();
250 while (frameSize == 0)
274 if (
const auto limit =
m_maxSize.value_or(
m_socket->GetTxAvailable()); frameSize > limit)
297 <<
" video traffic source schedule to sent " << size
298 <<
" bytes after latency of " << latency.As(
Time::US));
315 const auto actual =
static_cast<unsigned int>(
m_socket->Send(packet));
328 << size <<
" bytes to "
335 << size <<
" bytes to "
342 NS_LOG_DEBUG(
"Unable to send packet; actual " << actual <<
" size " << size
343 <<
"; caching for later attempt");
381 const auto size = unsentPacketInfo.packet->GetSize();
382 if (available >= size)
385 NS_LOG_DEBUG(
"Retry packet " << unsentPacketInfo.id <<
" with size " << size);
386 Send(unsentPacketInfo.id, size, unsentPacketInfo.latency);
Class for representing data rates.
AttributeValue implementation for DataRate.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
Hold variables of type enum.
The gamma distribution Random Number Generator (RNG) that allows stream numbers to be set determinist...
static Inet6SocketAddress ConvertFrom(const Address &addr)
Convert the address to a InetSocketAddress.
static bool IsMatchingType(const Address &addr)
If the address match.
static bool IsMatchingType(const Address &address)
static InetSocketAddress ConvertFrom(const Address &address)
Returns an InetSocketAddress which corresponds to the input Address.
virtual void DoInitialize()
Initialize() implementation.
Smart pointer class similar to boost::intrusive_ptr.
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
static Time Now()
Return the current simulation virtual time.
TypeId m_protocolTid
Protocol TypeId value.
SourceApplication(bool allowPacketSocket=true)
Constructor.
Ptr< Socket > m_socket
Socket.
TracedCallback< Ptr< const Packet > > m_txTrace
Traced Callback: transmitted packets.
bool m_connected
flag whether socket is connected
Address m_peer
Peer address.
static TypeId GetTypeId()
Get the type ID.
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 GetNextPayloadSize()
uint32_t m_remainingSize
Number of bytes to send directly to the socket because current video frame is too large to be sent at...
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.
~TgaxVideoTraffic() override
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.
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.
static Time FromDouble(double value, Unit unit)
Create a Time equal to value in unit unit.
a unique identifier for an interface.
@ ATTR_GET
The attribute can be read.
@ ATTR_CONSTRUCT
The attribute can be written at construction-time.
TypeId SetParent(TypeId tid)
Set the parent TypeId.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
The Weibull distribution Random Number Generator (RNG) which allows stream numbers to be set determin...
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file,...
Ptr< const AttributeAccessor > MakeDataRateAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeDataRateChecker()
Ptr< const AttributeChecker > MakeDoubleChecker()
Ptr< const AttributeAccessor > MakeDoubleAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeAccessor > MakeEnumAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Ptr< const AttributeChecker > MakeTypeIdChecker()
Ptr< const AttributeAccessor > MakeTypeIdAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Callback< R, Args... > MakeCallback(R(T::*memPtr)(Args...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Ptr< const TraceSourceAccessor > MakeTraceSourceAccessor(T a)
Create a TraceSourceAccessor which will control access to the underlying trace source.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< const AttributeChecker > MakeEnumChecker(T v, std::string n, Ts... args)
Make an EnumChecker pre-configured with a set of allowed values by name.