TCP get SND_CWND change on loss event

From: Lars Erik StorbukÃs
Date: Sat May 27 2017 - 08:08:30 EST


I want to store the value of snd_cwnd when a congestion event occurs
(value before snd_cwnd is reduced), and the new value of snd_cwnd (the
value it has been reduced to). In other words: the congestion window
before and after a congestion event occurs.

I'm uncertain where (and how) it would be logical to implement this. I
have found two possible locations in the tcp_input.c where (I think)
it could be implemented:

static void tcp_cong_control(...) {
...
if (tcp_in_cwnd_reduction(sk)) {
struct tcp_sock *tp = tcp_sk(sk);
prior_congestion_window = tp->snd_cwnd;

/* Reduce cwnd if state mandates */
tcp_cwnd_reduction(sk, acked_sacked, flag);

reduced_congestion_window = tp->snd_cwnd;
}
...
}

or

static void tcp_fastretrans_alert(...) {
...
default:
...
struct tcp_sock *tp = tcp_sk(sk);
prior_congestion_window = tp->snd_cwnd;

/* Otherwise enter Recovery state */
tcp_enter_recovery(sk, (flag & FLAG_ECE));
fast_rexmit = 1;

reduced_congestion_window = tp->snd_cwnd;
...
}

Does anyone have advice on where (and how) to implement this? Does any
of the proposed solutions above seem logical?

/ Lars Erik StorbukÃs