Why TCP Congestion Control is key to Application Performance – Medium

0
115

Sign up
Sign In
Sign up
Sign In
The Gray Area
Nov 25
Member-only
Save
TCP Congestion control allows the sender to fully utilize a network without flooding it with packets. This is done by controlling the rate of transmission at the sender.
Middle routers hold packets temporarily in a memory buffers to be processed and routed to the next hop. When a router’s buffer fills up, new packets are dropped signaling a congestion to the sender. When the sender detects a congestion it slows down data transmission using several algorithms.
In this article we discuss two major algorithms, the slow start and the congestion avoidance.
The Congestion Window (CWND) controls how many segments the sender can send without waiting for acknowledgment. Waiting for an ACK after sending each segment will significantly degrade performance. Having a window of bytes that the sender can send data freely without waiting for an ACK speed up transmission.
The initial value of CWND was always set to 1 maximum segment size (MSS), however in 2013 Google proposed RFC6928 to change the initial CWND value to up to 10 MSS. Of course there is a chance that the network might get congested at the start of transmission but Google has a fallback logic in the RFC.
Of course, the other solution was to compress the certificate chain, a harder thing to do. I talked about that here.
If I would to guess, 2013 is when TLS started to become abundant. Google realized that transmitting the uncompressed certificate chains in the server hello might take several segments. Sticking to 1 (or 2 MSS) will significantly slow down the TLS handshake. Starting with a large window helps speed up transmission.
Of course, I say that because tested that on wireshark and I clearly see Google’s server pushing certificate without waiting for ACK.
The other solution was to compress the certificate chain, a harder thing to do. I talked about that here.
The slow start algorithm kicks off the transmission. it increases the CWND by 1 maximum segment size (around 1500 bytes in most cases) for each acknowledgment the sender receives. This continues until the CWND reaches the slow start threshold (SSTHRES) the algorithm then changes to the congestion avoidance.
In the congestion avoidance algorithm, the CWND is increased by 1 MSS for each round trip and not each ack. This means if your CWND is 5 segments worth of size, sending 5 segments and getting acknowledgment for the entire 5 segments will get you an increase of 1 MSS to your CWND. This is as opposed to slow start where if you receive 5 acknowledgments you get +5 MSS to your CWND. That is why Slow Start starts slow but increases aggressively. While congestion avoidance increases slowly.
When congestion is detected, the slow start threshold is reduced by however many unacknowledged segments in flight (flight size) divided by two. A common implementation mistake is to aggressively reduce SSTHRESH by dividing CWND by default as the Flight size is usually lower than CWND.
The CWND is also reset to 1 MSS or whatever the implementation decides it to be. This kicks back the slow start algorithm again since the CWND is now lower than the SSTHRESH. This goes on over and over again until the slow start threshold becomes equal or less than the value of 2MSS.
The lower the slow start threshold the slower the increase of transmission because the slow start will reach the threshold faster and the congestion avoidance will kick in giving us linear increase.
Triggering congestion by dropping packets is very expensive and slow. There are better ways to notify the sender before a congestion happens using a bit in the IP packet called ECN (Explicit Congestion Notification). An improvement to ECN is TCP for the datacenter which adds more metadata to ECN so sender slows down only by the amount necessary.
The Homa paper takes that to the next level proposing a complete receiver controlled congestion instead of buffer based and sender control. But, nothing is perfect.
There are limits to network and senders must respect these limits. However, it is also important to take full advantage of network bandwidth and not underutilize it and for that we need congestion control in TCP.
If you enjoyed this post consider grabbing my fundamentals of network engineerings udemy course, I designed specifically for software engineers with top to bottom approach. Head to https://network.husseinnasser.com for a discount coupon.
The Gray Area is a collection of great cybersecurity and computer science posts. The best articles are highlighted in a weekly newsletter, sent out every Wednesday. To get updates whenever The Gray Area publishes an article, check out our Twitter page, @TGAonMedium.


For all different kinds of developers💻, hackers👾, and tech-savvy people👨‍💻 | Free newsletters each Wednesday on the newest tech hardware and software! | Now welcoming new writers!
Deep Mind Squared et al
sreehari
in
Geek Culture
Fauzan haeqal
Cristian Villaseca
Aarati khamakar
Sarah Maddox
in
kubeflow
you.com
Paul Keen
in
JTWay
AboutHelpTermsPrivacy
Software Engineer passionate about Backend Engineering
Help
Status
Writers
Blog
Careers
Privacy
Terms
About
Text to speech

source