Limiting network throughput of an already launched process ? (Linux/FreeBSD)

Solution 1:

Unfortunately there is no such a solution for FreeBSD. There are many solutions like dummynet/ipfw or altq/pf which are used to limit network usage based on different patterns but not on pids.

On linux there is a way to limit network usage on a user basis:

iptables -t mangle -A OUTPUT -p tcp -m owner --uid-owner test -j MARK --set-mark 1

I think there is no solution to limit the network utilization based on pid.

Solution 2:

lsof the process to get the network ports that the proc is using. Once you know which ports are being used you can use IPTABLES rules to rate limit these ports. These articles should give you a better idea: http://linux-ip.net/articles/Traffic-Control-HOWTO/ http://blog.edseek.com/~jasonb/articles/traffic_shaping/ http://wikis.sun.com/pages/viewpage.action?pageId=49906332