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"
18#include "ns3/string.h"
19#include "ns3/udp-client-server-helper.h"
20#include "ns3/udp-server.h"
21#include "ns3/uinteger.h"
22#include "ns3/wifi-mac.h"
23#include "ns3/wifi-net-device.h"
24#include "ns3/yans-wifi-channel.h"
25#include "ns3/yans-wifi-helper.h"
72main(
int argc,
char* argv[])
75 Time simulationTime{
"10s"};
77 bool enableRts{
false};
78 bool enablePcap{
false};
79 bool verifyResults{
false};
82 cmd.AddValue(
"payloadSize",
"Payload size in bytes", payloadSize);
83 cmd.AddValue(
"enableRts",
"Enable or disable RTS/CTS", enableRts);
84 cmd.AddValue(
"simulationTime",
"Simulation time", simulationTime);
85 cmd.AddValue(
"distance",
86 "Distance in meters between the station and the access point",
88 cmd.AddValue(
"enablePcap",
"Enable/disable pcap file generation", enablePcap);
89 cmd.AddValue(
"verifyResults",
90 "Enable/disable results verification at the end of the simulation",
92 cmd.Parse(argc, argv);
109 wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
129 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
132 mac.SetType(
"ns3::ApWifiMac",
135 "EnableBeaconJitter",
137 apDeviceA =
wifi.Install(phy, mac, wifiApNodes.
Get(0));
142 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
149 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
151 mac.SetType(
"ns3::ApWifiMac",
154 "EnableBeaconJitter",
156 apDeviceB =
wifi.Install(phy, mac, wifiApNodes.
Get(1));
161 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
166 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
174 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
175 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
177 mac.SetType(
"ns3::ApWifiMac",
180 "EnableBeaconJitter",
182 apDeviceC =
wifi.Install(phy, mac, wifiApNodes.
Get(2));
188 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(0));
189 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(7935));
194 mac.SetType(
"ns3::StaWifiMac",
"Ssid",
SsidValue(ssid));
202 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
203 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
205 mac.SetType(
"ns3::ApWifiMac",
208 "EnableBeaconJitter",
210 apDeviceD =
wifi.Install(phy, mac, wifiApNodes.
Get(3));
216 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize",
UintegerValue(32768));
217 wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize",
UintegerValue(3839));
222 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
225 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
226 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
227 positionAlloc->Add(Vector(20.0, 0.0, 0.0));
228 positionAlloc->Add(Vector(30.0, 0.0, 0.0));
230 positionAlloc->Add(Vector(distance, 0.0, 0.0));
231 positionAlloc->Add(Vector(10 + distance, 0.0, 0.0));
232 positionAlloc->Add(Vector(20 + distance, 0.0, 0.0));
233 positionAlloc->Add(Vector(30 + distance, 0.0, 0.0));
235 mobility.SetPositionAllocator(positionAlloc);
241 stack.Install(wifiApNodes);
242 stack.Install(wifiStaNodes);
245 address.SetBase(
"192.168.1.0",
"255.255.255.0");
247 StaInterfaceA =
address.Assign(staDeviceA);
249 ApInterfaceA =
address.Assign(apDeviceA);
251 address.SetBase(
"192.168.2.0",
"255.255.255.0");
253 StaInterfaceB =
address.Assign(staDeviceB);
255 ApInterfaceB =
address.Assign(apDeviceB);
257 address.SetBase(
"192.168.3.0",
"255.255.255.0");
259 StaInterfaceC =
address.Assign(staDeviceC);
261 ApInterfaceC =
address.Assign(apDeviceC);
263 address.SetBase(
"192.168.4.0",
"255.255.255.0");
265 StaInterfaceD =
address.Assign(staDeviceD);
267 ApInterfaceD =
address.Assign(apDeviceD);
277 clientA.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
279 clientA.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
291 clientB.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
293 clientB.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
305 clientC.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
307 clientC.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
319 clientD.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
321 clientD.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
329 phy.EnablePcap(
"AP_A", apDeviceA.
Get(0));
330 phy.EnablePcap(
"STA_A", staDeviceA.
Get(0));
331 phy.EnablePcap(
"AP_B", apDeviceB.
Get(0));
332 phy.EnablePcap(
"STA_B", staDeviceB.
Get(0));
333 phy.EnablePcap(
"AP_C", apDeviceC.
Get(0));
334 phy.EnablePcap(
"STA_C", staDeviceC.
Get(0));
335 phy.EnablePcap(
"AP_D", apDeviceD.
Get(0));
336 phy.EnablePcap(
"STA_D", staDeviceD.
Get(0));
350 auto throughput = totalPacketsThroughA * payloadSize * 8 / simulationTime.GetMicroSeconds();
351 std::cout <<
"Throughput with default configuration (A-MPDU aggregation enabled, 65kB): "
359 throughput = totalPacketsThroughB * payloadSize * 8 / simulationTime.GetMicroSeconds();
360 std::cout <<
"Throughput with aggregation disabled: " <<
throughput <<
" Mbit/s" <<
'\n';
367 throughput = totalPacketsThroughC * payloadSize * 8 / simulationTime.GetMicroSeconds();
368 std::cout <<
"Throughput with A-MPDU disabled and A-MSDU enabled (8kB): " <<
throughput
369 <<
" Mbit/s" <<
'\n';
376 throughput = totalPacketsThroughD * payloadSize * 8 / simulationTime.GetMicroSeconds();
377 std::cout <<
"Throughput with A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " <<
throughput
378 <<
" Mbit/s" <<
'\n';
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.
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.
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 Seconds(double value)
Construct a Time in the indicated unit.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.