examples: Use the static setup helper in wifi-{ht,vht,he,eht}-network examples

This commit is contained in:
Stefano Avallone
2025-06-24 12:08:04 +02:00
parent f07225608b
commit 5c3f08f905
5 changed files with 139 additions and 36 deletions

View File

@@ -85,17 +85,17 @@ cpp_examples = [
"True",
),
(
"wifi-vht-network --simulationTime=0.2s --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=620",
"wifi-vht-network --simulationTime=0.2s --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=630",
"True",
"True",
),
(
"wifi-vht-network --simulationTime=0.2s --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=557",
"wifi-vht-network --simulationTime=0.2s --useRts=1 --minExpectedThroughput=5 --maxExpectedThroughput=565",
"True",
"True",
),
(
"wifi-vht-network --simulationTime=0.2s --useRts=0 --use80Plus80=1 --minExpectedThroughput=5 --maxExpectedThroughput=620",
"wifi-vht-network --simulationTime=0.2s --useRts=0 --use80Plus80=1 --minExpectedThroughput=5 --maxExpectedThroughput=630",
"True",
"True",
),
@@ -195,7 +195,7 @@ cpp_examples = [
"True",
),
(
"wifi-eht-network --simulationTime=0.25s --udp=0 --downlink=0 --useRts=0 --nStations=4 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mpduBufferSize=1024 --mcs=8 --muSchedAccessReqInterval=45ms --frequency2=6 --minExpectedThroughput=50 --maxExpectedThroughput=550",
"wifi-eht-network --simulationTime=0.25s --udp=0 --downlink=0 --useRts=0 --nStations=4 --dlAckType=AGGR-MU-BAR --enableUlOfdma=1 --enableBsrp=1 --mpduBufferSize=1024 --mcs=8 --muSchedAccessReqInterval=45ms --frequency2=6 --minExpectedThroughput=50 --maxExpectedThroughput=550 --RngRun=6",
"True",
"True",
),

View File

@@ -18,6 +18,7 @@
#include "ns3/log.h"
#include "ns3/mobility-helper.h"
#include "ns3/multi-model-spectrum-channel.h"
#include "ns3/neighbor-cache-helper.h"
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
@@ -28,8 +29,7 @@
#include "ns3/udp-server.h"
#include "ns3/uinteger.h"
#include "ns3/wifi-acknowledgment.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
#include "ns3/wifi-static-setup-helper.h"
#include <algorithm>
#include <array>
@@ -148,6 +148,8 @@ main(int argc, char* argv[])
uint16_t auxPhyChWidth{20};
bool auxPhyTxCapable{true};
Time simulationTime{"10s"};
bool staticSetup{true};
auto clientAppStartTime = Seconds(1);
meter_u distance{1.0};
double frequency{5}; // whether the first link operates in the 2.4, 5 or 6 GHz
double frequency2{0}; // whether the second link operates in the 2.4, 5 or 6 GHz (0 means no
@@ -170,6 +172,9 @@ main(int argc, char* argv[])
Time accessReqInterval{0};
CommandLine cmd(__FILE__);
cmd.AddValue("staticSetup",
"Whether devices are configured using the static setup helper",
staticSetup);
cmd.AddValue(
"frequency",
"Whether the first link operates in the 2.4, 5 or 6 GHz band (other values gets rejected)",
@@ -481,6 +486,8 @@ main(int argc, char* argv[])
mac.SetType("ns3::ApWifiMac",
"EnableBeaconJitter",
BooleanValue(false),
"BeaconGeneration",
BooleanValue(!staticSetup),
"Ssid",
SsidValue(ssid));
apDevice = wifi.Install(phy, mac, wifiApNode);
@@ -509,6 +516,17 @@ main(int argc, char* argv[])
mobility.Install(wifiApNode);
mobility.Install(wifiStaNodes);
if (staticSetup)
{
/* static setup of association and BA agreements */
auto apDev = DynamicCast<WifiNetDevice>(apDevice.Get(0));
NS_ASSERT(apDev);
WifiStaticSetupHelper::SetStaticAssociation(apDev, staDevices);
WifiStaticSetupHelper::SetStaticEmlsr(apDev, staDevices);
WifiStaticSetupHelper::SetStaticBlockAck(apDev, staDevices, {0});
clientAppStartTime = MilliSeconds(1);
}
/* Internet stack*/
InternetStackHelper stack;
stack.Install(wifiApNode);
@@ -524,6 +542,13 @@ main(int argc, char* argv[])
staNodeInterfaces = address.Assign(staDevices);
apNodeInterface = address.Assign(apDevice);
if (staticSetup)
{
/* static setup of ARP cache */
NeighborCacheHelper nbCache;
nbCache.PopulateNeighborCache();
}
/* Setting applications */
ApplicationContainer serverApp;
auto serverNodes = downlink ? std::ref(wifiStaNodes) : std::ref(wifiApNode);
@@ -551,7 +576,7 @@ main(int argc, char* argv[])
streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
const auto packetInterval = payloadSize * 8.0 / maxLoad;
for (std::size_t i = 0; i < nStations; i++)
@@ -563,8 +588,8 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
}
else
@@ -577,7 +602,7 @@ main(int argc, char* argv[])
streamNumber += packetSinkHelper.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
for (std::size_t i = 0; i < nStations; i++)
{
@@ -594,8 +619,8 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = onoff.Install(clientNodes.Get(i));
streamNumber += onoff.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
}
@@ -604,17 +629,17 @@ main(int argc, char* argv[])
if (tputInterval.IsStrictlyPositive())
{
Simulator::Schedule(Seconds(1) + tputInterval,
Simulator::Schedule(clientAppStartTime + tputInterval,
&PrintIntermediateTput,
cumulRxBytes,
udp,
serverApp,
payloadSize,
tputInterval,
simulationTime + Seconds(1));
simulationTime + clientAppStartTime);
}
Simulator::Stop(simulationTime + Seconds(1));
Simulator::Stop(simulationTime + clientAppStartTime);
Simulator::Run();
// When multiple stations are used, there are chances that association requests

