Skip to content

Lab

The whole path

A connection goes through three stages before its reply comes. The client gets a port, and the target puts the connection in its accept queue. Then the request goes on the path, where a fault can stop it. Each stage has its own page in this lab. This page puts the three stages together on one timeline, and it computes, in your browser, the stage where the connection ends.

Where does the connection end?
The fault
The request

The connection is ready at 1 ms, and the fault starts then. From the fault: The program knows first, at 10 s. TCP would know at 15 min 25 s to 18 min 4 s.

A port from the whole range at one connect each 10 ms, a queue with room, and a call with a deadline of 10 s behind a black hole.

  1. The port of the clientThe connect gets a port, at 0 s.
  2. The accept queueThe connect finds a place, at 1 ms.
  3. The request and the faultThe program knows first, at 10.001 s.
The black hole starts at 1 msPortQueueRequestRequest starts at 1 ms0 s200 ms1 s5 s20 s60 s5 min20 minSearchnever knowsConnect 1: 0 sHoldThe held port: 59.999 s to 64.096 srecovers 59.999 sThe first port is free again: 59.999 sMeasured, PR.5 the client closes first: each port stays held for 60 s from the FIN of the target, plus the wheel: 60.792 s (median of 4 runs)Queuenever knowsThe new connects dial: 0 sSYNnever knowsFinal ACKnever knowsProgramThe program: 10.001 sknows 10.001 sThe program sends the request: 1 msDeadline of try 1: 10.001 sRetry 1: 10.201 sDeadline of try 2: 20.201 sRetry 2: 20.601 sDeadline of try 3: 30.601 sSocketThe socket: 15 min 25 s to 18 min 4 sknows 15 min 25 sThe next read returns ETIMEDOUT: 15 min 25 sTCPTCP: 15 min 25 s to 18 min 4 sknows 15 min 25 sTail loss probe: 202 msRetransmission 1: 403 msRetransmission 2: 805 msRetransmission 3: 1.609 sRetransmission 4: 3.217 sRetransmission 5: 6.433 sRetransmission 6: 12.865 sRetransmission 7: 25.729 sRetransmission 8: 51.457 sRetransmission 9: 102.913 sRetransmission 10: 3 min 26 sRetransmission 11: 5 min 26 sRetransmission 12: 7 min 26 sRetransmission 13: 9 min 26 sRetransmission 14: 11 min 26 sRetransmission 15: 13 min 26 sthe retransmission give-up: ETIMEDOUT: 15 min 25 sKubernetescannot see the faultNICcannot see the faultSends: tail loss probe: 202 msSends: retransmission 1: 403 msSends: retransmission 2: 805 msSends: retransmission 3: 1.609 sSends: retransmission 4: 3.217 sSends: retransmission 5: 6.433 sSends: retransmission 6: 12.865 sSends: retransmission 7: 25.729 sSends: retransmission 8: 51.457 sSends: retransmission 9: 102.913 sSends: retransmission 10: 3 min 26 sSends: retransmission 11: 5 min 26 sSends: retransmission 12: 7 min 26 sSends: retransmission 13: 9 min 26 sSends: retransmission 14: 11 min 26 sSends: retransmission 15: 13 min 26 s
  • the fault
  • the lane acts, in this band
  • recovers
  • a send again or a timer
  • a probe
  • measured median of a cell

The axis is logarithmic, thus the first second and the last hour both fit. A dashed line is the start of a stage.

The port of the client

The times of these cards count from the start of this stage, at 0 s.

  1. The search for a local portA sysctl: the local ports that a connect can take. The default is 32768 to 60999, thus 28232 ports.

    Never knows

    Each connect finds a free port: one destination holds 6,409 ports at most, and the search reaches 28,232.

    Ports in the range
    28,232
    Ports that the search reads
    28,232
    Connects to one destination, before the error
    28,232
    Held ports of one destination, at most
    6,409
    The smallest gap with no error
    2.27 ms
    A sysctl: the local ports that a connect can take. The default is 32768 to 60999, thus 28232 ports.
  2. The held portThe state of a closed connection at the side that closed first. It holds the port for 60 s, thus a late segment cannot reach a new connection.

    Recovers at 59.999 s to 64.096 s

    The client closes first, thus its socket waits in TIME_WAIT. The port is free again at 59.999 s to 64.096 s.

    The side in TIME_WAIT
    the client
    TIME_WAIT
    60 s
    tcp_tw_reuse
    2, on loopback only
    Retransmissions of each close
    0
    Each connection
    A sysctl: 1 lets a new connect take a port in TIME_WAIT after tcp_tw_reuse_delay. The default 2 does this on loopback only.
    The ACK of the FIN of the client
    The clock of the kernel: the ticks in each second. A timer fires on a tick, thus it can be late by one tick or more.

The accept queue

