[Gllug] traffic shapping

Chris Ball chris at void.printf.net
Fri May 23 12:39:34 UTC 2003


>> On 23 May 2003 10:19:58, Alistair Mann <alistair at lgeezer.net> said:

   > Thus spaketh Jonathan Dye on Wednesday 21 May 2003 1:11 pm:
   >> I'm trying to set up some traffic shaping on my dial up connection
   >> to limit the speed of incoming packets

   > Stop right there. There is no traffic-shaping solution anywhere
   > that can help you to shape /incoming/ traffic. By definition,
   > traffic cannot be shaped until it has already arrived, by which
   > time, your dialup line has already been swamped.

For complex traffic shaping, perhaps.  There are certainly shaping
(limiting) solutions that *can* work from the same machine, though.
Consider the following, taken from the GNU wget(1) source:
  
   limit_data.dltime += delta;
   expected = (long)(1000.0 * limit_data.bytes / opt.limit_rate);

   if (expected > limit_data.dltime) {
       long slp = expected - limit_data.dltime;
       usleep (1000 * slp);
   }

By usleep(3)ing while we read(2), we delay the ACK that is sent back
after a packet.  This in turn reduces the TCP window for the connection,
which reduces the rate that the remote machine sends us data.  Not only
is it possible to limit incoming traffic, it's possible to do it in
userland, too.

Generalising this approach, trickle[1] LD_PRELOADs its own read(2)
implementation and takes config file arguments of per-site and service
limits, usleeping as appropriate. :) It may well help for the situation
described, and portably so.

- Chris.
Footnotes:
  [1]:  <http://monkey.org/~marius/trickle/>
-- 
$a="printf.net";  Chris Ball | chris at void.$a | www.$a | finger: chris@$a
|    "I like how, in software, 'gracefully' means not exploding and
|    destroying everything." - gale:pub.comp.configure, 2003-04-29.



-- 
Gllug mailing list  -  Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug




More information about the GLLUG mailing list