From c9cab18bfd1e03bb4fc3a8997a6f080706346a3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deronne?= Date: Sat, 22 Feb 2025 15:42:24 +0100 Subject: [PATCH] examples: Add multicast wifi example with various GCR settings to regression --- examples/wireless/examples-to-run.py | 45 ++++++++++++++++++++++++++++ examples/wireless/wifi-multicast.cc | 39 ++++++++++++++++++++++++ 2 files changed, 84 insertions(+) mode change 100755 => 100644 examples/wireless/examples-to-run.py diff --git a/examples/wireless/examples-to-run.py b/examples/wireless/examples-to-run.py old mode 100755 new mode 100644 index b84fce58c..fecbad71a --- a/examples/wireless/examples-to-run.py +++ b/examples/wireless/examples-to-run.py @@ -294,6 +294,51 @@ cpp_examples = [ "True", "False", ), + ( + "wifi-multicast --minExpectedPackets=10", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrUr --minExpectedPackets=10", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrUr --multicastFrameErrorRate=0.2 --minExpectedPackets=10", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrUr --maxAmpduLength=65535 --maxPackets=0 --nStations=4 --dataRate=50Mbps --gcrProtection=Rts-Cts --rtsThreshold=0 --simulationTime=1 --minExpectedThroughput=35 --maxExpectedThroughput=40", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrUr --maxAmpduLength=65535 --maxPackets=0 --nStations=4 --dataRate=50Mbps --gcrProtection=Cts-To-Self --simulationTime=1 --minExpectedThroughput=40 --maxExpectedThroughput=45", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrBlockAck --minExpectedPackets=10", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrBlockAck --multicastFrameErrorRate=0.2 --minExpectedPackets=10", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrBlockAck --maxAmpduLength=65535 --maxPackets=0 --nStations=4 --dataRate=100Mbps --gcrProtection=Rts-Cts --rtsThreshold=0 --simulationTime=1s --minExpectedThroughput=100 --maxExpectedThroughput=100", + "True", + "True", + ), + ( + "wifi-multicast --gcrRetransmissionPolicy=GcrBlockAck --maxAmpduLength=65535 --maxPackets=0 --nStations=4 --dataRate=100Mbps --gcrProtection=Cts-To-Self --simulationTime=1s --minExpectedThroughput=100 --maxExpectedThroughput=100", + "True", + "True", + ), ] # A list of Python examples to run in order to ensure that they remain diff --git a/examples/wireless/wifi-multicast.cc b/examples/wireless/wifi-multicast.cc index 0f83fc836..21dbada7d 100644 --- a/examples/wireless/wifi-multicast.cc +++ b/examples/wireless/wifi-multicast.cc @@ -231,6 +231,11 @@ main(int argc, char* argv[]) std::string gcrProtection{"Rts-Cts"}; double multicastFrameErrorRate{0.0}; uint16_t maxAmpduLength{0}; + double minExpectedPackets{0}; + double maxExpectedPackets{0}; + double minExpectedThroughput{0}; + double maxExpectedThroughput{0}; + double tolerance{0.01}; CommandLine cmd(__FILE__); cmd.AddValue("logging", "turn on example log components", logging); @@ -269,6 +274,20 @@ main(int argc, char* argv[]) "artificial error rate for multicast frame", multicastFrameErrorRate); cmd.AddValue("maxAmpduLength", "maximum length in bytes of an A-MPDU", maxAmpduLength); + cmd.AddValue("minExpectedPackets", + "if set, simulation fails if the lowest amount of received packets is below this " + "value (in Mbit/s)", + minExpectedPackets); + cmd.AddValue("maxExpectedPackets", + "if set, simulation fails if the highest amount of received packets is above this " + "value (in Mbit/s)", + maxExpectedPackets); + cmd.AddValue("minExpectedThroughput", + "if set, simulation fails if the throughput is below this value", + minExpectedThroughput); + cmd.AddValue("maxExpectedThroughput", + "if set, simulation fails if the throughput is above this value", + maxExpectedThroughput); cmd.Parse(argc, argv); Config::SetDefault("ns3::WifiMac::RobustAVStreamingSupported", BooleanValue(true)); @@ -492,6 +511,26 @@ main(int argc, char* argv[]) : 0.0; // Mbit/s std::cout << "STA" << i + 1 << "\t\t\t0\t\t\t0\t\t\t" << rxPackets << "\t\t\t" << rxBytes << "\t\t\t" << throughput << "" << std::endl; + if (rxPackets < minExpectedPackets) + { + NS_LOG_ERROR("Obtained RX packets " << rxPackets << " is not expected!"); + exit(1); + } + if (maxExpectedPackets > 0 && rxPackets > maxExpectedPackets) + { + NS_LOG_ERROR("Obtained RX packets " << rxPackets << " is not expected!"); + exit(1); + } + if ((throughput * (1 + tolerance)) < minExpectedThroughput) + { + NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!"); + exit(1); + } + if (maxExpectedThroughput > 0 && (throughput > (maxExpectedThroughput * (1 + tolerance)))) + { + NS_LOG_ERROR("Obtained throughput " << throughput << " is not expected!"); + exit(1); + } } Simulator::Destroy();