What is the reason for using BitTorrent KRPC using BEncode instead of BSON?

Mainline DHT , used by BitTorrent to distribute peer lists, implements its own RPC protocol called KRPC. KRPC consists of BEncoded dictionaries, which are essentially a more compact form of JSON.

Is there any use to using BEncode over something like BSON (or even data compression)?

+5
source share
1 answer

I suspect it is bencodeused for historical reasons and eases the burden on developers who want to implement the DHT extension. Since all BitTorrent clients must have a working implementation bencodefor working with torrent files (which are just scanned metadata dictionaries), implementing DHT with help bencodewill not require new project dependencies.

Also note that DHT uses in bencodeconjunction with binary coding. Among other things, an identifier string of 26 bytes node is stored as a binary string (20 bytes for node -id, 6 bytes for ipv4 address / port) (see http://bittorrent.org/beps/bep_0005.html#contact-encoding ) , therefore, as a result, some minimal data compression is already occurring.

+3
source

All Articles