BitTorrent PEX Message Flags for Seeders and Encryption

Peer Exchange (PEX) messages in the BitTorrent protocol allow clients to share known peers directly without querying a central tracker. Within a PEX message, binary flags mapped to each peer indicate their status and connection capabilities. Specifically, the protocol uses the added.f field, where the 0x01 bitflag denotes that a peer supports Protocol Encryption (MSE/PE) and the 0x02 bitflag denotes that the peer is a seeder. These flags allow clients to filter unnecessary connections and enforce security preferences efficiently.

Structure of the PEX Message

The standard Peer Exchange extension (BEP 11 / ut_pex) formats its payload as a Bencoded dictionary. When a client shares newly discovered peers, it populates two parallel fields:

The Specific PEX Flags

Each byte in the added.f string functions as a bitfield to convey the following properties:

1. Encryption Support (0x01)

2. Seeder Status (0x02)

Combined Flag Values

Because these flags are bitfields, they can be combined using bitwise OR operations. For example:

Additional BEP 11 Flags

While 0x01 and 0x02 are the primary flags for encryption and seeding, modern extensions also define: