WebSocket Lifecycle & Frame Protocol

RFC 6455

HTTP 101 Switching Protocols upgrade, 4-byte XOR frame masking, fragmentation & Ping/Pong heartbeats

Step 1 of 12
Speed
Client Browser
new WebSocket('ws://.../chat')
CONNECTING
WebSocket API State
readyState: 0 (CONNECTING)
Sec-WS-Key: dGhlIHNhbXBsZQ==
Client Masking: Mandatory (MASK=1)
XOR Masking Engine (Plain ^ Key) Standby
Plain:
'H' (48)
'e' (65)
'l' (6C)
'l' (6C)
Key:
37
FA
21
3D
Wire:
7F
9F
4D
51
RFC 6455 Frame Dissector
2–14 Byte Wire Header Inspector
TCP STREAM
FIN Bit: -
Opcode: -
MASK Bit: -
Mask Key: -
Payload Length: -
Decoded Frame Payload
Awaiting HTTP 101 Upgrade...
WebSocket Server
ws:// Port 80/443 Endpoint
LISTEN
Server State & SHA-1 Accept
Socket State: LISTEN
Sec-WS-Accept: s3pPLMBiTxaQ9k...
Reassembly Buf: empty
XOR Unmasking (Mask ^ Key) Standby
Wire:
7F
9F
4D
51
Key:
37
FA
21
3D
Plain:
'H'
'e'
'l'
'l'