9#include "ns3/application-container.h"
10#include "ns3/application-helper.h"
11#include "ns3/config.h"
13#include "ns3/inet-socket-address.h"
14#include "ns3/internet-stack-helper.h"
15#include "ns3/ipv4-address-helper.h"
16#include "ns3/ipv4-address.h"
17#include "ns3/ipv4-interface-container.h"
18#include "ns3/ipv4-l3-protocol.h"
19#include "ns3/ipv4-list-routing-helper.h"
20#include "ns3/ipv4-static-routing-helper.h"
21#include "ns3/ipv4-static-routing.h"
22#include "ns3/node-container.h"
24#include "ns3/nstime.h"
25#include "ns3/packet-sink-helper.h"
26#include "ns3/packet-sink.h"
27#include "ns3/rng-seed-manager.h"
28#include "ns3/simple-net-device-helper.h"
29#include "ns3/string.h"
31#include "ns3/tgax-video-traffic.h"
32#include "ns3/traced-callback.h"
55 auto sub = context.substr(10);
56 auto pos = sub.find(
"/Device");
57 return std::stoi(sub.substr(0, pos));
149 const std::string& protocol,
150 double expectedBitRate,
151 std::optional<TgaxVideoTraffic::TrafficModelParameters> parameters = {},
152 std::optional<uint32_t> txBufferSizeLimit = {});
156 void DoRun()
override;
182 std::optional<TgaxVideoTraffic::TrafficModelParameters>
184 std::optional<uint32_t>
197 const std::string& protocol,
198 double expectedBitRate,
199 std::optional<TgaxVideoTraffic::TrafficModelParameters> parameters,
200 std::optional<uint32_t> txBufferSizeLimit)
216 m_sent += packet->GetSize();
255 const std::string multicastAddress =
"239.192.100.1";
262 nodes.Add(receivers);
272 listRouting.
Add(staticRouting, 0);
273 internet.SetRoutingHelper(listRouting);
275 internet.Install(
nodes);
278 ipv4Helper.
SetBase(
"10.11.12.0",
"255.255.255.0");
279 auto interfaces = ipv4Helper.
Assign(devices);
283 auto ipv4 = sender->GetObject<
Ipv4>();
285 routing->AddHostRouteTo(multicastAddress.c_str(),
286 ipv4->GetInterfaceForDevice(sender->GetDevice(0)),
292 : interfaces.GetAddress(1),
295 const std::string protocol =
"ns3::" +
m_protocol +
"SocketFactory";
307 auto sourceApp = sourceHelper.
Install(sender);
312 auto sinkApps = sinkHelper.
Install(receivers);
316 int64_t streamNumber = 55;
320 "/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::TgaxVideoTraffic/TxWithLatency",
324 "/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::TgaxVideoTraffic/VideoFrameGenerated",
339 for (std::size_t i = 0; i <
m_received.size(); ++i)
343 "Did not receive all transmitted video frames for receiver " << i);
344 const auto measuredBitrate =
349 "Unexpected video bit rate " << measuredBitrate
350 <<
" for receiver " << i);
353 const auto averageFrameSize =
359 const auto expectedInterFrameDuration =
361 std::vector<Time> interFrameDurations;
365 std::back_inserter(interFrameDurations),
366 [](
const auto& lhs,
const auto& rhs) { return (rhs - lhs); });
367 const auto totalInterFrameDurations =
368 std::accumulate(interFrameDurations.cbegin(),
369 interFrameDurations.cend(),
371 [](
auto sum,
const auto t) {
return sum + t; });
372 const auto interFrameDuration = totalInterFrameDurations / interFrameDurations.size();
374 expectedInterFrameDuration,
376 "Unexpected frame interval");
378 const auto totalLatency = std::accumulate(
m_latencies.cbegin(),
381 [](
auto sum,
auto latency) {
return sum + latency; });
382 const auto avgLatency = totalLatency /
m_latencies.size();
386 "Unexpected average networking latency");
404 for (
const auto& protocol : {
"Tcp",
"Udp"})
455 {{
DataRate(
"20Mbps"), 15000, 1.0}}),
TGax Video traffic test, check for the expected inter frame interval, bit rate and packets inter arri...
std::vector< Time > m_latencies
Store latency applied to each transmitted packet.
std::vector< uint64_t > m_received
number of bytes received per receiver
void FrameGenerated(uint32_t size)
Record video frame generated.
std::optional< uint32_t > m_txBufferSizeLimit
Optional limit for the TX buffer size of the TCP socket.
void DoRun() override
Implementation to actually run this TestCase.
TgaxVideoTraffic::TrafficModelClassIdentifier m_model
Selected buffered video traffic model.
void DoSetup() override
Implementation to do any local setup required for this TestCase.
TgaxVideoTrafficTestCase(TgaxVideoTraffic::TrafficModelClassIdentifier model, const std::string &protocol, double expectedBitRate, std::optional< TgaxVideoTraffic::TrafficModelParameters > parameters={}, std::optional< uint32_t > txBufferSizeLimit={})
Constructor.
std::string m_protocol
Udp or Tcp protocol.
std::optional< TgaxVideoTraffic::TrafficModelParameters > m_parameters
Optional traffic model parameters (used for custom traffic model).
std::vector< Time > m_generatedFrames
Store time at which each frame has been generated.
double m_expectedBitRate
Expected video bit rate.
void ReceiveRx(std::string context, Ptr< const Packet > p, const Address &addr)
Record a packet successfully received.
void PacketSent(Ptr< const Packet > packet, Time latency)
Record a packets successfully sent.
uint64_t m_sent
number of bytes sent
TgaxVideoTraffic TestSuite.
TgaxVideoTrafficTestSuite()
a polymophic address class
AttributeValue implementation for Address.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
A helper to make it easier to instantiate an application on a set of nodes.
ApplicationContainer Install(NodeContainer c)
Install an application on each node of the input container configured with all the attributes set wit...
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assigns a unique (monotonically increasing) stream number to all applications that match the configur...
void SetAttribute(const std::string &name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
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.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
static Ipv4Address GetAny()
Access to the IPv4 forwarding table, interfaces, and configuration.
Helper class that adds ns3::Ipv4ListRouting objects.
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
Helper class that adds ns3::Ipv4StaticRouting objects.
Ptr< Ipv4StaticRouting > GetStaticRouting(Ptr< Ipv4 > ipv4) const
Try and find the static routing protocol as either the main routing protocol or in the list of routin...
keep track of a set of node pointers.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
Smart pointer class similar to boost::intrusive_ptr.
static void SetRun(uint64_t run)
Set the run number of simulation.
static void SetSeed(uint32_t seed)
Set the seed.
build a set of SimpleNetDevice objects
NetDeviceContainer Install(Ptr< Node > node) const
This method creates an ns3::SimpleChannel with the attributes configured by SimpleNetDeviceHelper::Se...
static void Destroy()
Execute the events scheduled with ScheduleDestroy().
static Time Now()
Return the current simulation virtual time.
static void Run()
Run the simulation.
Hold variables of type string.
void AddTestCase(TestCase *testCase, Duration duration=Duration::QUICK)
Add an individual child TestCase to this test suite.
TestCase(const TestCase &)=delete
Caller graph was not generated because of its size.
TestSuite(std::string name, Type type=Type::UNIT)
Construct a new test suite.
static const TrafficModels m_trafficModels
Traffic models as defined in Table 5 from IEEE 802.11-14/0571r12 - 11ax Evaluation Methodology.
static TypeId GetTypeId()
Get the type ID.
TrafficModelClassIdentifier
TrafficModelClassIdentifier enumeration.
Simulation virtual time values and global simulation resolution.
Hold an unsigned integer type.
double GetMean() const
Returns the mean value for the Weibull distribution returned by this RNG stream.
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...
void SetDefault(std::string name, const AttributeValue &value)
void Connect(std::string path, const CallbackBase &cb)
void ConnectWithoutContext(std::string path, const CallbackBase &cb)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
#define NS_TEST_ASSERT_MSG_EQ(actual, limit, msg)
Test that an actual and expected (limit) value are equal and report and abort if not.
#define NS_TEST_EXPECT_MSG_EQ_TOL(actual, limit, tol, msg)
Test that actual and expected (limit) values are equal to plus or minus some tolerance and report if ...
Time Seconds(double value)
Construct a Time in the indicated unit.
bool IsMulticast(TgaxVideoTraffic::TrafficModelClassIdentifier model)
Get whether a model applies to multicast video traffic.
uint32_t ConvertContextToNodeId(const std::string &context)
Get the node ID from the context string.
std::string ModelToString(TgaxVideoTraffic::TrafficModelClassIdentifier model)
Get the string from the traffic model enum.
const auto simulationTime
The simulation time.
uint32_t GetAverageframeSize(double frameSizeBytesScale, double frameSizeBytesShape)
Get the expected average frame size.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static TgaxVideoTrafficTestSuite g_TgaxVideoTrafficTestSuite
Static variable for test initialization.