Once a handshake between peers happen via BitTorrent Handshake protocol, these peers talk and share data via this wire protocol.

All the messages shared via this protocol has this following structure:

fieldsize (bytes)desc
Length4length of message-id + payload (big-endian format), 0 for keep alive
Message ID1type of message being shared (ex: 0 for choke, 6 for req)
Payloadvariabledepends on the data

following are all the different types of Message ID possible and what they mean:

Message TypeMessage IDPayload FormatDescription
Choke0NoneTells the peer to stop sending requests.
Unchoke1NoneTells the peer it can send requests.
Interested2NoneIndicates interest in downloading from the peer.
Not Interested3NoneIndicates no interest in downloading from the peer.
Have44 bytes (piece index, big-endian)Announces that the sender has a piece.
Bitfield5Variable (bitfield)A bitmask showing which pieces the sender has.
Request612 bytes (index, begin, length, all big-endian)Requests a block of data from a piece.
Piece78 + length bytes (index, begin, block data)Contains the requested block of data.
Cancel812 bytes (index, begin, length, all big-endian)Cancels a pending request.
Port9IDKIDK… port number IG