20#include "ns3/boolean.h"
21#include "ns3/command-line.h"
22#include "ns3/config.h"
23#include "ns3/internet-stack-helper.h"
24#include "ns3/ipv4-address-helper.h"
26#include "ns3/mobility-helper.h"
27#include "ns3/packet-sink-helper.h"
28#include "ns3/pointer.h"
29#include "ns3/qos-txop.h"
31#include "ns3/string.h"
32#include "ns3/udp-client-server-helper.h"
33#include "ns3/udp-server.h"
34#include "ns3/uinteger.h"
35#include "ns3/wifi-mac.h"
36#include "ns3/wifi-net-device.h"
37#include "ns3/yans-wifi-channel.h"
38#include "ns3/yans-wifi-helper.h"
102 if (duration >
m_max)
109main(
int argc,
char* argv[])
112 Time simulationTime{
"10s"};
113 double txopLimit{3520};
115 bool enableRts{
false};
116 bool enablePcap{
false};
117 bool verifyResults{
false};
120 cmd.AddValue(
"payloadSize",
"Payload size in bytes", payloadSize);
121 cmd.AddValue(
"enableRts",
"Enable or disable RTS/CTS", enableRts);
122 cmd.AddValue(
"txopLimit",
"TXOP duration in microseconds", txopLimit);
123 cmd.AddValue(
"simulationTime",
"Simulation time", simulationTime);
124 cmd.AddValue(
"distance",
125 "Distance in meters between the station and the access point",
127 cmd.AddValue(
"enablePcap",
"Enable/disable pcap file generation", enablePcap);
128 cmd.AddValue(
"verifyResults",
129 "Enable/disable results verification at the end of the simulation",
131 cmd.Parse(argc, argv);
148 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
168 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
171 mac.SetType(
"ns3::ApWifiMac",
174 "EnableBeaconJitter",
178 apDeviceA =
wifi.Install(phy, mac, wifiApNodes.
Get(0));
185 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
195 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
201 wifi_dev = DynamicCast<WifiNetDevice>(dev);
202 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
204 mac.SetType(
"ns3::ApWifiMac",
207 "EnableBeaconJitter",
211 apDeviceB =
wifi.Install(phy, mac, wifiApNodes.
Get(1));
215 wifi_dev = DynamicCast<WifiNetDevice>(dev);
216 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
218 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
228 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
235 wifi_dev = DynamicCast<WifiNetDevice>(dev);
236 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
237 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
239 mac.SetType(
"ns3::ApWifiMac",
242 "EnableBeaconJitter",
246 apDeviceC =
wifi.Install(phy, mac, wifiApNodes.
Get(2));
251 wifi_dev = DynamicCast<WifiNetDevice>(dev);
252 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
253 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
255 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
265 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
272 wifi_dev = DynamicCast<WifiNetDevice>(dev);
273 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
274 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
276 mac.SetType(
"ns3::ApWifiMac",
279 "EnableBeaconJitter",
283 apDeviceD =
wifi.Install(phy, mac, wifiApNodes.
Get(3));
288 wifi_dev = DynamicCast<WifiNetDevice>(dev);
289 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
290 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
292 wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
302 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
305 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
306 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
307 positionAlloc->Add(Vector(20.0, 0.0, 0.0));
308 positionAlloc->Add(Vector(30.0, 0.0, 0.0));
310 positionAlloc->Add(Vector(distance, 0.0, 0.0));
311 positionAlloc->Add(Vector(10 + distance, 0.0, 0.0));
312 positionAlloc->Add(Vector(20 + distance, 0.0, 0.0));
313 positionAlloc->Add(Vector(30 + distance, 0.0, 0.0));
315 mobility.SetPositionAllocator(positionAlloc);
321 stack.Install(wifiApNodes);
322 stack.Install(wifiStaNodes);
325 address.SetBase(
"192.168.1.0",
"255.255.255.0");
327 StaInterfaceA =
address.Assign(staDeviceA);
329 ApInterfaceA =
address.Assign(apDeviceA);
331 address.SetBase(
"192.168.2.0",
"255.255.255.0");
333 StaInterfaceB =
address.Assign(staDeviceB);
335 ApInterfaceB =
address.Assign(apDeviceB);
337 address.SetBase(
"192.168.3.0",
"255.255.255.0");
339 StaInterfaceC =
address.Assign(staDeviceC);
341 ApInterfaceC =
address.Assign(apDeviceC);
343 address.SetBase(
"192.168.4.0",
"255.255.255.0");
345 StaInterfaceD =
address.Assign(staDeviceD);
347 ApInterfaceD =
address.Assign(apDeviceD);
357 clientA.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
359 clientA.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
371 clientB.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
373 clientB.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
385 clientC.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
387 clientC.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
399 clientD.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
401 clientD.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
409 phy.EnablePcap(
"AP_A", apDeviceA.
Get(0));
410 phy.EnablePcap(
"STA_A", staDeviceA.
Get(0));
411 phy.EnablePcap(
"AP_B", apDeviceB.
Get(0));
412 phy.EnablePcap(
"STA_B", staDeviceB.
Get(0));
413 phy.EnablePcap(
"AP_C", apDeviceC.
Get(0));
414 phy.EnablePcap(
"STA_C", staDeviceC.
Get(0));
415 phy.EnablePcap(
"AP_D", apDeviceD.
Get(0));
416 phy.EnablePcap(
"STA_D", staDeviceD.
Get(0));
423 double totalPacketsThroughA = DynamicCast<UdpServer>(serverAppA.
Get(0))->GetReceived();
424 double totalPacketsThroughB = DynamicCast<UdpServer>(serverAppB.
Get(0))->GetReceived();
425 double totalPacketsThroughC = DynamicCast<UdpServer>(serverAppC.
Get(0))->GetReceived();
426 double totalPacketsThroughD = DynamicCast<UdpServer>(serverAppD.
Get(0))->GetReceived();
430 auto throughput = totalPacketsThroughA * payloadSize * 8 / simulationTime.GetMicroSeconds();
431 std::cout <<
"Default configuration (A-MPDU aggregation enabled, 65kB): " <<
'\n'
432 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
433 if (verifyResults && (throughput < 57.5 || throughput > 58.5))
440 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
441 <<
"us): " << netA.m_max.GetMicroSeconds() <<
" us" <<
'\n';
442 if (verifyResults && txopLimit &&
446 <<
" is not in the expected boundaries!");
451 throughput = totalPacketsThroughB * payloadSize * 8 / simulationTime.GetMicroSeconds();
452 std::cout <<
"Aggregation disabled: " <<
'\n'
453 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
454 if (verifyResults && (throughput < 38 || throughput > 39))
461 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
462 <<
"us): " << netB.m_max.GetMicroSeconds() <<
" us" <<
'\n';
466 <<
" is not in the expected boundaries!");
471 throughput = totalPacketsThroughC * payloadSize * 8 / simulationTime.GetMicroSeconds();
472 std::cout <<
"A-MPDU disabled and A-MSDU enabled (8kB): " <<
'\n'
473 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
474 if (verifyResults && (throughput < 52 || throughput > 53))
481 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
482 <<
"us): " << netC.m_max.GetMicroSeconds() <<
" us" <<
'\n';
486 <<
" is not in the expected boundaries!");
491 throughput = totalPacketsThroughD * payloadSize * 8 / simulationTime.GetMicroSeconds();
492 std::cout <<
"A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " <<
'\n'
493 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
494 if (verifyResults && (throughput < 58 || throughput > 59))
501 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
502 <<
"us): " << netD.m_max.GetMicroSeconds() <<
" us" <<
'\n';
503 if (verifyResults && txopLimit &&
507 <<
" 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.
AttributeValue implementation for Boolean.
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.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
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.
AttributeValue implementation for Time.
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.
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...
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