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
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ This flags represents regular expression that match generated **data file names*

E.g. if `--metrics-filter = "cwnd/.*"`, NoNS measures only CWND values, if `--metrics-filter = ".*_link1.*"`, only metircs about link1.

## How to add new congestion control algorithm

If you want to implement TCP-like algorithm, follow these steps:

1. Create class (`YourCC` further) that implements [`ITcpCC`](source/flow/tcp/i_tcp_cc.hpp). It should be a class that contains all logic of your congestion control algorithm. See example: [`TcpTahoeCC`](source/flow/tcp/tahoe/tcp_tahoe_cc.cpp).
2. Add alias for `TcpFlow<YourCC>` (`YourTcp` further). Its is recomended to put it in the same directory with `YourCC`.
3. Add implememtation for `Parser<YourTcp>::parse_tcp_cc`. It is a function that parses `YourCC` from yaml file. See [implementation](source/parser/identifiable_parser/flow/parse_tcp_tahoe_cc.cpp) for `TchTahoe`
4. Add alias (`YourSmulator` further) for simulator class based on `YourTcp` and put it in the end of [simulator.hpp](source/simulator.hpp) file.
5. Add parsing of `YourSmulator` in [`create_simulator` function](source/simulator.cpp). The string you match `algorithm` will be used in simulation config. See [simulation config](configuration_examples/simulation_examples/tcp_simulation.yml) for `TcpTahoe` algorithm.

If your algorithm is not TCP-like (e.g. credit-based), do fillowing:
1. Create class (`YourFlow` further) that implements [`IFllow`](source/flow/i_flow.hpp). `YourFlow` should repersent all logic of sending packets. See example: [`TcpFlow`](source/flow/tcp/tcp_flow.hpp).
3. Add implememtation for `Parser<YourFlow>::parse_object`. This function should parse `YourFlow` from yaml file. See [implementation](source/parser/identifiable_parser/flow/parse_tcp_flow.hpp) for `TcpFlow`
4. Add alias (`YourSmulator` further) for simulator class based on `YourFlow` and put it in the end of [simulator.hpp](source/simulator.hpp) file.
5. Add parsing of `YourSmulator` in [`create_simulator` function](source/simulator.cpp). The string you match `algorithm` will be used in simulation config. See [simulation config](configuration_examples/simulation_examples/tcp_simulation.yml) for `TcpTahoe` algorithm.

## Resuls of simulations

Metrics and results of load testing of all simulation runs deploys to [gihub pages](https://cloud-storage-team.github.io/algnet)
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