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)
109 main(
int argc,
char* argv[])
111 uint32_t payloadSize = 1472;
112 double simulationTime = 10;
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 in seconds", 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",
194 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
ssid));
200 wifi_dev = DynamicCast<WifiNetDevice>(dev);
203 mac.SetType(
"ns3::ApWifiMac",
206 "EnableBeaconJitter",
212 wifi_dev = DynamicCast<WifiNetDevice>(dev);
227 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
ssid));
234 wifi_dev = DynamicCast<WifiNetDevice>(dev);
238 mac.SetType(
"ns3::ApWifiMac",
241 "EnableBeaconJitter",
248 wifi_dev = DynamicCast<WifiNetDevice>(dev);
264 mac.SetType(
"ns3::StaWifiMac",
"Ssid", SsidValue(
ssid));
271 wifi_dev = DynamicCast<WifiNetDevice>(dev);
275 mac.SetType(
"ns3::ApWifiMac",
278 "EnableBeaconJitter",
285 wifi_dev = DynamicCast<WifiNetDevice>(dev);
301 mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
304 positionAlloc->Add(Vector(0.0, 0.0, 0.0));
305 positionAlloc->Add(Vector(10.0, 0.0, 0.0));
306 positionAlloc->Add(Vector(20.0, 0.0, 0.0));
307 positionAlloc->Add(Vector(30.0, 0.0, 0.0));
309 positionAlloc->Add(Vector(distance, 0.0, 0.0));
310 positionAlloc->Add(Vector(10 + distance, 0.0, 0.0));
311 positionAlloc->Add(Vector(20 + distance, 0.0, 0.0));
312 positionAlloc->Add(Vector(30 + distance, 0.0, 0.0));
314 mobility.SetPositionAllocator(positionAlloc);
320 stack.Install(wifiApNodes);
324 address.SetBase(
"192.168.1.0",
"255.255.255.0");
326 StaInterfaceA =
address.Assign(staDeviceA);
328 ApInterfaceA =
address.Assign(apDeviceA);
330 address.SetBase(
"192.168.2.0",
"255.255.255.0");
332 StaInterfaceB =
address.Assign(staDeviceB);
334 ApInterfaceB =
address.Assign(apDeviceB);
336 address.SetBase(
"192.168.3.0",
"255.255.255.0");
338 StaInterfaceC =
address.Assign(staDeviceC);
340 ApInterfaceC =
address.Assign(apDeviceC);
342 address.SetBase(
"192.168.4.0",
"255.255.255.0");
344 StaInterfaceD =
address.Assign(staDeviceD);
346 ApInterfaceD =
address.Assign(apDeviceD);
356 clientA.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
358 clientA.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
370 clientB.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
372 clientB.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
384 clientC.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
386 clientC.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
398 clientD.SetAttribute(
"MaxPackets",
UintegerValue(4294967295U));
400 clientD.SetAttribute(
"PacketSize",
UintegerValue(payloadSize));
408 phy.EnablePcap(
"AP_A", apDeviceA.
Get(0));
409 phy.EnablePcap(
"STA_A", staDeviceA.
Get(0));
410 phy.EnablePcap(
"AP_B", apDeviceB.
Get(0));
411 phy.EnablePcap(
"STA_B", staDeviceB.
Get(0));
412 phy.EnablePcap(
"AP_C", apDeviceC.
Get(0));
413 phy.EnablePcap(
"STA_C", staDeviceC.
Get(0));
414 phy.EnablePcap(
"AP_D", apDeviceD.
Get(0));
415 phy.EnablePcap(
"STA_D", staDeviceD.
Get(0));
422 uint64_t totalPacketsThroughA = DynamicCast<UdpServer>(serverAppA.
Get(0))->GetReceived();
423 uint64_t totalPacketsThroughB = DynamicCast<UdpServer>(serverAppB.
Get(0))->GetReceived();
424 uint64_t totalPacketsThroughC = DynamicCast<UdpServer>(serverAppC.
Get(0))->GetReceived();
425 uint64_t totalPacketsThroughD = DynamicCast<UdpServer>(serverAppD.
Get(0))->GetReceived();
429 double throughput = totalPacketsThroughA * payloadSize * 8 / (simulationTime * 1000000.0);
430 std::cout <<
"Default configuration (A-MPDU aggregation enabled, 65kB): " <<
'\n'
431 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
432 if (verifyResults && (throughput < 57.5 || throughput > 58.5))
439 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
441 if (verifyResults && txopLimit &&
445 <<
" is not in the expected boundaries!");
450 throughput = totalPacketsThroughB * payloadSize * 8 / (simulationTime * 1000000.0);
451 std::cout <<
"Aggregation disabled: " <<
'\n'
452 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
453 if (verifyResults && (throughput < 38 || throughput > 39))
460 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
465 <<
" is not in the expected boundaries!");
470 throughput = totalPacketsThroughC * payloadSize * 8 / (simulationTime * 1000000.0);
471 std::cout <<
"A-MPDU disabled and A-MSDU enabled (8kB): " <<
'\n'
472 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
473 if (verifyResults && (throughput < 52 || throughput > 53))
480 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
485 <<
" is not in the expected boundaries!");
490 throughput = totalPacketsThroughD * payloadSize * 8 / (simulationTime * 1000000.0);
491 std::cout <<
"A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " <<
'\n'
492 <<
" Throughput = " <<
throughput <<
" Mbit/s" <<
'\n';
493 if (verifyResults && (throughput < 58 || throughput > 59))
500 std::cout <<
" Maximum TXOP duration (TXOP limit = " << txopLimit
502 if (verifyResults && txopLimit &&
506 <<
" 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.
bool TraceConnectWithoutContext(std::string name, const CallbackBase &cb)
Connect a TraceSource to a Callback without a context.
void SetAttribute(std::string name, const AttributeValue &value)
Set a single attribute, raising fatal errors if unsuccessful.
void GetAttribute(std::string name, AttributeValue &value) const
Get the value of an attribute, raising fatal errors if unsuccessful.
Hold objects of type Ptr<T>.
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.
Hold variables of type string.
Simulation virtual time values and global simulation resolution.
int64_t GetMicroSeconds() const
Get an approximation of the time stored in this instance in the indicated unit.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
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.
Ptr< WifiMac > GetMac() const
@ 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.
void(* Time)(Time oldValue, Time newValue)
TracedValue callback signature for Time.
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