examples: Reduce amount of generated packets in wifi examples

This commit is contained in:
Sébastien Deronne
2024-03-06 20:50:32 +01:00
committed by Sébastien Deronne
parent a5c42bc879
commit 890bc05f07
11 changed files with 39 additions and 21 deletions

View File

@@ -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",
),

View File

@@ -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));

View File

@@ -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);

View File

@@ -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);

View File

@@ -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);

View File

@@ -480,7 +480,7 @@ Experiment::ApplicationSetup(Ptr<Node> client, Ptr<Node> 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)));

View File

@@ -375,7 +375,7 @@ main(int argc, char* argv[])
for (uint32_t i = 0; i < 2; i++)
{
double throughput = static_cast<double>(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;
}

View File

@@ -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));

View File

@@ -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));

View File

@@ -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));

View File

@@ -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);