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/uinteger.h" 
   34#include "ns3/wifi-mac.h" 
   35#include "ns3/wifi-net-device.h" 
   36#include "ns3/yans-wifi-channel.h" 
   37#include "ns3/yans-wifi-helper.h" 
  101    if (duration > 
m_max)
 
  108main(
int argc, 
char* argv[])
 
  111    double simulationTime = 10;  
 
  112    double txopLimit = 3520;     
 
  116    bool verifyResults = 0; 
 
  119    cmd.AddValue(
"payloadSize", 
"Payload size in bytes", payloadSize);
 
  120    cmd.AddValue(
"enableRts", 
"Enable or disable RTS/CTS", enableRts);
 
  121    cmd.AddValue(
"txopLimit", 
"TXOP duration in microseconds", txopLimit);
 
  122    cmd.AddValue(
"simulationTime", 
"Simulation time in seconds", simulationTime);
 
  123    cmd.AddValue(
"distance",
 
  124                 "Distance in meters between the station and the access point",
 
  126    cmd.AddValue(
"enablePcap", 
"Enable/disable pcap file generation", enablePcap);
 
  127    cmd.AddValue(
"verifyResults",
 
  128                 "Enable/disable results verification at the end of the simulation",
 
  130    cmd.Parse(argc, argv);
 
  147    wifi.SetRemoteStationManager(
"ns3::ConstantRateWifiManager",
 
  167    mac.SetType(
"ns3::StaWifiMac", 
"Ssid", 
SsidValue(ssid));
 
  170    mac.SetType(
"ns3::ApWifiMac",
 
  173                "EnableBeaconJitter",
 
  175    apDeviceA = 
wifi.Install(phy, mac, wifiApNodes.
Get(0));
 
  182    wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
 
  193    mac.SetType(
"ns3::StaWifiMac", 
"Ssid", 
SsidValue(ssid));
 
  199    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  200    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(0));
 
  202    mac.SetType(
"ns3::ApWifiMac",
 
  205                "EnableBeaconJitter",
 
  207    apDeviceB = 
wifi.Install(phy, mac, wifiApNodes.
Get(1));
 
  211    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  212    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(0));
 
  215    wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
 
  226    mac.SetType(
"ns3::StaWifiMac", 
"Ssid", 
SsidValue(ssid));
 
  233    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  234    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(0));
 
  235    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize", 
UintegerValue(7935));
 
  237    mac.SetType(
"ns3::ApWifiMac",
 
  240                "EnableBeaconJitter",
 
  242    apDeviceC = 
wifi.Install(phy, mac, wifiApNodes.
Get(2));
 
  247    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  248    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(0));
 
  249    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize", 
UintegerValue(7935));
 
  252    wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
 
  263    mac.SetType(
"ns3::StaWifiMac", 
"Ssid", 
SsidValue(ssid));
 
  270    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  271    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(32768));
 
  272    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize", 
UintegerValue(3839));
 
  274    mac.SetType(
"ns3::ApWifiMac",
 
  277                "EnableBeaconJitter",
 
  279    apDeviceD = 
wifi.Install(phy, mac, wifiApNodes.
Get(3));
 
  284    wifi_dev = DynamicCast<WifiNetDevice>(dev);
 
  285    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmpduSize", 
UintegerValue(32768));
 
  286    wifi_dev->GetMac()->SetAttribute(
"BE_MaxAmsduSize", 
UintegerValue(3839));
 
  289    wifi_dev->GetMac()->GetAttribute(
"BE_Txop", ptr);
 
  300    mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
 
  303    positionAlloc->Add(Vector(0.0, 0.0, 0.0));
 
  304    positionAlloc->Add(Vector(10.0, 0.0, 0.0));
 
  305    positionAlloc->Add(Vector(20.0, 0.0, 0.0));
 
  306    positionAlloc->Add(Vector(30.0, 0.0, 0.0));
 
  308    positionAlloc->Add(Vector(distance, 0.0, 0.0));
 
  309    positionAlloc->Add(Vector(10 + distance, 0.0, 0.0));
 
  310    positionAlloc->Add(Vector(20 + distance, 0.0, 0.0));
 
  311    positionAlloc->Add(Vector(30 + distance, 0.0, 0.0));
 
  313    mobility.SetPositionAllocator(positionAlloc);
 
  319    stack.Install(wifiApNodes);
 
  320    stack.Install(wifiStaNodes);
 
  323    address.SetBase(
"192.168.1.0", 
"255.255.255.0");
 
  325    StaInterfaceA = 
address.Assign(staDeviceA);
 
  327    ApInterfaceA = 
address.Assign(apDeviceA);
 
  329    address.SetBase(
"192.168.2.0", 
"255.255.255.0");
 
  331    StaInterfaceB = 
address.Assign(staDeviceB);
 
  333    ApInterfaceB = 
address.Assign(apDeviceB);
 
  335    address.SetBase(
"192.168.3.0", 
"255.255.255.0");
 
  337    StaInterfaceC = 
