libtorrent
libtorrent copied to clipboard
uTP selective ACK payload size differs from BEP
BEP 29 says that the selective ACK 'payload is a bitmask of at least 32 bits, in multiples of 32 bits.' If I'm reading the code correctly, libtorrent appears to use an 8 bit minimum with 8 bit multiples when sending selective ACKs:
https://github.com/arvidn/libtorrent/blob/d5f74cb7edb489de5931f81f8269f4e718237949/src/utp_stream.cpp#L1370
Note that sack
is the selective ACK payload size in bytes (the extension's len
field in the BEP). m_inbuf.span()
is in bits, so sack
would need to be a multiple of 4. Maybe something like this:
sack = ((m_inbuf.span() + 31) / 32) * 4;
I'm not sure if non 32-bit multiples are an issue at all in practice though. I guess it depends on how strictly other clients might have been coded to handle it.