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 1/7] :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", From 9c30326e339c1dee1c0fd1fd9bfbf9107170b637 Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 17:54:44 +0300 Subject: [PATCH 2/7] :bug: fix issues --- src/combined-frr-no-udp.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/combined-frr-no-udp.cc b/src/combined-frr-no-udp.cc index cd0ef8d2..aad07684 100644 --- a/src/combined-frr-no-udp.cc +++ b/src/combined-frr-no-udp.cc @@ -229,7 +229,7 @@ int main(int argc, char* argv[]) 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(offest + 1), nodes.Get(offset + 3)); + p2p_alternate.Install(nodes.Get(offset + 1), nodes.Get(offset + 3)); NetDeviceContainer devices_4_3 = p2p_alternate.Install(nodes.Get(offset + 3), nodes.Get(offset + 2)); NetDeviceContainer devices_3_5 = @@ -252,9 +252,9 @@ int main(int argc, char* argv[]) Ipv4InterfaceContainer interfaces_0_2 = address.Assign(devices_0_2); address.NewNetwork(); - for (int i = 0; i < number_of_tcp_senders; i++) { - address.Assign(tcp_senders[i]); - address.NewNetwork(); + for (auto& tcp_sender : tcp_senders) { + address.Assign(tcp_sender); + address.NewNetwork(); } Ipv4InterfaceContainer interfaces_2_3 = address.Assign(devices_2_3); From d0d428d82475922a4d278203ec0381dcf70e7011 Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 17:55:56 +0300 Subject: [PATCH 3/7] :art: format files --- src/combined-frr-no-udp.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/combined-frr-no-udp.cc b/src/combined-frr-no-udp.cc index aad07684..a0ebcfec 100644 --- a/src/combined-frr-no-udp.cc +++ b/src/combined-frr-no-udp.cc @@ -253,8 +253,8 @@ int main(int argc, char* argv[]) address.NewNetwork(); for (auto& tcp_sender : tcp_senders) { - address.Assign(tcp_sender); - address.NewNetwork(); + address.Assign(tcp_sender); + address.NewNetwork(); } Ipv4InterfaceContainer interfaces_2_3 = address.Assign(devices_2_3); From 142da0613cd6d940a8484dc2cd4aa48ae3d932ad Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 20:11:08 +0300 Subject: [PATCH 4/7] :sparkles: working implementation --- src/combined-frr-no-udp.cc | 58 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/combined-frr-no-udp.cc b/src/combined-frr-no-udp.cc index aad07684..54bc4888 100644 --- a/src/combined-frr-no-udp.cc +++ b/src/combined-frr-no-udp.cc @@ -177,19 +177,21 @@ int main(int argc, char* argv[]) // Topology setup NS_LOG_INFO("Creating Topology"); NodeContainer nodes; - nodes.Create(5 + number_of_tcp_senders); + NodeContainer tcp_devices; + nodes.Create(5); + tcp_devices.Create(number_of_tcp_senders); Names::Add("CongestionSender", nodes.Get(0)); for (int i = 0; i < number_of_tcp_senders; i++) - Names::Add("TrafficSender" + std::to_string(i), nodes.Get(1 + i)); + Names::Add("TrafficSender" + std::to_string(i), tcp_devices.Get(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)); + Names::Add("Router01", nodes.Get(1)); + Names::Add("Router02", nodes.Get(2)); + Names::Add("Router03", nodes.Get(3)); + Names::Add("Receiver", nodes.Get(4)); InternetStackHelper stack; stack.Install(nodes); + stack.Install(tcp_devices); // Configure PointToPoint link for normal traffic PointToPointHelper p2p_traffic; @@ -223,17 +225,17 @@ int main(int argc, char* argv[]) 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))); + p2p_traffic.Install(tcp_devices.Get(i), nodes.Get(1))); } - NetDeviceContainer devices_2_3 = p2p_congested_link.Install( - nodes.Get(offset + 1), nodes.Get(offset + 2)); + NetDeviceContainer devices_2_3 = + p2p_congested_link.Install(nodes.Get(1), nodes.Get(2)); NetDeviceContainer devices_2_4 = - p2p_alternate.Install(nodes.Get(offset + 1), nodes.Get(offset + 3)); + p2p_alternate.Install(nodes.Get(1), nodes.Get(3)); NetDeviceContainer devices_4_3 = - p2p_alternate.Install(nodes.Get(offset + 3), nodes.Get(offset + 2)); + p2p_alternate.Install(nodes.Get(3), nodes.Get(2)); NetDeviceContainer devices_3_5 = - p2p_traffic.Install(nodes.Get(offset + 2), nodes.Get(offset + 4)); + p2p_traffic.Install(nodes.Get(2), nodes.Get(4)); // Configure PointToPoint link for congestion link PointToPointHelper p2p_congestion; @@ -244,7 +246,7 @@ int main(int argc, char* argv[]) p2p_congestion.SetQueue("ns3::DropTailQueue"); // Install devices and channels between nodes NetDeviceContainer devices_0_2 = - p2p_congestion.Install(nodes.Get(0), nodes.Get(2)); + p2p_congestion.Install(nodes.Get(0), nodes.Get(1)); // Assign IP addresses to subnets Ipv4AddressHelper address; @@ -253,8 +255,8 @@ int main(int argc, char* argv[]) address.NewNetwork(); for (auto& tcp_sender : tcp_senders) { - address.Assign(tcp_sender); - address.NewNetwork(); + address.Assign(tcp_sender); + address.NewNetwork(); } Ipv4InterfaceContainer interfaces_2_3 = address.Assign(devices_2_3); @@ -299,30 +301,32 @@ int main(int argc, char* argv[]) // TCP Setup SetupTCPConfig(); uint16_t tcp_port = 50002; - BulkSendHelper tcp_source("ns3::TcpSocketFactory", - InetSocketAddress(receiver_addr, tcp_port)); - tcp_source.SetAttribute("MaxBytes", - UintegerValue(100000)); // 0 for unlimited data - tcp_source.SetAttribute("SendSize", - UintegerValue(1024)); // Packet size in bytes + std::list tcp_apps; 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)); + BulkSendHelper tcp_source("ns3::TcpSocketFactory", + InetSocketAddress(receiver_addr, tcp_port)); + tcp_source.SetAttribute("MaxBytes", + UintegerValue(100000)); // 0 for unlimited data + tcp_source.SetAttribute("SendSize", + UintegerValue(1024)); // Packet size in bytes + + tcp_apps.push_back(tcp_source.Install(tcp_devices.Get(i))); + tcp_apps.back().Start(Seconds(0.0)); + tcp_apps.back().Stop(Seconds(5.0)); } // Packet sink setup (Receiver node) PacketSinkHelper sink("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), tcp_port)); - ApplicationContainer sink_app = sink.Install(nodes.Get(5)); + ApplicationContainer sink_app = sink.Install(nodes.Get(4)); sink_app.Start(Seconds(0.0)); sink_app.Stop(Seconds(10.0)); PacketSinkHelper udp_sink( "ns3::UdpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), udp_port)); - ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(5)); + ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(4)); udp_sink_app.Start(Seconds(0.0)); udp_sink_app.Stop(Seconds(10.0)); From 8dfd2a92c34fd0b3bd9b7d74bc91db74d93f6893 Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:41:44 +0300 Subject: [PATCH 5/7] :sparkles: implemented tcp split --- src/combined-baseline-no-udp.cc | 142 +++++++++++++------------------- src/combined-baseline-udp.cc | 80 +++++++++++------- src/combined-frr.cc | 82 +++++++++++------- 3 files changed, 157 insertions(+), 147 deletions(-) diff --git a/src/combined-baseline-no-udp.cc b/src/combined-baseline-no-udp.cc index 1ca4b3f6..0a52292e 100644 --- a/src/combined-baseline-no-udp.cc +++ b/src/combined-baseline-no-udp.cc @@ -18,50 +18,6 @@ using namespace ns3; -using CongestionPolicy = BasicCongestionPolicy; - -// using CongestionPolicy = RandomCongestionPolicy<100>; -using FRRPolicy = LFAPolicy; - -using SimulationQueue = FRRQueue; -using FRRNetDevice = PointToPointFRRNetDevice; -using FRRChannel = PointToPointFRRChannel; - -void toggleCongestion(Ptr queue) -{ - ; - // queue->m_congestionPolicy.turnOff(); -} - -// void enableRerouting(Ptr queue) -// { -// // queue->m_congestionPolicy.enable(); -// } - -NS_OBJECT_ENSURE_REGISTERED(SimulationQueue); -NS_OBJECT_ENSURE_REGISTERED(FRRChannel); -NS_OBJECT_ENSURE_REGISTERED(FRRNetDevice); - -template -Ptr getDevice(const NetDeviceContainer& devices) -{ - return devices.Get(INDEX)->GetObject(); -} - -template -Ptr getQueue(const NetDeviceContainer& devices) -{ - return DynamicCast( - getDevice(devices)->GetQueue()); -} - -template -void setAlternateTarget(const NetDeviceContainer& devices, - Ptr target) -{ - getDevice(devices)->addAlternateTarget(target); -} - // TCP parameters uint32_t segmentSize = 1024; uint32_t MTU_bytes = segmentSize + 54; @@ -127,6 +83,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", @@ -141,6 +98,7 @@ int main(int argc, char* argv[]) bandwidth_alternate); cmd.AddValue("policy_threshold", "Congestion policy threshold", cong_threshold); + cmd.AddValue("tcp_senders", "Number of TCP Senders", number_of_tcp_senders); cmd.AddValue("dir", "Traces directory", dir); cmd.Parse(argc, argv); @@ -176,16 +134,21 @@ int main(int argc, char* argv[]) // Topology setup NS_LOG_INFO("Creating Topology"); NodeContainer nodes; - nodes.Create(6); + NodeContainer tcp_devices; + nodes.Create(5); + tcp_devices.Create(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), tcp_devices.Get(i)); + + Names::Add("Router01", nodes.Get(1)); + Names::Add("Router02", nodes.Get(2)); + Names::Add("Router03", nodes.Get(3)); + Names::Add("Receiver", nodes.Get(4)); InternetStackHelper stack; stack.Install(nodes); + stack.Install(tcp_devices); // Configure PointToPoint link for normal traffic PointToPointHelper p2p_traffic; @@ -201,13 +164,10 @@ int main(int argc, char* argv[]) StringValue(bandwidth_bottleneck)); p2p_congested_link.SetChannelAttribute("Delay", StringValue(delay_bottleneck)); - // p2p_congested_link.SetQueue(SimulationQueue::getQueueString()); p2p_congested_link.SetQueue("ns3::DropTailQueue"); Config::SetDefault("ns3::DropTailQueue::MaxSize", StringValue("10p")); - Config::SetDefault(SimulationQueue::getQueueString() + "::MaxSize", - StringValue("10p")); PointToPointHelper p2p_alternate; p2p_alternate.SetDeviceAttribute("DataRate", @@ -215,16 +175,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)); + std::list tcp_senders; + + for (int i = 0; i < number_of_tcp_senders; i++) { + tcp_senders.push_back( + p2p_traffic.Install(tcp_devices.Get(i), nodes.Get(1))); + } + NetDeviceContainer devices_2_3 = - p2p_congested_link.Install(nodes.Get(2), nodes.Get(3)); + p2p_congested_link.Install(nodes.Get(1), nodes.Get(2)); NetDeviceContainer devices_2_4 = - p2p_alternate.Install(nodes.Get(2), nodes.Get(4)); + p2p_alternate.Install(nodes.Get(1), nodes.Get(3)); NetDeviceContainer devices_4_3 = - p2p_alternate.Install(nodes.Get(4), nodes.Get(3)); + p2p_alternate.Install(nodes.Get(3), nodes.Get(2)); NetDeviceContainer devices_3_5 = - p2p_traffic.Install(nodes.Get(3), nodes.Get(5)); + p2p_traffic.Install(nodes.Get(2), nodes.Get(4)); // Configure PointToPoint link for congestion link PointToPointHelper p2p_congestion; @@ -235,31 +200,33 @@ int main(int argc, char* argv[]) p2p_congestion.SetQueue("ns3::DropTailQueue"); // Install devices and channels between nodes NetDeviceContainer devices_0_2 = - p2p_congestion.Install(nodes.Get(0), nodes.Get(2)); + p2p_congestion.Install(nodes.Get(0), nodes.Get(1)); // Assign IP addresses to subnets 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 (auto& tcp_sender : tcp_senders) { + address.Assign(tcp_sender); + 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 Ipv4Address receiver_addr = interfaces_3_5.GetAddress(1); - + std::cout << receiver_addr << std::endl; // UDP Congestion traffic setup uint16_t udp_port = 50001; OnOffHelper udp_source("ns3::UdpSocketFactory", @@ -285,38 +252,39 @@ int main(int argc, char* argv[]) // TCP Setup SetupTCPConfig(); uint16_t tcp_port = 50002; - BulkSendHelper tcp_source("ns3::TcpSocketFactory", - InetSocketAddress(receiver_addr, tcp_port)); - tcp_source.SetAttribute("MaxBytes", - 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)); + + std::list tcp_apps; + for (int i = 0; i < number_of_tcp_senders; i++) { + BulkSendHelper tcp_source("ns3::TcpSocketFactory", + InetSocketAddress(receiver_addr, tcp_port)); + tcp_source.SetAttribute("MaxBytes", + UintegerValue(100000)); // 0 for unlimited data + tcp_source.SetAttribute("SendSize", + UintegerValue(1024)); // Packet size in bytes + + tcp_apps.push_back(tcp_source.Install(tcp_devices.Get(i))); + tcp_apps.back().Start(Seconds(0.0)); + tcp_apps.back().Stop(Seconds(5.0)); + } // Packet sink setup (Receiver node) PacketSinkHelper sink("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), tcp_port)); - ApplicationContainer sink_app = sink.Install(nodes.Get(5)); + ApplicationContainer sink_app = sink.Install(nodes.Get(4)); sink_app.Start(Seconds(0.0)); sink_app.Stop(Seconds(10.0)); PacketSinkHelper udp_sink( "ns3::UdpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), udp_port)); - ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(5)); + ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(4)); udp_sink_app.Start(Seconds(0.0)); udp_sink_app.Stop(Seconds(10.0)); + // SimulationQueue::sinkAddress = + // Mac48Address::ConvertFrom(getDevice<1>(devices_3_5)->GetAddress()); + // NOTE: Is TrafficControlHelper needed here? - // LFA Alternate Path setup - // Set up an alternate forwarding target, assuming you have an alternate - // path configured - // devices_2_3, getDevice<0, ns3::PointToPointNetDevice>(devices_2_4)); - // setAlternateTarget<1>( - // devices_2_3, getDevice<1, ns3::PointToPointNetDevice>(devices_4_3)); - // setAlternateTarget<0>(devices01, getDevice<0>(devices02)); - // setAlternateTarget<0>(devices02, getDevice<0>(devices01)); + // CalculateExpectedPackets(10000, DataRate("1Mbps")); p2p_traffic.EnablePcapAll(dir); p2p_congestion.EnablePcapAll(dir); diff --git a/src/combined-baseline-udp.cc b/src/combined-baseline-udp.cc index 1d9ee631..403d895e 100644 --- a/src/combined-baseline-udp.cc +++ b/src/combined-baseline-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", @@ -140,6 +141,7 @@ int main(int argc, char* argv[]) bandwidth_alternate); cmd.AddValue("policy_threshold", "Congestion policy threshold", cong_threshold); + cmd.AddValue("tcp_senders", "Number of TCP Senders", number_of_tcp_senders); cmd.AddValue("dir", "Traces directory", dir); cmd.Parse(argc, argv); @@ -175,16 +177,21 @@ int main(int argc, char* argv[]) // Topology setup NS_LOG_INFO("Creating Topology"); NodeContainer nodes; - nodes.Create(6); + NodeContainer tcp_devices; + nodes.Create(5); + tcp_devices.Create(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), tcp_devices.Get(i)); + + Names::Add("Router01", nodes.Get(1)); + Names::Add("Router02", nodes.Get(2)); + Names::Add("Router03", nodes.Get(3)); + Names::Add("Receiver", nodes.Get(4)); InternetStackHelper stack; stack.Install(nodes); + stack.Install(tcp_devices); // Configure PointToPoint link for normal traffic PointToPointHelper p2p_traffic; @@ -214,16 +221,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)); + std::list tcp_senders; + + for (int i = 0; i < number_of_tcp_senders; i++) { + tcp_senders.push_back( + p2p_traffic.Install(tcp_devices.Get(i), nodes.Get(1))); + } + NetDeviceContainer devices_2_3 = - p2p_congested_link.Install(nodes.Get(2), nodes.Get(3)); + p2p_congested_link.Install(nodes.Get(1), nodes.Get(2)); NetDeviceContainer devices_2_4 = - p2p_alternate.Install(nodes.Get(2), nodes.Get(4)); + p2p_alternate.Install(nodes.Get(1), nodes.Get(3)); NetDeviceContainer devices_4_3 = - p2p_alternate.Install(nodes.Get(4), nodes.Get(3)); + p2p_alternate.Install(nodes.Get(3), nodes.Get(2)); NetDeviceContainer devices_3_5 = - p2p_traffic.Install(nodes.Get(3), nodes.Get(5)); + p2p_traffic.Install(nodes.Get(2), nodes.Get(4)); // Configure PointToPoint link for congestion link PointToPointHelper p2p_congestion; @@ -234,27 +246,30 @@ int main(int argc, char* argv[]) p2p_congestion.SetQueue("ns3::DropTailQueue"); // Install devices and channels between nodes NetDeviceContainer devices_0_2 = - p2p_congestion.Install(nodes.Get(0), nodes.Get(2)); + p2p_congestion.Install(nodes.Get(0), nodes.Get(1)); // Assign IP addresses to subnets 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 (auto& tcp_sender : tcp_senders) { + address.Assign(tcp_sender); + 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 Ipv4Address receiver_addr = interfaces_3_5.GetAddress(1); @@ -284,27 +299,32 @@ int main(int argc, char* argv[]) // TCP Setup SetupTCPConfig(); uint16_t tcp_port = 50002; - BulkSendHelper tcp_source("ns3::TcpSocketFactory", - InetSocketAddress(receiver_addr, tcp_port)); - tcp_source.SetAttribute("MaxBytes", - 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)); + + std::list tcp_apps; + for (int i = 0; i < number_of_tcp_senders; i++) { + BulkSendHelper tcp_source("ns3::TcpSocketFactory", + InetSocketAddress(receiver_addr, tcp_port)); + tcp_source.SetAttribute("MaxBytes", + UintegerValue(100000)); // 0 for unlimited data + tcp_source.SetAttribute("SendSize", + UintegerValue(1024)); // Packet size in bytes + + tcp_apps.push_back(tcp_source.Install(tcp_devices.Get(i))); + tcp_apps.back().Start(Seconds(0.0)); + tcp_apps.back().Stop(Seconds(5.0)); + } // Packet sink setup (Receiver node) PacketSinkHelper sink("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), tcp_port)); - ApplicationContainer sink_app = sink.Install(nodes.Get(5)); + ApplicationContainer sink_app = sink.Install(nodes.Get(4)); sink_app.Start(Seconds(0.0)); sink_app.Stop(Seconds(10.0)); PacketSinkHelper udp_sink( "ns3::UdpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), udp_port)); - ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(5)); + ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(4)); udp_sink_app.Start(Seconds(0.0)); udp_sink_app.Stop(Seconds(10.0)); // SimulationQueue::sinkAddress = diff --git a/src/combined-frr.cc b/src/combined-frr.cc index 74009ba4..c7681e4e 100644 --- a/src/combined-frr.cc +++ b/src/combined-frr.cc @@ -101,6 +101,7 @@ void SetupTCPConfig() 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", @@ -113,6 +114,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); @@ -147,19 +149,24 @@ int main(int argc, char* argv[]) * | | * 5+----------+ */ - // Topology setup + // Topology Setup NS_LOG_INFO("Creating Topology"); NodeContainer nodes; - nodes.Create(6); + NodeContainer tcp_devices; + nodes.Create(5); + tcp_devices.Create(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), tcp_devices.Get(i)); + + Names::Add("Router01", nodes.Get(1)); + Names::Add("Router02", nodes.Get(2)); + Names::Add("Router03", nodes.Get(3)); + Names::Add("Receiver", nodes.Get(4)); InternetStackHelper stack; stack.Install(nodes); + stack.Install(tcp_devices); // Configure PointToPoint link for normal traffic PointToPointHelper p2p_traffic; @@ -189,16 +196,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)); + std::list tcp_senders; + + for (int i = 0; i < number_of_tcp_senders; i++) { + tcp_senders.push_back( + p2p_traffic.Install(tcp_devices.Get(i), nodes.Get(1))); + } + NetDeviceContainer devices_2_3 = - p2p_congested_link.Install(nodes.Get(2), nodes.Get(3)); + p2p_congested_link.Install(nodes.Get(1), nodes.Get(2)); NetDeviceContainer devices_2_4 = - p2p_alternate.Install(nodes.Get(2), nodes.Get(4)); + p2p_alternate.Install(nodes.Get(1), nodes.Get(3)); NetDeviceContainer devices_4_3 = - p2p_alternate.Install(nodes.Get(4), nodes.Get(3)); + p2p_alternate.Install(nodes.Get(3), nodes.Get(2)); NetDeviceContainer devices_3_5 = - p2p_traffic.Install(nodes.Get(3), nodes.Get(5)); + p2p_traffic.Install(nodes.Get(2), nodes.Get(4)); // Configure PointToPoint link for congestion link PointToPointHelper p2p_congestion; @@ -209,26 +221,31 @@ int main(int argc, char* argv[]) p2p_congestion.SetQueue("ns3::DropTailQueue"); // Install devices and channels between nodes NetDeviceContainer devices_0_2 = - p2p_congestion.Install(nodes.Get(0), nodes.Get(2)); + p2p_congestion.Install(nodes.Get(0), nodes.Get(1)); // Assign IP addresses to subnets 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 (auto& tcp_sender : tcp_senders) { + address.Assign(tcp_sender); + 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 @@ -259,27 +276,32 @@ int main(int argc, char* argv[]) // TCP Setup SetupTCPConfig(); uint16_t tcp_port = 50002; - BulkSendHelper tcp_source("ns3::TcpSocketFactory", - InetSocketAddress(receiver_addr, tcp_port)); - tcp_source.SetAttribute("MaxBytes", - 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)); + + std::list tcp_apps; + for (int i = 0; i < number_of_tcp_senders; i++) { + BulkSendHelper tcp_source("ns3::TcpSocketFactory", + InetSocketAddress(receiver_addr, tcp_port)); + tcp_source.SetAttribute("MaxBytes", + UintegerValue(100000)); // 0 for unlimited data + tcp_source.SetAttribute("SendSize", + UintegerValue(1024)); // Packet size in bytes + + tcp_apps.push_back(tcp_source.Install(tcp_devices.Get(i))); + tcp_apps.back().Start(Seconds(0.0)); + tcp_apps.back().Stop(Seconds(5.0)); + } // Packet sink setup (Receiver node) PacketSinkHelper sink("ns3::TcpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), tcp_port)); - ApplicationContainer sink_app = sink.Install(nodes.Get(5)); + ApplicationContainer sink_app = sink.Install(nodes.Get(4)); sink_app.Start(Seconds(0.0)); sink_app.Stop(Seconds(10.0)); PacketSinkHelper udp_sink( "ns3::UdpSocketFactory", InetSocketAddress(Ipv4Address::GetAny(), udp_port)); - ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(5)); + ApplicationContainer udp_sink_app = udp_sink.Install(nodes.Get(4)); udp_sink_app.Start(Seconds(0.0)); udp_sink_app.Stop(Seconds(10.0)); From ff7ba2921ae4c54507ec77be5450a36971b6efaf Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:42:03 +0300 Subject: [PATCH 6/7] :sparkles: updated the bash script --- run_ns3.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/run_ns3.sh b/run_ns3.sh index 67d23ca9..1c9fe26d 100755 --- a/run_ns3.sh +++ b/run_ns3.sh @@ -12,10 +12,10 @@ run_experiment() { mkdir -p "$dir/baseline-udp/" mkdir -p "$dir/baseline-no-udp/" - NS_LOG="" ./ns3 run "scratch/combined-frr.cc --$test_variable=$test_value --policy_threshold=$policy_threshold --dir=$dir/frr/" - NS_LOG="" ./ns3 run "scratch/combined-frr-no-udp.cc --$test_variable=$test_value --policy_threshold=$policy_threshold --dir=$dir/frr-no-udp/" - NS_LOG="" ./ns3 run "scratch/combined-baseline-udp.cc --$test_variable=$test_value --policy_threshold=$policy_threshold --dir=$dir/baseline-udp/" - NS_LOG="" ./ns3 run "scratch/combined-baseline-no-udp.cc --$test_variable=$test_value --policy_threshold=$policy_threshold --dir=$dir/baseline-no-udp/" + NS_LOG="" ./ns3 run "scratch/combined-frr.cc --$test_variable=$test_value --tcp_senders=1 --policy_threshold=$policy_threshold --dir=$dir/frr/" + NS_LOG="" ./ns3 run "scratch/combined-frr-no-udp.cc --$test_variable=$test_value --tcp_senders=1 --policy_threshold=$policy_threshold --dir=$dir/frr-no-udp/" + NS_LOG="" ./ns3 run "scratch/combined-baseline-udp.cc --$test_variable=$test_value --tcp_senders=1 --policy_threshold=$policy_threshold --dir=$dir/baseline-udp/" + NS_LOG="" ./ns3 run "scratch/combined-baseline-no-udp.cc --$test_variable=$test_value --tcp_senders=1 --policy_threshold=$policy_threshold --dir=$dir/baseline-no-udp/" } # Delay primary experiments From a5ba5b70443301d0f2cba714bd11c969f354d6e3 Mon Sep 17 00:00:00 2001 From: YousefEZ <45167695+YousefEZ@users.noreply.github.com> Date: Sat, 6 Apr 2024 23:49:05 +0300 Subject: [PATCH 7/7] :bug: fix ipv4 populating issue --- src/combined-baseline-no-udp.cc | 2 +- src/combined-baseline-udp.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/combined-baseline-no-udp.cc b/src/combined-baseline-no-udp.cc index 0a52292e..14ad17de 100644 --- a/src/combined-baseline-no-udp.cc +++ b/src/combined-baseline-no-udp.cc @@ -223,7 +223,7 @@ int main(int argc, char* argv[]) address.NewNetwork(); Ipv4InterfaceContainer interfaces_3_5 = address.Assign(devices_3_5); - + Ipv4GlobalRoutingHelper::PopulateRoutingTables(); // Receiver address Ipv4Address receiver_addr = interfaces_3_5.GetAddress(1); std::cout << receiver_addr << std::endl; diff --git a/src/combined-baseline-udp.cc b/src/combined-baseline-udp.cc index 403d895e..4d3e0dac 100644 --- a/src/combined-baseline-udp.cc +++ b/src/combined-baseline-udp.cc @@ -273,7 +273,7 @@ int main(int argc, char* argv[]) // Receiver address Ipv4Address receiver_addr = interfaces_3_5.GetAddress(1); - + Ipv4GlobalRoutingHelper::PopulateRoutingTables(); // UDP Congestion traffic setup uint16_t udp_port = 50001; OnOffHelper udp_source("ns3::UdpSocketFactory",