The times of these cards count from the start of this stage, at 0 s.

  1. The accept queueThe length of the accept queue that a program asks for in listen(2). The queue keeps each connection that the program did not accept.

    Never knows

    listen(2) gets 4, thus the queue holds 5. Each new connect finds a place.

    listen(2) gets
    4
    The limit, after somaxconn
    4
    A full queue holds
    5
    In the queue at 0 s
    0
    New connects that find a place
    1
    SYNs that drop
    0
    Final ACKs that overflow
    0
    listen(2) gets
    The length of the accept queue that a program asks for in listen(2). The queue keeps each connection that the program did not accept.
    A sysctl: the largest backlog. A larger backlog in listen(2) gets this value. The default is 4096.
    In the queue at 0 s
    New connects
    The connects come
    The program accepts
  2. A SYN at a full queueA sysctl: the count of SYNs that a connect sends again before ETIMEDOUT. The default 6 gives 131 s.

    Never knows

    No SYN finds the queue full.

    tcp_syn_retries
    6
    tcp_syn_linear_timeouts
    4
  3. A final ACK at a full queueA sysctl: 1 answers a final ACK at a full queue with a reset. The default 0 drops the ACK and keeps the request.

    Never knows

    No final ACK finds the queue full.

    tcp_abort_on_overflow
    0
    tcp_synack_retries
    5
    A sysctl: 1 answers a final ACK at a full queue with a reset. The default 0 drops the ACK and keeps the request.

The request and the fault

The times of these cards count from the fault, at 1 ms on the timeline.

  1. The program

    First · Knows at 10 s

    The deadline finds the fault at 10 s. 2 retries also wait, and the call fails at 30.6 s.

    Deadline
    10 s
    Tries
    3
    The call gives up at
    30.6 s
    The time that a program waits for one reply before it stops the call. 10 s
  2. The socketThe handle of a program on one TCP connection. The program writes to it and reads from it.

    Knows at 15 min 25 s to 18 min 4 s

    The socket shows nothing until TCP gives up. At 15 min 25 s to 18 min 4 s, the next read or write returns ETIMEDOUT.

    The write
    returns at once
    Send queue
    the request, until an ACK
  3. TCPRetransmission timeout. TCP sends a segment again if no ACK comes in this time. Each new try waits two times longer.

    Knows at 15 min 25 s to 18 min 4 s

    The retransmission give-up finds the fault at 15 min 25 s to 18 min 4 s, and the socket gets ETIMEDOUT.

    First RTO
    201 ms
    Retransmissions
    15
    Delayed ACK, at most
    40 ms
    keepalive
    held: tx.retransmit.first cancels it
    The socket option that turns on keepalive. It is off on a socket by default.
    A socket option: the longest time that sent data can stay without an ACK. 0 turns it off. off
  4. KubernetesThe program on each node that writes the rules that send the traffic of a Service to its pods.

    Cannot see it

    The kubelet probes the pod from its own node, and the black hole is on the path between the nodes. Each probe passes, and the pod stays in the Service.

    Propagation, iptables
    27 ms to 92 ms (measured)
    conntrack keeps this flow
    while packets pass
    The program on each node that writes the rules that send the traffic of a Service to its pods.
  5. The NICNetwork interface card: the hardware that puts the packets on the wire.

    Cannot see it

    The NIC sends each segment, 16 after the request. The loss is past its wire, thus its link stays up and its counters show no error.

    A full queue drains in
    1.2 ms
    Segments it sends after the request
    16
    Link rate
    Maximum transmission unit: the largest packet on the link, in bytes.
  • The headline tells how the connection ends, and at which time.
  • The trail has one step for each stage. A green step passes, a red step ends the connection, and a dashed step is a stage that the connection does not reach.
  • The timeline has a group of lanes for each stage. A dashed line is the start of a stage. Press Play to see the story.
  • The stages below the timeline give the cards of each stage, with their knobs. A stage that the connection does not reach shows only its knobs.
  • The presets set the knobs for six stories: the defaults, no port, a SYN drop, a reset, a drain, and a drain with a partition.

Each stage is a set of lenses, and each lens is also on its own page. The page of the whole path adds no law of its own. It moves each stage on the timeline to the time when the stage before it passes.

  • The port passes at once when the search finds a free port. It ends with The error of a connect when no local port is free for its destination. No SYN leaves. when each port of the range is in use.
  • The accept queue passes one round trip later when the queue has room. A SYN that drops passes at a later SYN that finds a place, or ends with The error that the kernel gives to the socket when TCP stops a connection on a timer.. A final ACK that drops passes after the accept, or ends with The error that the kernel gives to the socket when a reset from the peer ends the connection..
  • The request starts when the connection is ready, and the fault starts at the same time. Its times come from the page of the request path.

After a stage ends, the next stages have no lanes. Their knobs stay on the page, thus you can change the story and see the later stages again.

The three stages share some knobs, for example the round trip. The page shows each knob one time, on the first card that uses it. The send of the client follows the request. The client sends at once when a request is in flight, and it sends nothing on an idle connection. Thus the send has no knob on this page.