From 0d975991d63f3c00e0b9030f13930eec6d745508 Mon Sep 17 00:00:00 2001 From: Neil Spring Date: Wed, 25 Aug 2021 13:44:55 -0700 Subject: [PATCH] packetdrill: add test of tcp window clamp socket option Modifies a test of TCP_WINDOW_CLAMP, including lowering, raising, and lowering again the clamp while the connection is in progress to add a test of brief lowering before raising. Requires a patch to tcp_set_window_clamp discussed as "tcp: enable mid stream window clamp". Signed-off-by: Neil Spring --- .../clamp-window-takes-effect.pkt | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/gtests/net/tcp/window_clamp/clamp-window-takes-effect.pkt b/gtests/net/tcp/window_clamp/clamp-window-takes-effect.pkt index 7effcfab..9daa5dc2 100644 --- a/gtests/net/tcp/window_clamp/clamp-window-takes-effect.pkt +++ b/gtests/net/tcp/window_clamp/clamp-window-takes-effect.pkt @@ -68,6 +68,48 @@ // Read to clear the receive buffer, will not raise the window. +.01 read(4, ..., 129000) = 128000 - // Small data, just to check that the clamp remains. + // Raise briefly and lower the clamp to ensure the last write takes effect. + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [1280000], 4) = 0 + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [128000], 4) = 0 + + // Small data, just to check that the clamp was raised; the increase + // opens in proportion to the amount of data sent to avoid epic burst +.01 < . 640000:641000(1000) ack 1 win 320 - +0 > . 1:1(0) ack 641000 win 50 + +0 > . 1:1(0) ack 641000 win 62 + +.01 < . 641000:643000(2000) ack 1 win 320 + +0 > . 1:1(0) ack 643000 win 78 + +.01 < . 643000:646000(3000) ack 1 win 320 + +0 > . 1:1(0) ack 646000 win 101 + +.01 < . 646000:704000(58000) ack 1 win 320 + +0 > . 1:1(0) ack 704000 win 500 + + // Read to clear the receive buffer, will not raise the window. + +.01 read(4, ..., 129000) = 64000 + + // Lower briefly and return the clamp to ensure that the last write + // takes effect and that the window doesn't decrease unnecessarily. + // (It still increases slowly based on the volume of data received.) + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [12800], 4) = 0 + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [256000], 4) = 0 + + +.01 < . 704000:705000(1000) ack 1 win 320 + +0 > . 1:1(0) ack 705000 win 512 + +.01 < . 705000:707000(2000) ack 1 win 320 + +0 > . 1:1(0) ack 707000 win 528 + + +.01 < . 707000:768000(61000) ack 1 win 320 + +0 > . 1:1(0) ack 768000 win 1000 + + +.01 read(4, ..., 129000) = 64000 + + // Repeat the transient drop, but include a small packet in between. + // The advertised window should return to the high value quickly, + // since the receiver never committed to a tiny window. + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [12800], 4) = 0 + +.01 < . 768000:769000(1000) ack 1 win 320 + +0 > . 1:1(0) ack 769000 win 997 + + +0 setsockopt(4, IPPROTO_TCP, TCP_WINDOW_CLAMP, [256000], 4) = 0 + +.01 < . 769000:770000(1000) ack 1 win 320 + +0 > . 1:1(0) ack 770000 win 1000 +