Chapter 13. OS Traffic shaping

Table of Contents
BSD Traffic Shaping
Linux Traffic Shaping

The bandwidth preferences are an excellent tool for controlling gtk-gnutella's bandwidth. However, you must often be a pessimistic when using application layer bandwidth control. Consider a system running gtk-gnutella, a BitTorrent client, a web server and a secure shell server (sshd). The bandwidth can be divided into four (possibly unequal) parts at the application level.

Simple division of bandwidth is not ideal. The ssh task doesn't need a lot of bandwidth. The important item is response or "latency". This is also true for many real time gaming applications. Ftp, and peer-to-peer applications like gtk-gnutella need bandwidth. Web pages also need to be responsive. It also becomes obvious that dividing the bandwidth is not making full use of your network connection. Web traffic is very bursty as users click links. gtk-gnutella and BitTorrent traffic is also bursty as new clients come and go.

Fortunately there are better ways to do this. Linux provides the "tc" program. BSD provides "ipfw" queue and pipe commands. When using traffic shaping, it is useful to have some diagnostic tools. The iftop program is useful in observing bandwidth usage.

The following is an example ".iftoprc" that is useful for sorting bandwidth based on destination port.


interface: ppp0
dns-resolution: yes
port-resolution: no
show-bars: yes
promiscuous: no
port-display: source-only
hide-source: yes
hide-destination: yes
use-bytes: yes
sort: 2s
line-display: one-line-both
show-totals: yes
log-scale: no

The "iftop" program requires libpcap and must be run as root. However, root access is not an issue as all traffic shaping commands need to be run a root level.

As mentioned previously, there are two factors that affect network performance. One is bandwidth, the other is latency. As most network traffic is bursty, all routers on the Internet buffer packets. This allows momentary handling of traffic that is above a links capacity. However, this buffer forms a queue which increases latency. If the traffic never subsides latency will increase for interactive traffic, like ssh, web and gaming applications. A key to configuring traffic shaping is to limit the total outbound traffic below the link capacity (bandwidth). Running "iftop" without any traffic shaping and use "ftp" or another application to use all your bandwidth. It is important to get real numbers. If you over-estimate your bandwidth, the latency will increase. The "f" key allows a filter to be installed. The filter "src host ip" will show only outbound traffic on most home networks (single IP). Your ip is your actual ip, found with "ifconfig" or any other method.

It is not simple to control incoming traffic and you may never be sucessful as it requires support on both ends. It is probably best to use the application layer controls for download bandwidth.

BSD Traffic Shaping

Please add information here.

gtk-gnutella development hosted bySourceForge.net Logo