Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ flows:
sender_id: "sender1"
receiver_id: "receiver1"
packet_size: 1024
packet_interval: 100
number_of_packets: 10000
flow2:
sender_id: "sender2"
receiver_id: "receiver2"
packet_size: 1024
packet_interval: 100
number_of_packets: 10000

algorithm: basic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@ flows:
sender_id: sender0
receiver_id: receiver0
packet_size: 1500
packet_interval: 500
number_of_packets: 100
flow1:
sender_id: sender1
receiver_id: receiver0
packet_size: 1500
packet_interval: 500
number_of_packets: 100
flow2:
sender_id: sender2
receiver_id: receiver0
packet_size: 1500
packet_interval: 500
number_of_packets: 100
flow3:
sender_id: sender3
receiver_id: receiver0
packet_size: 1500
packet_interval: 500
number_of_packets: 100
flow4:
sender_id: sender4
receiver_id: receiver0
packet_size: 1500
packet_interval: 500
number_of_packets: 100
algorithm: tcp
simulation_time: 50000
2 changes: 0 additions & 2 deletions configuration_examples/simulation_examples/tcp_simulation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ flows:
sender_id: "sender1"
receiver_id: "receiver1"
packet_size: 64
packet_interval: 600
number_of_packets: 100
flow2:
sender_id: "sender2"
receiver_id: "receiver2"
packet_size: 128
packet_interval: 600
number_of_packets: 100

algorithm: tcp
Expand Down
25 changes: 0 additions & 25 deletions source/event/generate.cpp

This file was deleted.

23 changes: 0 additions & 23 deletions source/event/generate.hpp

This file was deleted.

6 changes: 2 additions & 4 deletions source/flow/i_flow.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ namespace sim {

class IFlow : public Identifiable {
public:
// Start sending packets
virtual void start() = 0;
// Adds new packet to sending queue
// This packet will be send at some time in future (depends on concrete
// flow) Used in event Generate
virtual TimeNs create_new_data_packet() = 0;

// Update the internal state according to some congestion control algorithm
// Calls when data available for sending on corresponding device
virtual void update(Packet packet, DeviceType type) = 0;

virtual std::shared_ptr<IHost> get_sender() const = 0;
virtual std::shared_ptr<IHost> get_receiver() const = 0;
};
Expand Down
5 changes: 2 additions & 3 deletions source/flow/tcp/basic/basic_cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

namespace sim {

bool BasicCC::on_ack(TimeNs rtt, bool ecn_flag) {
(void)rtt;
(void)ecn_flag;
bool BasicCC::on_ack([[maybe_unused]] TimeNs rtt, [[maybe_unused]] TimeNs avg_rtt,
[[maybe_unused]] bool ecn_flag) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion source/flow/tcp/basic/basic_cc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace sim {
class BasicCC : public ITcpCC {
public:
bool on_ack(TimeNs rtt, bool ecn_flag) final;
bool on_ack(TimeNs rtt, TimeNs avg_rtt, bool ecn_flag) final;
TimeNs get_pacing_delay() const final;
double get_cwnd() const final;
std::string to_string() const final;
Expand Down
2 changes: 1 addition & 1 deletion source/flow/tcp/i_tcp_cc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class ITcpCC {
public:
// Callback that triggers every time ACK receives on sender
// returns true if congestion detected; false otherwice
virtual bool on_ack(TimeNs rtt, bool ecn_flag) = 0;
virtual bool on_ack(TimeNs rtt, TimeNs avg_rtt, bool ecn_flag) = 0;
virtual TimeNs get_pacing_delay() const = 0;
virtual double get_cwnd() const = 0;
virtual std::string to_string() const = 0;
Expand Down
23 changes: 17 additions & 6 deletions source/flow/tcp/tahoe/tcp_tahoe_cc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,33 @@

#include <spdlog/fmt/fmt.h>

#include "scheduler.hpp"

namespace sim {
TcpTahoeCC::TcpTahoeCC(TimeNs a_delay_threshold, double a_sstresh)
: m_delay_threshold(a_delay_threshold),
m_ssthresh(a_sstresh),
m_cwnd(1.0) {}
m_cwnd(1.0),
m_last_congestion_detected(0) {}

bool TcpTahoeCC::on_ack(TimeNs rtt, bool ecn_flag) {
if (ecn_flag || rtt > m_delay_threshold) {
bool TcpTahoeCC::on_ack([[maybe_unused]] TimeNs rtt, TimeNs avg_rtt,
bool ecn_flag) {
Time current_time = Scheduler::get_instance().get_current_time();
if (ecn_flag || avg_rtt > m_delay_threshold) {
// trigger_congestion
m_ssthresh = m_cwnd / 2;
m_cwnd = 1.;
if (current_time > m_last_congestion_detected + avg_rtt) {
// To avoid too frequent cwnd and sstresh decreases
m_last_congestion_detected = current_time;
m_ssthresh = m_cwnd / 2;
m_cwnd = 1.;
}
return true;
}
if (m_cwnd < m_ssthresh) {
// Slow start
m_cwnd++;
} else {
// Congestion avoidance
m_cwnd += 1 / m_cwnd;
Comment thread
Az3git marked this conversation as resolved.
}
return false;
Expand All @@ -32,4 +43,4 @@ std::string TcpTahoeCC::to_string() const {
m_delay_threshold.value(), m_cwnd, m_ssthresh);
}

} // namespace sim
} // namespace sim
3 changes: 2 additions & 1 deletion source/flow/tcp/tahoe/tcp_tahoe_cc.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class TcpTahoeCC : public ITcpCC {
TcpTahoeCC(TimeNs a_delay_threshold = TimeNs(4000), double a_ssthresh = 8);
~TcpTahoeCC() = default;

bool on_ack(TimeNs rtt, bool ecn_flag) final;
bool on_ack(TimeNs rtt, TimeNs avg_rtt, bool ecn_flag) final;
TimeNs get_pacing_delay() const final;
double get_cwnd() const final;
std::string to_string() const final;
Expand All @@ -17,5 +17,6 @@ class TcpTahoeCC : public ITcpCC {

double m_ssthresh; // Slow start threshold
double m_cwnd; // Congestion window
TimeNs m_last_congestion_detected;
};
} // namespace sim
Loading