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/internet-stack-helper.h"
14#include "ns3/ipv4-address-helper.h"
15#include "ns3/ipv4-address.h"
16#include "ns3/ipv4-interface-container.h"
17#include "ns3/ipv4-l3-protocol.h"
18#include "ns3/ipv4-list-routing-helper.h"
19#include "ns3/node-container.h"
21#include "ns3/nstime.h"
22#include "ns3/packet-sink-helper.h"
23#include "ns3/packet-sink.h"
24#include "ns3/pointer.h"
25#include "ns3/rng-seed-manager.h"
26#include "ns3/simple-net-device-helper.h"
27#include "ns3/string.h"
29#include "ns3/tgax-virtual-desktop.h"
30#include "ns3/traced-callback.h"
61 "41.0 3.2;1478.3 11.6"};
74 void DoRun()
override;
134 const auto simulationTime =
Seconds(600);
148 internet.Install(
nodes);
151 ipv4Helper.
SetBase(
"10.11.12.0",
"255.255.255.0");
152 auto interfaces = ipv4Helper.
Assign(devices);
157 const auto protocol =
"ns3::TcpSocketFactory";
167 auto sourceApp = sourceHelper.
Install(sender);
172 auto sinkApp = sinkHelper.
Install(receiver);
174 sinkApp.Stop(
Seconds(2.0) + simulationTime);
176 int64_t streamNumber = 100;
180 "/NodeList/*/$ns3::Node/ApplicationList/*/$ns3::TgaxVirtualDesktop/Tx",
194 std::accumulate(
m_sent.cbegin(),
m_sent.cend(), 0ULL, [](
auto sum,
const auto& tx) {
195 return sum + tx.size;
199 const auto delayConnectionEstablished =
MilliSeconds(18);
201 delayConnectionEstablished,
203 "Initial packet arrival larger than upper bound");
205 std::vector<Time> packetArrivals;
206 std::transform(
m_sent.cbegin(),
209 std::back_inserter(packetArrivals),
210 [](
const auto& lhs,
const auto& rhs) { return (rhs.tstamp - lhs.tstamp); });
211 const auto totalPacketArrivals =
212 std::accumulate(packetArrivals.cbegin(),
213 packetArrivals.cend(),
215 [](
auto sum,
const auto t) {
return sum + t; });
216 const auto averagePacketArrivalNs =
217 static_cast<double>(totalPacketArrivals.GetNanoSeconds()) / packetArrivals.size();
218 const auto expectedAveragePacketArrivalNs =
m_params.meanPacketArrivalTime.GetNanoSeconds();
220 expectedAveragePacketArrivalNs,
221 0.01 * expectedAveragePacketArrivalNs,
222 "Unexpected average packet arrival");
224 const auto averagePacketSize =
static_cast<double>(totalTx) /
m_sent.size();
225 const auto modalPos =
m_params.parametersPacketSize.find(
';');
226 double expectedAveragePacketSize{};
227 auto pos =
m_params.parametersPacketSize.find(
' ');
228 const auto mu1 =
m_params.parametersPacketSize.substr(0, pos);
229 const auto mean1 = std::stod(mu1);
230 if (modalPos == std::string::npos)
233 expectedAveragePacketSize = mean1;
238 auto mode2 =
m_params.parametersPacketSize.substr(modalPos + 1,
239 m_params.parametersPacketSize.size() - 1);
240 pos = mode2.find(
' ');
241 const auto mu2 = mode2.substr(0, pos);
242 const auto mean2 = std::stod(mu2);
243 const auto bernoulliProb = 22.4 / 76.1;
244 expectedAveragePacketSize = (mean1 * (1 - bernoulliProb)) + (mean2 * bernoulliProb);
248 expectedAveragePacketSize,
249 0.015 * expectedAveragePacketSize,
250 "Unexpected average packet size");
void DoSetup() override
Implementation to do any local setup required for this TestCase.
void PacketSent(Ptr< const Packet > packet)
Record a transmitted VDI packet.
uint64_t m_received
number of bytes received
Time m_startAppTime
Time at which the application is started.
std::vector< TxInfo > m_sent
transmitted VDI packets
VdiParams m_params
VDI parameters.
void ReceiveRx(std::string context, Ptr< const Packet > p, const Address &addr)
Record a VDI packet successfully received.
TgaxVirtualDesktopTestCase(const std::string &name, const VdiParams ¶ms)
Constructor.
void DoRun() override
Implementation to actually run this TestCase.
TgaxVirtualDesktop TestSuite.
TgaxVirtualDesktopTestSuite()
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()
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.
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 TypeId GetTypeId()
Get the type ID.
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.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time NanoSeconds(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.
Information about a transmitted VDI packet.
uint32_t size
size of the packet in bytes
Time tstamp
timestamp at which the packet is transmitted
Information about VDI parameters.
Time meanPacketArrivalTime
mean of the distribution used to generate packet arrival
std::string parametersPacketSize
parameters of the distribution used to generate the packet sizes
static TgaxVirtualDesktopTestSuite g_TgaxVirtualDesktopTestSuite
Static variable for test initialization.