wifi: Extend the wifi-he-network script

Add an option to select DL or UL traffic and an option to configure
the channel access timer of the MultiUserScheduler.
This commit is contained in:
Stefano Avallone
2022-05-11 12:02:24 +02:00
committed by Stefano Avallone
parent f8c2613e47
commit 1be8c8a874

View File

@@ -18,6 +18,7 @@
* Author: Sebastien Deronne <sebastien.deronne@gmail.com>
*/
#include <functional>
#include "ns3/command-line.h"
#include "ns3/config.h"
#include "ns3/uinteger.h"
@@ -67,6 +68,7 @@ NS_LOG_COMPONENT_DEFINE ("he-wifi-network");
int main (int argc, char *argv[])
{
bool udp {true};
bool downlink {true};
bool useRts {false};
bool useExtendedBlockAck {false};
double simulationTime {10}; //seconds
@@ -81,12 +83,14 @@ int main (int argc, char *argv[])
std::string phyModel {"Yans"};
double minExpectedThroughput {0};
double maxExpectedThroughput {0};
Time accessReqInterval {0};
CommandLine cmd (__FILE__);
cmd.AddValue ("frequency", "Whether working in the 2.4, 5 or 6 GHz band (other values gets rejected)", frequency);
cmd.AddValue ("distance", "Distance in meters between the station and the access point", distance);
cmd.AddValue ("simulationTime", "Simulation time in seconds", simulationTime);
cmd.AddValue ("udp", "UDP if set to 1, TCP otherwise", udp);
cmd.AddValue ("downlink", "Generate downlink flows if set to 1, uplink flows otherwise", downlink);
cmd.AddValue ("useRts", "Enable/disable RTS/CTS", useRts);
cmd.AddValue ("useExtendedBlockAck", "Enable/disable use of extended BACK", useExtendedBlockAck);
cmd.AddValue ("nStations", "Number of non-AP HE stations", nStations);
@@ -94,6 +98,7 @@ int main (int argc, char *argv[])
dlAckSeqType);
cmd.AddValue ("enableUlOfdma", "Enable UL OFDMA (useful if DL OFDMA is enabled and TCP is used)", enableUlOfdma);
cmd.AddValue ("enableBsrp", "Enable BSRP (useful if DL and UL OFDMA are enabled and TCP is used)", enableBsrp);
cmd.AddValue ("muSchedAccessReqInterval", "Duration of the interval between two requests for channel access made by the MU scheduler", accessReqInterval);
cmd.AddValue ("mcs", "if set, limit testing to a specific MCS (0-11)", mcs);
cmd.AddValue ("payloadSize", "The application payload size in bytes", payloadSize);
cmd.AddValue ("phyModel", "PHY model to use when OFDMA is disabled (Yans or Spectrum). If OFDMA is enabled then Spectrum is automatically selected", phyModel);
@@ -224,8 +229,9 @@ int main (int argc, char *argv[])
if (dlAckSeqType != "NO-OFDMA")
{
mac.SetMultiUserScheduler ("ns3::RrMultiUserScheduler",
"EnableUlOfdma", BooleanValue (enableUlOfdma),
"EnableBsrp", BooleanValue (enableBsrp));
"EnableUlOfdma", BooleanValue (enableUlOfdma),
"EnableBsrp", BooleanValue (enableBsrp),
"AccessReqInterval", TimeValue (accessReqInterval));
}
mac.SetType ("ns3::ApWifiMac",
"EnableBeaconJitter", BooleanValue (false),
@@ -288,22 +294,31 @@ int main (int argc, char *argv[])
/* Setting applications */
ApplicationContainer serverApp;
auto serverNodes = downlink ? std::ref (wifiStaNodes) : std::ref (wifiApNode);
Ipv4InterfaceContainer serverInterfaces;
NodeContainer clientNodes;
for (std::size_t i = 0; i < nStations; i++)
{
serverInterfaces.Add (downlink ? staNodeInterfaces.Get (i) : apNodeInterface.Get (0));
clientNodes.Add (downlink ? wifiApNode.Get (0) : wifiStaNodes.Get (i));
}
if (udp)
{
//UDP flow
uint16_t port = 9;
UdpServerHelper server (port);
serverApp = server.Install (wifiStaNodes);
serverApp = server.Install (serverNodes.get ());
serverApp.Start (Seconds (0.0));
serverApp.Stop (Seconds (simulationTime + 1));
for (std::size_t i = 0; i < nStations; i++)
{
UdpClientHelper client (staNodeInterfaces.GetAddress (i), port);
UdpClientHelper client (serverInterfaces.GetAddress (i), port);
client.SetAttribute ("MaxPackets", UintegerValue (4294967295u));
client.SetAttribute ("Interval", TimeValue (Time ("0.00001"))); //packets/s
client.SetAttribute ("PacketSize", UintegerValue (payloadSize));
ApplicationContainer clientApp = client.Install (wifiApNode.Get (0));
ApplicationContainer clientApp = client.Install (clientNodes.Get (i));
clientApp.Start (Seconds (1.0));
clientApp.Stop (Seconds (simulationTime + 1));
}
@@ -314,7 +329,7 @@ int main (int argc, char *argv[])
uint16_t port = 50000;
Address localAddress (InetSocketAddress (Ipv4Address::GetAny (), port));
PacketSinkHelper packetSinkHelper ("ns3::TcpSocketFactory", localAddress);
serverApp = packetSinkHelper.Install (wifiStaNodes);
serverApp = packetSinkHelper.Install (serverNodes.get ());
serverApp.Start (Seconds (0.0));
serverApp.Stop (Seconds (simulationTime + 1));
@@ -325,9 +340,9 @@ int main (int argc, char *argv[])
onoff.SetAttribute ("OffTime", StringValue ("ns3::ConstantRandomVariable[Constant=0]"));
onoff.SetAttribute ("PacketSize", UintegerValue (payloadSize));
onoff.SetAttribute ("DataRate", DataRateValue (1000000000)); //bit/s
AddressValue remoteAddress (InetSocketAddress (staNodeInterfaces.GetAddress (i), port));
AddressValue remoteAddress (InetSocketAddress (serverInterfaces.GetAddress (i), port));
onoff.SetAttribute ("Remote", remoteAddress);
ApplicationContainer clientApp = onoff.Install (wifiApNode.Get (0));
ApplicationContainer clientApp = onoff.Install (clientNodes.Get (i));
clientApp.Start (Seconds (1.0));
clientApp.Stop (Seconds (simulationTime + 1));
}