On Wed, Apr 01, 2009 at 08:49:16PM +0100, Thomas Grimshaw wrote:
> Hey all,
> 
> I was just wondering if there was any practical reason why AppendedAcks 
> are not zerocoded in the packet data?
> 
> Saving a few bytes means fitting more Acks into each message, 
> potentially reducing the number of PacketAck messages being sent, which 
> means a potentially substantial protocol overhead reduction.
> 
> This could also be implemented  with backward compatibility by using a 
> new flag to indicate zerocoded appendedacks.

There is another way that might be even more efficient,
especially if/once most values are (much) larger than 256
but smaller than 16384; which seems to be a possibility
in the future(?).

This method works as follows: the first bit of every byte
is flag, if the flag is set - then it's the last byte.

Let p point the start of such an encoding, then you could
decode it as follows:

unsigned char* p = data;
int count = 1;
while (!(*p & 0x80)) { ++p; ++count; }
unsigned long val = *p & 0x7f;
while (--count) { val <<= 7; val |= *--p; }

This would take:
range           #bytes
0-127           1
128-16383       2
16384-2097151   3

-- 
Carlo Wood <[email protected]>
_______________________________________________
Policies and (un)subscribe information available here:
http://wiki.secondlife.com/wiki/SLDev
Please read the policies before posting to keep unmoderated posting privileges

Reply via email to