DHCP protocol summary

DHCP Dynamic Host Configuration Protocol, simply put, is provided to automatically obtain ip address of the function, based on four of the UDP protocol;

The following description of the entire workflow of this protocol:

(1) The client sends a discovery packet, two three broadcast packets, the source address of all 0 ip;

(2) servers receiving the discovery packet, a ip address assignment, find ip address, and performs arp detection, when found

After this idle ip address, packet group offer, sent to the client, with the internal ip address, the client mac address, the lease time and other information;

(3) the client after receiving offer messages will select a (typically the first) responds and sends a request message to the server, will also be

ARP probe, and when there ip address conflict, will send a decline message to the server to terminate the use of the ip address, and then resend the discovery;

(4) The server sends confirmation ack packet address, after the client receives ack, start using the ip address;

--- above processes messages are broadcast;

(5) The client will attempt to start 1/2 and 3/4 time of renewal of the lease time ip address, successfully continue to use, otherwise the lease expires

Can not continue to use, you need to cast the ip address, and resend discovery;

(6) client can send a release message at any time to abandon the use of the ip address;

 

We focus on that some of the implementation issues under the server:

1. Establish bit array, or can not be dispensed in the partitioned bit address tag array;

After comparing rotten realize is that each received a discovery request, a random address first, then each address to lease the list to find,

To see whether the lease is dispensed; a better start performance, but when the assigned address when close to the limit, there will be n * n traversal

Cases, which greatly affects the performance;

Use bit array holds addresses, each with 32 direct the way to iterate, 0xffffffff not find the range, and then look for idle in accordance with bit

bit, thereby determining the idle address; maximum of only n / 32 traversal; performance will be greatly enhanced;

2. Use the oldest lease:

Sometimes, clients may off the assembly line and did not notify the server at this time if the server's address pool has been used up, you can select the earliest

Assigned lease out ip arp for detection, if already in use, the ip address is assigned to the new client; herein relates to lease list

Maintenance, update or add better ensure that each interpolation method uses the tail, thus ensuring a direct access to the first node is necessarily the oldest lease, shortening

The traversal time;

3.arp anti-collision:

arp put the conflict here is mainly to save some of the arp cache address information, first of all to prevent detection of the same ip address has been sent arp;

arp anti-collision would normally use a timer if the timeout is still no conflict is found, the offer to send the message; otherwise, the need to continue to look at

An available ip address, find the address of the next note can not detect previous conflict, if conflict needs marking in the bit array;

4.offer Bowen and ack packet processing lease of:

When transmission offer, generates a list tmplease inserted into the lease, when it becomes the transmission of ack formal lease, i.e. tag assigned;

If an offer of an existing ip address is the address of the original lease will delete and re-add; exceptions in certain testing tools

Scenario, ip address has been assigned out, this time to the discovery, and no conflict is detected, because the tool does not reply arp, it will be deleted

Off lease, send offer, but finds that he has had ip address, so not respond, resulting in lease was mistakenly deleted; this can result in lower case ha

Some on the synchronous abnormal situation;

Guess you like

Origin www.cnblogs.com/98pyh/p/11953355.html