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.
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.
- The port of the clientThe connect gets a port, at 0 s.
- The accept queueThe connect finds a place, at 1 ms.
- The request and the faultThe program knows first, at 10.001 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.
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 knowsEach 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.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 sThe 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
- PR.5 the client closes first: each port stays held for 60 s from the FIN of the target, plus the wheelMeasured 60.792 s (median of 4 runs)Computed 59.999 s to 64.096 s
Each connectionA 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 clientThe 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.
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 knowslisten(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) getsThe 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 sNew connectsThe connects comeThe program acceptsA SYN at a full queueA sysctl: the count of SYNs that a connect sends again before ETIMEDOUT. The default 6 gives 131 s.
Never knowsNo SYN finds the queue full.
- tcp_syn_retries
- 6
- tcp_syn_linear_timeouts
- 4
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 knowsNo 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.
The program
First · Knows at 10 sThe 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.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 sThe 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
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 sThe 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.KubernetesThe program on each node that writes the rules that send the traffic of a Service to its pods.
Cannot see itThe 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.The NICNetwork interface card: the hardware that puts the packets on the wire.
Cannot see itThe 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 rateMaximum transmission unit: the largest packet on the link, in bytes.
How to read the page
Section titled “How to read the page”- 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.
How the stages join
Section titled “How the stages join”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.
Each knob once
Section titled “Each knob once”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.
Limits
Section titled “Limits”- The limits of each stage are on its own page: the port range, the accept queue and the request path.
- The page follows one connection. Other connections change only the count of the ports in use and the places in the queue.