[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: CPS/throttle patches
I wonder if the transmission rate couldn't be computed without an array
at all similar to the way the early TCP stacks tracked round trip
times. In TCP, they used to use the formula:
ARTT = a * ARTT + (1-a)*MRTT
Where 'ARTT' is the average round trip time, 'MRTT' is the last measured
round trip time and 'a' is some constant that determines how much
averaging gets done (0.9) is typical.
It seems like this could be adapted to computing the current DCC
transmission rate averaged over some number of samples like so.
average-rate = a * average-rate + (1-a)*rate-during-last-interval.
So assume you compute the transmission rate every second based on the
gain during the last second. Using a value for 'a' of 0.9 (average over
the last 10 samples)...
average-rate = 0.9*(average-rate) + 0.1*(gain in last second)
Start the transfer with an initial average-rate of 0 and over the next
10 seconds it will increase to the average over the last 10 seconds.
Then it will remain at the average over the last 10 seconds for the rest
of the transfer. If 10 seconds is too long or too short of an average
interval, change the value used for 'a'. If you record gains at an
interval different than 1 second, you'll need to normalize it to
bytes/second before using it in the calculation (but 1 second
measurement on the gains seems reasonable).
Anyway, just a thought.
Paydon
> It seems to me that the cps calculations could be done alot simpler, without
> needing an array of struct timevals. For example, every second, you record the
> file position:
>
> time pos gain
> 0 0 0
> 1 4096 4096
> 2 8192 4096
> 3 10000 1808
> 4 12000 2000
> 5 17000 5000
> 6 20000 3000
>
> cps = (4096 + 4096 + 1808 + 2000 + 5000 + 3000) / 6
> cps = 3333
> sounds about right I think?
> Of course, you only keep a record of the last X (10 or 20?) "gains".
> Then, if the xfer stalls, you should notice:
>
> time pos gain
> 7 21000 1000
> 8 21000 0
> 9 21000 0
> 10 21000 0
>
> cps = (1000 + 0 + 0 + 0) / 4
> cps = 250 (and eventually zero, once the "sliding window" moves beyond
> the gain of 1000).
>
> This way, you only need to keep an array of CPS_NUM_SAMPLES ints:
>
> int gains[CPS_NUM_SAMPLES];/* bytes received in the last few seconds */
> int index_into_gains;
>
> Ok, now pick holes in my theory :)
>
> --
> Peter Zelezny.
> --
> XChat-discuss: mailing list for XChat users
> Archive: http://mail.nl.linux.org/xchat-discuss/
>
>
--
XChat-discuss: mailing list for XChat users
Archive: http://mail.nl.linux.org/xchat-discuss/