Skip to content

Commit

Permalink
✨ added tcp sender (flows) as argument to cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
YousefEZ committed Apr 6, 2024
1 parent 302e655 commit d7d71d8
Showing 1 changed file with 39 additions and 21 deletions.
60 changes: 39 additions & 21 deletions src/combined-frr-no-udp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -214,16 +219,21 @@ int main(int argc, char* argv[])
p2p_alternate.SetChannelAttribute("Delay", StringValue(delay_alternate));
p2p_alternate.SetQueue("ns3::DropTailQueue<Packet>");

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<NetDeviceContainer> 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;
Expand All @@ -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
Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit d7d71d8

Please sign in to comment.