jump to navigation

tcpnice the Linux Bandwidth conrtoller on your local network February 14, 2011

Posted by Tournas Dimitrios in Linux admin tools.

If you have a local network at home and the Internet access is shared between the members of your family , often you will face the problem of  ” Bandwidth overloading ” . You know , kids are downloading their favorite .mp3 songs , and you kan not enjoy even a simple web surf experience . Another scenario , say you’re at an internet cafe and some dude sitting next to you is hogging up all the bandwidth with his multiple torrent downloads of illegal software. You’re at your machine and you are trying to upload some important documents to your website. The frustration grows as your uploads begin to time out. Thanks to Dug Song the creator of dsniff , we have a method to slow-down our neighbour’s / family’s member network speed , …. introducing tcpnice .

My previous article outlined the tcpkill utility that can be used to kill live tcp connections to or from a host, network, port or a combination of them all. Similarly, Tcpnice doesnt necessarily kill the connections, but attempt to slow them down.

In our scenario we will hack our box to function as an Bandwidth Controller 🙂

  • First we need to perform a MITM man in the middle attack (arpspoof or ettercap shall do) , then enable forwarding in the  kernel as follows:
    # echo 1 > /proc/sys/net/ipv4/ip _forward
  • We then need to determine what local ip is hogging up the bandwidth. There is a useful sniffer that i use call tcptrack that list the live connections that it sees and the bandwidth/speed of the data that is being transferred back and forth on each connection.
    #tcptrack  -i  eth0
  • Once you determine the IP of the bandwidth hogger (in this example, ), its time to unleash our magic.
    # tcpnice  -i  eth0  -A host 

    If no option (A,I,M) is given, all would be used.
    -A Inject TCP tiny window advertisements.
    -I (Ai) Inject ICMP source quench replies.
    -M Inject ICMP fragmentation-needed replies with tiny next-hop MTUs.
    -i interface to listen on



No comments yet — be the first.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s