9#include "ns3/application-container.h"
10#include "ns3/application-helper.h"
11#include "ns3/config.h"
12#include "ns3/double.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/node-container.h"
22#include "ns3/nstime.h"
23#include "ns3/packet-sink-helper.h"
24#include "ns3/packet-sink.h"
25#include "ns3/packet-socket-address.h"
26#include "ns3/pointer.h"
27#include "ns3/rng-seed-manager.h"
28#include "ns3/rta-tig-mobile-gaming.h"
29#include "ns3/simple-net-device-helper.h"
30#include "ns3/string.h"
32#include "ns3/traced-callback.h"
88 void DoRun()
override;
134 m_sent.push_back({packet->GetSize(), now, stage});
155 const auto simulationTime =
Seconds(60);
169 internet.Install(
nodes);
172 ipv4Helper.
SetBase(
"10.11.12.0",
"255.255.255.0");
173 auto interfaces = ipv4Helper.
Assign(devices);
207 auto sourceApp = sourceHelper.
Install(sender);
208 const auto startAppTime =
Seconds(1.0);
209 sourceApp.Start(startAppTime);
210 sourceApp.Stop(startAppTime + simulationTime);
214 auto sinkApp = sinkHelper.
Install(receiver);
216 sinkApp.Stop(
Seconds(2.0) + simulationTime);
218 int64_t streamNumber = 100;
222 "/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::RtaTigMobileGaming/TxWithStage",
236 std::accumulate(
m_sent.cbegin(),
m_sent.cend(), 0ULL, [](
auto sum,
const auto& tx) {
237 return sum + tx.length;
243 "First received packet is not an initial packet");
246 "Last received packet is not an ending packet");
247 const auto allGamingPackets =
248 std::all_of(
m_sent.cbegin() + 1,
m_sent.cend() - 1, [](
const auto& tx) {
249 return tx.stage == RtaTigMobileGaming::TrafficModelStage::GAMING;
255 "Size of initial packet is lower than expected");
258 "Size of initial packet is higher than expected");
262 "Size of end packet is lower than expected");
265 "Size of end packet is higher than expected");
267 const auto totalGamingTx =
268 std::accumulate(
m_sent.cbegin() + 1,
m_sent.cend() - 1, 0.0, [](
auto sum,
const auto& tx) {
269 return sum + tx.length;
271 const auto averageGamingPacketSize = totalGamingTx / (
m_sent.size() - 2);
272 const auto expectedAverageGamingPacketSize =
276 expectedAverageGamingPacketSize,
278 "Unexpected average gaming packet size");
280 std::vector<Time> packetArrivals;
281 std::transform(
m_sent.cbegin(),
284 std::back_inserter(packetArrivals),
285 [](
const auto& lhs,
const auto& rhs) { return (rhs.tstamp - lhs.tstamp); });
286 const auto totalPacketArrivals =
287 std::accumulate(packetArrivals.cbegin(),
288 packetArrivals.cend(),
290 [](
auto sum,
const auto t) {
return sum + t; });
291 const auto averagePacketArrivalUs =
292 static_cast<double>(totalPacketArrivals.GetMicroSeconds()) / packetArrivals.size();
294 m_params.packetArrivalLevLocation.GetMicroSeconds(),
295 m_params.packetArrivalLevScale.GetMicroSeconds());
297 expectedAveragePacketArrivalUs,
298 0.01 * expectedAveragePacketArrivalUs,
299 "Unexpected average packet arrival");
315 :
TestSuite(
"applications-rta-tig-mobile-gaming",
Type::UNIT)
318 "Check real-time mobile gaming traffic for DL status-sync",
322 "Check real-time mobile gaming traffic for UL status-sync",
326 "Check real-time mobile gaming traffic for DL lockstep",
330 "Check real-time mobile gaming traffic for UL lockstep",
RT mobile gaming traffic test.
uint64_t m_received
number of bytes received
void ReceiveRx(std::string context, Ptr< const Packet > p, const Address &addr)
Record a packet successfully received.
GamingParams m_params
parameters of the model
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void DoRun() override
Implementation to actually run this TestCase.
RtaTigMobileGamingTestCase(const std::string &name, const GamingParams ¶ms)
Constructor.
std::vector< TxInfo > m_sent
transmitted gaming packets
void PacketTx(Ptr< const Packet > packet, RtaTigMobileGaming::TrafficModelStage stage)
Record a packets successfully sent.
RtaTigMobileGaming TestSuite.
RtaTigMobileGamingTestSuite()
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.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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()
double GetMean() const
Returns the mean value for the Largest Extreme Value distribution returned by this RNG stream.
keep track of a set of node pointers.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
AttributeValue implementation for Pointer.
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.
static TypeId GetTypeId()
Get the type ID.
TrafficModelStage
Traffic model stages.
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.
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.
Simulation virtual time values and global simulation resolution.
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 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.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
#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 ...
#define NS_TEST_ASSERT_MSG_LT_OR_EQ(actual, limit, msg)
Test that an actual value is less than or equal to a limit and report and abort if not.
#define NS_TEST_ASSERT_MSG_GT_OR_EQ(actual, limit, msg)
Test that an actual value is greater than or equal to a limit and report and abort if not.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Time MilliSeconds(uint64_t value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static RtaTigMobileGamingTestSuite g_RtaTigMobileGamingTestSuite
Static variable for test initialization.
Information about gaming parameters.
Time packetArrivalLevLocation
Location of largest extreme value distribution used to calculate packet arrivals.
Time packetArrivalLevScale
Scale of largest extreme value distribution used to calculate packet arrivals.
uint32_t maxEndPacketSize
Maximum size in bytes for end packet payload.
uint32_t maxInitialPacketSize
Maximum size in bytes for initial packet payload.
double packetSizeLevScale
Scale of largest extreme value distribution used to calculate packet sizes.
uint32_t minInitialPacketSize
Minimum size in bytes for initial packet payload.
uint32_t minEndPacketSize
Minimum size in bytes for end packet payload.
uint32_t packetSizeLevLocation
Location of largest extreme value distribution used to calculate packet sizes.
Information about transmitted packet.
Time tstamp
timestamp at which the packet is transmitted
RtaTigMobileGaming::TrafficModelStage stage
traffic model stage when the packet is transmitted
uint32_t length
length of the packet in bytes