45#include "ns3/applications-module.h"
46#include "ns3/core-module.h"
47#include "ns3/internet-module.h"
48#include "ns3/mobility-module.h"
49#include "ns3/network-module.h"
50#include "ns3/wifi-module.h"
75main(
int argc,
char* argv[])
78 std::string model{
"status-sync-dl"};
82 cmd.Usage(
"Real-time mobile gaming traffic example");
83 cmd.AddValue(
"duration",
"Duration of traffic flow, in seconds", duration);
85 "Traffic model preset (status-sync-dl, status-sync-ul, lockstep-dl, lockstep-ul). "
86 "Default: status-sync-dl",
88 cmd.AddValue(
"verbose",
89 "Enable verbose logging of RtaTigMobileGaming, PacketSink, and this program",
91 cmd.Parse(argc, argv);
96 "RtaTigMobileGamingExample",
129 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
133 mobility.SetPositionAllocator(
"ns3::GridPositionAllocator",
146 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
153 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
156 allDevices.
Add(apDevices);
157 allDevices.
Add(staDevices);
164 std::string protocolFactory =
"ns3::UdpSocketFactory";
165 uint16_t
port = 5000;
176 if (model ==
"status-sync-dl")
186 NS_LOG_INFO(
"Using Status-Sync Downlink model (default parameters)");
188 else if (model ==
"status-sync-ul")
191 sourceNode = staNode;
200 sourceHelper.SetAttribute(
"InitialPacketSize",
PointerValue(ips));
206 sourceHelper.SetAttribute(
"EndPacketSize",
PointerValue(eps));
213 sourceHelper.SetAttribute(
"PacketArrivalLev",
PointerValue(pal));
219 sourceHelper.SetAttribute(
"PacketSizeLev",
PointerValue(psl));
223 else if (model ==
"lockstep-dl")
235 sourceHelper.SetAttribute(
"InitialPacketSize",
PointerValue(ips));
241 sourceHelper.SetAttribute(
"EndPacketSize",
PointerValue(eps));
248 sourceHelper.SetAttribute(
"PacketArrivalLev",
PointerValue(pal));
254 sourceHelper.SetAttribute(
"PacketSizeLev",
PointerValue(psl));
256 NS_LOG_INFO(
"Using Frame Lockstep Downlink model");
258 else if (model ==
"lockstep-ul")
261 sourceNode = staNode;
270 sourceHelper.SetAttribute(
"InitialPacketSize",
PointerValue(ips));
276 sourceHelper.SetAttribute(
"EndPacketSize",
PointerValue(eps));
283 sourceHelper.SetAttribute(
"PacketArrivalLev",
PointerValue(pal));
289 sourceHelper.SetAttribute(
"PacketSizeLev",
PointerValue(psl));
298 <<
". Use 'status-sync-dl', 'status-sync-ul', 'lockstep-dl', or 'lockstep-ul'.");
302 sourceHelper.SetAttribute(
"Remote",
AddressValue(remoteAddr));
304 auto sourceApps = sourceHelper.Install(sourceNode);
305 sourceApps.Start(
Seconds(1.0));
306 sourceApps.Stop(
Seconds(1.0) + duration);
309 auto sinkApps = sinkHelper.Install(sinkNode);
311 sinkApps.Stop(
Seconds(2.0) + duration);
314 Config::Connect(
"/NodeList/*/ApplicationList/*/$ns3::RtaTigMobileGaming/TxWithStage",
345 NS_LOG_INFO(
"Gaming TX [" << context <<
"]: Packet size (bytes): " << packet->GetSize()
346 <<
" Stage: " << stage);
352 NS_LOG_INFO(
"Packet RX [" << context <<
"]: Size(bytes): " << packet->GetSize());
a polymophic address class
AttributeValue implementation for Address.
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.
Ipv4 addresses are stored in host order in this class.
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 TypeId GetTypeId()
Get the type ID.
TrafficModelStage
Traffic model stages.
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.
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 GamingPacketSent(std::string context, Ptr< const Packet > packet, RtaTigMobileGaming::TrafficModelStage stage)
Callback invoked when a gaming packet is transmitted.
Ptr< PacketSink > sink
Pointer to the packet sink application.