87#include "ns3/command-line.h"
88#include "ns3/config.h"
89#include "ns3/string.h"
90#include "ns3/double.h"
91#include "ns3/spectrum-wifi-helper.h"
93#include "ns3/mobility-helper.h"
94#include "ns3/application-container.h"
95#include "ns3/multi-model-spectrum-channel.h"
96#include "ns3/wifi-net-device.h"
97#include "ns3/ap-wifi-mac.h"
98#include "ns3/he-configuration.h"
99#include "ns3/packet-socket-helper.h"
100#include "ns3/packet-socket-client.h"
101#include "ns3/packet-socket-server.h"
110 std::string sub = context.substr (10);
111 uint32_t pos = sub.find (
"/Device");
112 return atoi (sub.substr (0, pos).c_str ());
123main (
int argc,
char *argv[])
125 double duration = 10.0;
129 double powSta1 = 10.0;
130 double powSta2 = 10.0;
131 double powAp1 = 21.0;
132 double powAp2 = 21.0;
133 double ccaEdTrSta1 = -62;
134 double ccaEdTrSta2 = -62;
135 double ccaEdTrAp1 = -62;
136 double ccaEdTrAp2 = -62;
137 double minimumRssi = -82;
138 int channelBandwidth = 20;
141 double interval = 0.001;
142 bool enableObssPd =
true;
143 double obssPdThreshold = -72.0;
146 cmd.AddValue (
"duration",
"Duration of simulation (s)", duration);
147 cmd.AddValue (
"interval",
"Inter packet interval (s)", interval);
148 cmd.AddValue (
"enableObssPd",
"Enable/disable OBSS_PD", enableObssPd);
149 cmd.AddValue (
"d1",
"Distance between STA1 and AP1 (m)", d1);
150 cmd.AddValue (
"d2",
"Distance between STA2 and AP2 (m)", d2);
151 cmd.AddValue (
"d3",
"Distance between AP1 and AP2 (m)", d3);
152 cmd.AddValue (
"powSta1",
"Power of STA1 (dBm)", powSta1);
153 cmd.AddValue (
"powSta2",
"Power of STA2 (dBm)", powSta2);
154 cmd.AddValue (
"powAp1",
"Power of AP1 (dBm)", powAp1);
155 cmd.AddValue (
"powAp2",
"Power of AP2 (dBm)", powAp2);
156 cmd.AddValue (
"ccaEdTrSta1",
"CCA-ED Threshold of STA1 (dBm)", ccaEdTrSta1);
157 cmd.AddValue (
"ccaEdTrSta2",
"CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2);
158 cmd.AddValue (
"ccaEdTrAp1",
"CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1);
159 cmd.AddValue (
"ccaEdTrAp2",
"CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2);
160 cmd.AddValue (
"minimumRssi",
"Minimum RSSI for the ThresholdPreambleDetectionModel", minimumRssi);
161 cmd.AddValue (
"channelBandwidth",
"Bandwidth of the channel in MHz [20, 40, or 80]", channelBandwidth);
162 cmd.AddValue (
"obssPdThreshold",
"Threshold for the OBSS PD Algorithm", obssPdThreshold);
163 cmd.AddValue (
"mcs",
"The constant MCS value to transmit HE PPDUs", mcs);
164 cmd.Parse (argc, argv);
175 spectrumChannel->AddPropagationLossModel (lossModel);
177 spectrumChannel->SetPropagationDelayModel (delayModel);
181 switch (channelBandwidth)
184 spectrumPhy.
Set (
"ChannelSettings",
StringValue (
"{36, 20, BAND_5GHZ, 0}"));
187 spectrumPhy.
Set (
"ChannelSettings",
StringValue (
"{62, 40, BAND_5GHZ, 0}"));
190 spectrumPhy.
Set (
"ChannelSettings",
StringValue (
"{171, 80, BAND_5GHZ, 0}"));
193 NS_ABORT_MSG (
"Unrecognized channel bandwidth: " << channelBandwidth);
203 wifi.SetObssPdAlgorithm (
"ns3::ConstantObssPdAlgorithm",
208 std::ostringstream oss;
209 oss <<
"HeMcs" << mcs;
210 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
220 mac.SetType (
"ns3::StaWifiMac",
229 mac.SetType (
"ns3::ApWifiMac",
246 mac.SetType (
"ns3::StaWifiMac",
255 mac.SetType (
"ns3::ApWifiMac",
268 positionAlloc->Add (
Vector (0.0, 0.0, 0.0));
269 positionAlloc->Add (
Vector (d3, 0.0, 0.0));
270 positionAlloc->Add (
Vector (0.0, d1, 0.0));
271 positionAlloc->Add (
Vector (d3, d2, 0.0));
272 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
273 mobility.SetPositionAllocator (positionAlloc);
278 packetSocket.
Install (wifiApNodes);
281 TypeId tid = TypeId::LookupByName (
"ns3::UdpSocketFactory");
290 client->SetRemote (socketAddr);
292 client->SetAttribute (
"PacketSize",
UintegerValue (payloadSize));
296 server->SetLocal (socketAddr);
307 client->SetRemote (socketAddr);
309 client->SetAttribute (
"PacketSize",
UintegerValue (payloadSize));
313 server->SetLocal (socketAddr);
319 Simulator::Stop (
Seconds (duration));
322 Simulator::Destroy ();
326 double throughput =
static_cast<double> (
bytesReceived[2 + i]) * 8 / 1000 / 1000 / duration;
327 std::cout <<
"Throughput for BSS " << i + 1 <<
": " << throughput <<
" Mbit/s" << std::endl;
a polymophic address class
holds a vector of ns3::Application pointers.
Parse command-line arguments.
This class can be used to hold variables of floating point type such as 'double' or 'float'.
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.
virtual Address GetAddress(void) const =0
virtual uint32_t GetIfIndex(void) const =0
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.
uint32_t AddApplication(Ptr< Application > application)
Associate an Application to this Node.
Ptr< T > GetObject(void) const
Get a pointer to the requested aggregated Object.
uint32_t GetSize(void) const
Returns the the size in bytes of the packet (including the zero-filled initial payload).
an address for a packet socket
void SetProtocol(uint16_t protocol)
Set the protocol.
void SetPhysicalAddress(const Address address)
Set the destination address.
void SetSingleDevice(uint32_t device)
Set the address to match only a specified NetDevice.
Give ns3::PacketSocket powers to ns3::Node.
void Install(Ptr< Node > node) const
Aggregate an instance of a ns3::PacketSocketFactory onto the provided node.
Make it easy to create and manage PHY objects for the spectrum model.
void SetChannel(Ptr< SpectrumChannel > channel)
The IEEE 802.11 SSID Information Element.
AttributeValue implementation for Ssid.
Hold variables of type string.
AttributeValue implementation for Time.
a unique identifier for an interface.
Hold an unsigned integer type.
Vector3D Vector
Vector alias typedef for compatibility with mobility models.
helps to create WifiNetDevice objects
create MAC layers for a ns3::WifiNetDevice.
Hold together all Wifi-related objects.
Ptr< WifiMac > GetMac(void) const
Ptr< HeConfiguration > GetHeConfiguration(void) const
void SetErrorRateModel(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())
void Set(std::string name, const AttributeValue &v)
void SetPreambleDetectionModel(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())
void Connect(std::string path, const CallbackBase &cb)
#define NS_ABORT_MSG(msg)
Unconditional abnormal program termination with a message.
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, Ts... > MakeCallback(R(T::*memPtr)(Ts...), OBJ objPtr)
Build Callbacks for class method members which take varying numbers of arguments and potentially retu...
uint32_t ContextToNodeId(std::string context)
std::vector< uint32_t > bytesReceived(4)
void SocketRx(std::string context, Ptr< const Packet > p, const Address &addr)