Hi, I'm coding an ed2k library on my own, for learning purpose and I'm using libed2k as a reference,
since there is no so much detailed documentation on ed2k protocol.
First of all, congratulations for this great work!
I have a doubt about the format of the part status field which is sent in the peer File Status Answer message.
Initially, I thought that, i-th bit of the bitfield was stored at byte offset i / 8 (and bit offset i % 8), and this is also confirmed by libed2k.
However, when downloading files made of only a single part (while testing my own library), I found that peers holding the entire file send the following single-byte bitfield: 00000001. Naturally, I expected the following bitfield: 10000000 (also according to libed2k).
So I suspect that the format of the bitfield is "reversed", that is to say one should compute the offset of the i-th bit starting from the end of the stream (going from right to left).
I also noticed that, in this case, because of the function "clear_trailing_bits", libed2k would have cleared the last bit set to one,
giving a zero bitfield, but I don't think this is correct (if the peer didn't get the only part the file is made of, he wouldn't send the part status field, setting the field "downloadedParts" to 0, instead of 1).
Can you give an explanation to such behaviour?
Hi, I'm coding an ed2k library on my own, for learning purpose and I'm using libed2k as a reference,
since there is no so much detailed documentation on ed2k protocol.
First of all, congratulations for this great work!
I have a doubt about the format of the part status field which is sent in the peer File Status Answer message.
Initially, I thought that, i-th bit of the bitfield was stored at byte offset i / 8 (and bit offset i % 8), and this is also confirmed by libed2k.
However, when downloading files made of only a single part (while testing my own library), I found that peers holding the entire file send the following single-byte bitfield: 00000001. Naturally, I expected the following bitfield: 10000000 (also according to libed2k).
So I suspect that the format of the bitfield is "reversed", that is to say one should compute the offset of the i-th bit starting from the end of the stream (going from right to left).
I also noticed that, in this case, because of the function "clear_trailing_bits", libed2k would have cleared the last bit set to one,
giving a zero bitfield, but I don't think this is correct (if the peer didn't get the only part the file is made of, he wouldn't send the part status field, setting the field "downloadedParts" to 0, instead of 1).
Can you give an explanation to such behaviour?