16
16
17
17
#include <linux/mm.h>
18
18
#include <linux/module.h>
19
+ #include <linux/time.h>
19
20
#include <net/tcp.h>
20
21
21
22
#define BICTCP_BETA_SCALE 1024 /* Scale factor beta calculation
@@ -55,6 +56,7 @@ struct bictcp {
55
56
u32 epoch_start ; /* beginning of an epoch */
56
57
#define ACK_RATIO_SHIFT 4
57
58
u32 delayed_ack ; /* estimate the ratio of Packets/ACKs << 4 */
59
+ u64 start_time ;
58
60
};
59
61
60
62
static inline void bictcp_reset (struct bictcp * ca )
@@ -65,6 +67,7 @@ static inline void bictcp_reset(struct bictcp *ca)
65
67
ca -> last_time = 0 ;
66
68
ca -> epoch_start = 0 ;
67
69
ca -> delayed_ack = 2 << ACK_RATIO_SHIFT ;
70
+ ca -> start_time = ktime_get_boot_fast_ns ();
68
71
}
69
72
70
73
static void bictcp_init (struct sock * sk )
@@ -75,6 +78,19 @@ static void bictcp_init(struct sock *sk)
75
78
76
79
if (initial_ssthresh )
77
80
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
+ );
78
94
}
79
95
80
96
/*
@@ -147,11 +163,23 @@ static void bictcp_cong_avoid(struct sock *sk, u32 ack, u32 acked)
147
163
148
164
if (tcp_in_slow_start (tp )) {
149
165
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
+ );
151
172
return ;
173
+ }
152
174
}
153
175
bictcp_update (ca , tcp_snd_cwnd (tp ));
154
176
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
+ );
155
183
}
156
184
157
185
/*
@@ -163,6 +191,12 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk)
163
191
const struct tcp_sock * tp = tcp_sk (sk );
164
192
struct bictcp * ca = inet_csk_ca (sk );
165
193
194
+ pr_info (
195
+ "Enter fast retransmit: time %llu, start %llu\n" ,
196
+ ktime_get_boot_fast_ns (),
197
+ ca -> start_time
198
+ );
199
+
166
200
ca -> epoch_start = 0 ; /* end of epoch */
167
201
168
202
/* Wmax and fast convergence */
@@ -180,8 +214,20 @@ static u32 bictcp_recalc_ssthresh(struct sock *sk)
180
214
181
215
static void bictcp_state (struct sock * sk , u8 new_state )
182
216
{
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
+
184
227
bictcp_reset (inet_csk_ca (sk ));
228
+
229
+ ca -> start_time = tmp ;
230
+ }
185
231
}
186
232
187
233
/* Track delayed acknowledgment ratio using sliding window
@@ -201,6 +247,7 @@ static void bictcp_acked(struct sock *sk, const struct ack_sample *sample)
201
247
202
248
static struct tcp_congestion_ops bictcp __read_mostly = {
203
249
.init = bictcp_init ,
250
+ .release = bictcp_release ,
204
251
.ssthresh = bictcp_recalc_ssthresh ,
205
252
.cong_avoid = bictcp_cong_avoid ,
206
253
.set_state = bictcp_state ,
0 commit comments