Skip to content
Merged
Show file tree
Hide file tree
Changes from 16 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
129 changes: 0 additions & 129 deletions source/flow/basic_flow.cpp

This file was deleted.

59 changes: 0 additions & 59 deletions source/flow/basic_flow.hpp

This file was deleted.

9 changes: 9 additions & 0 deletions source/flow/tcp/basic/bacic_flow.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "basic_cc.hpp"
#include "flow/tcp/tcp_flow.hpp"
namespace sim {

using BasicFlow = TcpFlow<BasicCC>;

} // namespace sim
19 changes: 19 additions & 0 deletions source/flow/tcp/basic/basic_cc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#include "basic_cc.hpp"

#include <limits>

namespace sim {

bool BasicCC::on_ack(Time rtt, bool ecn_flag) {
(void)rtt;
(void)ecn_flag;
return false;
}

double BasicCC::get_cwnd() const { return std::numeric_limits<double>::max(); }

Time BasicCC::get_pacing_delay() const { return 0; }

std::string BasicCC::to_string() const { return ""; }

} // namespace sim
13 changes: 13 additions & 0 deletions source/flow/tcp/basic/basic_cc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#pragma once
#include "flow/tcp/i_tcp_cc.hpp"

// Represents no congestion control
namespace sim {
class BasicCC : public ITcpCC {
public:
bool on_ack(Time rtt, bool ecn_flag) final;
Time get_pacing_delay() const final;
double get_cwnd() const final;
std::string to_string() const final;
};
} // namespace sim
16 changes: 16 additions & 0 deletions source/flow/tcp/i_tcp_cc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once
#include "types.hpp"

namespace sim {

// Interfacce of TCP-like congestion control (CC) module
class ITcpCC {
public:
// Callback that triggers every time ACK receives on sender
// returns true if congestion detected; false otherwice
virtual bool on_ack(Time rtt, bool ecn_flag) = 0;
virtual Time get_pacing_delay() const = 0;
virtual double get_cwnd() const = 0;
virtual std::string to_string() const = 0;
};
} // namespace sim
35 changes: 35 additions & 0 deletions source/flow/tcp/tahoe/tcp_tahoe_cc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#include "tcp_tahoe_cc.hpp"

#include <spdlog/fmt/fmt.h>

namespace sim {
TcpTahoeCC::TcpTahoeCC(Time a_dealay_threshold, double a_sstresh)
: m_delay_threshold(a_dealay_threshold),
m_ssthresh(a_sstresh),
m_cwnd(1.0) {}

bool TcpTahoeCC::on_ack(Time rtt, bool ecn_flag) {
if (ecn_flag || rtt >= m_delay_threshold) {
// trigger_congestion
m_ssthresh = m_cwnd / 2;
m_cwnd = 1.;
return true;
}
if (m_cwnd < m_ssthresh) {
m_cwnd *= 2;
} else {
m_cwnd += 1.;
}
return false;
}

Time TcpTahoeCC::get_pacing_delay() const { return 0; }

double TcpTahoeCC::get_cwnd() const { return m_cwnd; }

std::string TcpTahoeCC::to_string() const {
return fmt::format("[delay threshold: {}, cwnd: {}, sstresh: {}]",
m_delay_threshold, m_cwnd, m_ssthresh);
}

} // namespace sim
21 changes: 21 additions & 0 deletions source/flow/tcp/tahoe/tcp_tahoe_cc.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#pragma once
#include "flow/tcp/i_tcp_cc.hpp"

namespace sim {
class TcpTahoeCC : public ITcpCC {
public:
TcpTahoeCC(Time a_dealay_threshold = 4000, double a_sstresh = 8);
~TcpTahoeCC() = default;

bool on_ack(Time rtt, bool ecn_flag) final;
Time get_pacing_delay() const final;
double get_cwnd() const final;
std::string to_string() const final;

private:
Time m_delay_threshold; // delay threshold for update

double m_ssthresh; // Slow start threshold
double m_cwnd; // Congestion window
};
} // namespace sim
9 changes: 9 additions & 0 deletions source/flow/tcp/tahoe/tcp_tahoe_flow.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once

#include "flow/tcp/tcp_flow.hpp"
#include "tcp_tahoe_cc.hpp"
namespace sim {

using TcpTahoeFlow = TcpFlow<TcpTahoeCC>;

} // namespace sim
Loading