1616
1717#include <linux/mm.h>
1818#include <linux/module.h>
19+ #include <linux/time.h>
1920#include <net/tcp.h>
2021
2122#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation
@@ -55,6 +56,7 @@ struct bictcp {
5556 u32 epoch_start ; /* beginning of an epoch */
5657#define ACK_RATIO_SHIFT 4
5758 u32 delayed_ack ; /* estimate the ratio of Packets/ACKs << 4 */
59+ u64 start_time ;
5860};
5961
6062static inline void bictcp_reset (struct bictcp * ca )
@@ -65,6 +67,7 @@ static inline void bictcp_reset(struct bictcp *ca)
6567 ca -> last_time = 0 ;
6668 ca -> epoch_start = 0 ;
6769 ca -> delayed_ack = 2 << ACK_RATIO_SHIFT ;
70+ ca -> start_time = ktime_get_boot_fast_ns ();
6871}
6972
7073static void bictcp_init (struct sock * sk )
@@ -75,6 +78,19 @@ static void bictcp_init(struct sock *sk)
7578
7679 if (initial_ssthresh )
7780 tcp_sk (sk )-> snd_ssthresh = initial_ssthresh ;
81+
82+ pr_info ("Socket created: start %llu\n" , ca -> start_time );
83+ }
84+
85+ static void bictcp_release (struct sock * sk )
86+ {
87+ struct bictcp * ca = inet_csk_ca (sk );
88+
89+ pr_info (
90+ "Socket destroyed: start %llu, end %llu\n" ,
91+ ca -> start_time ,
92+ ktime_get_boot_fast_ns ()
93+ );
7894}
7995
8096/*
@@ -147,11 +163,23 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
147163
148164 if (tcp_in_slow_start (tp )) {
149165 acked = tcp_slow_start (tp , acked );
150- if (!acked )
166+ if (!acked ) {
167+ pr_info (
168+ "New cwnd: %u, time %llu, ssthresh %u, start %llu, ss 1\n" ,
169+ tp -> snd_cwnd , ktime_get_boot_fast_ns (),
170+ tp -> snd_ssthresh , ca -> start_time
171+ );
151172 return ;
173+ }
152174 }
153175 bictcp_update (ca , tcp_snd_cwnd (tp ));
154176 tcp_cong_avoid_ai (tp , ca -> cnt , acked );
177+
178+ pr_info (
179+ "New cwnd: %u, time %llu, ssthresh %u, start %llu, ss 1\n" ,
180+ tp -> snd_cwnd , ktime_get_boot_fast_ns (),
181+ tp -> snd_ssthresh , ca -> start_time
182+ );
155183}
156184
157185/*
@@ -163,6 +191,12 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk)
163191 const struct tcp_sock * tp = tcp_sk (sk );
164192 struct bictcp * ca = inet_csk_ca (sk );
165193
194+ pr_info (
195+ "Enter fast retransmit: time %llu, start %llu\n" ,
196+ ktime_get_boot_fast_ns (),
197+ ca -> start_time
198+ );
199+
166200 ca -> epoch_start = 0 ; /* end of epoch */
167201
168202 /* Wmax and fast convergence */
@@ -180,8 +214,20 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk)
180214
181215static void bictcp_state (struct sock * sk , u8 new_state )
182216{
183- if (new_state == TCP_CA_Loss )
217+ if (new_state == TCP_CA_Loss ) {
218+ struct bictcp * ca = inet_csk_ca (sk );
219+ u64 tmp = ca -> start_time ;
220+
221+ pr_info (
222+ "Retransmission timeout fired: time %llu, start %llu\n" ,
223+ ktime_get_boot_fast_ns (),
224+ ca -> start_time
225+ );
226+
184227 bictcp_reset (inet_csk_ca (sk ));
228+
229+ ca -> start_time = tmp ;
230+ }
185231}
186232
187233/* Track delayed acknowledgment ratio using sliding window
@@ -201,6 +247,7 @@ static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
201247
202248static struct tcp_congestion_ops bictcp __read_mostly = {
203249 .init = bictcp_init ,
250+ .release = bictcp_release ,
204251 .ssthresh = bictcp_recalc_ssthresh ,
205252 .cong_avoid = bictcp_cong_avoid ,
206253 .set_state = bictcp_state ,
0 commit comments