To better understand a network protocol, we must clearly define and structure it. We have also explained the definition of the DHCP protocol. Here we will analyze the DHCP packet format.
DHCP packet format
Let's introduce the DHCP packet format, 1
OP (1) |
Htype (1) |
Hlen (1) |
Hops (1) |
Transaction ID (4) |
Seconds (2) |
Flags (2) |
Ciaddr4) |
Yiaddr4) |
Siaddr4) |
Giaddr4) |
Chaddr16) |
Sname64) |
File128) |
Optionsvariable) |
Figure 1 DHCP packet format)
OP: if the client sends a packet to the server, set it to 1 and reverse to 2;
Htype: hardware type. The value of ethernet is 1;
Hlen: hardware length. The ethernet value is 6;
Hops: if the data packet needs to be transmitted through the router, add 1 to each station. If the data packet is in the same network, it is 0;
Transaction ID: Transaction ID, which is a random number used to match requests and messages between the customer and the server;
Seconds: the time specified by the user. It refers to the time after the address is obtained and updated;
Flags: from 0 to 15 bits, when the leftmost bit is 1, the server sends packets to the client in broadcast mode, and the rest are not used yet;
Ciaddr: user IP address;
Yiaddr: the customer's IP address;
Siaddr: IP Address used in the bootstrap process;
Giaddr: IP address of the forwarding Proxy gateway;
Chaddr: The hardware address of the client;
Sname: name of an optional server, ending with 0x00;
File: the Startup File Name;
Options:, vendor ID, optional parameter field