address.Assign(staDeviceC);
 
  339    ApInterfaceC = 
address.Assign(apDeviceC);
 
  341    address.SetBase(
"192.168.4.0", 
"255.255.255.0");
 
  343    StaInterfaceD = 
address.Assign(staDeviceD);
 
  345    ApInterfaceD = 
address.Assign(apDeviceD);
 
  355    clientA.SetAttribute(
"MaxPackets", 
UintegerValue(4294967295U));
 
  357    clientA.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  369    clientB.SetAttribute(
"MaxPackets", 
UintegerValue(4294967295U));
 
  371    clientB.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  383    clientC.SetAttribute(
"MaxPackets", 
UintegerValue(4294967295U));
 
  385    clientC.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  397    clientD.SetAttribute(
"MaxPackets", 
UintegerValue(4294967295U));
 
  399    clientD.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  407        phy.EnablePcap(
"AP_A", apDeviceA.
Get(0));
 
  408        phy.EnablePcap(
"STA_A", staDeviceA.
Get(0));
 
  409        phy.EnablePcap(
"AP_B", apDeviceB.
Get(0));
 
  410        phy.EnablePcap(
"STA_B", staDeviceB.
Get(0));
 
  411        phy.EnablePcap(
"AP_C", apDeviceC.
Get(0));
 
  412        phy.EnablePcap(
"STA_C", staDeviceC.
Get(0));
 
  413        phy.EnablePcap(
"AP_D", apDeviceD.
Get(0));
 
  414        phy.EnablePcap(
"STA_D", staDeviceD.
Get(0));
 
  421    uint64_t totalPacketsThroughA = DynamicCast<UdpServer>(serverAppA.
Get(0))->GetReceived();
 
  422    uint64_t totalPacketsThroughB = DynamicCast<UdpServer>(serverAppB.
Get(0))->GetReceived();
 
  423    uint64_t totalPacketsThroughC = DynamicCast<UdpServer>(serverAppC.
Get(0))->GetReceived();
 
  424    uint64_t totalPacketsThroughD = DynamicCast<UdpServer>(serverAppD.
Get(0))->GetReceived();
 
  428    double throughput = totalPacketsThroughA * payloadSize * 8 / (simulationTime * 1000000.0);
 
  429    std::cout << 
"Default configuration (A-MPDU aggregation enabled, 65kB): " << 
'\n' 
  430              << 
"  Throughput = " << throughput << 
" Mbit/s" << 
'\n';
 
  431    if (verifyResults && (throughput < 57.5 || throughput > 58.5))
 
  433        NS_LOG_ERROR(
"Obtained throughput " << throughput << 
" is not in the expected boundaries!");
 
  438        std::cout << 
"  Maximum TXOP duration (TXOP limit = " << txopLimit
 
  440        if (verifyResults && txopLimit &&
 
  444                                                  << 
" is not in the expected boundaries!");
 
  449    throughput = totalPacketsThroughB * payloadSize * 8 / (simulationTime * 1000000.0);
 
  450    std::cout << 
"Aggregation disabled: " << 
'\n' 
  451              << 
"  Throughput = " << throughput << 
" Mbit/s" << 
'\n';
 
  452    if (verifyResults && (throughput < 38 || throughput > 39))
 
  454        NS_LOG_ERROR(
"Obtained throughput " << throughput << 
" is not in the expected boundaries!");
 
  459        std::cout << 
"  Maximum TXOP duration (TXOP limit = " << txopLimit
 
  464                                                  << 
" is not in the expected boundaries!");
 
  469    throughput = totalPacketsThroughC * payloadSize * 8 / (simulationTime * 1000000.0);
 
  470    std::cout << 
"A-MPDU disabled and A-MSDU enabled (8kB): " << 
'\n' 
  471              << 
"  Throughput = " << throughput << 
" Mbit/s" << 
'\n';
 
  472    if (verifyResults && (throughput < 52 || throughput > 53))
 
  474        NS_LOG_ERROR(
"Obtained throughput " << throughput << 
" is not in the expected boundaries!");
 
  479        std::cout << 
"  Maximum TXOP duration (TXOP limit = " << txopLimit
 
  484                                                  << 
" is not in the expected boundaries!");
 
  489    throughput = totalPacketsThroughD * payloadSize * 8 / (simulationTime * 1000000.0);
 
  490    std::cout << 
"A-MPDU enabled (32kB) and A-MSDU enabled (4kB): " << 
'\n' 
  491              << 
"  Throughput = " << throughput << 
" Mbit/s" << 
'\n';
 
  492    if (verifyResults && (throughput < 58 || throughput > 59))
 
  494        NS_LOG_ERROR(
"Obtained throughput " << throughput << 
" is not in the expected boundaries!");
 
  499        std::cout << 
"  Maximum TXOP duration (TXOP limit = " << txopLimit
 
  501        if (verifyResults && txopLimit &&
 
  505                                                  << 
" 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.
 
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.
 
AttributeValue implementation for Ssid.
 
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.
 
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