9#include "ns3/boolean.h"
10#include "ns3/command-line.h"
11#include "ns3/config.h"
12#include "ns3/internet-stack-helper.h"
13#include "ns3/ipv4-address-helper.h"
15#include "ns3/mobility-helper.h"
16#include "ns3/packet-sink-helper.h"
17#include "ns3/pointer.h"
18#include "ns3/qos-txop.h"
20#include "ns3/string.h"
21#include "ns3/udp-client-server-helper.h"
22#include "ns3/udp-server.h"
23#include "ns3/uinteger.h"
24#include "ns3/wifi-mac.h"
25#include "ns3/wifi-net-device.h"
26#include "ns3/yans-wifi-channel.h"
27#include "ns3/yans-wifi-helper.h"
98main(
int argc,
char* argv[])
101 Time simulationTime{
"10s"};
102 double txopLimit{3520};
104 bool enableRts{
false};
105 bool enablePcap{
false};
106 bool verifyResults{
false};
109 cmd.AddValue(
"payloadSize",
"Payload size in bytes", payloadSize);
110 cmd.AddValue(
"enableRts",
"Enable or disable RTS/CTS", enableRts);
111 cmd.AddValue(
"txopLimit",
"TXOP duration in microseconds", txopLimit);
112 cmd.AddValue(
"simulationTime",
"Simulation time", simulationTime);
113 cmd.AddValue(
"distance",
114 "Distance in meters between the station and the access point",
116 cmd.AddValue(
"enablePcap",
"Enable/disable pcap file generation", enablePcap);
117 cmd.AddValue(
"verifyResults",
118 "Enable/disable results verification at the end of the simulation",
120 cmd.Parse(argc, argv);
137 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
157 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
160 mac.SetType(
"ns3::ApWifiMac",
163 "EnableBeaconJitter",
167 apDeviceA =
wifi.Install(phy, mac, wifiApNodes.
Get(0));
174 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
184 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
191 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
193 mac.SetType(
"ns3::ApWifiMac",
196 "EnableBeaconJitter",
200 apDeviceB =
wifi.Install(phy, mac, wifiApNodes.
Get(1));
205 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
207 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
217 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
225 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
226 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
228 mac.SetType(
"ns3::ApWifiMac",
231 "EnableBeaconJitter",
235 apDeviceC =
wifi.Install(phy, mac, wifiApNodes.
Get(2));
241 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
242 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
244 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
254 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
262 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
263 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
265 mac.SetType(
"ns3::ApWifiMac",
268 "EnableBeaconJitter",
272 apDeviceD =
wifi.Install(phy, mac, wifiApNodes.
Get(3));
278 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
279 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
281 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
291 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
294 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
295 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
296 positionAlloc->Add(Vector(20.0, 0.0, 0.0));
297 positionAlloc->Add(Vector(30.0, 0.0, 0.0));
299 positionAlloc->Add(Vector(distance, 0.0, 0.0));
300 positionAlloc->Add(Vector(10 + distance, 0.0, 0.0));
301 positionAlloc->Add(Vector(20 + distance, 0.0, 0.0));
302 positionAlloc->Add(Vector(30 + distance, 0.0, 0.0));
304 mobility.SetPositionAllocator(positionAlloc);
310 stack.Install(wifiApNodes);
311 stack.Install(wifiStaNodes);
314 address.SetBase(
"192.168.1.0",
"255.255.255.0");
316 StaInterfaceA =
address.Assign(staDeviceA);
318 ApInterfaceA =
address.Assign(apDeviceA);
320 address.SetBase(
"192.168.2.0",
"255.255.255.0");
322 StaInterfaceB =
address.Assign(staDeviceB);
324 ApInterfaceB =
address.Assign(apDeviceB);
326 address.SetBase(
"192.168.3.0",
"255.255.255.0");
328 StaInterfaceC =
address.Assign(staDeviceC);
330 ApInterfaceC =
address.Assign(apDeviceC);
332 address.SetBase(
"192.168.4.0",
"255.255.255.0");
334 StaInterfaceD =
address.Assign(staDeviceD);
336 ApInterfaceD =
address.Assign(apDeviceD);
346 clientA.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
348 clientA.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
360 clientB.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
362 clientB.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
374 clientC.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
376 clientC.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
388 clientD.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
390 clientD.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
398 phy.EnablePcap(
"AP_A", apDeviceA.
Get(0));
399 phy.EnablePcap(
"STA_A", staDeviceA.
Get(0));
400 phy.EnablePcap(
"AP_B", apDeviceB.
Get(0));
401 phy.EnablePcap(
"STA_B", staDeviceB.
Get(0));
402 phy.EnablePcap(
"AP_C", apDeviceC.
Get(0));
403 phy.EnablePcap(
"STA_C", staDeviceC.
Get(0));
404 phy.EnablePcap(
"AP_D", apDeviceD.
Get(0));
405 phy.EnablePcap(
"STA_D", staDeviceD.
Get(0));
419 auto throughput = totalPacketsThroughA * payloadSize * 8 / simulationTime.GetMicroSeconds();
420 std::cout <<
"Default configuration (A-MPDU aggregation enabled, 65kB): " <<
'\n'
421 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
429 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
430 <<
"us): " << netA.m_max.GetMicroSeconds() <<
" us" <<
'\n';
431 if (verifyResults && txopLimit &&
435 <<
" is not in the expected boundaries!");
440 throughput = totalPacketsThroughB * payloadSize * 8 / simulationTime.GetMicroSeconds();
441 std::cout <<
"Aggregation disabled: " <<
'\n'
442 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
450 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
451 <<
"us): " << netB.m_max.GetMicroSeconds() <<
" us" <<
'\n';
455 <<
" is not in the expected boundaries!");
460 throughput = totalPacketsThroughC * payloadSize * 8 / simulationTime.GetMicroSeconds();
461 std::cout <<
"A-MPDU disabled and A-MSDU enabled (8kB): " <<
'\n'
462 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
470 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
471 <<
"us): " << netC.m_max.GetMicroSeconds() <<
" us" <<
'\n';
475 <<
" is not in the expected boundaries!");
480 throughput = totalPacketsThroughD * payloadSize * 8 / simulationTime.GetMicroSeconds();
481 std::cout <<
"A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " <<
'\n'
482 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
490 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
491 <<
"us): " << netD.m_max.GetMicroSeconds() <<
" us" <<
'\n';
492 if (verifyResults && txopLimit &&
496 <<
" is not in the expected boundaries!");
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.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Stop(Time stop) const
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter.
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.
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
Ptr< NetDevice > Get(uint32_t i) const
Get the Ptr<NetDevice> stored in this container at a given index.
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.
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
AttributeValue implementation for Pointer.
Smart pointer class similar to boost::intrusive_ptr.
Handles the packet queue and stores DCF/EDCA access parameters (one Txop per AC).
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.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
Create a server application which waits for input UDP packets and uses the information carried into t...
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
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.
void SetDefault(std::string name, const AttributeValue &value)
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
#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 MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
Time Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
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...
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
Keeps the maximum duration among all TXOPs.
void Trace(Time startTime, Time duration, uint8_t linkId)
Callback connected to TXOP duration trace source.
Time m_max
maximum TXOP duration