Repository navigation
Home
Adam edited this page Feb 12, 2015
·
13 revisions
Welcome to the cnt5106c wiki!
The handshake consists of three parts: handshake header, zero bits, and peer ID. The length of the handshake message is 32 bytes. The handshake header is 18-byte string ‘P2PFILESHARINGPROJ’, which is followed by 10-byte zero bits, which is followed by 4-byte peer ID which is the integer representation of the peer ID. handshake header zero bits peer ID
After handshaking, each peer can send a stream of actual messages. An actual message consists of
- 4-byte message length field
- 1-byte message type
- a message payload with variable size
The 4-byte message length specifies the message length in bytes. It does not include the length of the message length field itself.
The 1-byte message type field specifies the type of the message. There are eight types of messages
| Message Type | Value |
|---|---|
| Choke | 0 |
| unchoke | 1 |
| interested | 2 |
| not interested | 3 |
| have | 4 |
| bitfield | 5 |
| request | 6 |
| piece | 7 |