21 #include "ns3/core-module.h"
22 #include "ns3/applications-module.h"
23 #include "ns3/wifi-module.h"
24 #include "ns3/mobility-module.h"
25 #include "ns3/internet-module.h"
96 std::string apTypeString;
99 apTypeString =
"WIFI_PHY_STANDARD_80211g";
103 apTypeString =
"WIFI_PHY_STANDARD_80211n_2_4GHZ";
106 std::cout <<
"Run: " << params.
testName
111 <<
"\n\t apType=" << apTypeString
114 <<
"\n\t rifsMode=" << params.
rifsMode
115 <<
"\n\t nWifiB=" << params.
nWifiB
117 <<
"\n\t nWifiG=" << params.
nWifiG
127 double throughput = 0;
128 uint32_t nWifiB = params.
nWifiB;
129 uint32_t nWifiG = params.
nWifiG;
136 wifiBStaNodes.
Create (nWifiB);
138 wifiGStaNodes.
Create (nWifiG);
140 wifiNNGFStaNodes.
Create (nWifiNNGF);
142 wifiNGFStaNodes.
Create (nWifiNGF);
162 mac.
SetType (
"ns3::StaWifiMac",
170 bStaDevice = wifi.
Install (phy, mac, wifiBStaNodes);
175 gStaDevice = wifi.
Install (phy, mac, wifiGStaNodes);
180 mac.
SetType (
"ns3::StaWifiMac",
187 nNGFStaDevice = wifi.
Install (phy, mac, wifiNNGFStaNodes);
189 nGFStaDevice = wifi.
Install (phy, mac, wifiNGFStaNodes);
204 apDevice = wifi.
Install (phy, mac, wifiApNode);
213 wifi_mac->GetAttribute (
"BE_EdcaTxopN", ptr);
223 wifi_mac->GetAttribute (
"BE_EdcaTxopN", ptr);
233 wifi_mac->GetAttribute (
"BE_EdcaTxopN", ptr);
242 positionAlloc->
Add (Vector (0.0, 0.0, 0.0));
243 for (uint32_t i = 0; i < nWifiB; i++)
245 positionAlloc->
Add (Vector (5.0, 0.0, 0.0));
247 for (uint32_t i = 0; i < nWifiG; i++)
249 positionAlloc->
Add (Vector (0.0, 5.0, 0.0));
251 for (uint32_t i = 0; i < nWifiNNGF; i++)
253 positionAlloc->
Add (Vector (0.0, 0.0, 5.0));
255 for (uint32_t i = 0; i < nWifiNGF; i++)
257 positionAlloc->
Add (Vector (0.0, 0.0, 5.0));
263 mobility.
Install (wifiBStaNodes);
264 mobility.
Install (wifiGStaNodes);
265 mobility.
Install (wifiNNGFStaNodes);
266 mobility.
Install (wifiNGFStaNodes);
273 stack.
Install (wifiNNGFStaNodes);
274 stack.
Install (wifiNGFStaNodes);
277 address.
SetBase (
"192.168.1.0",
"255.255.255.0");
279 bStaInterface = address.
Assign (bStaDevice);
281 gStaInterface = address.
Assign (gStaDevice);
283 nNGFStaInterface = address.
Assign (nNGFStaDevice);
285 nGFStaInterface = address.
Assign (nGFStaDevice);
287 ApInterface = address.
Assign (apDevice);
300 client.SetAttribute (
"Interval",
TimeValue (
Time (
"0.0002")));
301 client.SetAttribute (
"PacketSize",
UintegerValue (payloadSize));
306 clientApps.
Add (client.Install (wifiBStaNodes));
310 clientApps.
Add (client.Install (wifiGStaNodes));
314 clientApps.
Add (client.Install (wifiNNGFStaNodes));
318 clientApps.
Add (client.Install (wifiNGFStaNodes));
327 uint64_t totalPacketsThrough = DynamicCast<UdpServer> (serverApp.
Get (0))->GetReceived ();
328 throughput = totalPacketsThrough * payloadSize * 8 / (simulationTime * 1000000.0);
332 uint16_t
port = 50000;
352 clientApps.
Add (onoff.
Install (wifiBStaNodes));
356 clientApps.
Add (onoff.
Install (wifiGStaNodes));
360 clientApps.
Add (onoff.
Install (wifiNNGFStaNodes));
364 clientApps.
Add (onoff.
Install (wifiNGFStaNodes));
373 uint64_t totalPacketsThrough = DynamicCast<PacketSink> (serverApp.
Get (0))->GetTotalRx ();
374 throughput += totalPacketsThrough * 8 / (simulationTime * 1000000.0);
379 int main (
int argc,
char *argv[])
403 bool verifyResults = 0;
408 cmd.
AddValue (
"isUdp",
"UDP if set to 1, TCP otherwise", params.
isUdp);
409 cmd.
AddValue (
"verifyResults",
"Enable/disable results verification at the end of the simulation", verifyResults);
410 cmd.
Parse (argc, argv);
413 double throughput = 0;
415 params.
testName =
"g only with all g features disabled";
416 throughput = experiment.
Run (params);
417 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
419 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
422 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
424 params.
testName =
"g only with short slot time enabled";
429 throughput = experiment.
Run (params);
430 if (verifyResults && (throughput < 29 || throughput > 30))
432 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
435 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
437 params.
testName =
"Mixed b/g with all g features disabled";
442 throughput = experiment.
Run (params);
443 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
445 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
448 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
450 params.
testName =
"Mixed b/g with short plcp preamble enabled";
455 throughput = experiment.
Run (params);
456 if (verifyResults && (throughput < 22.5 || throughput > 23.5))
458 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
461 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
463 params.
testName =
"Mixed b/g with short slot time enabled using RTS-CTS protection";
469 throughput = experiment.
Run (params);
470 if (verifyResults && (throughput < 19 || throughput > 20))
472 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
475 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
477 params.
testName =
"Mixed b/g with short plcp preamble enabled using RTS-CTS protection";
482 throughput = experiment.
Run (params);
483 if (verifyResults && (throughput < 19 || throughput > 20))
485 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
488 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
490 params.
testName =
"Mixed b/g with short slot time enabled using CTS-TO-SELF protection";
496 throughput = experiment.
Run (params);
497 if (verifyResults && (throughput < 20.5 || throughput > 21.5))
499 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
502 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
504 params.
testName =
"Mixed b/g with short plcp preamble enabled using CTS-TO-SELF protection";
509 throughput = experiment.
Run (params);
510 if (verifyResults && (throughput < 20.5 || throughput > 21.5))
512 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
515 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
517 params.
testName =
"HT GF not supported";
531 throughput = experiment.
Run (params);
532 if (verifyResults && (throughput < 43 || throughput > 44))
534 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
537 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
539 params.
testName =
"HT only with GF used";
553 throughput = experiment.
Run (params);
554 if (verifyResults && (throughput < 44 || throughput > 45))
556 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
559 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
561 params.
testName =
"HT only with GF allowed but disabled by protection";
575 throughput = experiment.
Run (params);
576 if (verifyResults && (throughput < 43 || throughput > 44))
578 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
581 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
583 params.
testName =
"HT only with GF not supported by the receiver";
597 throughput = experiment.
Run (params);
598 if (verifyResults && (throughput < 43 || throughput > 44))
600 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
603 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
605 params.
testName =
"Mixed HT/non-HT with GF enabled";
619 throughput = experiment.
Run (params);
620 if (verifyResults && (throughput < 44 || throughput > 45))
622 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
625 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
627 params.
testName =
"HT only with RIFS enabled";
643 throughput = experiment.
Run (params);
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 with RIFS enabled but not forbidden";
667 throughput = experiment.
Run (params);
668 if (verifyResults && (throughput < 44 || throughput > 45))
670 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
673 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
675 params.
testName =
"Mixed HT/non-HT with RIFS enabled but forbidden";
691 throughput = experiment.
Run (params);
692 if (verifyResults && (throughput < 43 || throughput > 44))
694 NS_LOG_ERROR (
"Obtained throughput " << throughput <<
" is not in the expected boundaries!");
697 std::cout <<
"Throughput: " << throughput <<
" Mbit/s \n" << std::endl;
ERP-OFDM PHY (Clause 19, Section 19.5)
void AddPropagationLoss(std::string name, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Helper class for UAN CW MAC example.
void Set(std::string name, const AttributeValue &v)
holds a vector of ns3::Application pointers.
Simulation virtual time values and global simulation resolution.
static Ipv4Address GetAny(void)
Smart pointer class similar to boost::intrusive_ptr.
AttributeValue implementation for Boolean.
holds a vector of std::pair of Ptr and interface index.
Ptr< YansWifiChannel > Create(void) const
void SetRemoteStationManager(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue())
Hold variables of type string.
Make it easy to create and manage PHY objects for the yans model.
static YansWifiChannelHelper Default(void)
Create a channel helper in a default working state.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
static void Run(void)
Run the simulation.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
aggregate IP/TCP/UDP functionality to existing Nodes.
uint32_t nWifiNGreenfield
A helper to make it easier to instantiate an ns3::PacketSinkApplication on a set of nodes...
HT PHY for the 2.4 GHz band (clause 20)
static YansWifiPhyHelper Default(void)
Create a phy helper in a default working state.
helps to create WifiNetDevice objects
A helper to make it easier to instantiate an ns3::OnOffApplication on a set of nodes.
a polymophic address class
virtual void SetStandard(WifiPhyStandard standard)
void SetChannel(Ptr< YansWifiChannel > channel)
WifiPhyStandard
Identifies the PHY specification that a Wifi device is configured to use.
This queue contains packets for a particular access class.
double Run(Parameters params)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
Create a client application which sends UDP packets carrying a 32bit sequence number and a 64 bit tim...
AttributeValue implementation for Time.
Hold an unsigned integer type.
holds a vector of ns3::NetDevice pointers
Create a server application which waits for input UDP packets and uses the information carried into t...
virtual NetDeviceContainer Install(const WifiPhyHelper &phy, const WifiMacHelper &mac, NodeContainer::Iterator first, NodeContainer::Iterator last) const
Ptr< NetDevice > GetDevice(uint32_t index) const
Retrieve the index-th NetDevice associated to this node.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Parse command-line arguments.
bool nGreenfieldHasTraffic
static void Destroy(void)
Execute the events scheduled with ScheduleDestroy().
void SetAttribute(std::string name, const AttributeValue &value)
Record an attribute to be set in each Application after it is is created.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Ptr< Application > Get(uint32_t i) const
Get the Ptr
stored in this container at a given index.
Hold objects of type Ptr.
std::string erpProtectionMode
DSSS PHY (Clause 15) and HR/DSSS PHY (Clause 18)
void SetMobilityModel(std::string type, std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue())
void Install(std::string nodeName) const
Aggregate implementations of the ns3::Ipv4, ns3::Ipv6, ns3::Udp, and ns3::Tcp classes onto the provid...
manage and create wifi channel objects for the yans model.
create MAC layers for a ns3::WifiNetDevice.
void SetPcapDataLinkType(SupportedPcapDataLinkTypes dlt)
Set the data link type of PCAP traces to be used.
uint32_t nWifiNNonGreenfield
The IEEE 802.11 SSID Information Element.
virtual void SetType(std::string type, std::string n0="", const AttributeValue &v0=EmptyAttributeValue(), std::string n1="", const AttributeValue &v1=EmptyAttributeValue(), std::string n2="", const AttributeValue &v2=EmptyAttributeValue(), std::string n3="", const AttributeValue &v3=EmptyAttributeValue(), std::string n4="", const AttributeValue &v4=EmptyAttributeValue(), std::string n5="", const AttributeValue &v5=EmptyAttributeValue(), std::string n6="", const AttributeValue &v6=EmptyAttributeValue(), std::string n7="", const AttributeValue &v7=EmptyAttributeValue(), std::string n8="", const AttributeValue &v8=EmptyAttributeValue(), std::string n9="", const AttributeValue &v9=EmptyAttributeValue(), std::string n10="", const AttributeValue &v10=EmptyAttributeValue())
Helper class used to assign positions and mobility models to nodes.
AttributeValue implementation for Address.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
Ipv4InterfaceContainer Assign(const NetDeviceContainer &c)
Assign IP addresses to the net devices specified in the container based on the current network prefix...
ApplicationContainer Install(NodeContainer c)
Create one UDP server application on each of the Nodes in the NodeContainer.
void SetTxopLimit(Time txopLimit)
Set the TXOP limit.
AttributeValue implementation for DataRate.
void AddValue(const std::string &name, const std::string &help, T &value)
Add a program argument, assigning to POD.
static void Stop(void)
Tell the Simulator the calling event should be the last one executed.
Ptr< Node > Get(uint32_t i) const
Get the Ptr stored in this container at a given index.
bool nNonGreenfieldHasTraffic
Time Seconds(double value)
Construct a Time in the indicated unit.
AttributeValue implementation for Ssid.
void SetDefault(std::string name, const AttributeValue &value)
void Add(Vector v)
Add a position to the list of positions.
Ptr< WifiMac > GetMac(void) const
ApplicationContainer Install(NodeContainer c) const
Install an ns3::PacketSinkApplication on each node of the input container configured with all the att...
void Parse(int argc, char *argv[])
Parse the program arguments.
A helper class to make life easier while doing simple IPv4 address assignment in scripts.
Time MicroSeconds(uint64_t value)
Construct a Time in the indicated unit.
#define NS_LOG_ERROR(msg)
Use NS_LOG to output a message of level LOG_ERROR.
void Create(uint32_t n)
Create n nodes and append pointers to them to the end of this NodeContainer.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
ApplicationContainer Install(NodeContainer c) const
Install an ns3::OnOffApplication on each node of the input container configured with all the attribut...
Include Radiotap link layer information.
bool apSupportsGreenfield
void SetAttribute(std::string name, const AttributeValue &value)
Helper function used to set the underlying application attributes.
bool enableShortPlcpPreamble
void SetBase(Ipv4Address network, Ipv4Mask mask, Ipv4Address base="0.0.0.1")
Set the base network number, network mask and base address.
Ipv4Address GetAddress(uint32_t i, uint32_t j=0) const
void experiment(bool enableCtsRts, std::string wifiManager)
Run single 10 seconds experiment.