Skip to content

Commit

Permalink
Fix raw socket maximum length limit (#508)
Browse files Browse the repository at this point in the history
* Fix raw socket maximum length limit
* Introduce 25th raw socket payload length bit
* Tweak raw socket payload length example text
  • Loading branch information
ecorm committed Nov 16, 2023
1 parent f67f1e6 commit 5c6d52d
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions rfc/text/advanced/ap_38_transport_rawsocket.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ The possible values for `LENGTH` are:
0: 2**9 octets
1: 2**10 octets
...
14: 2**23 octets
15: 2**24 octets

This means a *Client* can choose the maximum message length between **512** and **16M** octets.
Expand Down Expand Up @@ -221,16 +222,32 @@ The serialized octets for a message to be sent are prefixed with exactly 4 octet
{align="left"}
MSB LSB
31 0
RRRR RTTT LLLL LLLL LLLL LLLL LLLL LLLL
RRRR XTTT LLLL LLLL LLLL LLLL LLLL LLLL

The *first octet* has the following structure
The *three least significant octets* constitute an unsigned 24 bit integer that provides the length of transport message payload following, excluding the 4 octets that constitute the prefix.

The *most significant octet* has the following structure

{align="left"}
MSB LSB
7 0
RRRR RTTT
RRRR XTTT

The four bits `RRRR` are reserved for future use and MUST be all zeros for now.

`X` is an extra (25th) bit used to encode the message payload length. This bit is only set when the payload length is exactly 16M octets, with the 24 remaining `L` bits cleared:

{align="left"}
MSB LSB
31 0
RRRR 1TTT 0000 0000 0000 0000 0000 0000

When the payload length is 16M-1 octets, for example, the prefix would be:

The five bits `RRRRR` are reserved for future use and MUST be all zeros for now.
{align="left"}
MSB LSB
31 0
RRRR 0TTT 1111 1111 1111 1111 1111 1111

The three bits `TTT` encode the type of the transport message:

Expand All @@ -240,8 +257,6 @@ The three bits `TTT` encode the type of the transport message:
2: PONG
3-7: reserved

The *three remaining octets* constitute an unsigned 24 bit integer that provides the length of transport message payload following, excluding the 4 octets that constitute the prefix.

For a regular WAMP message (`TTT == 0`), the length is the length of the serialized WAMP message: the number of octets after serialization (excluding the 4 octets of the prefix).

For a `PING` message (`TTT == 1`), the length is the length of the arbitrary payload that follows. A *Peer* MUST reply to each `PING` by sending exactly one `PONG` immediately, and the `PONG` MUST echo back the payload of the `PING` exactly.
Expand Down

0 comments on commit 5c6d52d

Please sign in to comment.