A kind of link detecting and the implementation method repaired
Technical field
The present invention relates to DHCP (Dynamic Host Configuration Protocol, abbreviation
DHCP), the Internet protocol address of address resolution protocol (Address Resolution Protocol, abbreviation ARP)
(Internet Protocol Address, abbreviation IP address) method of salary distribution;Specifically related to address server (DHCP
Server) after to client (DHCP Client) distribution IP address, there is provided base between one kind detection address server and client
Quick recovery method after the method for IP linkage availabilities, and failure.
Background technology
With Internet service high speed development these years, network has come into huge numbers of families, and network insertion amount is annual
All growths of high speed, for this rapid growth, limited IP address is increasingly critical, the increasingly preciousness of change;So
How the limited IP address of utilization of high speed, DHCP just played its great effect, limited IP address is obtained more efficient
Utilize.Because the effective property of the IP address of dynamically distributes, it has certain lease time, and this lease time is by DHCP
What Server was distributed, if the rental period to and if client is not re-rented, DHCP Server will be returned to it
Receive, the client user of other IP address requestings is then assigned them to again.If in this rental period this period link it is abnormal or
Person is because when some incorrect configurations or specific environment may result in the recovery IP that DHCP Sever shift to an earlier date, so may be used
The IP address for netting interior client can be caused to fail, but visitor opens end to be found in the IP rental periods of oneself also within the normal rental period,
Do not know that the IP of oneself has been failed more originally, so may result in client cannot carry out normal communication;Until
When the IP rental periods expire, visitor opens end and can just initiate request of renewing a contract, but possible this time can be very long, directly influences the body of user
Test and normal work.
The content of the invention
The present invention is in passive state based on the link failure existed with client when existing address server, client
And cannot perceive and the problem repaired, there is provided a kind of link detecting and the implementation method repaired.
A kind of link detecting and the implementation method repaired, comprise the following steps:
S1:Client obtains the IP address of address server distribution;
S2:Client is established a communications link with the IP address distributed with address server, if client does not receive feedback,
Step S1 is then jumped to, IP address is redistributed;Otherwise enter next step;
S3:Judge whether current IP address is occupied, step S2 is performed after new IP is distributed during occupancy;When vacant, perform
Next step;
S4:Client periodically sends ARP request message, if client does not receive the response of address server, jumps
Step S3 is gone to, next step is otherwise performed;
S5:After the arp reply message for receiving address server response, visitor is updated according to the arp reply message for receiving
The IP information that family end accesses.
It is preferred that client can not receive the response of address server for continuous three times in step S2, then step S1 is jumped to.
It is preferred that when IP address takes in step S3, the DHCP Nack information with new IP address is returned to, when vacant
Return to DHCP Ack information.
It is preferred that in step S4, if client can not receive the response of address server for continuous three times, jumping to step
S2。
The present invention is no longer on passive status in order that obtaining client, is maintaining chain between address server and client
The ageing aspect in road, allows client also to have certain real-time discovery and this abnormal ability for the treatment of, allow this abnormality when
Between be spaced become very short, it is preferred that in the case that user will not discover, just recovered normal again.Similar to by address service
A kind of mechanism equivalent to heartbeat being added between device and client, during with adding this heartbeat chance, service end is not interfered with again
Normal work;The role of this heartbeat is served as by ARP, because ARP is a general agreement on link, just very well
Take on this role.
Using improvement of the invention, the client in passive position is not only allowed to have initiative, while also allowing client
User's discovery as early as possible is out of joint, while to process this problem, rather than wait there quietly.
Brief description of the drawings
Fig. 1 is running environment figure of the invention;
Fig. 2 is that address server and client user interact schematic diagram in the present invention;
Fig. 3 is operation principle flow chart one of the invention;
Fig. 4 is operation principle flowchart 2 of the invention.
Specific embodiment
Below in conjunction with the drawings and specific embodiments, invention is described in detail.
Referring to figs. 1 to Fig. 4, concrete methods of realizing of the invention is as follows:
S1, client obtain the IP address of address server distribution;
S101:In LAN, client initiates DHCP inquiries (DHCP Discover);
S102:DHCP Server receive inquiry, and response is with an inquiry response (DHCP for available IP address
Offer);
S103:Whether client receives DHCP Offer, the return to step S101 if not receiving, under being performed if receiving
Step.
S2, client are established a communications link with the IP address and address server distributed, if client does not receive feedback,
Step S1 is then jumped to, IP address is redistributed;Otherwise enter next step;
S201:Client initiates Address requests (DHCP Request) using the IP address of distribution to DHCP Server;
Wherein, if client can not receive the response of address server for continuous three times, step S1 is jumped to.
S3, judge whether current IP address is occupied, step S2 is performed after new IP is distributed during occupancy;When vacant, perform
Next step;
S301:If after DHCP Server receive DHCP Request, judging whether IP address is occupied, if occupied,
The DHCP Nack information with new IP address is returned, and jumps to step S2;If vacant, DHCP Ack information is returned.
S4, client periodically send ARP request message, if client does not receive the response of address server, jump
Step S3 is gone to, next step is otherwise performed;
S401:Client obtains the DHCP Nack information of feedback, represents link establishment success;Setting heart beat cycle, client
End periodically sends ARP request message (ARP Request);
S402:Judge whether client receives the response of DHCP Server;
Wherein, if client can not receive the response of DHCP Server for continuous three times, step S2 is jumped to.
S5, receive address server response arp reply message after, according to receive arp reply message update visitor
The IP information that family end accesses;
S501:After if DHCP Server receive ARP Request, one arp reply message of response (ARP Reply), visitor
Family end updates the IP information of its access according to ARP Reply.
The above, the only present invention preferably specific embodiment, but protection scope of the present invention is not limited thereto,
Any one skilled in the art in the technical scope of present disclosure, technology according to the present invention scheme and its
Inventive concept is subject to equivalent or change, should all be included within the scope of the present invention.