-
Notifications
You must be signed in to change notification settings - Fork 207
Network Encodings
terorie edited this page Dec 18, 2018
·
2 revisions
The communication between nodes is wrapped in Messages.
The maximum size of a message is 10 MiB
(10 * 2^20 bytes
).
A message is serialized as follows:
Type | Name | Description |
---|---|---|
uint32_t |
magic |
Magic Number: Always 0x42042042
|
var_uint |
type |
Message Type number (ID of message) |
uint32_t |
length |
Length of the message content |
uint32_t |
checksum |
CRC32 checksum of the message content |
binary |
body |
Message content |
Currently, there are 33 different types of messages in use.
The serialized message is then split in chunks and sent using the encoding defined in DataChannel.js
.
Before messages are sent out to the network, they are split in chunks not more than 16 KiB
(16 * 2^10 bytes
) long.
A chunk is encoded as follows:
Type | Name | Description |
---|---|---|
uint8_t |
tag |
Chunk counter. Begins at 0 and is incremented with each chunk. After 255 it resets back to 0. |
binary |
chunk |
Chunk content. |
Chunks are currently transmitted over two types of connections.
- Needs a publicly addressable node that listens for incoming connections.
- Other nodes connect to the server to establish a WebSocket channel.
- There are two types of WebSocket connections
-
ws://
: Unencrypted communication over TCP. -
wss://
: Encrypted communication over TLS. The server requires a valid HTTPS certificate for this mode.
-
- Creates direct connections between two nodes that are not publicly addressable/peers behind NAT. (e.g. Browsers in WiFi)
- Needs publicly addressable signaling servers for negotiating connections between two nodes.