3

Is it possible to tune which applications receive the most bandwidth on a NIC, similar to the -20 to +20 Nice value but for bandwidth instead of processor-time?

Transmission seems to choke out my other applications. I can slow down the application from its options but I wondered if there was a linux/non-application-specific solution where I can view and tune everything that has network access.

Update: I suspect the problem is shown in the output below. Currently all web and transmission traffic is TCP source port 80 and a dynamic destination port, and is lumped together in class 0:3 (with 16810552 bytes and 171075 packets). So, because my web connection is not that fast, transmission is choking it out just enough for me to get timeouts. The output shows that no packets are being dropped by the queuing discipline.

I'm looking at tcng as a possible solution because of the configuration already present.

$ tc qdisc show dev wlp2s0
qdisc mq 0: root 
qdisc fq_codel 0: parent :4 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn 
qdisc fq_codel 0: parent :3 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn 
qdisc fq_codel 0: parent :2 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn 
qdisc fq_codel 0: parent :1 limit 10240p flows 1024 quantum 1514 target 5.0ms interval 100.0ms memory_limit 32Mb ecn 

$ tc -g -s class show dev wlp2s0
+---(:4) mq 
|       Sent 5670 bytes 105 pkt (dropped 0, overlimits 0 requeues 1) 
|       backlog 0b 0p requeues 1
|   
+---(:3) mq 
|       Sent 16810552 bytes 171075 pkt (dropped 0, overlimits 0 requeues 0) 
|       backlog 0b 0p requeues 0   competing for bandwidth
|     
+---(:2) mq 
|       Sent 2538 bytes 31 pkt (dropped 0, overlimits 0 requeues 1) 
|       backlog 0b 0p requeues 1
|     
+---(:1) mq 
        Sent 13432 bytes 76 pkt (dropped 0, overlimits 0 requeues 0) 
        backlog 0b 0p requeues 0
flerb
  • 963
  • You can do this with namespaces. I have only done this with services in docker. However it will be possible to do what you want as well. But I have not done it. (It is a feature of the Linux kernel, finding user mode tools may or may not be tricky.) – ctrl-alt-delor Aug 11 '18 at 08:48

2 Answers2

2

Traffic shaping QoS

I've historically used tools such as Wondershaper, Trickle, or pyshaper to throttle network traffic.

Examples

Trickle

To throttle the upload/download speed to 20Kbps.

$ trickle -d 20 wget -c http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm

You can also set these independently in the above scenario. You can also make these settings the default like so.

$ trickled -d 50 -u 10

Wondershaper

You can also use Wondershaper to control the bandwidth at the network level. For example say I want to throttle my eth1 device.

$ sudo wondershaper eth1 1024 256

This will give me a Download speed of 1024 Kbits and 256 Kbits Upload. Which are 128KB and 16KB.

When you want to release the caps.

$ sudo wondershaper clear eth1

pyshaper

I've extensively covered pyshaper on the site before, see these U&L Q&As titled:

These are pretty capable tools so this is just meant to show you the potential.

References

slm
  • 369,824
1

Probably what you are looking for is quality of service (QoS) which may not be easily available in your favorite firewall (like iptables, nftables, pf, ufw, etc) but should be simple on any modern router and operates by IP/port.

iptables example; https://serverfault.com/questions/762921/qos-with-iptables-and-tc-with-unstable-wan

As slm mentioned trickle can be used when starting a process when not using commands (like rsync, curl, wget) which have rate limiting as a built in option.

wondershaper can be used to limit by [virtual] interface which is usefull for commands and VMs that can be bound to a nic (like rsync, curl, wget).

user1133275
  • 5,574