D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] ping-based throttling scripts

 

On Fri, 23 Oct 2009 12:22:05 +0100, Martijn Grooten <sweetwatergeek@xxxxxxxxxxxxxx> wrote:

Sounds like a clever little idea.
Thanks :)

I do wonder if you won't be going
back and forth between 4 and 5: your bandwidth limit is increased as
long as pings are fine, so at some point you will reach the maximum,
when pings become slow and you'll decrease your bandwidth limit until
pings are fine again and bandwidth is increased etcetera.
Yes that is sort of the point. It is about the most basic feedback control. Like a thermostat, you create an oscillation which you (hopefully) keep small enough you don't notice it.

I think that
would mean you're in case 4 quite a lot of the time. (Not sure if
there's a good solution to that problem other than setting a hard
maximum for the bandwidth limit though.)
Actually it spends most of the time on step 5 due to a deliberate choice on my part. I took the view that high latency is more upsetting than my downloads going a too slow, so the bandwidth limit is reduced faster than it is increased (if that makes sense). If I had made it symmetric, I have no doubt your observation would have been right.

I set it so in step 4 it'll decrease by 4kbit/s or 8kbit/s (i can't remember) if the ping is above 200. If the ping is above 600ms, the limit is decreased by 5% and if it's above 4000 is reduced to the minimum limit (which I set at 8kbit/s). By contrast, in step 5, the limit will only be increased by 1kbit/s in each step.

What I'm finding is that most of the time it is gradually increasing the limit. When the average ping increases to 100ms, the limit stays the same a few times but the ping keeps increasing, normally up to around 600ms. It will then step down 3 or 4 times then the ping drops back down to 50 or so. Note that these are averages, so when the script reports 600ms, the latest reading is likely around 1000ms. The blip lasts maybe 5-10 seconds.

Ideally i want it to spend most of the time between the 2 setpoints but clearly it's overshooting too much in both directions. I think that averaging the pings is partly to blame for this so I'll try knocking that out and see if that improves things. I might also move the setpoints closer together to reduce the delay further.

I think the control method could be improved but I haven't decided how. Maybe an approximation of a PID.

Re 1:
nslookup $hostname | grep Address | head -n2 | tail -n1 | cut -d' ' -f2
ah thanks.  I always forget about cut.

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/linux_adm/list-faq.html