Skip to content

Commit 7dcb123

Browse files
tcp: Split up handle ack part into smaller bits, started on Eifel algo (outcommented)
1 parent 6ca9ee2 commit 7dcb123

3 files changed

Lines changed: 244 additions & 119 deletions

File tree

api/net/tcp/connection.hpp

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ class Connection : public std::enable_shared_from_this<Connection> {
676676

677677
/** Congestion control */
678678
// is fast recovery state
679-
bool fast_recovery = false;
679+
bool fast_recovery_ = false;
680680
// First partial ack seen
681681
bool reno_fpack_seen = false;
682682
/** limited transmit [RFC 3042] active */
@@ -692,6 +692,16 @@ class Connection : public std::enable_shared_from_this<Connection> {
692692
uint8_t dack_{0};
693693
seq_t last_ack_sent_;
694694

695+
/** RFC 3522 - The Eifel Detection Algorithm for TCP */
696+
//int16_t spurious_recovery = 0;
697+
//static constexpr int8_t SPUR_TO {1};
698+
//uint32_t rtx_ts_ = 0;
699+
/** RFC 4015 - The Eifel Response Algorithm for TCP */
700+
//uint32_t pipe_prev = 0;
701+
//static constexpr int8_t LATE_SPUR_TO {1};
702+
//RTTM::seconds SRTT_prev{1.0f};
703+
//RTTM::seconds RTTVAR_prev{1.0f};
704+
695705
/// --- CALLBACKS --- ///
696706

697707
/**
@@ -868,11 +878,57 @@ class Connection : public std::enable_shared_from_this<Connection> {
868878
*/
869879
bool handle_ack(const Packet&);
870880

871-
/*
872-
When a duplicate ACK is received.
873-
*/
881+
/**
882+
* @brief Determines if the incoming segment is a legit window update.
883+
*
884+
* @param[in] in TCP Segment
885+
* @param[in] win The calculated window
886+
*
887+
* @return True if window update, False otherwise.
888+
*/
889+
bool is_win_update(const Packet& in, const uint32_t win) const
890+
{
891+
return cb.SND.WND != win and
892+
(cb.SND.WL1 < in.seq() or (cb.SND.WL1 == in.seq() and cb.SND.WL2 <= in.ack()));
893+
}
894+
895+
/**
896+
* @brief Determines if duplicate acknowledge, described in [RFC 5681] p.3
897+
*
898+
* @param[in] in TCP segment
899+
*
900+
* @return True if duplicate acknowledge, False otherwise.
901+
*/
902+
bool is_dup_ack(const Packet& in, const uint32_t win) const
903+
{
904+
return in.ack() == cb.SND.UNA
905+
and flight_size() > 0
906+
and !in.has_tcp_data()
907+
and cb.SND.WND == win
908+
and !in.isset(SYN) and !in.isset(FIN);
909+
}
910+
911+
/**
912+
* @brief Handle duplicate ACK according to New Reno
913+
*
914+
* @param[in] <unnamed> Incoming TCP segment (duplicate ACK)
915+
*/
874916
void on_dup_ack(const Packet&);
875917

918+
/**
919+
* @brief Handle segment according to congestion control (New Reno)
920+
*
921+
* @param[in] <unnamed> Incoming TCP segment
922+
*/
923+
void congestion_control(const Packet&);
924+
925+
/**
926+
* @brief Handle segment according to fast recovery (New Reno)
927+
*
928+
* @param[in] <unnamed> Incoming TCP segment
929+
*/
930+
void fast_recovery(const Packet&);
931+
876932
/**
877933
* @brief Determines ability to send ONE segment, not caring about the usable window.
878934
*

api/net/tcp/options.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ struct Option {
106106
ecr{htonl(echo)}
107107
{}
108108

109+
uint32_t get_val() const noexcept
110+
{ return ntohl(val); }
111+
112+
uint32_t get_ecr() const noexcept
113+
{ return ntohl(ecr); }
114+
109115
} __attribute__((packed));
110116

111117
/**

0 commit comments

Comments
 (0)