examples: Fix randomness in wifi network examples

This commit is contained in:
Sébastien Deronne
2024-03-11 18:33:19 +01:00
committed by Sébastien Deronne
parent 1c0809c31e
commit 63514f53e7
5 changed files with 57 additions and 1 deletions

View File

@@ -145,7 +145,7 @@ cpp_examples = [
"True",
),
(
"wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --mpduBufferSize=1024 --frequency2=6 --minExpectedThroughput=7 --maxExpectedThroughput=1300",
"wifi-eht-network --simulationTime=0.1 --frequency=5 --useRts=0 --mpduBufferSize=1024 --frequency2=6 --minExpectedThroughput=7 --maxExpectedThroughput=1444",
"True",
"True",
),

View File

@@ -461,6 +461,8 @@ main(int argc, char* argv[])
InternetStackHelper stack;
stack.Install(wifiApNode);
stack.Install(wifiStaNodes);
streamNumber += stack.AssignStreams(wifiApNode, streamNumber);
streamNumber += stack.AssignStreams(wifiStaNodes, streamNumber);
Ipv4AddressHelper address;
address.SetBase("192.168.1.0", "255.255.255.0");
@@ -490,6 +492,8 @@ main(int argc, char* argv[])
uint16_t port = 9;
UdpServerHelper server(port);
serverApp = server.Install(serverNodes.get());
streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
const auto packetInterval = payloadSize * 8.0 / maxLoad;
@@ -501,6 +505,8 @@ main(int argc, char* argv[])
client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
client.SetAttribute("PacketSize", UintegerValue(payloadSize));
ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}
@@ -512,6 +518,8 @@ main(int argc, char* argv[])
Address localAddress(InetSocketAddress(Ipv4Address::GetAny(), port));
PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
serverApp = packetSinkHelper.Install(serverNodes.get());
streamNumber += packetSinkHelper.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
@@ -528,6 +536,8 @@ main(int argc, char* argv[])
InetSocketAddress(serverInterfaces.GetAddress(i), port));
onoff.SetAttribute("Remote", remoteAddress);
ApplicationContainer clientApp = onoff.Install(clientNodes.Get(i));
streamNumber += onoff.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}

View File

@@ -346,6 +346,8 @@ main(int argc, char* argv[])
InternetStackHelper stack;
stack.Install(wifiApNode);
stack.Install(wifiStaNodes);
streamNumber += stack.AssignStreams(wifiApNode, streamNumber);
streamNumber += stack.AssignStreams(wifiStaNodes, streamNumber);
Ipv4AddressHelper address;
address.SetBase("192.168.1.0", "255.255.255.0");
@@ -374,6 +376,8 @@ main(int argc, char* argv[])
uint16_t port = 9;
UdpServerHelper server(port);
serverApp = server.Install(serverNodes.get());
streamNumber += server.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
const auto packetInterval = payloadSize * 8.0 / maxLoad;
@@ -385,6 +389,8 @@ main(int argc, char* argv[])
client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
client.SetAttribute("PacketSize", UintegerValue(payloadSize));
ApplicationContainer clientApp = client.Install(clientNodes.Get(i));
streamNumber += client.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}
@@ -396,6 +402,8 @@ main(int argc, char* argv[])
Address localAddress(InetSocketAddress(Ipv4Address::GetAny(), port));
PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
serverApp = packetSinkHelper.Install(serverNodes.get());
streamNumber += packetSinkHelper.AssignStreams(serverNodes.get(), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
@@ -412,6 +420,8 @@ main(int argc, char* argv[])
InetSocketAddress(serverInterfaces.GetAddress(i), port));
onoff.SetAttribute("Remote", remoteAddress);
ApplicationContainer clientApp = onoff.Install(clientNodes.Get(i));
streamNumber += onoff.AssignStreams(clientNodes.Get(i), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}

View File

