gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/test/packetdrill/tcp_defer_accept_timeout.pkt (about)

     1  // Test that a bare ACK is accepted after TCP_DEFER_ACCEPT timeout
     2  // is hit and a connection is delivered.
     3  
     4  0  socket(..., SOCK_STREAM, IPPROTO_TCP) = 3
     5  +0 setsockopt(3, SOL_TCP, TCP_DEFER_ACCEPT, [3], 4) = 0
     6  +0.000 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
     7  +0 bind(3, ..., ...) = 0
     8  
     9  // Set backlog to 1 so that we can easily test.
    10  +0 listen(3, 1) = 0
    11  
    12  // Establish a connection without timestamps.
    13  +0.0 < S 0:0(0) win 32792 <mss 1460,sackOK,nop,nop,nop,wscale 7>
    14  +0.0 > S. 0:0(0) ack 1    <...>
    15  
    16  // Send a bare ACK this should not complete the connection as we
    17  // set the TCP_DEFER_ACCEPT above.
    18  +0.0 < . 1:1(0) ack 1 win 257
    19  
    20  // The bare ACK should be dropped and no connection should be delivered
    21  // to the accept queue.
    22  +0.100 accept(3, ..., ...) = -1 EWOULDBLOCK (operation would block)
    23  
    24  // Send another bare ACK and it should still fail we set TCP_DEFER_ACCEPT
    25  // to 5 seconds above.
    26  +2.5 < . 1:1(0) ack 1 win 257
    27  +0.100 accept(3, ..., ...) = -1 EWOULDBLOCK (operation would block)
    28  
    29  // set accept socket back to blocking.
    30  +0.000 fcntl(3, F_SETFL, O_RDWR) = 0
    31  
    32  // We should see one more retransmit of the SYN-ACK as a last ditch
    33  // attempt when TCP_DEFER_ACCEPT timeout is hit to trigger another
    34  // ACK or a packet with data.
    35  +.35~+2.35 > S. 0:0(0) ack 1 <...>
    36  
    37  // Now send another bare ACK after TCP_DEFER_ACCEPT time has been passed.
    38  +0.0 < . 1:1(0) ack 1 win 257
    39  
    40  // The ACK above should cause connection to transition to connected state.
    41  +0.000 accept(3, ..., ...) = 4
    42  +0.000 fcntl(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0
    43  
    44  +0.000 close(4) = 0
    45  
    46  +0.0 > F. 1:1(0) ack 1 <...>
    47  +0.0 < F. 1:1(0) ack 2 win 257
    48  +0.01 > . 2:2(0) ack 2 <...>