From c866e09b18af820fa1507c17fbb63081cf230bc0 Mon Sep 17 00:00:00 2001 From: EmaMaker Date: Sat, 30 Dec 2023 12:10:49 +0000 Subject: [PATCH] simplify onoffhelper syntax --- scratch/task_2001600.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/scratch/task_2001600.cc b/scratch/task_2001600.cc index d7ed8c53d..ee1d3b236 100644 --- a/scratch/task_2001600.cc +++ b/scratch/task_2001600.cc @@ -308,35 +308,29 @@ int main(int argc, char* argv[]) server1_app.Start(Seconds(0)); // Node 11 that sends to server 0 - OnOffHelper onOffHelper_11("ns3::TcpSocketFactory", iStations.GetAddress(1)); + OnOffHelper onOffHelper_11("ns3::TcpSocketFactory", InetSocketAddress(ipptp02.GetAddress(0), port0)); onOffHelper_11.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_11.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_11.SetAttribute("PacketSize", UintegerValue(1821)); - AddressValue address0_11(InetSocketAddress(ipptp02.GetAddress(0), port0)); - onOffHelper_11.SetAttribute("Remote", address0_11); onOffHelper_11.SetAttribute("StartTime", StringValue("1.15s")); ApplicationContainer node11_app; node11_app.Add(onOffHelper_11.Install(wifiStaNodes.Get(1))); node11_app.Start(Seconds(1.15)); // Node 15 that sends to server 1 - OnOffHelper onOffHelper_10("ns3::TcpSocketFactory", iStations.GetAddress(0)); + OnOffHelper onOffHelper_10("ns3::TcpSocketFactory", InetSocketAddress(ipptp12.GetAddress(0), port0)); onOffHelper_10.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_10.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_10.SetAttribute("PacketSize", UintegerValue(1829)); - AddressValue address0_10(InetSocketAddress(InetSocketAddress(ipptp12.GetAddress(0), port0))); onOffHelper_10.SetAttribute("StartTime", StringValue("3.39s")); - onOffHelper_10.SetAttribute("Remote", address0_10); ApplicationContainer node10_app; node10_app.Add(onOffHelper_10.Install(wifiStaNodes.Get(0))); node10_app.Start(Seconds(3.39)); // Node 15 that sends to server 0 - OnOffHelper onOffHelper_15("ns3::TcpSocketFactory", iStations.GetAddress(5)); + OnOffHelper onOffHelper_15("ns3::TcpSocketFactory", InetSocketAddress(ipptp02.GetAddress(0), port1)); onOffHelper_15.SetAttribute("OnTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_15.SetAttribute("OffTime", StringValue("ns3::ExponentialRandomVariable[Mean=1]")); onOffHelper_15.SetAttribute("PacketSize", UintegerValue(1099)); - AddressValue address0_15(InetSocketAddress(ipptp02.GetAddress(0), port1)); onOffHelper_15.SetAttribute("StartTime", StringValue("3.71s")); - onOffHelper_15.SetAttribute("Remote", address0_15); ApplicationContainer node15_app; node15_app.Add(onOffHelper_15.Install(wifiStaNodes.Get(5))); node15_app.Start(Seconds(3.71));