@@ -32,6 +32,7 @@
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
#include "ns3/rng-seed-manager.h"
#include "ns3/ssid.h"
#include "ns3/string.h"
#include "ns3/tuple.h"
@@ -197,6 +198,12 @@ main(int argc, char* argv[])
NetDeviceContainer apDevice;
apDevice = wifi.Install(phy, mac, wifiApNode);
RngSeedManager::SetSeed(1);
RngSeedManager::SetRun(1);
int64_t streamNumber = 150;
streamNumber += wifi.AssignStreams(apDevice, streamNumber);
streamNumber += wifi.AssignStreams(staDevice, streamNumber);
// mobility.
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
@@ -214,6 +221,8 @@ main(int argc, char* argv[])
InternetStackHelper stack;
stack.Install(wifiApNode);
stack.Install(wifiStaNode);
streamNumber += stack.AssignStreams(wifiApNode, streamNumber);
streamNumber += stack.AssignStreams(wifiStaNode, streamNumber);
Ipv4AddressHelper address;
address.SetBase("192.168.1.0", "255.255.255.0");
@@ -232,6 +241,8 @@ main(int argc, char* argv[])
uint16_t port = 9;
UdpServerHelper server(port);
serverApp = server.Install(wifiStaNode.Get(0));
streamNumber += server.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
const auto packetInterval = payloadSize * 8.0 / maxLoad;
@@ -241,6 +252,8 @@ main(int argc, char* argv[])
client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
client.SetAttribute("PacketSize", UintegerValue(payloadSize));
ApplicationContainer clientApp = client.Install(wifiApNode.Get(0));
streamNumber += client.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}
@@ -251,6 +264,9 @@ main(int argc, char* argv[])
Address localAddress(InetSocketAddress(Ipv4Address::GetAny(), port));
PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
serverApp = packetSinkHelper.Install(wifiStaNode.Get(0));
streamNumber +=
packetSinkHelper.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
@@ -265,6 +281,8 @@ main(int argc, char* argv[])
InetSocketAddress(staNodeInterface.GetAddress(0), port));
onoff.SetAttribute("Remote", remoteAddress);
ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0));
streamNumber += onoff.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}

View File

@@ -29,6 +29,7 @@
#include "ns3/on-off-helper.h"
#include "ns3/packet-sink-helper.h"
#include "ns3/packet-sink.h"
#include "ns3/rng-seed-manager.h"
#include "ns3/ssid.h"
#include "ns3/string.h"
#include "ns3/udp-client-server-helper.h"
@@ -178,6 +179,12 @@ main(int argc, char* argv[])
NetDeviceContainer apDevice;
apDevice = wifi.Install(phy, mac, wifiApNode);
RngSeedManager::SetSeed(1);
RngSeedManager::SetRun(1);
int64_t streamNumber = 150;
streamNumber += wifi.AssignStreams(apDevice, streamNumber);
streamNumber += wifi.AssignStreams(staDevice, streamNumber);
// mobility.
MobilityHelper mobility;
Ptr<ListPositionAllocator> positionAlloc = CreateObject<ListPositionAllocator>();
@@ -195,6 +202,8 @@ main(int argc, char* argv[])
InternetStackHelper stack;
stack.Install(wifiApNode);
stack.Install(wifiStaNode);
streamNumber += stack.AssignStreams(wifiApNode, streamNumber);
streamNumber += stack.AssignStreams(wifiStaNode, streamNumber);
Ipv4AddressHelper address;
address.SetBase("192.168.1.0", "255.255.255.0");
@@ -213,6 +222,8 @@ main(int argc, char* argv[])
uint16_t port = 9;
UdpServerHelper server(port);
serverApp = server.Install(wifiStaNode.Get(0));
streamNumber += server.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
const auto packetInterval = payloadSize * 8.0 / maxLoad;
@@ -222,6 +233,8 @@ main(int argc, char* argv[])
client.SetAttribute("Interval", TimeValue(Seconds(packetInterval)));
client.SetAttribute("PacketSize", UintegerValue(payloadSize));
ApplicationContainer clientApp = client.Install(wifiApNode.Get(0));
streamNumber += client.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}
@@ -232,6 +245,9 @@ main(int argc, char* argv[])
Address localAddress(InetSocketAddress(Ipv4Address::GetAny(), port));
PacketSinkHelper packetSinkHelper("ns3::TcpSocketFactory", localAddress);
serverApp = packetSinkHelper.Install(wifiStaNode.Get(0));
streamNumber +=
packetSinkHelper.AssignStreams(wifiStaNode.Get(0), streamNumber);
serverApp.Start(Seconds(0.0));
serverApp.Stop(Seconds(simulationTime + 1));
@@ -246,6 +262,8 @@ main(int argc, char* argv[])
InetSocketAddress(staNodeInterface.GetAddress(0), port));
onoff.SetAttribute("Remote", remoteAddress);
ApplicationContainer clientApp = onoff.Install(wifiApNode.Get(0));
streamNumber += onoff.AssignStreams(wifiApNode.Get(0), streamNumber);
clientApp.Start(Seconds(1.0));
clientApp.Stop(Seconds(simulationTime + 1));
}