Skip to content

Commit d375717

Browse files
tcp: Updated RTTM to use float instead of double, edited clock gran
1 parent d19cb72 commit d375717

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

api/net/tcp/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ namespace net {
3939
// the maximum amount of half-open connections per port (listener)
4040
static constexpr size_t default_max_syn_backlog {64};
4141
// clock granularity of the timestamp value clock
42-
static constexpr double clock_granularity {0.0001};
42+
static constexpr float clock_granularity {0.0001};
4343

4444
static const std::chrono::seconds default_msl {30};
4545
static const std::chrono::milliseconds default_dack_timeout {40};

api/net/tcp/rttm.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ namespace tcp {
3232
// TODO: Appendix G. RTO Calculation Modification https://tools.ietf.org/html/rfc7323#appendix-G
3333
struct RTTM {
3434
using milliseconds = std::chrono::milliseconds;
35-
using seconds = std::chrono::duration<double>; // seconds as double
35+
using seconds = std::chrono::duration<float>; // seconds as float
3636

3737
// clock granularity
38-
static constexpr double CLOCK_G {clock_granularity};
38+
static constexpr float CLOCK_G {clock_granularity};
3939

40-
static constexpr double K = 4.0;
41-
static constexpr double alpha = 1.0 / 8.0;
42-
static constexpr double beta = 1.0 / 4.0;
40+
static constexpr float K = 4.0;
41+
static constexpr float alpha = 1.0 / 8.0;
42+
static constexpr float beta = 1.0 / 4.0;
4343

4444
seconds SRTT; // smoothed round-trip time
4545
seconds RTTVAR; // round-trip time variation
@@ -112,7 +112,7 @@ struct RTTM {
112112
// 1. A multiplier member could be added to be used for "backing off" the timer (return compute_rto() * multiplier).
113113
// 2. Dunno how to set RTO = 3s when timeout on ACK for SYN.
114114
seconds compute_rto() const
115-
{ return seconds{std::max(SRTT.count() + std::max(CLOCK_G, K * RTTVAR.count()), 1.0)}; }
115+
{ return seconds{std::max(SRTT.count() + std::max(CLOCK_G, K * RTTVAR.count()), 1.0f)}; }
116116

117117
/**
118118
* @brief Take a RTT (Round trip time) measurment

src/net/tcp/rttm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919

2020
using namespace net::tcp;
2121

22-
constexpr double RTTM::CLOCK_G;
23-
constexpr double RTTM::K;
24-
constexpr double RTTM::alpha;
25-
constexpr double RTTM::beta;
22+
constexpr float RTTM::CLOCK_G;
23+
constexpr float RTTM::K;
24+
constexpr float RTTM::alpha;
25+
constexpr float RTTM::beta;
2626

2727
/*
2828
When the first RTT measurement R is made, the host MUST set

0 commit comments

Comments
 (0)