wire / wire-format / vsock-header

VSOCK (VM sockets) packet 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).

wire-format kind wire-format status standard verification verified tier B wire-format@1

aka: VSOCK (VM sockets) packet header

wire format

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).

fieldsizemeaning
src_cid4 bytes (__u32)Source context ID (VM ID; 2 = host, 3+ = guest).
dst_cid4 bytes (__u32)Destination context ID.
src_port4 bytes (__u32)Source port (ephemeral or well-known; 9p, etc.).
dst_port4 bytes (__u32)Destination port.
type2 bytes (__u16)Socket type: 1 stream, 2 dgram, 3 seqpacket.
op2 bytes (__u16)Operation: REQUEST, RESPONSE, RST, SHUTDOWN, RW, CREDIT_UPDATE, CREDIT_REQUEST.
flags4 bytes (__u32)Op-specific flags.
len8 bytes (__u64)Payload length.
fwd_cnt4 bytes (__u32)Forward count (credit-based flow control).
buf_alloc4 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


provenance

agent: curl -H 'accept: application/json' wire.phall.io/wire-format/vsock-header or /wire-format/vsock-header.json