Commit eab35989 authored by Soham Chakradeo's avatar Soham Chakradeo Committed by Jakub Kicinski
Browse files

selftests/net: packetdrill: import tcp/fast_recovery, tcp/nagle, tcp/timestamping



Use the standard import and testing method, as described in the
import of tcp/ecn , tcp/close , tcp/sack , tcp/tcp_info.

Signed-off-by: default avatarWillem de Bruijn <willemb@google.com>
Signed-off-by: default avatarSoham Chakradeo <sohamch@google.com>
Link: https://patch.msgid.link/20241217185203.297935-3-sohamch.kernel@gmail.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 88395c07
Loading
Loading
Loading
Loading
+72 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// Test PRR-slowstart implementation.
// In this variant we test a simple case where in-flight == ssthresh
// all the way through recovery, so during fast recovery we send one segment
// for each segment SACKed/ACKed.

// Set up config.
`./defaults.sh`

// Establish a connection.
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

  +.1 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
// RTT 100ms
  +.1 < . 1:1(0) ack 1 win 320
   +0 accept(3, ..., ...) = 4

// Send 10 data segments.
   +0 write(4, ..., 10000) = 10000
   +0 > P. 1:10001(10000) ack 1

// Lost packet 1:1001.
 +.11 < . 1:1(0) ack 1 win 320 <sack 1001:2001,nop,nop>
 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:3001,nop,nop>
 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:4001,nop,nop>
// Enter fast recovery.
   +0 > . 1:1001(1000) ack 1
 +.01 %{
assert tcpi_ca_state == TCP_CA_Recovery, tcpi_ca_state
assert tcpi_snd_cwnd == 7, tcpi_snd_cwnd
assert tcpi_snd_ssthresh == 7, tcpi_snd_ssthresh
}%

// Write some more, which we will send 1 MSS at a time,
// as in-flight segments are SACKed or ACKed.
 +.01 write(4, ..., 7000) = 7000

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:5001,nop,nop>
   +0 > . 10001:11001(1000) ack 1

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:6001,nop,nop>
   +0 > . 11001:12001(1000) ack 1

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:7001,nop,nop>
   +0 > . 12001:13001(1000) ack 1

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:8001,nop,nop>
   +0 > . 13001:14001(1000) ack 1

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:9001,nop,nop>
   +0 > . 14001:15001(1000) ack 1

 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:10001,nop,nop>
   +0 > . 15001:16001(1000) ack 1

 +.02 < . 1:1(0) ack 10001 win 320
   +0 > P. 16001:17001(1000) ack 1
// Leave fast recovery.
 +.01 %{
assert tcpi_ca_state == TCP_CA_Open, tcpi_ca_state
assert tcpi_snd_cwnd == 7, tcpi_snd_cwnd
assert tcpi_snd_ssthresh == 7, tcpi_snd_ssthresh
}%

 +.03 < . 1:1(0) ack 12001 win 320
 +.02 < . 1:1(0) ack 14001 win 320
 +.02 < . 1:1(0) ack 16001 win 320
 +.02 < . 1:1(0) ack 17001 win 320
+50 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// Test PRR-slowstart implementation. The sender sends 20 packets. Packet
// 1 to 4, and 11 to 16 are dropped.
`./defaults.sh`

// Establish a connection.
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>

 +.01 < . 1:1(0) ack 1 win 320
   +0 accept(3, ..., ...) = 4

// Write 20 data segments.
   +0 write(4, ..., 20000) = 20000
   +0 > P. 1:10001(10000) ack 1

// Receive first DUPACK, entering PRR part
 +.01 < . 1:1(0) ack 1 win 320 <sack 4001:5001,nop,nop>
   +0 > . 10001:11001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:6001,nop,nop>
   +0 > . 11001:12001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:7001,nop,nop>
   +0 > . 1:1001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:8001,nop,nop>
   +0 > . 1001:2001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:9001,nop,nop>
   +0 > . 2001:3001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:10001,nop,nop>
   +0 > . 3001:4001(1000) ack 1
// Enter PRR CRB
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:11001,nop,nop>
   +0 > . 12001:13001(1000) ack 1
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:12001,nop,nop>
   +0 > . 13001:14001(1000) ack 1
// Enter PRR slow start
 +.01 < . 1:1(0) ack 1001 win 320 <sack 4001:12001,nop,nop>
   +0 > P. 14001:16001(2000) ack 1
+.002 < . 1:1(0) ack 1001 win 320 <sack 2001:12001,nop,nop>
   +0 > . 1001:2001(1000) ack 1
   +0 > . 16001:17001(1000) ack 1
// inflight reaches ssthresh, goes into packet conservation mode
+.002 < . 1:1(0) ack 1001 win 320 <sack 2001:13001,nop,nop>
   +0 > . 17001:18001(1000) ack 1
+.002 < . 1:1(0) ack 1001 win 320 <sack 2001:14001,nop,nop>
   +0 > . 18001:19001(1000) ack 1
+43 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// Test PRR-slowstart implementation. The sender sends 20 packets. Packet
// 1 to 4 are lost. The sender writes another 10 packets.
`./defaults.sh`

// Establish a connection.
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 7>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>

 +.01 < . 1:1(0) ack 1 win 320
   +0 accept(3, ..., ...) = 4

