{"id":118,"date":"2020-05-10T12:07:12","date_gmt":"2020-05-10T11:07:12","guid":{"rendered":"https:\/\/blog.thomarite.uk\/?p=118"},"modified":"2020-05-11T23:44:50","modified_gmt":"2020-05-11T22:44:50","slug":"tcp-congestion-control-and-recovery","status":"publish","type":"post","link":"https:\/\/blog.thomarite.uk\/index.php\/2020\/05\/10\/tcp-congestion-control-and-recovery\/","title":{"rendered":"TCP Congestion Control and Recovery"},"content":{"rendered":"\n<p>I have reading this new post from <a href=\"https:\/\/blog.cloudflare.com\/cubic-and-hystart-support-in-quiche\/\">Cloudflare<\/a> about their congestion control implementations for <a href=\"https:\/\/en.wikipedia.org\/wiki\/QUIC\">QUIC<\/a>.<\/p>\n\n\n\n<p>Reading the article I wanted to check the TCP CCA (Congestion Control Algorithm) available in my laptop (Debian 1o Testing).<\/p>\n\n\n\n<p>So I searched a bit and found a couple of useful links like <a href=\"https:\/\/superuser.com\/questions\/992919\/how-to-check-the-tcp-congestion-control-algorithm-flavour-in-ubuntu\">this<\/a>:<\/p>\n\n\n\n<p>For checking your current TCP CCA:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># sysctl net.ipv4.tcp_congestion_control\nnet.ipv4.tcp_congestion_control = cubic\n\n$ cat \/proc\/sys\/net\/ipv4\/tcp_congestion_control\ncubic<\/pre>\n\n\n\n<p>For checking the available TCP CCAs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># sysctl net.ipv4.tcp_available_congestion_control\nnet.ipv4.tcp_available_congestion_control = reno cubic<\/pre>\n\n\n\n<p>As well, you can see via &#8220;ss&#8221; the CCA per connection:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ss -ti\n...\ntcp   ESTAB      0       0                                     192.168.1.158:60238                     169.54.204.232:https       \n\t cubic wscale:7,7 rto:320 rtt:116.813\/2.428 ato:40 mss:1448 pmtu:1500 rcvmss:1448 advmss:1448 cwnd:10 bytes_sent:4366 bytes_acked:4367 bytes_received:7038 segs_out:98 segs_in:183 data_segs_out:91 data_segs_in:93 send 991.7Kbps lastsnd:1260 lastrcv:1260 lastack:1140 pacing_rate 2.0Mbps delivery_rate 102.2Kbps delivered:92 app_limited busy:10632ms rcv_space:14480 rcv_ssthresh:64088 minrtt:113.391\n...<\/pre>\n\n\n\n<p>If you want to change your TCP CCA, this is a good <a href=\"https:\/\/securenetweb.wordpress.com\/2017\/01\/24\/add-tcp-congestion-control-variant-to-linux-ubuntu-comparing\/\">link<\/a>:<\/p>\n\n\n\n<p>Check the modules installed:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ ls -la \/lib\/modules\/$(uname -r)\/kernel\/net\/ipv4<\/pre>\n\n\n\n<p>Check the kernel config:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ grep TCP_CONG \/boot\/config-$(uname -r)\nCONFIG_TCP_CONG_ADVANCED=y\nCONFIG_TCP_CONG_BIC=m\nCONFIG_TCP_CONG_CUBIC=y\nCONFIG_TCP_CONG_WESTWOOD=m\nCONFIG_TCP_CONG_HTCP=m\nCONFIG_TCP_CONG_HSTCP=m\nCONFIG_TCP_CONG_HYBLA=m\nCONFIG_TCP_CONG_VEGAS=m\nCONFIG_TCP_CONG_NV=m\nCONFIG_TCP_CONG_SCALABLE=m\nCONFIG_TCP_CONG_LP=m\nCONFIG_TCP_CONG_VENO=m\nCONFIG_TCP_CONG_YEAH=m\nCONFIG_TCP_CONG_ILLINOIS=m\nCONFIG_TCP_CONG_DCTCP=m\nCONFIG_TCP_CONG_CDG=m\nCONFIG_TCP_CONG_BBR=m\nCONFIG_DEFAULT_TCP_CONG=\"cubic\"\n<\/pre>\n\n\n\n<p>We can see that &#8220;cubic&#8221; is the default TCP CCA and we have for example BBR available as a module.<\/p>\n\n\n\n<p>So let&#8217;s change to BBR (<a href=\"https:\/\/tools.ietf.org\/html\/draft-cardwell-iccrg-bbr-congestion-control-00\">rfc<\/a>, <a href=\"https:\/\/github.com\/google\/bbr\">github<\/a>, <a href=\"https:\/\/cloud.google.com\/blog\/products\/gcp\/tcp-bbr-congestion-control-comes-to-gcp-your-internet-just-got-faster\">blog<\/a>) based on this <a href=\"https:\/\/www.tecmint.com\/increase-linux-server-internet-speed-with-tcp-bbr\/\">link<\/a>:<\/p>\n\n\n\n<p>Check the kernel supports BBR:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat \/boot\/config-$(uname -r) | grep 'CONFIG_TCP_CONG_BBR'\nCONFIG_TCP_CONG_BBR=m\n$ cat \/boot\/config-$(uname -r) | grep 'CONFIG_NET_SCH_FQ'\nCONFIG_NET_SCH_FQ_CODEL=m\nCONFIG_NET_SCH_FQ=m<\/pre>\n\n\n\n<p>Enable TCP BBR:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># vi \/etc\/sysctl.conf\nnet.core.default_qdisc=fq\nnet.ipv4.tcp_congestion_control=bbr<\/pre>\n\n\n\n<p>Apply the changes:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># sysctl --system<\/pre>\n\n\n\n<p>And check:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ cat \/proc\/sys\/net\/ipv4\/tcp_congestion_control\nbbr<\/pre>\n\n\n\n<p>So we have moved from CUBIC to BBR. Let&#8217;s see how is the experience in the following days.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have reading this new post from Cloudflare about their congestion control implementations for QUIC. Reading the article I wanted to check the TCP CCA (Congestion Control Algorithm) available in my laptop (Debian 1o Testing). So I searched a bit and found a couple of useful links like this: For checking your current TCP CCA: &hellip; <a href=\"https:\/\/blog.thomarite.uk\/index.php\/2020\/05\/10\/tcp-congestion-control-and-recovery\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;TCP Congestion Control and Recovery&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,2],"tags":[],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-unix","category-networks"],"_links":{"self":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/comments?post=118"}],"version-history":[{"count":2,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":130,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/posts\/118\/revisions\/130"}],"wp:attachment":[{"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/media?parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/categories?post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.thomarite.uk\/index.php\/wp-json\/wp\/v2\/tags?post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}