wire / wire-format / vsock-header
VSOCK provides socket-based communication between a host and a guest VM (or between guests) without a network stack. The packet header: 4-byte src CID, 4-byte dst CID, 4-byte src port, 4-byte dst port, 4-byte type (stream/dgram/seqpacket), 2-byte op, 2-byte flags, 8-byte length, 8-byte socket ID (src/dst).
aka: VSOCK (VM sockets) packet header
spec: Linux kernel (vsock)
VSOCK provides socket-based communication between a host and a guest VM (or between guests) without a network stack. The packet header: 4-byte src CID, 4-byte dst CID, 4-byte src port, 4-byte dst port, 4-byte type (stream/dgram/seqpacket), 2-byte op, 2-byte flags, 8-byte length, 8-byte socket ID (src/dst).
| field | size | meaning |
|---|---|---|
| src_cid | 4 bytes (__u32) | Source context ID (VM ID; 2 = host, 3+ = guest). |
| dst_cid | 4 bytes (__u32) | Destination context ID. |
| src_port | 4 bytes (__u32) | Source port (ephemeral or well-known; 9p, etc.). |
| dst_port | 4 bytes (__u32) | Destination port. |
| type | 2 bytes (__u16) | Socket type: 1 stream, 2 dgram, 3 seqpacket. |
| op | 2 bytes (__u16) | Operation: REQUEST, RESPONSE, RST, SHUTDOWN, RW, CREDIT_UPDATE, CREDIT_REQUEST. |
| flags | 4 bytes (__u32) | Op-specific flags. |
| len | 8 bytes (__u64) | Payload length. |
| fwd_cnt | 4 bytes (__u32) | Forward count (credit-based flow control). |
| buf_alloc | 4 bytes (__u32) | Buffer allocation (credit-based flow control). |
example:
02 00 00 00 03 00 00 00 00 10 00 00 00 20 00 00 01 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
VSOCK packet: src CID 2 (host) -> dst CID 3 (guest), ports 4096->8192, stream, RW op
agent: curl -H 'accept: application/json' wire.phall.io/wire-format/vsock-header
or /wire-format/vsock-header.json