63 #include "ns3/command-line.h"
64 #include "ns3/config.h"
65 #include "ns3/string.h"
66 #include "ns3/spectrum-wifi-helper.h"
68 #include "ns3/mobility-helper.h"
69 #include "ns3/application-container.h"
70 #include "ns3/multi-model-spectrum-channel.h"
71 #include "ns3/wifi-net-device.h"
72 #include "ns3/ap-wifi-mac.h"
73 #include "ns3/he-configuration.h"
74 #include "ns3/packet-socket-helper.h"
75 #include "ns3/packet-socket-client.h"
76 #include "ns3/packet-socket-server.h"
85 std::string sub = context.substr (10);
86 uint32_t pos = sub.find (
"/Device");
87 return atoi (sub.substr (0, pos).c_str ());
98 main (
int argc,
char *argv[])
100 double duration = 10.0;
104 double powSta1 = 10.0;
105 double powSta2 = 10.0;
106 double powAp1 = 21.0;
107 double powAp2 = 21.0;
108 double ccaEdTrSta1 = -62;
109 double ccaEdTrSta2 = -62;
110 double ccaEdTrAp1 = -62;
111 double ccaEdTrAp2 = -62;
112 uint32_t payloadSize = 1500;
114 double interval = 0.001;
115 bool enableObssPd =
true;
116 double obssPdThreshold = -72.0;
119 cmd.AddValue (
"duration",
"Duration of simulation (s)", duration);
120 cmd.AddValue (
"interval",
"Inter packet interval (s)", interval);
121 cmd.AddValue (
"enableObssPd",
"Enable/disable OBSS_PD", enableObssPd);
122 cmd.AddValue (
"d1",
"Distance between STA1 and AP1 (m)", d1);
123 cmd.AddValue (
"d2",
"Distance between STA2 and AP2 (m)", d2);
124 cmd.AddValue (
"d3",
"Distance between AP1 and AP2 (m)", d3);
125 cmd.AddValue (
"powSta1",
"Power of STA1 (dBm)", powSta1);
126 cmd.AddValue (
"powSta2",
"Power of STA2 (dBm)", powSta2);
127 cmd.AddValue (
"powAp1",
"Power of AP1 (dBm)", powAp1);
128 cmd.AddValue (
"powAp2",
"Power of AP2 (dBm)", powAp2);
129 cmd.AddValue (
"ccaEdTrSta1",
"CCA-ED Threshold of STA1 (dBm)", ccaEdTrSta1);
130 cmd.AddValue (
"ccaEdTrSta2",
"CCA-ED Threshold of STA2 (dBm)", ccaEdTrSta2);
131 cmd.AddValue (
"ccaEdTrAp1",
"CCA-ED Threshold of AP1 (dBm)", ccaEdTrAp1);
132 cmd.AddValue (
"ccaEdTrAp2",
"CCA-ED Threshold of AP2 (dBm)", ccaEdTrAp2);
133 cmd.AddValue (
"mcs",
"The constant MCS value to transmit HE PPDUs", mcs);
134 cmd.Parse (argc, argv);
145 spectrumChannel->AddPropagationLossModel (lossModel);
147 spectrumChannel->SetPropagationDelayModel (delayModel);
156 wifi.SetStandard (WIFI_STANDARD_80211ax_5GHZ);
159 wifi.SetObssPdAlgorithm (
"ns3::ConstantObssPdAlgorithm",
164 std::ostringstream oss;
165 oss <<
"HeMcs" << mcs;
166 wifi.SetRemoteStationManager (
"ns3::ConstantRateWifiManager",
176 mac.SetType (
"ns3::StaWifiMac",
185 mac.SetType (
"ns3::ApWifiMac",
202 mac.SetType (
"ns3::StaWifiMac",
211 mac.SetType (
"ns3::ApWifiMac",
224 positionAlloc->Add (Vector (0.0, 0.0, 0.0));
225 positionAlloc->Add (Vector (d3, 0.0, 0.0));
226 positionAlloc->Add (Vector (0.0, d1, 0.0));
227 positionAlloc->Add (Vector (d3, d2, 0.0));
228 mobility.SetMobilityModel (
"ns3::ConstantPositionMobilityModel");
229 mobility.SetPositionAllocator (positionAlloc);
234 packetSocket.
Install (wifiApNodes);
246 client->SetRemote (socketAddr);
248 client->SetAttribute (
"PacketSize",
UintegerValue (payloadSize));
252 server->SetLocal (socketAddr);
263 client->SetRemote (socketAddr);
265 client->SetAttribute (
"PacketSize",
UintegerValue (payloadSize));
269 server->SetLocal (socketAddr);
280 for (uint32_t i = 0; i < 2; i++)
282 double throughput =
static_cast<double> (
bytesReceived[2 + i]) * 8 / 1000 / 1000 / duration;
283 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.
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.
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.
static TypeId LookupByName(std::string name)
Get a TypeId by name.
Hold an unsigned integer type.
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 Set(std::string name, const AttributeValue &v)
void SetErrorRateModel(std::string type, Args &&... args)
Helper function used to set the error rate model.
void SetPreambleDetectionModel(std::string type, Args &&... args)
Helper function used to set the preamble detection model.
void Connect(std::string path, const CallbackBase &cb)
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)