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 22, 2023
1 parent ccd8274 commit 5873c12
Show file tree
Hide file tree
Showing 2 changed files with 14 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 @@ -397,25 +397,36 @@ static void tcp_derive_rto(struct tcp *conn)
}

#ifdef CONFIG_NET_TCP_CONGESTION_AVOIDANCE

static void tcp_new_reno_log(struct tcp *conn, char *step)
{
NET_DBG("conn: %p, ca %s, win=%d, ssthres=%d, state=%s",
conn, step, conn->ca.congestion_win, conn->ca.ssthresh,
TCP_NEW_RENO_STATE_STR(conn->ca.state));
}

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

static void tcp_new_reno_fast_retransmit(struct tcp *conn)
{
conn->ca.congestion_win = MAX(conn_mss(conn), conn->ca.congestion_win / 2);
conn->ca.ssthresh = MAX(conn_mss(conn) * 2, conn->ca.congestion_win);
conn->ca.state = TCP_NEW_RENO_LINEAR;
tcp_new_reno_log(conn, "fast_retransmit");
}

static void tcp_new_reno_timeout(struct tcp *conn)
{
conn->ca.ssthresh = conn->ca.congestion_win / 2;
conn->ca.congestion_win = conn_mss(conn) * TCP_CONGESTION_INITIAL_WIN;
conn->ca.state = TCP_NEW_RENO_RAMPUP;
tcp_new_reno_log(conn, "timeout");
}

static void tcp_new_reno_pkts_acked(struct tcp *conn)
Expand All @@ -434,6 +445,7 @@ static void tcp_new_reno_pkts_acked(struct tcp *conn)
if (conn->ca.congestion_win > conn->ca.ssthresh) {
conn->ca.state = TCP_NEW_RENO_LINEAR;
}
tcp_new_reno_log(conn, "pkts_acked");
}
#endif

Expand Down
2 changes: 2 additions & 0 deletions subsys/net/ip/tcp_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ enum tcp_new_reno_state {
TCP_NEW_RENO_LINEAR
};

#define TCP_NEW_RENO_STATE_STR(x) (((x) == TCP_NEW_RENO_RAMPUP) ? "ramp-up" : "linear")

struct tcp_collision_avoidance_reno {
uint16_t congestion_win;
uint16_t ssthresh;
Expand Down

0 comments on commit 5873c12

Please sign in to comment.