-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bitset format #6
Comments
Hi, I've reviewed the code in libed2k: you are right, in libed2k bits order is from left to right, so the first bit will be 10000000.
So it looks like bug in libed2k. The source code was taken from libtorrent and original bits order was saved. |
Thank you for this confirmation. I could do a pull request to fix this issue |
It is important, but affects downloading not so badly as you can expect. |
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?
The text was updated successfully, but these errors were encountered: