Recently I have been trying to understand how syncthing works under the hood. I started with the Local Discovery Protocol v4. While reading, I got stuck trying to understand how the Announcement message conveys its length without explicitly transmitting the length in a protobuf field or a length-prefixed frame.
I looked into the source code but couldn’t figure out much. So I ran wireshark on to study the packets sent. I got the magic number that syncthing uses. After stripping the magic number from the byte sequence, I ran the protobuf decoder (protoc --decode
) on the message and it decoded fine. So I want to know how syncthing distinguishes between two announce packets.
I am a newbie in networking and stuff so please bear with me. Thanks