View File

@@ -19,6 +19,7 @@
#include "ns3/log.h"
#include "ns3/mobility-helper.h"
#include "ns3/multi-model-spectrum-channel.h"
#include "ns3/neighbor-cache-helper.h"
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
@@ -29,6 +30,7 @@
#include "ns3/udp-server.h"
#include "ns3/uinteger.h"
#include "ns3/wifi-acknowledgment.h"
#include "ns3/wifi-static-setup-helper.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
@@ -66,6 +68,8 @@ main(int argc, char* argv[])
bool use80Plus80{false};
bool useExtendedBlockAck{false};
Time simulationTime{"10s"};
bool staticSetup{true};
auto clientAppStartTime = Seconds(1);
meter_u distance{1.0};
double frequency{5}; // whether 2.4, 5 or 6 GHz
std::size_t nStations{1};
@@ -84,6 +88,9 @@ main(int argc, char* argv[])
Time accessReqInterval{0};
CommandLine cmd(__FILE__);
cmd.AddValue("staticSetup",
"Whether devices are configured using the static setup helper",
staticSetup);
cmd.AddValue("frequency",
"Whether working in the 2.4, 5 or 6 GHz band (other values gets rejected)",
frequency);
@@ -332,6 +339,8 @@ main(int argc, char* argv[])
mac.SetType("ns3::ApWifiMac",
"EnableBeaconJitter",
BooleanValue(false),
"BeaconGeneration",
BooleanValue(!staticSetup),
"Ssid",
SsidValue(ssid));
apDevice = wifi.Install(phy, mac, wifiApNode);
@@ -376,6 +385,16 @@ main(int argc, char* argv[])
mobility.Install(wifiApNode);
mobility.Install(wifiStaNodes);
if (staticSetup)
{
/* static setup of association and BA agreements */
auto apDev = DynamicCast<WifiNetDevice>(apDevice.Get(0));
NS_ASSERT(apDev);
WifiStaticSetupHelper::SetStaticAssociation(apDev, staDevices);
WifiStaticSetupHelper::SetStaticBlockAck(apDev, staDevices, {0});
clientAppStartTime = MilliSeconds(1);
}
/* Internet stack*/
InternetStackHelper stack;
stack.Install(wifiApNode);
@@ -391,6 +410,13 @@ main(int argc, char* argv[])
staNodeInterfaces = address.Assign(staDevices);
apNodeInterface = address.Assign(apDevice);
if (staticSetup)
{
/* static setup of ARP cache */
NeighborCacheHelper nbCache;
nbCache.PopulateNeighborCache();
}
/* Setting applications */
ApplicationContainer serverApp;
auto serverNodes = downlink ? std::ref(wifiStaNodes) : std::ref(wifiApNode);
@@ -415,7 +441,7 @@ main(int argc, char* argv[])
streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
const auto packetInterval = payloadSize * 8.0 / maxLoad;
for (std::size_t i = 0; i < nStations; i++)
@@ -427,8 +453,8 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
}
else
@@ -441,7 +467,7 @@ main(int argc, char* argv[])
streamNumber += packetSinkHelper.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
for (std::size_t i = 0; i < nStations; i++)
{
@@ -458,14 +484,14 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = onoff.Install(clientNodes.Get(i));
streamNumber += onoff.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
}
Simulator::Schedule(Seconds(0), &Ipv4GlobalRoutingHelper::PopulateRoutingTables);
Simulator::Stop(simulationTime + Seconds(1));
Simulator::Stop(simulationTime + clientAppStartTime);
Simulator::Run();
// When multiple stations are used, there are chances that association requests

