// Test that receiver-side RTT estimation is sane when // using TCP timestamps. We assert that the receive-side // RTT estimate is between 95 and 105ms. // Use a small receive buffer so that we advertise small windows, to keep the // test short. `sysctl -q net.ipv4.tcp_rmem="4096 10000 2097152"` // Create a socket. 0.000 socket(..., SOCK_STREAM, IPPROTO_TCP) = 3 0.000 setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0 // Verify that the receive buffer is the tcp_rmem default. 0.000 getsockopt(3, SOL_SOCKET, SO_RCVBUF, [10000], [4]) = 0 0.000 bind(3, ..., ...) = 0 0.000 listen(3, 1) = 0 // Establish a connection. 0.100 < S 0:0(0) win 20000 0.100 > S. 0:0(0) ack 1 0.200 < . 1:1(0) ack 1 win 20000 0.200 accept(3, ..., ...) = 4 0.200 %{ assert tcpi_rcv_rtt == 0 }% // First flight. 0.200 < . 1:1001(1000) ack 1 win 20000 0.200 > . 1:1(0) ack 1001 0.200 < . 1001:2001(1000) ack 1 win 20000 0.200 > . 1:1(0) ack 2001 0.200 read(4, ..., 2000) = 2000 0.200 %{ assert tcpi_rcv_rtt >= 95*1000 and tcpi_rcv_rtt <= 105*1000 }% // Second flight. 0.300 < . 2001:3001(1000) ack 1 win 20000 0.300 > . 1:1(0) ack 3001 0.300 < . 3001:4001(1000) ack 1 win 20000 0.300 > . 1:1(0) ack 4001 0.300 < . 4001:5001(1000) ack 1 win 20000 0.300 > . 1:1(0) ack 5001 0.300 < . 5001:6001(1000) ack 1 win 20000 0.300 read(4, ..., 4000) = 4000 0.300 > . 1:1(0) ack 6001 0.300 %{ assert tcpi_rcv_rtt >= 95*1000 and tcpi_rcv_rtt <= 105*1000 }% // Third flight. // We omit outgoing ACKs because we don't care about this behavior, // and don't want to introduce dependencies on the receive window behavior. 0.400 < . 6001:7001(1000) ack 1 win 20000 0.400 < . 7001:8001(1000) ack 1 win 20000 0.400 < . 8001:9001(1000) ack 1 win 20000 0.400 < . 9001:10001(1000) ack 1 win 20000 0.400 < . 10001:11001(1000) ack 1 win 20000 0.400 read(4, ..., 5000) = 5000 0.400 %{ assert tcpi_rcv_rtt >= 95*1000 and tcpi_rcv_rtt <= 105*1000 }% 0.500 `sysctl -q net.ipv4.tcp_rmem="4096 87380 3732736"`