// Send 20 data segments.
   +0 write(4, ..., 10000) = 10000
   +0 > P. 1:10001(10000) ack 1

// Lost packet 1,2,3,4
 +.01 < . 1:1(0) ack 1 win 320 <sack 4001:5001,nop,nop>
+.002 < . 1:1(0) ack 1 win 320 <sack 4001:6001,nop,nop>
   +0 < . 1:1(0) ack 1 win 320 <sack 4001:7001,nop,nop>
   +0 > . 1:1001(1000) ack 1
   +0 < . 1:1(0) ack 1 win 320 <sack 4001:8001,nop,nop>
   +0 > . 1001:2001(1000) ack 1
   +0 < . 1:1(0) ack 1 win 320 <sack 4001:9001,nop,nop>
   +0 > . 2001:3001(1000) ack 1
   +0 < . 1:1(0) ack 1 win 320 <sack 4001:10001,nop,nop>
   +0 > . 3001:4001(1000) ack 1

// Receiver ACKs all data.
 +.01 < . 1:1(0) ack 1001 win 320 <sack 4001:10001,nop,nop>
   +0 < . 1:1(0) ack 2001 win 320 <sack 4001:10001,nop,nop>
   +0 < . 1:1(0) ack 3001 win 320 <sack 4001:10001,nop,nop>
   +0 < . 1:1(0) ack 10001 win 320

// Writes another 10 packets, which the ssthresh*mss amount
// should be sent right away
 +.01 write(4, ..., 10000) = 10000
   +0 > . 10001:17001(7000) ack 1
+41 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// Test PRR-slowstart implementation.
// In this variant we verify that the sender uses SACK info on an ACK
// below snd_una.

// Set up config.
`./defaults.sh`

// Establish a connection.
    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
   +0 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
   +0 bind(3, ..., ...) = 0
   +0 listen(3, 1) = 0

   +0 < S 0:0(0) win 32792 <mss 1000,sackOK,nop,nop,nop,wscale 8>
   +0 > S. 0:0(0) ack 1 <mss 1460,nop,nop,sackOK,nop,wscale 8>
// RTT 10ms
 +.01 < . 1:1(0) ack 1 win 320
   +0 accept(3, ..., ...) = 4

// Send 10 data segments.
   +0 write(4, ..., 10000) = 10000
   +0 > P. 1:10001(10000) ack 1

// Lost packet 1:1001,4001:5001,7001:8001.
 +.01 < . 1:1(0) ack 1 win 320 <sack 1001:2001,nop,nop>
   +0 < . 1:1(0) ack 1 win 320 <sack 1001:3001,nop,nop>
   +0 < . 1:1(0) ack 1 win 320 <sack 1001:3001 8001:9001,nop,nop>
   +0 > . 1:1001(1000) ack 1

+.012 < . 1:1(0) ack 4001 win 320 <sack 8001:9001,nop,nop>
   +0 > . 4001:7001(3000) ack 1

   +0 write(4, ..., 10000) = 10000

// The following ACK was reordered - delayed so that it arrives with
// an ACK field below snd_una. Here we check that the newly-SACKed
// 2MSS at 5001:7001 cause us to send out 2 more MSS.
+.002 < . 1:1(0) ack 3001 win 320 <sack 5001:7001,nop,nop>
   +0 > . 7001:8001(1000) ack 1
   +0 > . 10001:11001(1000) ack 1
+40 −0
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
// This is a test inspired by an Android client app using SSL. This
// test verifies using TCP_NODELAY would save application latency
// (Perhaps even better with TCP_NAGLE).
//
`./defaults.sh
ethtool -K tun0 tso off gso off
./set_sysctls.py /proc/sys/net/ipv4/tcp_timestamps=0`

    0 socket(..., SOCK_STREAM, IPPROTO_TCP) = 4
   +0 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
   +0 setsockopt(4, SOL_TCP, TCP_NODELAY, [1], 4) = 0

   +0 connect(4, ..., ...) = -1 EINPROGRESS (Operation now in progress)
   +0 > S 0:0(0) <mss 1460,nop,nop,sackOK,nop,wscale 8>
  +.1 < S. 0:0(0) ack 1 win 5792 <mss 974,nop,nop,sackOK,nop,wscale 7>
   +0 > . 1:1(0) ack 1

// SSL handshake (resumed session)
   +0 write(4, ..., 517) = 517
   +0 > P. 1:518(517) ack 1
  +.1 < . 1:1(0) ack 518 win 229

   +0 < P. 1:144(143) ack 1 win 229
   +0 > . 518:518(0) ack 144
   +0 read(4, ..., 1000) = 143

// Application POST header (51B) and body (2002B)
   +0 write(4, ..., 51) = 51
   +0 > P. 518:569(51) ack 144
 +.03 write(4, ..., 2002) = 2002
   +0 > . 569:1543(974) ack 144
   +0 > P. 1543:2517(974) ack 144
// Without disabling Nagle, this packet will not happen until the remote ACK.
   +0 > P. 2517:2571(54) ack 144

  +.1 < . 1:1(0) ack 2571 win 229

// Reset sysctls
`/tmp/sysctl_restore_${PPID}.sh`
Loading