Skip to content

Commit

Permalink
net: tcp: Log the steps in the collision avoidance
Browse files Browse the repository at this point in the history
To allow insighed into the correct functioning of the collision avoidance,
log the internal values and function calls.

Signed-off-by: Sjors Hettinga <s.a.hettinga@gmail.com>
  • Loading branch information
ssharks committed Jul 28, 2023
1 parent 20200a2 commit 0104b36
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions subsys/net/ip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,19 @@ static void tcp_derive_rto(struct tcp *conn)

/* Implementation according to RFC6582 */

static void tcp_new_reno_log(struct tcp *conn, char *step)
{
NET_DBG("conn: %p, ca %s, cwnd=%d, ssthres=%d, fast_pend=%i",
conn, step, conn->ca.cwnd, conn->ca.ssthresh,
conn->ca.pending_fast_retransmit_bytes);
}

static void tcp_new_reno_init(struct tcp *conn)
{
conn->ca.cwnd = conn_mss(conn) * TCP_CONGESTION_INITIAL_WIN;
conn->ca.ssthresh = conn_mss(conn) * TCP_CONGESTION_INITIAL_SSTHRESH;
conn->ca.pending_fast_retransmit_bytes = 0;
tcp_new_reno_log(conn, "init");
}

static void tcp_new_reno_fast_retransmit(struct tcp *conn)
Expand All @@ -414,13 +422,15 @@ static void tcp_new_reno_fast_retransmit(struct tcp *conn)
/* Account for the lost segments */
conn->ca.cwnd = conn_mss(conn) * 3 + conn->ca.ssthresh;
conn->ca.pending_fast_retransmit_bytes = conn->unacked_len;
tcp_new_reno_log(conn, "fast_retransmit");
}
}

static void tcp_new_reno_timeout(struct tcp *conn)
{
conn->ca.ssthresh = MAX(conn_mss(conn) * 2, conn->unacked_len / 2);
conn->ca.cwnd = conn_mss(conn);
tcp_new_reno_log(conn, "timeout");
}

/* For every duplicate ack increment the cwnd by mss */
Expand All @@ -430,6 +440,7 @@ static void tcp_new_reno_dup_ack(struct tcp *conn)

new_win += conn_mss(conn);
conn->ca.cwnd = MIN(new_win, UINT16_MAX);
tcp_new_reno_log(conn, "dup_ack");
}

static void tcp_new_reno_pkts_acked(struct tcp *conn, uint32_t acked_len)
Expand All @@ -455,6 +466,7 @@ static void tcp_new_reno_pkts_acked(struct tcp *conn, uint32_t acked_len)
conn->ca.cwnd -= acked_len;
}
}
tcp_new_reno_log(conn, "pkts_acked");
}

static void tcp_ca_init(struct tcp *conn)
Expand Down

0 comments on commit 0104b36

Please sign in to comment.