Startec
Startec

Reputation: 13216

How do I read this network "frame" diagram?

Many times, such as on the website describing the WebSocket diagram here I see "frame" diagrams (at least that is what I think they are called) like the following:

0                   1                   2                   3
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
 +-+-+-+-+-------+-+-------------+-------------------------------+
 |F|R|R|R| opcode|M| Payload len |    Extended payload length    |
 |I|S|S|S|  (4)  |A|     (7)     |             (16/63)           |
 |N|V|V|V|       |S|             |   (if payload len==126/127)   |
 | |1|2|3|       |K|             |                               |
 +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - +
 |     Extended payload length continued, if payload len == 127  |
 + - - - - - - - - - - - - - - - +-------------------------------+
 |                               |Masking-key, if MASK set to 1  |
 +-------------------------------+-------------------------------+
 | Masking-key (continued)       |          Payload Data         |
 +-------------------------------- - - - - - - - - - - - - - - - +
 :                     Payload Data continued ...                :
 + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +
 |                     Payload Data continued ...                |
 +---------------------------------------------------------------+

Can someone explain to me how to read such a diagram? The way I interpret it would be that the 0 1 2 3 on the top would be the bytes that arrive in a packet, and the 0-9 repeating would be the individual bits. However this doesn't make sense as there are only 8 bits in a byte.

Further more:

Upvotes: 0

Views: 111

Answers (2)

0m3
0m3

Reputation: 9

Hello, everyone.

There is a beautiful diagram here: TCP/IP Reference.

It also explains:

The order of transmission of the header (from left to right)

 0                    1                   2                   3      - the tens
[0] 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1    - the ones

where:

[0] is the most significant bit (MSB). That is, the bit labeled 0 is the most significant bit.

 0
[0]          - 0th (00), total 1

 0
 _ 1         - 1st (01), total 2

 0
 _ _ 2       - 2nd (02), total 3

 0
 _ _ _ ... 9 - 9th (09), total 10

    1
... 0        - 10th (10), total 11

    2
... _ 1      - 21st (21), total 22

and so on  

Upvotes: 1

Takahiko Kawasaki
Takahiko Kawasaki

Reputation: 19011

0                   1                   2                   3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1

means

|    1st byte     |    2nd byte     |    3rd byte     |    4th byte     |
+-----------------+-----------------+-----------------+-----------------+
| 0 0 0 0 0 0 0 0 | 0 0 1 1 1 1 1 1 | 1 1 1 1 2 2 2 2 | 2 2 2 2 2 2 3 3 |
| 0 1 2 3 4 5 6 7 | 8 9 0 1 2 3 4 5 | 6 7 8 9 0 1 2 3 | 4 5 6 7 8 9 0 1 |

That is, the table is 32-bit (= 4-byte) wide.

Descriptions about fin, rsv, opcode and mask are written right after the table you excerpted from RFC 6455.

Payload Data is a byte array. It is application-specific data.

The table represents the structure of one frame. A message consists of either one frame or multiple frames.

Upvotes: 2

Related Questions