9#include "ns3/command-line.h" 
   10#include "ns3/config.h" 
   11#include "ns3/ht-configuration.h" 
   12#include "ns3/internet-stack-helper.h" 
   13#include "ns3/ipv4-address-helper.h" 
   15#include "ns3/mobility-helper.h" 
   16#include "ns3/on-off-helper.h" 
   17#include "ns3/packet-sink-helper.h" 
   18#include "ns3/packet-sink.h" 
   19#include "ns3/pointer.h" 
   20#include "ns3/qos-txop.h" 
   22#include "ns3/string.h" 
   23#include "ns3/udp-client-server-helper.h" 
   24#include "ns3/udp-server.h" 
   25#include "ns3/wifi-mac.h" 
   26#include "ns3/wifi-net-device.h" 
   27#include "ns3/yans-wifi-channel.h" 
   28#include "ns3/yans-wifi-helper.h" 
   95    std::string apTypeString;
 
   98        apTypeString = 
"WIFI_STANDARD_80211g";
 
  102        apTypeString = 
"WIFI_STANDARD_80211n_2_4GHZ";
 
  105    std::cout << 
"Run: " << params.testName
 
  106              << 
"\n\t enableErpProtection=" << params.enableErpProtection
 
  107              << 
"\n\t erpProtectionMode=" << params.erpProtectionMode
 
  108              << 
"\n\t enableShortSlotTime=" << params.enableShortSlotTime
 
  109              << 
"\n\t enableShortPhyPreamble=" << params.enableShortPhyPreamble
 
  110              << 
"\n\t apType=" << apTypeString << 
"\n\t nWifiB=" << params.nWifiB
 
  111              << 
"\n\t bHasTraffic=" << params.bHasTraffic << 
"\n\t nWifiG=" << params.nWifiG
 
  112              << 
"\n\t gHasTraffic=" << params.gHasTraffic << 
"\n\t nWifiN=" << params.nWifiN
 
  113              << 
"\n\t nHasTraffic=" << params.nHasTraffic << std::endl;
 
  122    auto simulationTime = params.simulationTime;
 
  123    uint32_t payloadSize = params.payloadSize;
 
  126    wifiBStaNodes.
Create(nWifiB);
 
  128    wifiGStaNodes.
Create(nWifiG);
 
  130    wifiNStaNodes.
