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.
source
share