42#include "ns3/applications-module.h"
43#include "ns3/core-module.h"
44#include "ns3/internet-module.h"
45#include "ns3/mobility-module.h"
46#include "ns3/network-module.h"
47#include "ns3/wifi-module.h"
69main(
int argc,
char* argv[])
72 std::string direction{
"downlink"};
76 cmd.Usage(
"Virtual Desktop Infrastructure (VDI) traffic example");
77 cmd.AddValue(
"duration",
"Duration of traffic flow, in seconds", duration);
78 cmd.AddValue(
"direction",
79 "Traffic direction (downlink, uplink, or bidirectional). Default: downlink",
81 cmd.AddValue(
"verbose",
82 "Enable verbose logging of TgaxVirtualDesktop, PacketSink, and this program",
84 cmd.Parse(argc, argv);
89 "TgaxVirtualDesktopExample",
122 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
126 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
139 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
146 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
149 allDevices.
Add(apDevices);
150 allDevices.
Add(staDevices);
157 std::string protocolFactory =
"ns3::TcpSocketFactory";
158 uint16_t dlPort = 5000;
159 uint16_t ulPort = 5001;
165 if (direction ==
"downlink" || direction ==
"bidirectional")
176 dlSourceHelper.SetAttribute(
"Remote",
AddressValue(dlRemoteAddr));
178 auto dlSourceApp = dlSourceHelper.Install(apNode);
179 dlSourceApp.Start(
Seconds(1.0));
180 dlSourceApp.Stop(
Seconds(1.0) + duration);
181 sourceApps.
Add(dlSourceApp);
185 auto dlSinkApp = dlSinkHelper.Install(staNode);
187 dlSinkApp.Stop(
Seconds(2.0) + duration);
188 sinkApps.
Add(dlSinkApp);
190 NS_LOG_INFO(
"Downlink VDI traffic configured (AP -> STA)");
192 NS_LOG_INFO(
" Packet size: Bimodal Normal (41.0/1478.3 bytes)");
196 if (direction ==
"uplink" || direction ==
"bidirectional")
207 ulSourceHelper.SetAttribute(
"InterPacketArrivals",
PointerValue(ulInterArrival));
208 ulSourceHelper.SetAttribute(
"ParametersPacketSize",
StringValue(
"50.598 5.0753"));
211 ulSourceHelper.SetAttribute(
"Remote",
AddressValue(ulRemoteAddr));
213 auto ulSourceApp = ulSourceHelper.Install(staNode);
214 ulSourceApp.Start(
Seconds(1.0));
215 ulSourceApp.Stop(
Seconds(1.0) + duration);
216 sourceApps.
Add(ulSourceApp);
220 auto ulSinkApp = ulSinkHelper.Install(apNode);
222 ulSinkApp.Stop(
Seconds(2.0) + duration);
223 sinkApps.
Add(ulSinkApp);
225 NS_LOG_INFO(
"Uplink VDI traffic configured (STA -> AP)");
227 NS_LOG_INFO(
" Packet size: Normal (mean 50.598 bytes)");
230 if (direction !=
"downlink" && direction !=
"uplink" && direction !=
"bidirectional")
233 <<
". Use 'downlink', 'uplink', or 'bidirectional'.");
237 Config::Connect(
"/NodeList/*/ApplicationList/*/$ns3::TgaxVirtualDesktop/Tx",
257 NS_LOG_INFO(
"Sink " << i <<
" received: " << bytesRx <<
" bytes");
269 NS_LOG_INFO(
"VDI TX [" << context <<
"]: Packet size (bytes): " << packet->GetSize());
275 NS_LOG_INFO(
"Packet RX [" << context <<
"]: Size(bytes): " << packet->GetSize());
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
uint32_t GetN() const
Get the number of Ptr<Application> stored in this container.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
A helper to make it easier to instantiate an application on a set of nodes.
Parse command-line arguments.
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.
static Ipv4Address GetAny()
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
Helper class used to assign positions and mobility models to nodes.
holds a vector of ns3::NetDevice pointers
void Add(NetDeviceContainer other)
Append the contents of another NetDeviceContainer to the end of this container.
keep track of a set of node pointers.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
Ptr< Node > Get(uint32_t i) const
Get the Ptr<Node> stored in this container at a given index.
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 Destroy()
Execute the events scheduled with ScheduleDestroy().
static void Run()
Run the simulation.
static void Stop()
Tell the Simulator the calling event should be the last one executed.
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
static TypeId GetTypeId()
Get the type ID.
Simulation virtual time values and global simulation resolution.
TimeWithUnit As(const Unit unit=Time::AUTO) const
Attach a unit to a Time, to facilitate output in a specific unit.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
AttributeValue implementation for TypeId.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default()
Create a channel helper in a default working state.
Make it easy to create and manage PHY objects for the YANS model.
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)
#define NS_FATAL_ERROR(msg)
Report a fatal error with a message and terminate.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
#define NS_LOG_INFO(msg)
Use NS_LOG to output a message of level LOG_INFO.
Ptr< T > CreateObjectWithAttributes(Args... args)
Allocate an Object on the heap and initialize with a set of attributes.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void LogComponentEnable(const std::string &name, LogLevel level)
Enable the logging output associated with that log component.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
LogLevel
Logging severity classes and levels.
@ LOG_LEVEL_ALL
Print everything.
@ LOG_PREFIX_FUNC
Prefix all trace prints with function.
@ LOG_PREFIX_TIME
Prefix all trace prints with simulation time.
@ LOG_PREFIX_NODE
Prefix all trace prints with simulation node.
@ LOG_LEVEL_INFO
LOG_INFO and above.
void PacketReceived(std::string context, Ptr< const Packet > packet, const Address &address)
Callback invoked when the PacketSink receives a packet.
void PacketReceived(std::string context, Ptr< const Packet > packet, const Address &address)
Callback invoked when the PacketSink receives a packet.
void VdiPacketSent(std::string context, Ptr< const Packet > packet)
Callback invoked when a VDI packet is transmitted.
Ptr< PacketSink > sink
Pointer to the packet sink application.