TCP performance: windows, congestion and latency
You find the cause of a slow connection by measuring latency, loss, window size and congestion control, then fix it with kernel settings.
Level 301 · 18 lessons · 15 practice labs
Lessons
Measuring
- The bandwidth-delay product
- TCP and UDP tests with iperf3
- How latency limits throughput
- Reading cwnd, rtt and retransmits with ss -ti
- Short task: record a performance baseline between two hosts
Congestion control
- Slow start and the congestion window
- Cubic and BBR: comparing congestion algorithms
- How packet loss hurts throughput (with netem)
- Reordering and duplicate ACKs
- ECN: signalling congestion without dropping
- Short task: pick and prove the best algorithm for a lossy link
Tuning
- Window scaling and socket buffers
- TCP settings with sysctl and safe limits
- Nagle and delayed ACK: the small-packet problem
- MSS clamping and MTU problems in tunnels
- TIME_WAIT and ephemeral port exhaustion
- Short task: tune a slow backup transfer
Wrap-up
- Capstone: root cause and fix for a slow branch-to-HQ transfer
Practice labs
- The right window size for this link: Calculate the bandwidth-delay product from the RTT you measure and the given link speed, and estimate the highest rate one TCP flow can reach.
- One stream is slow, four are fast: Compare single and parallel stream results in iperf3, and explain with ss -ti values that the difference comes from a window limit.
- Video calls break up: jitter and loss: Measure the link’s jitter and loss at different rates with iperf3 UDP tests, and determine the highest safe rate for video calls.
- Inside a running transfer: Read cwnd, rtt and retransmits of a running transfer with ss -ti, and write down which value is the limiting one.
- The sender is ready, the receiver can’t keep up: Capture the zero-window advertisements caused by a slow-reading receiver application, and prove the bottleneck is the receiver, not the network.
- Track cwnd over time: Write a script that logs ss -ti values once a second during a transfer, and mark the slow-start and loss moments in the output.
- Switch the congestion algorithm: List the algorithms available on the system, enable BBR and show with ss that a new connection uses it.
- The remote site: a high-latency link: Imitate a remote site’s high-latency link with netem, compare cubic and BBR, and justify with measurements the setting you recommend for the site.
- A congestion signal without drops: ECN: Enable ECN at both ends and on the queue in between, show CE-marked packets in a capture and measure the change in retransmissions.
- A buffer limit caps the speed: Find the socket buffer limit that was left too small, raise it to a safe value and show the gain with iperf3.
- Window scaling is switched off: Show the effect of disabled window scaling in a handshake capture, fix the setting and measure the speed difference on a high-latency link.
- A 40 ms delay on small requests: Prove from a capture the interaction of Nagle and delayed ACK in a client-server pair doing small writes, and measure the delay vanishing with TCP_NODELAY.
- No new connections: port exhaustion: Show with ss that the ‘cannot assign requested address’ error in a load test comes from ephemeral port exhaustion, and fix it by widening the port range.
- HTTPS through the tunnel freezes: Prove from the MSS values in a capture why large responses stall for clients behind a tunnel, and apply MSS clamping on the router.
- Three problems on one link: Separate the MTU, buffer and loss problems sitting together on one link, prove each with a measurement and fix the ones that can be fixed.
About this course
You find the cause of a slow connection by measuring latency, loss, window size and congestion control, then fix it with kernel settings.
What you will learn
- Measuring
- Congestion control
- Tuning
- Wrap-up
Prerequisites
You should be comfortable with the level 101 and 201 topics of the same path.
Lab environment
Lessons run in your own Kali Linux terminal in the browser, connected to a private lab network. Nothing to install.
Frequently asked questions
- Is this course right for my level?
- The course is at level 301; it assumes you know the topics of the lower-level courses.
- Is there anything to install?
- No. Every lesson runs in your own lab environment that opens in the browser.
- How do lessons work?
- Each lesson has 8 to 10 steps and a short quiz. Early steps show the command to type, later steps give less help; if two attempts fail, the solution opens.
- Can I try it for free?
- Yes. The first three lessons of every course are free.