Finite State Machine of DHCP protocol and Related Problems

Source: Internet
Author: User

The Finite State Machine of DHCP is as follows;

This finite state machine includes most status jumps.

 

The transition from INIT-REBOOT status to rebooting is sent when the client machine restarts and wants to re-confirm the validity of the IP being used. The client broadcasts the dhcprequest message. If the server's dhcpack response is received, the request enters the bound status. If the server receives the dhcpnak message, the request enters the init status.

 

In the init status, the client broadcasts dhcpdiscover and enters the selecting status. After the server receives the dhcpdiscover packet, select the appropriate IP address and put it into the dhcpoffer packet for unicast transmission. Fill in the destination IP address to be sent with the assigned IP address (before sending, use the ping command to check the availability of the IP address. If the IP address is available, send the command ). If Multiple DHCP servers exist in the CIDR Block, the client may receive multiple dhcpoffer instances, generally, the client sends the dhcprequest packet (the packet contains the IP address information it chooses) in response to the first dhcpoffer received, in this way, the server can determine whether the client selects the IP address provided by Alibaba ). After the server receives the dhcprequest, it will respond to the dhcpack message, which also uses unicast. If the client receives the dhcpack packet, it uses the ARP command to test the availability of the IP address. If the packet is available, it sets the timer T1 and T2 and enters the bound status. If the packet is unavailable, then, it is sent to the server DHCPDECLINE, indicating that the IP address is unavailable, so that the server will delete the lease entries of the IP address in its lease table. When the client receives other packets, such as dhcpoffer, all the packets are discarded. In bound, as time passes, when the T1 timer times out (T1 is generally set to half of the lease time), it will send a dhcprequest packet to the server unicast that provides the IP address to it, if you receive the server's dhcpack response, you will jump to the bound status, record the lease, and set the T1 and T2 timers. If you receive the dhcpnak, you will go directly to the init status. If a dhcprequest message is unicast and no response is received until the T2 timer times out (T2 is set to 3/4 of the lease time), the dhcprequest message is broadcast, similar to the previous one, after receiving the server's dhcpack packet, it will return to the bound status. Otherwise, it will be directly transferred to init to enter the next cycle.

The common problems about DHCP are summarized as follows:

1. The client sends the dhcpdiscover message as broadcast, and the server responds to the dhcpoffer as unicast. At this time, the client does not have an IP address. How can I send a client's IP address for server unicast?

When the server and client are in the same subnet segment, consider the following:

The server records the MAC address of the client by accepting the dhcpdiscover packet, but does not know the IP address, because the client itself does not have an IP address. In this case, the server wants to unicast dhcpoffer packets to the client, but does not know the IP address. What should I do? Use the MAC address for sending. The server side usually calls the original socket and directly sends the data link layer message to the client.

Of course, this is the case where the client and server are in the same subnet. When they are not in the same subnet, DHCP reply agent must be used to transmit packets.

2. After an interaction between the client and the server, the client already knows the IP address of the server. Why do I need to broadcast the DHCP-request message instead of directly accessing unicast?

Consider the situation where Multiple DHCP servers exist. The client broadcasts dhcpdiscover packets. multiple servers are responsible for the response. The server selects its own available IP addresses to encapsulate them in the dhcpoffer message and writes the IP addresses and the client's MAC addresses to the lease table. If the client does not broadcast but Unicast (the target IP address is the server that provides the IP address) The dhcprequest message informs the server to which the IP address is selected, it is impossible for the server whose IP address is selected to know the IP address, in this way, the client does not use its IP address, but it is recorded in the lease table, which causes a great waste of IP addresses. If the client broadcasts a dhcprequest packet (the packet contains the IP address selected by the client), the server accepts the packet and extracts the IP address selected by the client and the IP address provided by the server. If the packet is consistent, it indicates that the client selects the IP address provided by the server, otherwise it is not selected. If not selected, the lease information of the IP address in the server lease table can be eliminated.

I enjoy the copyright of blog articles, reprint please indicate the source http://blog.csdn.net/baidu20008

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.