BitTorrent Protocol: Interested vs Not Interested Messages

In the BitTorrent peer-to-peer protocol, communication between peers relies on distinct state flags to manage data flow efficiently. Among the most fundamental of these are the “interested” and “not interested” state messages, which signal whether a client wants pieces of a file that a connected peer possesses. Together with “choked” and “unchoked” states, these messages form the core state machine that controls when and how data requests are transmitted across the swarm.

The Role of Peer States in BitTorrent

Every peer connection in BitTorrent is symmetric and bidirectional, meaning both sides maintain two independent state variables regarding each other:

  1. Choked / Unchoked: Dictates whether a peer is permitted to request data from the other.
  2. Interested / Not Interested: Dictates whether a peer desires data from the other.

Data transfer only occurs when a peer is simultaneously interested in the remote peer and unchoked by that remote peer.

The “Interested” Message

The “interested” message is a fixed-length notification consisting of a single byte (Message ID 2) preceded by a 4-byte length prefix of 1.

The “Not Interested” Message

The “not interested” message is also a fixed-length notification, consisting of Message ID 3 with a 4-byte length prefix of 1.

Interaction Between States

The combination of the interested and choked states determines the behavior of the connection:

By utilizing “interested” and “not interested” messages, BitTorrent clients minimize unnecessary network overhead and ensure upload bandwidth is directed exclusively to peers ready to consume it.