View File

@@ -19,6 +19,7 @@
#include "ns3/ipv4-global-routing-helper.h"
#include "ns3/log.h"
#include "ns3/mobility-helper.h"
#include "ns3/neighbor-cache-helper.h"
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
@@ -28,6 +29,7 @@
#include "ns3/udp-client-server-helper.h"
#include "ns3/udp-server.h"
#include "ns3/uinteger.h"
#include "ns3/wifi-static-setup-helper.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
@@ -60,6 +62,8 @@ main(int argc, char* argv[])
bool udp{true};
bool useRts{false};
Time simulationTime{"10s"};
bool staticSetup{true};
auto clientAppStartTime = Seconds(1);
meter_u distance{1.0};
double frequency{5}; // whether 2.4 or 5 GHz
std::string mcsStr;
@@ -70,6 +74,9 @@ main(int argc, char* argv[])
double maxExpectedThroughput{0.0};
CommandLine cmd(__FILE__);
cmd.AddValue("staticSetup",
"Whether devices are configured using the static setup helper",
staticSetup);
cmd.AddValue("frequency",
"Whether working in the 2.4 or 5.0 GHz band (other values gets rejected)",
frequency);
@@ -233,6 +240,8 @@ main(int argc, char* argv[])
mac.SetType("ns3::ApWifiMac",
"EnableBeaconJitter",
BooleanValue(false),
"BeaconGeneration",
BooleanValue(!staticSetup),
"Ssid",
SsidValue(ssid));
@@ -256,6 +265,16 @@ main(int argc, char* argv[])
mobility.Install(wifiApNode);
mobility.Install(wifiStaNode);
if (staticSetup)
{
/* static setup of association and BA agreements */
auto apDev = DynamicCast<WifiNetDevice>(apDevice.Get(0));
NS_ASSERT(apDev);
WifiStaticSetupHelper::SetStaticAssociation(apDev, staDevice);
WifiStaticSetupHelper::SetStaticBlockAck(apDev, staDevice, {0});
clientAppStartTime = MilliSeconds(1);
}
/* Internet stack*/
InternetStackHelper stack;
stack.Install(wifiApNode);
@@ -271,6 +290,13 @@ main(int argc, char* argv[])
staNodeInterface = address.Assign(staDevice);
apNodeInterface = address.Assign(apDevice);
if (staticSetup)
{
/* static setup of ARP cache */
NeighborCacheHelper nbCache;
nbCache.PopulateNeighborCache();
}
/* Setting applications */
const auto maxLoad = HtPhy::GetDataRate(mcs,
MHz_u{static_cast<double>(width)},
@@ -286,7 +312,7 @@ main(int argc, char* argv[])
streamNumber += server.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
const auto packetInterval = payloadSize * 8.0 / maxLoad;
UdpClientHelper client(staNodeInterface.GetAddress(0), port);
@@ -296,8 +322,8 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = client.Install(wifiApNode.Get(0));
streamNumber += client.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
else
{
@@ -310,7 +336,7 @@ main(int argc, char* argv[])
packetSinkHelper.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
OnOffHelper onoff("ns3::TcpSocketFactory", Ipv4Address::GetAny());
onoff.SetAttribute("OnTime",
@@ -325,13 +351,13 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0));
streamNumber += onoff.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
Simulator::Stop(simulationTime + Seconds(1));
Simulator::Stop(simulationTime + clientAppStartTime);
Simulator::Run();
auto rxBytes = 0.0;

View File

@@ -17,6 +17,7 @@
#include "ns3/log.h"
#include "ns3/mobility-helper.h"
#include "ns3/multi-model-spectrum-channel.h"
#include "ns3/neighbor-cache-helper.h"
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
@@ -27,6 +28,7 @@
#include "ns3/udp-server.h"
#include "ns3/uinteger.h"
#include "ns3/vht-phy.h"
#include "ns3/wifi-static-setup-helper.h"
#include "ns3/yans-wifi-channel.h"
#include "ns3/yans-wifi-helper.h"
@@ -61,6 +63,8 @@ main(int argc, char* argv[])
bool useRts{false};
bool use80Plus80{false};
Time simulationTime{"10s"};
bool staticSetup{true};
auto clientAppStartTime = Seconds(1);
meter_u distance{1.0};
std::string mcsStr;
std::vector<uint64_t> mcsValues;
@@ -71,6 +75,9 @@ main(int argc, char* argv[])
double maxExpectedThroughput{0.0};
CommandLine cmd(__FILE__);
cmd.AddValue("staticSetup",
"Whether devices are configured using the static setup helper",
staticSetup);
cmd.AddValue("distance",
"Distance in meters between the station and the access point",
distance);
@@ -247,6 +254,8 @@ main(int argc, char* argv[])
mac.SetType("ns3::ApWifiMac",
"EnableBeaconJitter",
BooleanValue(false),
"BeaconGeneration",
BooleanValue(!staticSetup),
"Ssid",
SsidValue(ssid));
apDevice = wifi.Install(phy, mac, wifiApNode);
@@ -289,6 +298,16 @@ main(int argc, char* argv[])
mobility.Install(wifiApNode);
mobility.Install(wifiStaNode);
if (staticSetup)
{
/* static setup of association and BA agreements */
auto apDev = DynamicCast<WifiNetDevice>(apDevice.Get(0));
NS_ASSERT(apDev);
WifiStaticSetupHelper::SetStaticAssociation(apDev, staDevice);
WifiStaticSetupHelper::SetStaticBlockAck(apDev, staDevice, {0});
clientAppStartTime = MilliSeconds(1);
}
/* Internet stack*/
InternetStackHelper stack;
stack.Install(wifiApNode);
@@ -304,6 +323,13 @@ main(int argc, char* argv[])
staNodeInterface = address.Assign(staDevice);
apNodeInterface = address.Assign(apDevice);
if (staticSetup)
{
/* static setup of ARP cache */
NeighborCacheHelper nbCache;
nbCache.PopulateNeighborCache();
}
/* Setting applications */
const auto maxLoad = VhtPhy::GetDataRate(mcs,
MHz_u{static_cast<double>(width)},
@@ -319,7 +345,7 @@ main(int argc, char* argv[])
streamNumber += server.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
const auto packetInterval = payloadSize * 8.0 / maxLoad;
UdpClientHelper client(staNodeInterface.GetAddress(0), port);
@@ -329,8 +355,8 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = client.Install(wifiApNode.Get(0));
streamNumber += client.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
else
{
@@ -343,7 +369,7 @@ main(int argc, char* argv[])
packetSinkHelper.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0));
serverApp.Stop(simulationTime + Seconds(1));
serverApp.Stop(simulationTime + clientAppStartTime);
OnOffHelper onoff("ns3::TcpSocketFactory", Ipv4Address::GetAny());
onoff.SetAttribute("OnTime",
@@ -358,13 +384,13 @@ main(int argc, char* argv[])
ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0));
streamNumber += onoff.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1));
clientApp.Stop(simulationTime + Seconds(1));
clientApp.Start(clientAppStartTime);
clientApp.Stop(simulationTime + clientAppStartTime);
}
Ipv4GlobalRoutingHelper::PopulateRoutingTables();
Simulator::Stop(simulationTime + Seconds(1));
Simulator::Stop(simulationTime + clientAppStartTime);
Simulator::Run();
auto rxBytes = 0.0;