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 diff --git a/src/combined-baseline-no-udp.cc b/src/combined-baseline-no-udp.cc index 1ca4b3f6..14ad17de 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..4d3e0dac 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,31 +246,34 @@ 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); - + Ipv4GlobalRoutingHelper::PopulateRoutingTables(); // UDP Congestion traffic setup uint16_t udp_port = 50001; OnOffHelper udp_source("ns3::UdpSocketFactory", @@ -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-no-udp.cc b/src/combined-frr-no-udp.cc index 173d2e44..54bc4888 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,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,26 +246,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 @@ -284,27 +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 - 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)); 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));