Skip to content

Network

xiaocong edited this page Nov 7, 2018 · 10 revisions

Network Protocol

The following diagram lists all fields of Network Protocol.

|-------byte-------|------byte------|------byte------|------byte------| (4bytes)
|---HeaderLength---|                                
|-------------------------------- Magic ------------------------------|
|-------------------------------- Code -------------------------------|
|-------------------------------- DataLength -------------------------|
|-------------------------------- DataChecksum -----------------------|
|-------------------------------- Reserved ---------------------------|
|-------------------------------- Body -------------------------------|

MessageHeader is including:

  • Magic
  • Code
  • DataLength
  • DataChecksum
  • Reserved

MessageBody is including:

  • Body

HeaderLength: 8bits(1byte)

  • The total length of the message header.

Magic: 32bits(4bytes)

  • Check for if the message is for Mainnet or Testnet.

Code: 32bits(4bytes)

  • Stand for the types of message:
    • 0x00 Ping
    • 0x01 Pong
    • 0x02 PeerDiscover
    • 0x03 PeerDiscoverReply
    • 0x04 NewBlockMsg
    • 0x05 TransacionMsg
    • 0x10 LocateForkPointRequest
    • 0x11 LocateForkPointResponse
    • 0x12 BlockChunkRequest
    • 0x13 BlockChunkResponse

DataLength: 32bits(4bytes)

  • The total length of message body.

DataChecksum: 32bits(4bytes)

  • The CRC32 checksum of the data.

Reserved: 32bits(4bytes)

  • reserved field.

Body

  • The message body.
  • The body length is dynamically expanding, the maximum length is 512MB.

Clone this wiki locally