[BitTorrent] Re: IP_TOS setting wrong (patch)

Aaron Hope Aaron.Hope at unh.edu
Mon Dec 13 00:26:16 EST 2004

--- In BitTorrent at yahoogroups.com, "Gregory P. Smith" <gpsmith at g...>
> In RawServer.py it looks like someone attempted to set the IP_TOS
> bits.  However it is set very oddly:
> in the bind() method:
> server.setsockopt(socket.IPPROTO_IP, socket.IP_TOS, 32)
> What does 32 mean?  
> Its diffserv "IPTOS_PREC_PRIORITY 0x20"
> A more appropriate value would be "IPTOS_THROUGHPUT 0x08"
> Also, it needs to be set on outgoing connections for it to matter. 
> Not just the server socket.

The value TOS value of 32 equates to the DSCP value of 8, which is used
by the scavenger service.  Instead of indicating that throughput matters
more than latency for this application, it indicates that the traffic is
low priority, but can consume much bandwidth, and thus should be
throttled unless there is "excess" capacity.  For example, at work I am
on a university campus where capacity is high, but where unfettered
consumption will draw the attention of the network administrators.  As
long as their routers are configured to shape scavenger traffic, I
should not need to cap my usage to a fixed rate.  At home I control the
router and configure my own traffic shaping to prevent bittorrent and
kazaa from drowning out my ssh and web sessions.  

At least, that's my take on it.  See http://qbone.internet2.edu/qbss/
for general info on the scavenger service and
http://www.aarnet.edu.au/engineering/networkdesign/qos/ for details on
the history and use of these fields ("Precedence and DSCP" and "Using
the Scavenger service").

As for the code, I agree that it is both abstruse and incorrect.  I
offer the attached patch in the name of clarity and correctness.
Without a modification such as this, bittorrent traffic is not properly
shaped, and can get people (me) in trouble.  It was only today that I
dug out ethereal to find out why my policy wasn't being enforced as I

Be advised that the default queuing disciplines in linux respect the old
RFC 791 TOS values IPTOS_THROUGHPUT and IPTOS_LOWDELAY and do not make
use of newer DSCP values.  So you need to install your own policy such
as the one in the attached script if you wish to use this feature.  Even
wondershaper appears to ignore the scavenger service.

Aaron Hope <Aaron.Hope at unh.edu>
NPG System Administrator
PGP key: http://perennialmind.cjb.net/gpg_key.txt

[Non-text portions of this message have been removed]

------------------------ Yahoo! Groups Sponsor --------------------~--> 
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!

Yahoo! Groups Links

<*> To visit your group on the web, go to:

<*> To unsubscribe from this group, send an email to:
    BitTorrent-unsubscribe at yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:

More information about the BitTorrent mailing list