From 890bc05f076dd2983cfd81e47190fe3d651459cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Wed, 6 Mar 2024 20:50:32 +0100 Subject: [PATCH] examples: Reduce amount of generated packets in wifi examples --- examples/wireless/examples-to-run.py | 8 ++++---- examples/wireless/wifi-80211n-mimo.cc | 10 ++++++++-- examples/wireless/wifi-eht-network.cc | 7 +++++-- examples/wireless/wifi-he-network.cc | 6 ++++-- examples/wireless/wifi-ht-network.cc | 6 ++++-- examples/wireless/wifi-multirate.cc | 2 +- examples/wireless/wifi-spatial-reuse.cc | 2 +- examples/wireless/wifi-spectrum-per-example.cc | 5 +++-- examples/wireless/wifi-spectrum-per-interference.cc | 5 +++-- examples/wireless/wifi-spectrum-saturation-example.cc | 3 ++- examples/wireless/wifi-vht-network.cc | 6 ++++-- 11 files changed, 39 insertions(+), 21 deletions(-) diff --git a/examples/wireless/examples-to-run.py b/examples/wireless/examples-to-run.py index dc9b766cc..00e61973c 100755 --- a/examples/wireless/examples-to-run.py +++ b/examples/wireless/examples-to-run.py @@ -85,7 +85,7 @@ cpp_examples = [ "True", ), ( - "wifi-vht-network --simulationTime=0.2 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=583", + "wifi-vht-network --simulationTime=0.2 --useRts=0 --minExpectedThroughput=5 --maxExpectedThroughput=620", "True", "True", ), @@ -140,12 +140,12 @@ cpp_examples = [ "True", ), ( - "wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --minExpectedThroughput=6 --maxExpectedThroughput=550", + "wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --minExpectedThroughput=6 --maxExpectedThroughput=760", "True", "True", ), ( - "wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --mpduBufferSize=1024 --frequency2=6 --minExpectedThroughput=12 --maxExpectedThroughput=550", + "wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --mpduBufferSize=1024 --frequency2=6 --minExpectedThroughput=7 --maxExpectedThroughput=1300", "True", "True", ), @@ -155,7 +155,7 @@ cpp_examples = [ "True", ), ( - "wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=0 --mpduBufferSize=512 --frequency2=5 --minExpectedThroughput=12 --maxExpectedThroughput=500", + "wifi-eht-network --simulationTime=0.1 --frequency=2.4 --useRts=0 --mpduBufferSize=512 --frequency2=5 --minExpectedThroughput=7 --maxExpectedThroughput=330", "True", "True", ), diff --git a/examples/wireless/wifi-80211n-mimo.cc b/examples/wireless/wifi-80211n-mimo.cc index b6e7f1ef3..965aed4e3 100644 --- a/examples/wireless/wifi-80211n-mimo.cc +++ b/examples/wireless/wifi-80211n-mimo.cc @@ -41,6 +41,7 @@ #include "ns3/config.h" #include "ns3/double.h" #include "ns3/gnuplot.h" +#include "ns3/ht-phy.h" #include "ns3/internet-stack-helper.h" #include "ns3/ipv4-address-helper.h" #include "ns3/ipv4-global-routing-helper.h" @@ -213,6 +214,10 @@ main(int argc, char* argv[]) apNodeInterface = address.Assign(apDevice); /* Setting applications */ + const auto maxLoad = HtPhy::GetDataRate(i, + channelBonding ? 40 : 20, + shortGuardInterval ? 400 : 800, + nStreams); ApplicationContainer serverApp; if (udp) { @@ -222,10 +227,11 @@ main(int argc, char* argv[]) serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / maxLoad; UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.00001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); @@ -247,7 +253,7 @@ 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 + onoff.SetAttribute("DataRate", DataRateValue(maxLoad)); AddressValue remoteAddress(InetSocketAddress(staNodeInterface.GetAddress(0), port)); onoff.SetAttribute("Remote", remoteAddress); ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0)); diff --git a/examples/wireless/wifi-eht-network.cc b/examples/wireless/wifi-eht-network.cc index 035a45437..47370acfc 100644 --- a/examples/wireless/wifi-eht-network.cc +++ b/examples/wireless/wifi-eht-network.cc @@ -482,6 +482,8 @@ main(int argc, char* argv[]) clientNodes.Add(downlink ? wifiApNode.Get(0) : wifiStaNodes.Get(i)); } + const auto maxLoad = + nLinks * EhtPhy::GetDataRate(mcs, channelWidth, gi, 1) / nStations; if (udp) { // UDP flow @@ -490,12 +492,13 @@ main(int argc, char* argv[]) serverApp = server.Install(serverNodes.get()); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / maxLoad; for (std::size_t i = 0; i < nStations; i++) { UdpClientHelper client(serverInterfaces.GetAddress(i), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.00001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(clientNodes.Get(i)); clientApp.Start(Seconds(1.0)); @@ -520,7 +523,7 @@ 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 + onoff.SetAttribute("DataRate", DataRateValue(maxLoad)); AddressValue remoteAddress( InetSocketAddress(serverInterfaces.GetAddress(i), port)); onoff.SetAttribute("Remote", remoteAddress); diff --git a/examples/wireless/wifi-he-network.cc b/examples/wireless/wifi-he-network.cc index a13a9d5d8..7d4bbc591 100644 --- a/examples/wireless/wifi-he-network.cc +++ b/examples/wireless/wifi-he-network.cc @@ -367,6 +367,7 @@ main(int argc, char* argv[]) clientNodes.Add(downlink ? wifiApNode.Get(0) : wifiStaNodes.Get(i)); } + const auto maxLoad = HePhy::GetDataRate(mcs, channelWidth, gi, 1) / nStations; if (udp) { // UDP flow @@ -375,12 +376,13 @@ main(int argc, char* argv[]) serverApp = server.Install(serverNodes.get()); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / maxLoad; for (std::size_t i = 0; i < nStations; i++) { UdpClientHelper client(serverInterfaces.GetAddress(i), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.00001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(clientNodes.Get(i)); clientApp.Start(Seconds(1.0)); @@ -405,7 +407,7 @@ 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 + onoff.SetAttribute("DataRate", DataRateValue(maxLoad)); AddressValue remoteAddress( InetSocketAddress(serverInterfaces.GetAddress(i), port)); onoff.SetAttribute("Remote", remoteAddress); diff --git a/examples/wireless/wifi-ht-network.cc b/examples/wireless/wifi-ht-network.cc index 64f135ddc..b65100430 100644 --- a/examples/wireless/wifi-ht-network.cc +++ b/examples/wireless/wifi-ht-network.cc @@ -224,6 +224,7 @@ main(int argc, char* argv[]) apNodeInterface = address.Assign(apDevice); /* Setting applications */ + const auto maxLoad = HtPhy::GetDataRate(mcs, channelWidth, sgi ? 400 : 800, 1); ApplicationContainer serverApp; if (udp) { @@ -233,10 +234,11 @@ main(int argc, char* argv[]) serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / maxLoad; UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.00001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); @@ -258,7 +260,7 @@ main(int argc, char* argv[]) onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]")); onoff.SetAttribute("PacketSize", UintegerValue(payloadSize)); - onoff.SetAttribute("DataRate", DataRateValue(200000000)); // bit/s + onoff.SetAttribute("DataRate", DataRateValue(maxLoad)); AddressValue remoteAddress( InetSocketAddress(staNodeInterface.GetAddress(0), port)); onoff.SetAttribute("Remote", remoteAddress); diff --git a/examples/wireless/wifi-multirate.cc b/examples/wireless/wifi-multirate.cc index 409c1cea2..0a0671229 100644 --- a/examples/wireless/wifi-multirate.cc +++ b/examples/wireless/wifi-multirate.cc @@ -480,7 +480,7 @@ Experiment::ApplicationSetup(Ptr client, Ptr server, double start, d // Equipping the source node with OnOff Application used for sending OnOffHelper onoff("ns3::UdpSocketFactory", Address(InetSocketAddress(Ipv4Address("10.0.0.1"), m_port))); - onoff.SetConstantRate(DataRate(60000000)); + onoff.SetConstantRate(DataRate(54000000)); onoff.SetAttribute("PacketSize", UintegerValue(m_packetSize)); onoff.SetAttribute("Remote", AddressValue(InetSocketAddress(ipv4AddrServer, m_port))); diff --git a/examples/wireless/wifi-spatial-reuse.cc b/examples/wireless/wifi-spatial-reuse.cc index 1b898f0bd..8ab857ede 100644 --- a/examples/wireless/wifi-spatial-reuse.cc +++ b/examples/wireless/wifi-spatial-reuse.cc @@ -375,7 +375,7 @@ main(int argc, char* argv[]) for (uint32_t i = 0; i < 2; i++) { - double throughput = static_cast(bytesReceived[2 + i]) * 8 / 1000 / 1000 / duration; + const auto throughput = bytesReceived[2 + i] * 8.0 / 1000 / 1000 / duration; std::cout << "Throughput for BSS " << i + 1 << ": " << throughput << " Mbit/s" << std::endl; } diff --git a/examples/wireless/wifi-spectrum-per-example.cc b/examples/wireless/wifi-spectrum-per-example.cc index 931e66d4e..7f645ddba 100644 --- a/examples/wireless/wifi-spectrum-per-example.cc +++ b/examples/wireless/wifi-spectrum-per-example.cc @@ -474,10 +474,11 @@ main(int argc, char* argv[]) serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / (datarate * 1e6); UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.0001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); @@ -497,7 +498,7 @@ main(int argc, char* argv[]) onoff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]")); onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]")); onoff.SetAttribute("PacketSize", UintegerValue(payloadSize)); - onoff.SetAttribute("DataRate", DataRateValue(1000000000)); // bit/s + onoff.SetAttribute("DataRate", DataRateValue(datarate * 1e6)); AddressValue remoteAddress(InetSocketAddress(staNodeInterface.GetAddress(0), port)); onoff.SetAttribute("Remote", remoteAddress); ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0)); diff --git a/examples/wireless/wifi-spectrum-per-interference.cc b/examples/wireless/wifi-spectrum-per-interference.cc index 4cc273cfd..58354003c 100644 --- a/examples/wireless/wifi-spectrum-per-interference.cc +++ b/examples/wireless/wifi-spectrum-per-interference.cc @@ -531,10 +531,11 @@ main(int argc, char* argv[]) serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / (datarate * 1e6); UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.0001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); @@ -554,7 +555,7 @@ main(int argc, char* argv[]) onoff.SetAttribute("OnTime", StringValue("ns3::ConstantRandomVariable[Constant=1]")); onoff.SetAttribute("OffTime", StringValue("ns3::ConstantRandomVariable[Constant=0]")); onoff.SetAttribute("PacketSize", UintegerValue(payloadSize)); - onoff.SetAttribute("DataRate", DataRateValue(1000000000)); // bit/s + onoff.SetAttribute("DataRate", DataRateValue(datarate * 1e6)); AddressValue remoteAddress(InetSocketAddress(staNodeInterface.GetAddress(0), port)); onoff.SetAttribute("Remote", remoteAddress); ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0)); diff --git a/examples/wireless/wifi-spectrum-saturation-example.cc b/examples/wireless/wifi-spectrum-saturation-example.cc index c329c8c09..d2d16a2f9 100644 --- a/examples/wireless/wifi-spectrum-saturation-example.cc +++ b/examples/wireless/wifi-spectrum-saturation-example.cc @@ -645,10 +645,11 @@ main(int argc, char* argv[]) ApplicationContainer serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / (datarate * 1e6); UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.0001"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); diff --git a/examples/wireless/wifi-vht-network.cc b/examples/wireless/wifi-vht-network.cc index 34837f73b..cee36bea6 100644 --- a/examples/wireless/wifi-vht-network.cc +++ b/examples/wireless/wifi-vht-network.cc @@ -205,6 +205,7 @@ main(int argc, char* argv[]) apNodeInterface = address.Assign(apDevice); /* Setting applications */ + const auto maxLoad = VhtPhy::GetDataRate(mcs, channelWidth, sgi ? 400 : 800, 1); ApplicationContainer serverApp; if (udp) { @@ -214,10 +215,11 @@ main(int argc, char* argv[]) serverApp = server.Install(wifiStaNode.Get(0)); serverApp.Start(Seconds(0.0)); serverApp.Stop(Seconds(simulationTime + 1)); + const auto packetInterval = payloadSize * 8.0 / maxLoad; UdpClientHelper client(staNodeInterface.GetAddress(0), port); client.SetAttribute("MaxPackets", UintegerValue(4294967295U)); - client.SetAttribute("Interval", TimeValue(Time("0.00002"))); // packets/s + client.SetAttribute("Interval", TimeValue(Seconds(packetInterval))); client.SetAttribute("PacketSize", UintegerValue(payloadSize)); ApplicationContainer clientApp = client.Install(wifiApNode.Get(0)); clientApp.Start(Seconds(1.0)); @@ -239,7 +241,7 @@ 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 + onoff.SetAttribute("DataRate", DataRateValue(maxLoad)); AddressValue remoteAddress( InetSocketAddress(staNodeInterface.GetAddress(0), port)); onoff.SetAttribute("Remote", remoteAddress);