If your download consumes all bandwidth and internet is stuck then read this

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
2,102
Reaction score
1,655
Credits
17,216
When you download some large file such as big ISO or for instance seeding or downloading torrents, you may notice how browsing the internet is so stuck it takes some time until a web page is fully loaded, or watching videos is so slow all you see is spinning circle all the time.

Sometimes the problem is so horrible you can literary do nothing but to temporarily pause downloading or slowing down torrents.

Well no longer because here is why that's happening and how to fix it:

First show current qdisc for your NIC that's used for download:
Bash:
ip link

Let's say your interface used for download is called wlan0 the output might look like this:

Bash:
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
    link/ether 00:11:22:33:44:55 brd ff:ff:ff:ff:ff:ff

From this output it's visible the qdisc value which says noqueue, what this means is that packets which are most numerous (from download) will waste up driver queue, and your other packets like video streaming or web browsing will have to wait in queue for prolonged time making normal internet use horrible.

Suppose download packets are marked "X" and your web-browsing packets are marked "Y", packets go from left to right (that is from TCP/IP stack toward NIC controller and vice versa, then the driver queue will look like [Y X X X X X X...], as you can see Y packet has to wait until all X packets are transmitted, that's why web browsing and watching video sucks.

A solution is to change qdisc to fq_codel which stands for "Fair Queuing, Controlled Delay".

You can do it temporarily with tc command as follows (assuming your NIC is called wlan0):
Bash:
sudo tc qdisc add dev wlan0 root fq_codel

Then run ip link again to confirm the change.
This change will persist until reboot or until you change qdics to something else.

If you're using NetworkManager and want to make this setting permanent to persist reboots then:

Bash:
# List connections
nmcli connection show

Sample output

Bash:
NAME      UUID                                  TYPE      DEVICE       
MyWifi  5120ec15-0c1e-4252-8f2e-905eb533be30    wifi      wlan0
... etc

Then make the change for the connection you want to modify, in this sample it's called "MyWifi":

Bash:
nmcli connection modify MyWifi tc.qdiscs 'root fq_codel'

This one will persist reboots and will stay until you manually change it to some other queuing discipline.

After this change your driver queue will no longer be [Y X X X X X X...] but instead you'll have as many queues as needed to reduce traffic delay, so now it will turn into:
IP stack -> [ X X X X X X...] -> NIC controller
IP stack -> [Y] -> NIC controller

Meaning both types of packets have equal share of network resources.

You can now download big files and do torrenting as much as you like without suffering with web browsing, watching videos and maybe even playing online multiplayer games while you download.
 
Last edited:


Thanks @CaffeineAddict for the rundown on the qdisc configuration.

For those who don't run NetworkManager, the configuring of qdisc can be made using the traffic control command: tc. There are good examples online for the interested reader to research.

Fortunately here, with a broadband at 263 Mbit/s, the issue hasn't arisen :) YMMV
 
the configuring of qdisc can be made using the traffic control command: tc. There are good examples online for the interested reader to research.
You're welcome, unfortunately tc command is only temporary and that's one annoying thing, this is what made me ask the question on Unix SE because all the "dupe" answers are so-so, was not happy with them:

It took me some time to figure out how, redhat docs ask for payment to learn this info lol, so I decided to share it for free heh.
My internet is not that fast and qdisc helps a lot.
 
You're welcome, unfortunately tc command is only temporary and that's one annoying thing, this is what made me ask the question on Unix SE because all the "dupe" answers are so-so, was not happy with them:

It took me some time to figure out how, redhat docs ask for payment to learn this info lol, so I decided to share it for free heh.
My internet is not that fast and qdisc helps a lot.
Yes, it looks like the RH docs use nmcli to make the changes permanent:

For on-going configuration there's info on using sysctl there, and then there's options like creating a systemd service or old school rc.local.
 
Yes, it looks like the RH docs use nmcli to make the changes permanent:
Good find! I stumbled upon another one that doesn't tell you how:

For on-going configuration there's info on using sysctl there
I have it set but it doesn't affect my NIC for some reason, I guess because it's managed by NetworkManager

and then there's options like creating a systemd service
Tried that too with systemd-networkd there is [QDisc] section for *.network files but it's hard to set up, docs are not clear enough so I gave up and found this solution which is IMO better since everybody uses NetworkManager.
 


Members online


Latest posts

Top