Hack 99. Slow Down to Speed Up
On a flaky link, talking slowly can actually speed up data transfers.
In wireless networking, the speed at which a radio can communicate with another depends on how much signal is available. To maintain communications as the available signal fades, the radios need to transmit data at a slower rate. Normally, the radios attempt to work out the available signal on their own and automatically select the fastest possible speed for communications. But in fringe areas with a barely adequate signal, packets might be needlessly lost while the radios continually renegotiate the link speed.
For example, suppose you have a long distance point-to-point link made of Orinoco radios. The received signal at each end varies between -83 and -80 dBm. The threshold for an Orinoco to flip from 11 Mbps to 5.5 Mbps is -82 dBm, so the radios spend at least part of their time negotiating the best speed. Operating on a borderline signal level like this leads to excessive retransmissions that can seriously degrade performance.
While you may think that simply upgrading to 802.11g will provide a faster connection than 802.11b, remember that you still need to provide enough power to be received on the other end. With too much distance or interference in the path, 802.11g will come to a crawl just as quickly as 802.11b. When in doubt, calculate the estimated path loss [Hack #97] and make sure you have enough gain to achieve the data rate you need.
If you can't add more antenna gain or reposition your equipment to achieve enough signal for your link, consider forcing your card to sync at a lower rate. This will mean fewer retries, and can be substantially faster than using a continually flip-flopping link. Each driver has its own method for setting the link speed. In Linux, set the link speed with iwconfig:
iwconfig eth0 rate 2M
This forces the radio to always sync at 2 Mbps, even if other speeds are available. You can also set a particular speed as a ceiling, and allow the card to automatically scale to any slower speed, but go no faster. For example, you might use this on the previous example link:
iwconfig eth0 rate 5.5M auto
Using the auto directive this way tells the driver to allow speeds up to 5.5 Mbps, and to run slower if necessary, but will never try to sync at anything faster. To restore the card to full auto scaling, just specify auto by itself:
iwconfig eth0 rate auto
Cards can generally reach much further at 1 Mbps than they can at 11 Mbps. There is a difference of 12 dB between the 1 Mbps and 11 Mbps ratings of the Orinoco card; that's four times the potential distance just by dropping the data rate! On a marginal link, it is usually worth sacrificing an attempt at speed to achieve a more efficient link. If you absolutely need to go faster, find a way to get more signal between the two points.