跳到主要内容

8. Client/Server Message Formats

客户端和服务器之间发送的所有 DHCP 消息都共享相同的固定格式头部, 并带有一个可变格式的 options 区域.

消息头部和 options 中的所有值均采用网络字节序.

Options 串行存储在 "options" 字段中, options 之间没有填充. Options 按字节对齐, 但不采用其他方式对齐, 例如 2-byte 或 4-byte 边界.

下图展示客户端和服务器之间发送的 DHCP 消息格式:

    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
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| msg-type | transaction-id |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| |
. options .
. (variable number and length) .
| |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

图 2: Client/Server Message Format

msg-type: 标识 DHCP message type; 可用 message types 列于第 7.3 节. 这是一个 1-octet 字段.

transaction-id: 此 message exchange 的 transaction ID. 这是一个 3-octet 字段.

options: 此消息中携带的 Options; options 见第 21 节. 这是一个可变长度字段, 长度为消息大小减去 4 octets.