BEP9(ut_metadata) data message has a total_size field and I'm having trouble seeing what it means.
The message is in this format:
<4-byte length prefix><20><1-byte extended msg id><bencode part><piece data>
I'm confused about two things:
- Does length-prefix include
<piece data>part? - What does
total_sizefield inbencode_partspecify?
It looks to me like we don't need total_size, unless I'm misunderstanding something.
Here is currently how I'm parsing it:
- Length prefix includes
<piece data>so I know exactly how big this message is. I'm reading that many bytes. - After parsing
<bencode_part>, I'm just consuming rest of the bytes and consider this the data.
Can anyone help me understanding this format?
Thanks.