From d7d71d802bdbe9a05bf76d60da693393cbf15e9f Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 17:43:17 +0300 Subject: [PATCH] :sparkles: added tcp sender (flows) as argument to cmd --- src/combined-frr-no-udp.cc | 60 +++++++++++++++++++++++++------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/src/combined-frr-no-udp.cc b/src/combined-frr-no-udp.cc index 173d2e44..cd0ef8d2 100644 --- a/src/combined-frr-no-udp.cc +++ b/src/combined-frr-no-udp.cc @@ -126,6 +126,7 @@ void CalculateExpectedPackets(uint32_t tcp_max_bytes, DataRate udp_data_rate) int main(int argc, char* argv[]) { int cong_threshold = 0; + int number_of_tcp_senders = 1; std::string dir = ""; CommandLine cmd; cmd.AddValue("bandwidth_primary", "Bandwidth primary", @@ -138,6 +139,7 @@ int main(int argc, char* argv[]) cmd.AddValue("delay_alternate", "Delay Alternate", delay_alternate); cmd.AddValue("bandwidth_alternate", "Bandwidth Alternate", bandwidth_alternate); + cmd.AddValue("tcp_senders", "Number of TCP Senders", number_of_tcp_senders); cmd.AddValue("policy_threshold", "Congestion policy threshold", cong_threshold); cmd.AddValue("dir", "Traces directory", dir); @@ -175,13 +177,16 @@ int main(int argc, char* argv[]) // Topology setup NS_LOG_INFO("Creating Topology"); NodeContainer nodes; - nodes.Create(6); + nodes.Create(5 + number_of_tcp_senders); Names::Add("CongestionSender", nodes.Get(0)); - Names::Add("TrafficSender", nodes.Get(1)); - Names::Add("Router01", nodes.Get(2)); - Names::Add("Router02", nodes.Get(3)); - Names::Add("Router03", nodes.Get(4)); - Names::Add("Receiver", nodes.Get(5)); + for (int i = 0; i < number_of_tcp_senders; i++) + Names::Add("TrafficSender" + std::to_string(i), nodes.Get(1 + i)); + + int offset = number_of_tcp_senders; + Names::Add("Router01", nodes.Get(offset + 1)); + Names::Add("Router02", nodes.Get(offset + 2)); + Names::Add("Router03", nodes.Get(offset + 3)); + Names::Add("Receiver", nodes.Get(offset + 4)); InternetStackHelper stack; stack.Install(nodes); @@ -214,16 +219,21 @@ int main(int argc, char* argv[]) p2p_alternate.SetChannelAttribute("Delay", StringValue(delay_alternate)); p2p_alternate.SetQueue("ns3::DropTailQueue"); - NetDeviceContainer devices_1_2 = - p2p_traffic.Install(nodes.Get(1), nodes.Get(2)); - NetDeviceContainer devices_2_3 = - p2p_congested_link.Install(nodes.Get(2), nodes.Get(3)); + std::list tcp_senders; + + for (int i = 0; i < number_of_tcp_senders; i++) { + tcp_senders.push_back( + p2p_traffic.Install(nodes.Get(1 + i), nodes.Get(offset + 1))); + } + + NetDeviceContainer devices_2_3 = p2p_congested_link.Install( + nodes.Get(offset + 1), nodes.Get(offset + 2)); NetDeviceContainer devices_2_4 = - p2p_alternate.Install(nodes.Get(2), nodes.Get(4)); + p2p_alternate.Install(nodes.Get(offest + 1), nodes.Get(offset + 3)); NetDeviceContainer devices_4_3 = - p2p_alternate.Install(nodes.Get(4), nodes.Get(3)); + p2p_alternate.Install(nodes.Get(offset + 3), nodes.Get(offset + 2)); NetDeviceContainer devices_3_5 = - p2p_traffic.Install(nodes.Get(3), nodes.Get(5)); + p2p_traffic.Install(nodes.Get(offset + 2), nodes.Get(offset + 4)); // Configure PointToPoint link for congestion link PointToPointHelper p2p_congestion; @@ -240,20 +250,25 @@ int main(int argc, char* argv[]) Ipv4AddressHelper address; address.SetBase("10.1.1.0", "255.255.255.0"); Ipv4InterfaceContainer interfaces_0_2 = address.Assign(devices_0_2); - Ipv4InterfaceContainer interfaces_1_2 = address.Assign(devices_1_2); address.NewNetwork(); - address.SetBase("10.1.2.0", "255.255.255.0"); + + for (int i = 0; i < number_of_tcp_senders; i++) { + address.Assign(tcp_senders[i]); + address.NewNetwork(); + } + Ipv4InterfaceContainer interfaces_2_3 = address.Assign(devices_2_3); address.NewNetwork(); - address.SetBase("10.1.3.0", "255.255.255.0"); + Ipv4InterfaceContainer interfaces_2_4 = address.Assign(devices_2_4); address.NewNetwork(); - address.SetBase("10.1.4.0", "255.255.255.0"); + Ipv4InterfaceContainer interfaces_4_3 = address.Assign(devices_4_3); address.NewNetwork(); - address.SetBase("10.1.5.0", "255.255.255.0"); + Ipv4InterfaceContainer interfaces_3_5 = address.Assign(devices_3_5); address.NewNetwork(); + Ipv4GlobalRoutingHelper::PopulateRoutingTables(); // Receiver address @@ -290,9 +305,12 @@ int main(int argc, char* argv[]) UintegerValue(100000)); // 0 for unlimited data tcp_source.SetAttribute("SendSize", UintegerValue(1024)); // Packet size in bytes - ApplicationContainer tcp_app = tcp_source.Install(nodes.Get(1)); - tcp_app.Start(Seconds(0.0)); - tcp_app.Stop(Seconds(5.0)); + + for (int i = 0; i < number_of_tcp_senders; i++) { + ApplicationContainer tcp_app = tcp_source.Install(nodes.Get(1 + i)); + tcp_app.Start(Seconds(0.0)); + tcp_app.Stop(Seconds(5.0)); + } // Packet sink setup (Receiver node) PacketSinkHelper sink("ns3::TcpSocketFactory",