The method of IP address distribution
Technical field
The present invention relates to a kind of method of IP address distribution, belong to communication technical field.
Background technology
At present, mainly be by the DHCP form to IP address (Internet Protocol Address) distribution, during current DHCP distributing ip address, can not carry out the validity check of IP address, may cause IP address conflict; In the time of a plurality of DHCP, service-impacting, function singleness can not be carried out the Intelligence Selection configuration as required.
Summary of the invention
The objective of the invention is to overcome the deficiency that prior art exists, a kind of method of IP address distribution is provided.
Purpose of the present invention is achieved through the following technical solutions:
The method of IP address distribution, characteristics are: relate to client and server in the IP address distribution, server end is comprised of a plurality of server farm, is in the current server that is using and is authoritative server; Comprise the machine-processed process of IP address distribution, the competition process of authoritative server and the Message Processing behind definite authoritative server in the IP address distribution;
A) the machine-processed process of IP address distribution: between server end and client, realize, the client request of initiating a message is to server end, after server end receives message, the message that receives is carried out the management of IP address information, whether detect the distributing IP address information, judge whether new IP address, then detect and whether exist, to detect distributing IP address, new IP address in judging be no and the IP address is yes when having existed, and redistributes and obtain the IP address information; In judging, detect distributing IP address, new IP address for being to be no when having existed with the IP address, the IP address information of acquisition client; Be encapsulated as configuration information according to obtaining the IP address information, configuration information is pushed in the client, client is after information, the information that receives is processed, check whether distribution obtains the IP address successful, then to use this IP address, otherwise the mistake of 500 types of dishing out, namely error message is processed; The configuration client is up-to-date IP address information, obtain server information after, send the checking echo message, server receives authorization information, the mechanism of IP address distribution is finished;
B) competition process of authoritative server: have competitive relation between the server farm of server end, determine that by competing which station server is authoritative server, wherein a station server sends Alive to other servers, receive the server of Alive message, by the preference strategy that sends message server is compared, the server preference strategy numeral of receipt message is smaller, then begin to judge time point, if the time of receipt message server is newer, then revising reception server is authoritative server, otherwise send message server and receipt message server and stop response, namely determine authoritative server message, the preference strategy in the server arranges according to configuration file, the dynamic setting, time point is the time point when preference strategy is set;
C) determine Message Processing behind the authoritative server: through determining authoritative server after the server competition, be authoritative server such as a server, authoritative server sends a heartbeat packet at set intervals to other servers, other servers receive the heartbeat packet message of authoritative server, when not receiving heartbeat packet, carry out again the competition process of authoritative server; Simultaneously, authoritative server also sends up-to-date IP address information to other servers, after other servers receive message, is updated to up-to-date IP address information.
Further, the method for above-mentioned IP address distribution, wherein, to determine to only have a station server be authoritative server by competing, the inauthoritativeness server receives message and the synchronizing information of authoritative server.
Further, the method for above-mentioned IP address distribution, wherein, authoritative server sent a heartbeat packet to other servers every 5 seconds.
Again further, the method for above-mentioned IP address distribution, wherein, client is configured the IP address information of this locality, and client transmit a request to server end with configuration;
The server end receipt message is resolved its IP address information, server end judges whether the IP address information is available, if IP address information to be distributed is unavailable, then regenerate the IP address information, if IP address information to be distributed can be used, then server end continues follow-up IP address distribution flow process, server end sends to client with IP address information to be distributed as configuration information, client judges whether available according to receiving the IP address information, if IP address information to be distributed is unavailable, the client failed message of dishing out then, if IP address information to be distributed can be used, then client is finished follow-up IP address applications process concurrency and is sent identifying code to server end;
Server end is comprised of a plurality of server farm, wherein a station server sends Alive to other servers, receive the server of Alive message, by the preference strategy that sends message server is compared, the server preference strategy of receipt message is high, and (as: it is little to set the preference strategy numeral, be that priority ratio is higher), when the priority of server is identical, then begin to judge time point, if the time of receipt message server is newer, then revising reception server is authoritative server, otherwise transmission message server and receipt message server stop response, have so namely determined authoritative server message;
After through the server competition, determine authoritative server, authoritative server sends a heartbeat packet at set intervals to other servers, other servers receive the heartbeat packet message of authoritative server, when not receiving heartbeat packet, carry out again the competition process of authoritative server, simultaneously, authoritative server also sends up-to-date IP address information and other servers are arrived in the configuration information storehouse, after other servers receive message, upgrade local ip address information and configuration information storehouse.
The substantive distinguishing features that technical solution of the present invention is outstanding and significant progressive being mainly reflected in:
The present invention adopts the multicast mode more to be conducive to the distributing ip address, according to different ranks the distributing ip address is set, and efficient is high, the distributing ip address information there is testing mechanism, better guarantees the accuracy rate of IP address distribution, adopt special propelling movement mode, the multiple terminal plug and play, convenient and practical.
Description of drawings
Below in conjunction with accompanying drawing technical solution of the present invention is described further:
Fig. 1: the schematic diagram of the machine-processed process of IP address distribution;
Fig. 2: the schematic diagram of the competition process of authoritative server;
Fig. 3: the schematic diagram of determining the Message Processing behind the authoritative server;
Fig. 4: the schematic flow sheet that the inventive method realizes.
Embodiment
The method of IP address distribution relates to client and server in the IP address distribution, and server end is comprised of a plurality of server farm, is in the current server that is using and is authoritative server; Comprise the machine-processed process of IP address distribution, the competition process of authoritative server and the Message Processing behind definite authoritative server in the IP address distribution.
A) the machine-processed process of IP address distribution: as shown in Figure 1, between server end and client, realize, the client request of initiating a message is to server end, after server end receives message, the message that receives is carried out the management of IP address information, whether detect the distributing IP address information, judge whether new IP address, whether then detect and exist, to detect distributing IP address, new IP address in judging be no and the IP address is yes when having existed, and redistributes and obtain the IP address information; In judging, detect distributing IP address, new IP address for being to be no when having existed with the IP address, the IP address information of acquisition client; Be encapsulated as configuration information according to obtaining the IP address information, configuration information is pushed in the client, client is after information, the information that receives is processed, check whether distribution obtains the IP address successful, then to use this IP address, otherwise the mistake of 500 types of dishing out, namely error message is processed; The configuration client is up-to-date IP address information, obtain server information after, send the checking echo message, server receives authorization information, the mechanism of IP address distribution is finished;
B) competition process of authoritative server: as shown in Figure 2, there is competitive relation between the server farm of server end, determine that by competing which station server is authoritative server, wherein a station server sends Alive to other servers, receive the server of Alive message, by the preference strategy that sends message server is compared, the server preference strategy numeral of receipt message is smaller, then begin to judge time point, if the time of receipt message server is newer, then revising reception server is authoritative server, otherwise transmission message server and receipt message server stop response, namely determines authoritative server message, preference strategy in the server, arrange according to configuration file, the dynamic setting, time point is the time point when preference strategy is set; To determine to only have a station server be authoritative server by competing, and the inauthoritativeness server receives message and the synchronizing information of authoritative server;
C) determine Message Processing behind the authoritative server: as shown in Figure 3, through determining authoritative server after the server competition, be authoritative server such as a server, authoritative server sends a heartbeat packet at set intervals to other servers, other servers receive the heartbeat packet message of authoritative server, when not receiving heartbeat packet, carry out again the competition process of authoritative server; Simultaneously, authoritative server also sends up-to-date IP address information to other servers, after other servers receive message, is updated to up-to-date IP address information.
Embodiment
As shown in Figure 4, client is configured the IP address information of this locality, and client transmit a request to server end with configuration;
The server end receipt message is resolved its IP address information, server end judges whether the IP address information is available, if IP address information to be distributed is unavailable, then regenerate the IP address information, if IP address information to be distributed can be used, then server end continues follow-up IP address distribution flow process, server end sends to client with IP address information to be distributed as configuration information, client judges whether available according to receiving the IP address information, if IP address information to be distributed is unavailable, the client failed message of dishing out then, if IP address information to be distributed can be used, then client is finished follow-up IP address applications process concurrency and is sent identifying code to server end;
Server end is comprised of a plurality of server farm, wherein a station server sends Alive to other servers, receive the server of Alive message, by the preference strategy that sends message server is compared, the server preference strategy of receipt message is high, and (as: it is little to set the preference strategy numeral, be that priority ratio is higher), when the priority of server is identical, then begin to judge time point, if the time of receipt message server is newer, then revising reception server is authoritative server, otherwise transmission message server and receipt message server stop response, have so namely determined authoritative server message;
After through the server competition, determine authoritative server, authoritative server sent a heartbeat packet to other servers every 5 seconds, other servers receive the heartbeat packet message of authoritative server, when not receiving heartbeat packet, carry out again the competition process of authoritative server, simultaneously, authoritative server also sends up-to-date IP address information and other servers are arrived in the configuration information storehouse, after other servers receive message, upgrade local ip address information and configuration information storehouse.
In sum, the present invention adopts the multicast mode more to be conducive to the distributing ip address, according to different ranks the distributing ip address is set, efficient is higher, the distributing ip address information by testing mechanism, is better guaranteed the success rate of IP address distribution, adopt special propelling movement mode, the multiple terminal plug and play, convenient applicable.
What need to understand is: the above only is preferred implementation of the present invention; for those skilled in the art; under the prerequisite that does not break away from the principle of the invention, can also make some improvements and modifications, these improvements and modifications also should be considered as protection scope of the present invention.