21 #include "ns3/command-line.h"
22 #include "ns3/config.h"
23 #include "ns3/string.h"
24 #include "ns3/pointer.h"
26 #include "ns3/yans-wifi-helper.h"
28 #include "ns3/mobility-helper.h"
29 #include "ns3/internet-stack-helper.h"
30 #include "ns3/ipv4-address-helper.h"
31 #include "ns3/udp-client-server-helper.h"
32 #include "ns3/on-off-helper.h"
33 #include "ns3/yans-wifi-channel.h"
34 #include "ns3/wifi-net-device.h"
35 #include "ns3/qos-txop.h"
36 #include "ns3/wifi-mac.h"
37 #include "ns3/packet-sink-helper.h"
38 #include "ns3/packet-sink.h"
39 #include "ns3/ht-configuration.h"
104 std::string apTypeString;
107 apTypeString =
"WIFI_STANDARD_80211g";
109 else if (params.
apType == WIFI_STANDARD_80211n_2_4GHZ)
111 apTypeString =
"WIFI_STANDARD_80211n_2_4GHZ";
114 std::cout <<
"Run: " << params.
testName
119 <<
"\n\t apType=" << apTypeString
121 <<
"\n\t nWifiB=" << params.
nWifiB
123 <<
"\n\t nWifiG=" << params.
nWifiG
133 double throughput = 0;
134 uint32_t nWifiB = params.
nWifiB;
135 uint32_t nWifiG = params.
nWifiG;
142 wifiBStaNodes.
Create (nWifiB);
144 wifiGStaNodes.
Create (nWifiG);
146 wifiNNGFStaNodes.
Create (nWifiNNGF);
148 wifiNGFStaNodes.
Create (nWifiNGF);
153 channel.AddPropagationLoss (
"ns3::RangePropagationLossModel");
160 wifi.SetRemoteStationManager (
"ns3::IdealWifiManager");
168 mac.SetType (
"ns3::StaWifiMac",
176 bStaDevice =
wifi.Install (
phy,
mac, wifiBStaNodes);
181 gStaDevice =
wifi.Install (
phy,
mac, wifiGStaNodes);
184 wifi.SetStandard (WIFI_STANDARD_80211n_2_4GHZ);
186 mac.SetType (
"ns3::StaWifiMac",
190 nNGFStaDevice =
wifi.Install (
phy,
mac, wifiNNGFStaNodes);
191 nGFStaDevice =
wifi.Install (
phy,
mac, wifiNGFStaNodes);
196 mac.SetType (
"ns3::ApWifiMac",
205 if (params.
apType == WIFI_STANDARD_80211n_2_4GHZ)
213 wifi_mac->GetAttribute (
"BE_Txop", ptr);
224 wifi_mac->GetAttribute (
"BE_Txop", ptr);
233 htConfiguration->SetGreenfieldSupported (
true);
236 wifi_mac->GetAttribute (
"BE_Txop", ptr);
247 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
248 for (uint32_t i = 0; i < nWifiB; i++)
250 positionAlloc->Add (Vector (5.0, 0.0, 0.0));
252 for (uint32_t i = 0; i < nWifiG; i++)
254 positionAlloc->Add (Vector (0.0, 5.0, 0.0));
256 for (uint32_t i = 0; i < nWifiNNGF; i++)
258 positionAlloc->Add (Vector (0.0, 0.0, 5.0));
260 for (uint32_t i = 0; i < nWifiNGF; i++)
262 positionAlloc->Add (Vector (0.0, 0.0, 5.0));
265 mobility.SetPositionAllocator (positionAlloc);
266 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
270 mobility.Install (wifiNNGFStaNodes);
276 stack.Install (wifiBStaNodes);
277 stack.Install (wifiGStaNodes);
278 stack.Install (wifiNNGFStaNodes);
279 stack.Install (wifiNGFStaNodes);
282 address.SetBase (
"192.168.1.0",
"255.255.255.0");
284 bStaInterface =
address.Assign (bStaDevice);
286 gStaInterface =
address.Assign (gStaDevice);
288 nNGFStaInterface =
address.Assign (nNGFStaDevice);
290 nGFStaInterface =
address.Assign (nGFStaDevice);
292 ApInterface =
address.Assign (apDevice);
331 uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.
Get (0))->GetReceived ();
332 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
336 uint16_t
port = 50000;
376 uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.
Get (0))->GetTotalRx ();
377 throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
383 int main (
int argc,
char *argv[])
405 bool verifyResults = 0;
408 cmd.AddValue (
"payloadSize",
"Payload size in bytes", params.
payloadSize);
409 cmd.AddValue (
"simulationTime",
"Simulation time in seconds", params.
simulationTime);
410 cmd.AddValue (
"isUdp",
"UDP if set to 1, TCP otherwise", params.
isUdp);
411 cmd.AddValue (
"verifyResults",
"Enable/disable results verification at the end of the simulation", verifyResults);
412 cmd.Parse (argc, argv);
415 double throughput = 0;
417 params.
testName =
"g only with all g features disabled";
419 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
421 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
424 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
426 params.
testName =
"g only with short slot time enabled";
432 if (verifyResults && (throughput < 29 || throughput > 30))
434 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
437 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
439 params.
testName =
"Mixed b/g with all g features disabled";
445 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
447 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
450 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
452 params.
testName =
"Mixed b/g with short plcp preamble enabled";
458 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
460 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
463 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
465 params.
testName =
"Mixed b/g with short slot time enabled using RTS-CTS protection";
472 if (verifyResults && (throughput < 19 || throughput > 20))
474 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
477 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
479 params.
testName =
"Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
485 if (verifyResults && (throughput < 19 || throughput > 20))
487 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
490 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
492 params.
testName =
"Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
499 if (verifyResults && (throughput < 20.5 || throughput > 21.5))
501 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
504 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
506 params.
testName =
"Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
512 if (verifyResults && (throughput < 20.5 || throughput > 21.5))
514 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
517 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
519 params.
testName =
"HT GF not supported";
523 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
534 if (verifyResults && (throughput < 43 || throughput > 44))
536 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
539 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
541 params.
testName =
"HT only with GF used";
545 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
556 if (verifyResults && (throughput < 44 || throughput > 45))
558 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
561 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
563 params.
testName =
"HT only with GF allowed but disabled by protection";
567 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
578 if (verifyResults && (throughput < 43 || throughput > 44))
580 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
583 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
585 params.
testName =
"HT only with GF not supported by the receiver";
589 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
600 if (verifyResults && (throughput < 43 || throughput > 44))
602 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
605 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
607 params.
testName =
"Mixed HT/non-HT with GF enabled";
611 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
622 if (verifyResults && (throughput < 44 || throughput > 45))
624 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
627 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
633 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
644 if (verifyResults && (throughput < 44 || throughput > 45))
646 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
649 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
651 params.
testName =
"Mixed HT/non-HT";
655 params.
apType = WIFI_STANDARD_80211n_2_4GHZ;
666 if (verifyResults && (throughput < 44 || throughput > 45))
668 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
671 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
Helper class for UAN CW MAC example.
Gnuplot2dDataset Run(const WifiHelper &wifi, const YansWifiPhyHelper &wifiPhy, const WifiMacHelper &wifiMac, const YansWifiChannelHelper &wifiChannel)
a polymophic address class
AttributeValue implementation for Address.
holds a vector of ns3::Application pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter.
void Stop(Time stop)
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(void)
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.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes.
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
Hold objects of type Ptr<T>.
Handle packet fragmentation and retransmissions for QoS data frames as well as MSDU aggregation (A-MS...
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
static void Run(void)
Run the simulation.
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.
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...
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
ApplicationContainer Install(NodeContainer c)
Create a server application which waits for input UDP packets and uses the information carried into t...
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
Hold an unsigned integer type.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Ptr< HtConfiguration > GetHtConfiguration(void) const
Ptr< WifiMac > GetMac(void) const
@ DLT_IEEE802_11_RADIO
Include Radiotap link layer information.
manage and create wifi channel objects for the YANS model.
static YansWifiChannelHelper Default(void)
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.
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.
bool nGreenfieldHasTraffic
uint32_t nWifiNNonGreenfield
std::string erpProtectionMode
uint32_t nWifiNGreenfield
bool enableShortPhyPreamble
bool apSupportsGreenfield
bool nNonGreenfieldHasTraffic