29#include "ns3/boolean.h"
30#include "ns3/command-line.h"
31#include "ns3/config.h"
32#include "ns3/double.h"
33#include "ns3/internet-stack-helper.h"
34#include "ns3/ipv4-address-helper.h"
36#include "ns3/mobility-helper.h"
37#include "ns3/mobility-model.h"
39#include "ns3/neighbor-cache-helper.h"
40#include "ns3/on-off-helper.h"
41#include "ns3/packet-sink-helper.h"
43#include "ns3/string.h"
44#include "ns3/uinteger.h"
45#include "ns3/wifi-co-trace-helper.h"
46#include "ns3/wifi-phy-rx-trace-helper.h"
47#include "ns3/yans-wifi-channel.h"
48#include "ns3/yans-wifi-helper.h"
63main(
int argc,
char* argv[])
65 bool useDifferentAc =
false;
70 cmd.AddValue(
"useDifferentAc",
71 "Uses VO AC on 2 STAs and BE on rest if true. Uses BE AC on all 4 STAs if false.",
73 cmd.AddValue(
"duration",
"Duration of data transfer", duration);
74 cmd.Parse(argc, argv);
86 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
87 mobility.SetPositionAllocator(positionAlloc);
88 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
91 positionAlloc->Add(Vector(distance, 0.0, 0.0));
92 positionAlloc->Add(Vector(0.0, distance, 0.0));
93 positionAlloc->Add(Vector(0.0, -distance, 0.0));
94 positionAlloc->Add(Vector(-distance, 0.0, 0.0));
108 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
117 wifiMac.
SetType(
"ns3::ApWifiMac",
127 wifiMac.
SetType(
"ns3::StaWifiMac",
137 allDevices.
Add(apDevice);
138 allDevices.
Add(staDevices);
145 ipv4.SetBase(
"10.1.1.0",
"255.255.255.0");
148 uint16_t portNumber = 9;
149 std::vector<uint8_t> tosValues = {0x70, 0x28, 0xb8, 0xc0};
150 auto ipv4ap = apNode.Get(0)->GetObject<
Ipv4>();
151 const auto address = ipv4ap->GetAddress(1, 0).GetLocal();
189 wifiCoTraceHelper.Enable(allDevices);
195 std::cout <<
"*** Print statistics for all nodes using built-in print method:" << std::endl;
196 wifiCoTraceHelper.PrintStatistics(std::cout);
198 std::cout <<
"*** Print the statistics in your own way. Here, just sum the STAs total TX time:"
202 auto records = wifiCoTraceHelper.GetDeviceRecords();
204 for (
const auto& it : records)
208 const auto it2 = it.m_linkStateDurations.at(0).find(WifiPhyState::TX);
209 if (it2 != it.m_linkStateDurations.at(0).end())
211 sumStaTxTime += it2->second;
216 std::cout <<
"Sum of STA time in TX state is " << sumStaTxTime.
As(
Time::S) << std::endl;
holds a vector of ns3::Application pointers.
void Start(Time start) const
Start all of the Applications in this container at the start time given as a parameter.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container.
Parse command-line arguments.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Access to the IPv4 forwarding table, interfaces, and configuration.
holds a vector of std::pair of Ptr<Ipv4> and interface index.
Helper class used to assign positions and mobility models to nodes.
static void Add(std::string name, Ptr< Object > object)
Add the association between the string "name" and the Ptr<Object> obj.
A helper class to populate neighbor cache.
void PopulateNeighborCache()
Populate neighbor ARP and NDISC caches for all devices.
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
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 EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
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.
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.
Hold an unsigned integer type.
Track channel occupancy durations for WifiNetDevice.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
void SetType(std::string type, Args &&... args)
manage and create wifi channel objects for the YANS model.
void SetPropagationDelay(std::string name, Ts &&... args)
void AddPropagationLoss(std::string name, Ts &&... args)
Ptr< YansWifiChannel > Create() const
Make it easy to create and manage PHY objects for the YANS model.
void SetChannel(Ptr< YansWifiChannel > channel)
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
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.
void PopulateNeighborCache()