Create(nWifiN);
 
  132    wifiApNode.Create(1);
 
  135    channel.AddPropagationLoss(
"ns3::RangePropagationLossModel");
 
  138    phy.SetChannel(channel.Create());
 
  141    wifi.SetRemoteStationManager(
"ns3::IdealWifiManager");
 
  149    mac.SetType(
"ns3::StaWifiMac",
 
  152                "ShortSlotTimeSupported",
 
  156    phy.Set(
"ShortPlcpPreambleSupported", 
BooleanValue(params.enableShortPhyPreamble));
 
  159    bStaDevice = wifi.Install(phy, mac, wifiBStaNodes);
 
  164    gStaDevice = wifi.Install(phy, mac, wifiGStaNodes);
 
  169    mac.SetType(
"ns3::StaWifiMac",
 
  172                "BE_BlockAckThreshold",
 
  174                "ShortSlotTimeSupported",
 
  176    nStaDevice = wifi.Install(phy, mac, wifiNStaNodes);
 
  180    wifi.SetStandard(params.apType);
 
  181    mac.SetType(
"ns3::ApWifiMac",
 
  184                "EnableBeaconJitter",
 
  186                "BE_BlockAckThreshold",
 
  188                "EnableNonErpProtection",
 
  190                "ShortSlotTimeSupported",
 
  192    apDevice = wifi.Install(phy, mac, wifiApNode);
 
  201        wifi_mac->GetAttribute(
"BE_Txop", ptr);
 
  211        wifi_mac->GetAttribute(
"BE_Txop", ptr);
 
  216    Config::Set(
"/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Mac/BE_MaxAmpduSize",
 
  223    positionAlloc->Add(Vector(0.0, 0.0, 0.0));
 
  224    for (
uint32_t i = 0; i < nWifiB; i++)
 
  226        positionAlloc->Add(Vector(5.0, 0.0, 0.0));
 
  228    for (
uint32_t i = 0; i < nWifiG; i++)
 
  230        positionAlloc->Add(Vector(0.0, 5.0, 0.0));
 
  232    for (
uint32_t i = 0; i < nWifiN; i++)
 
  234        positionAlloc->Add(Vector(0.0, 0.0, 5.0));
 
  237    mobility.SetPositionAllocator(positionAlloc);
 
  238    mobility.SetMobilityModel(
"ns3::ConstantPositionMobilityModel");
 
  239    mobility.Install(wifiApNode);
 
  240    mobility.Install(wifiBStaNodes);
 
  241    mobility.Install(wifiGStaNodes);
 
  242    mobility.Install(wifiNStaNodes);
 
  246    stack.Install(wifiApNode);
 
  247    stack.Install(wifiBStaNodes);
 
  248    stack.Install(wifiGStaNodes);
 
  249    stack.Install(wifiNStaNodes);
 
  252    address.SetBase(
"192.168.1.0", 
"255.255.255.0");
 
  254    bStaInterface = address.Assign(bStaDevice);
 
  256    gStaInterface = address.Assign(gStaDevice);
 
  258    nStaInterface = address.Assign(nStaDevice);
 
  260    ApInterface = address.Assign(apDevice);
 
  272        client.SetAttribute(
"MaxPackets", 
UintegerValue(4294967295U));
 
  274        client.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  277        if (params.bHasTraffic)
 
  279            clientApps.Add(client.Install(wifiBStaNodes));
 
  281        if (params.gHasTraffic)
 
  283            clientApps.Add(client.Install(wifiGStaNodes));
 
  285        if (params.nHasTraffic)
 
  287            clientApps.Add(client.Install(wifiNStaNodes));
 
  290        clientApps.Stop(simulationTime + 
Seconds(1));
 
  296        throughput = totalPacketsThrough * payloadSize * 8 / simulationTime.GetMicroSeconds();
 
  300        uint16_t 
port = 50000;
 
  309        onoff.SetAttribute(
"OnTime", 
StringValue(
"ns3::ConstantRandomVariable[Constant=1]"));
 
  310        onoff.SetAttribute(
"OffTime", 
StringValue(
"ns3::ConstantRandomVariable[Constant=0]"));
 
  311        onoff.SetAttribute(
"PacketSize", 
UintegerValue(payloadSize));
 
  315        onoff.SetAttribute(
"Remote", remoteAddress);
 
  318        if (params.bHasTraffic)
 
  320            clientApps.Add(onoff.Install(wifiBStaNodes));
 
  322        if (params.gHasTraffic)
 
  324            clientApps.Add(onoff.Install(wifiGStaNodes));
 
  326        if (params.nHasTraffic)
 
  328            clientApps.Add(onoff.Install(wifiNStaNodes));
 
  331        clientApps.Stop(simulationTime + 
Seconds(1));
 
  337        throughput += totalPacketsThrough * 8 / simulationTime.GetMicroSeconds();
 
 
  344main(
int argc, 
char* argv[])
 
  347    params.testName = 
"";
 
  348    params.enableErpProtection = 
false;
 
  349    params.erpProtectionMode = 
"Cts-To-Self";
 
  350    params.enableShortSlotTime = 
false;
 
  351    params.enableShortPhyPreamble = 
false;
 
  354    params.bHasTraffic = 
false;
 
  356    params.gHasTraffic = 
true;
 
  358    params.nHasTraffic = 
false;
 
  360    params.payloadSize = 1472; 
 
  361    params.simulationTime = 
Seconds(10);
 
  363    bool verifyResults = 
false; 
 
  366    cmd.AddValue(
"payloadSize", 
"Payload size in bytes", params.payloadSize);
 
  367    cmd.AddValue(
"simulationTime", 
"Simulation time", params.simulationTime);
 
  368    cmd.AddValue(
"isUdp", 
"UDP if set to 1, TCP otherwise", params.isUdp);
 
  369    cmd.AddValue(
"verifyResults",
 
  370                 "Enable/disable results verification at the end of the simulation",
 
  372    cmd.Parse(argc, argv);
 
  377    params.testName = 
"g only with all g features disabled";
 
  384    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  386    params.testName = 
"g only with short slot time enabled";
 
  387    params.enableErpProtection = 
false;
 
  388    params.enableShortSlotTime = 
true;
 
  389    params.enableShortPhyPreamble = 
false;
 
  397    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  399    params.testName = 
"Mixed b/g with all g features disabled";
 
  400    params.enableErpProtection = 
false;
 
  401    params.enableShortSlotTime = 
false;
 
  402    params.enableShortPhyPreamble = 
false;
 
  410    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  412    params.testName = 
"Mixed b/g with short plcp preamble enabled";
 
  413    params.enableErpProtection = 
false;
 
  414    params.enableShortSlotTime = 
false;
 
  415    params.enableShortPhyPreamble = 
true;
 
  423    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  425    params.testName = 
"Mixed b/g with short slot time enabled using RTS-CTS protection";
 
  426    params.enableErpProtection = 
true;
 
  427    params.erpProtectionMode = 
"Rts-Cts";
 
  428    params.enableShortSlotTime = 
false;
 
  429    params.enableShortPhyPreamble = 
false;
 
  437    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  439    params.testName = 
"Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
 
  440    params.enableErpProtection = 
true;
 
  441    params.enableShortSlotTime = 
false;
 
  442    params.enableShortPhyPreamble = 
true;
 
  450    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  452    params.testName = 
"Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
 
  453    params.enableErpProtection = 
true;
 
  454    params.erpProtectionMode = 
"Cts-To-Self";
 
  455    params.enableShortSlotTime = 
false;
 
  456    params.enableShortPhyPreamble = 
false;
 
  464    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  466    params.testName = 
"Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
 
  467    params.enableErpProtection = 
true;
 
  468    params.enableShortSlotTime = 
false;
 
  469    params.enableShortPhyPreamble = 
true;
 
  477    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  479    params.testName = 
"HT only";
 
  480    params.enableErpProtection = 
false;
 
  481    params.enableShortSlotTime = 
false;
 
  482    params.enableShortPhyPreamble = 
false;
 
  485    params.bHasTraffic = 
false;
 
  487    params.gHasTraffic = 
false;
 
  489    params.nHasTraffic = 
true;
 
  496    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
  498    params.testName = 
"Mixed HT/non-HT";
 
  499    params.enableErpProtection = 
false;
 
  500    params.enableShortSlotTime = 
false;
 
  501    params.enableShortPhyPreamble = 
false;
 
  504    params.bHasTraffic = 
false;
 
  506    params.gHasTraffic = 
false;
 
  508    params.nHasTraffic = 
true;
 
  515    std::cout << 
"Throughput: " << 
throughput << 
" Mbit/s \n" << std::endl;
 
WiFi adhoc experiment class.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
Run an experiment.
a polymophic address class
AttributeValue implementation for Address.
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.
AttributeValue implementation for DataRate.
aggregate IP/TCP/UDP functionality to existing Nodes.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
static Ipv4Address GetAny()
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
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.
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
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.
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.
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 experiment(std::string queue_disc_type)
void SetDefault(std::string name, const AttributeValue &value)
void Set(std::string path, 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.
WifiStandard
Identifies the IEEE 802.11 specifications that a Wifi device can be configured to use.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Ptr< T1 > DynamicCast(const Ptr< T2 > &p)
Cast a Ptr.
params
Fit Fluctuating Two Ray model to the 3GPP TR 38.901 using the Anderson-Darling goodness-of-fit ##.
WifiStandard apType
Wifi standard for AP.
uint32_t nWifiB
Number of 802.11b stations.
uint32_t nWifiN
Number of 802.11n stations.
bool enableErpProtection
True to enable ERP protection.
bool nHasTraffic
True if 802.11n stations generate traffic.
bool gHasTraffic
True if 802.11g stations generate traffic.
std::string erpProtectionMode
ERP protection mode.
Time simulationTime
Simulation time.
bool enableShortSlotTime
True to enable short slot time.
bool bHasTraffic
True if 802.11b stations generate traffic.
bool isUdp
True to generate UDP traffic.
std::string testName
Test name.
bool enableShortPhyPreamble
True to enable short PHY preamble.
uint32_t nWifiG
Number of 802.11g stations.
uint32_t payloadSize
Payload size in bytes.