The content of the invention
The embodiment of the present invention provides a kind of ARP record management method and apparatus, with avoiding the occurrence of IP
Location conflicts.
On the one hand, the embodiment of the present invention provides a kind of ARP record management method, including:
At least two ARP records are obtained, the ARP records include:IP address with mapping relations,
The priority of MAC Address and the IP address;The IP address at least two ARP records is identical;
Target ARP records are only stored, the target ARP records are that have highest IP at least two ARP records
The record of the priority of address.
In method as described above, at least two ARP records of acquisition, including:Itself storage
The first ARP records and the 2nd ARP records that are got afterwards in the first ARP records, the 2nd ARP record is
Carried in the ARP request message that the transmitting terminal received is sent;
After the acquisition at least two ARP records, before the only storage target ARP records,
Also include:
By the preferential of the IP address in the priority of the IP address in the 2nd ARP records, with the first ARP records
Level is compared;
If the priority of the IP address in the 2nd ARP records, greater than or equal to the IP in the first ARP records
The priority of location, it is determined that the 2nd ARP is recorded as the target ARP records;Otherwise, it determines the first ARP is recorded as
The target ARP records;
When the 2nd ARP is recorded as the target ARP records, the target ARP that only stores is recorded, including:Using
The 2nd ARP records are replaced the first ARP records and stored.
In method as described above, if the purpose IP address that the ARP request message carries is itself
IP address;Then
To the transmitting terminal return arp response message, the arp response message carry itself ARP record, it is described itself
APR record include:The priority of itself IP address, MAC Address and the IP address.
In method as described above, at least two ARP records of acquisition, including:Itself storage
The first ARP records and the 2nd ARP records that are got afterwards in the first ARP records, the 2nd ARP record is
Carried in the ARP response message that the transmitting terminal received is sent;
After the reception ARP response message, before the only storage target ARP records, also wrap
Include:
It is determined that there is the preferential of highest IP address at least one analysis protocol arp response message received
The 2nd ARP records of level, are recorded for the target ARP;
The target ARP that only stores is recorded, including:Using the 2nd ARP of the priority with highest IP address
Record, replace the first ARP records.
In method as described above, at least one analysis protocol arp response message for determining to receive
The ARP records of priority with highest IP address, including:
If IP in the 2nd ARP records that the ARP response message of receive first carries
The priority of location, it is default limit priority, it is determined that first the 2nd ARP is recorded as the target ARP records.
In method as described above, at least one analysis protocol arp response message for determining to receive
The ARP records of priority with highest IP address, including:
If IP in the 2nd ARP records that the ARP response message of receive first carries
The priority of location, be not default limit priority, then after first arp response message is received, in addition to:
The 2nd ARP records in first arp response message are preserved, and start timer;
If in the range of the timing of the timer, first arp response message is only received, it is determined that the
The 2nd ARP in one arp response message is recorded as the target ARP records;
If in the range of the timing of the timer, also received after first arp response message to
A few arp response message, it is determined that there is highest in all arp response messages received in the range of the timing
IP address priority the 2nd ARP record, as the target ARP record.
Second aspect, the embodiment of the present invention provide a kind of ARP record management method, including:
ARP record is sent, the ARP records include:The IP address of itself with mapping relations,
The priority of MAC Address and the IP address of itself, include the purpose IP address of ARP request;
To cause the receiving terminal of the ARP records when getting at least two ARP records with identical IP address,
There is the record of the priority of highest IP address at least two ARP records according to determining the priority of the IP address
Stored for target ARP records.
As above the method described in second aspect, the transmission ARP records, including:ARP request message is sent, the ARP please
Message is asked to carry the first ARP records of itself, and the purpose IP address of the ARP request message is the IP address of itself;Then
After ARP request message is sent, in addition to:
Arp response message is received, the arp response message carries the 2nd ARP and recorded, the IP in the 2nd ARP records
IP address during address records with the first ARP is identical;
By the preferential of the IP address in the priority of the IP address in the first ARP records, with the 2nd ARP records
Level is compared, if both are identical, it is determined that the transmitting terminal of the arp response message produces IP address conflict with itself.
The third aspect, the embodiment of the present invention also provide a kind of ARP record management device, including:
Acquisition module, for obtaining at least two ARP records, the ARP records include:With mapping
The priority of the IP address of relation, MAC Address and the IP address;The IP address at least two ARP records
It is identical;
Memory module, for only storing target ARP records, the target ARP records are at least two ARP records
The record of priority with highest IP address.
Device as described above, the memory module, is specifically used for:
The priority of IP address during 2nd ARP is recorded, the priority of the IP address in being recorded with the first ARP are compared
Compared with;
If the priority of the IP address in the 2nd ARP records, greater than or equal to the IP in the first ARP records
The priority of location, it is determined that the 2nd ARP is recorded as the target ARP records;Otherwise, it determines the first ARP is recorded as
The target ARP records;
When the 2nd ARP is recorded as the target ARP records, described first is replaced using the 2nd ARP records
ARP records are stored.
Device as described above, in addition to:
Respond module, for returning to arp response message to transmitting terminal, the arp response message carries the ARP notes of itself
Record, the APR records of itself include:The priority of itself IP address, MAC Address and the IP address.
Device as described above, the acquisition module, is specifically used for:
It is determined that there is the preferential of highest IP address at least one analysis protocol arp response message received
The 2nd ARP records of level, are recorded for the target ARP;
The memory module, the 2nd ARP records using the priority with highest IP address are specifically additionally operable to,
The first ARP records are replaced to be stored.
Device as described above, the acquisition module, is specifically additionally operable to:
If IP in the 2nd ARP records that the ARP response message of receive first carries
The priority of location, it is default limit priority, it is determined that first the 2nd ARP is recorded as the target ARP records.
Device as described above, the acquisition module, is additionally operable to:
If IP in the 2nd ARP records that the ARP response message of receive first carries
The priority of location, it is not default limit priority, then:
After first arp response message is received, second in first arp response message is preserved
ARP is recorded, and starts timer;
If in the range of the timing of the timer, first arp response message is only received, it is determined that the
The 2nd ARP in one arp response message is recorded as the target ARP records;
If in the range of the timing of the timer, also received after first arp response message to
A few arp response message, it is determined that there is highest in all arp response messages received in the range of the timing
IP address priority the 2nd ARP record, as the target ARP record.
Fourth aspect, the embodiment of the present invention also provide a kind of ARP record management device, including:
Sending module, for sending ARP record, the ARP records include:With mapping relations from
The priority of the IP address of body, MAC Address and the IP address of itself, include the purpose IP address of ARP request;
Memory module, the receiving terminal for ARP records are getting at least two ARP with identical IP address
During record, there is the preferential of highest IP address at least two ARP records according to determining the priority of the IP address
The target ARP records that are recorded as of level are stored.
As above the device described in fourth aspect, in addition to:
Collision detection module, is used for:
Arp response message is received, the arp response message carries the 2nd ARP and recorded, the IP in the 2nd ARP records
IP address during address records with the first ARP is identical;
By the preferential of the IP address in the priority of the IP address in the first ARP records, with the 2nd ARP records
Level is compared, if both are identical, it is determined that the transmitting terminal of the arp response message produces IP address conflict with itself.
As above the device described in fourth aspect, in addition to:
Respond module, for receiving transmitting terminal ARP request message, and determine what the ARP request message carried
When purpose IP address is the IP address of itself, arp response message is sent to the transmitting terminal, and in the arp response message
Carry own IP address, MAC Address and IP address priority.
ARP record management method and apparatus provided in an embodiment of the present invention, by obtaining at least two
The ARP record of identical IP address, and the priority for including IP address in the ARP records obtained, the present embodiment
The record of the priority at least two ARP records with highest IP address is only stored according to the priority of IP address, so as to
Can solve the problems, such as IP address conflict caused by occurring double main or how main situations during more collaborative share floating IP address, therefore can keep away
Exempt from the service exception situation caused by IP address conflict.
Embodiment
To make the purpose, technical scheme and advantage of the embodiment of the present invention clearer, below in conjunction with the embodiment of the present invention
In accompanying drawing, the technical scheme in the embodiment of the present invention is clearly and completely described, it is clear that described embodiment is
Part of the embodiment of the present invention, rather than whole embodiments.Based on the embodiment in the present invention, those of ordinary skill in the art
The every other embodiment obtained under the premise of creative work is not made, belongs to the scope of protection of the invention.
The embodiment of the present invention is to solve in ethernet networks, and address conflict when multiple devices share floating IP address is asked
IP address, can be uniquely attributed to an equipment therein, to realize message according to the preferential grading of IP address by topic
Row correctly transmission.
It is described in detail respectively by the following examples.
Fig. 1 is the flow chart of ARP record management embodiment of the method one of the present invention, what the embodiment provided
ARP record management method is the method that receiving device is realized.As shown in figure 1, the method for the present embodiment
It can include:
S101, at least two ARP records are obtained, ARP, which is recorded, to be included:IP with mapping relations
The priority of address, MAC Address and IP address;IP address at least two ARP records is identical;
Wherein, the ARP records of acquisition can include:For example, it may be what is obtained before current have stored in network and sets
APR records in standby, storage is in a network in the ARP address mapping table of any appliance;Or or in sending ending equipment
It is sent to what is carried in the APR request messages of receiving device, it includes the IP address of sending ending equipment, MAC Address and connect
The IP address of receiving end equipment;Or can also be that receiving device is sent in the APR response messages of sending ending equipment and carried,
It includes the IP address of receiving device and the IP address of MAC Address and sending ending equipment.
Wherein, the priority of IP address can be the order of priority that any appliance possesses the IP address, for example, number can be used
Word 0,1,2,3 ... represent successively IP address priority by it is high on earth, it will be assumed that priority 0 be limit priority, is secondly 1, then
Secondary is 2 etc., i.e. the smaller person of priority value, and priority is higher, and the higher person of priority more preferentially possesses IP address.It is but of the invention
The optional arbitrary code of priority of IP address define, such as can also be represented with such as A, B, C, D ... IP address priority by
Height is on earth, it will be assumed that the priority highest for the IP address that A is represented.The form of IP address priority of the embodiment of the present invention does not limit
System, however it is not limited to only with numeral come define the rank of IP address priority height;Priority rule is not also limited.IP is set
The effect of the priority of location is in order that shared IP address is possessed by the equipment of highest priority, in order to convenient to equipment
The transmission of message is carried out according to the priority of IP address.
The above-mentioned network equipment be carry out data interaction physical equipment, can be PC, interchanger, router etc. all can
To be linked into the physical equipment in network.
Specifically, in the present embodiment, when two collaborative share IP address of transmitting terminal, in the message that they each send
ARP records the priority for including respective IP address, and receiving terminal can obtain the ARP records of transmitting terminal, can obtain in ARP records
Transmitting terminal IP address priority.
It is illustrated below:
So that gateway obtains the ARP records of multiple servers as an example, when multiple servers share a floating IP address, net
The request message for receiving multiple servers is closed, due to carrying the IP address of each server, MAC Address and IP address in message
Priority, gateway can obtain the records of the APR with IP address priority of each server.
S102, target ARP records are only stored, target ARP records are that have highest IP address at least two ARP records
Priority record.
Wherein, the target ARP records can be in the ARP records of above-mentioned at least two equipment with identical IP address
The priority highest ARP records of IP address, priority as escribed above is 0 IP address, sets priority highest one
It is standby really to possess the floating IP address.
For example, when receiving device receives request message, what is carried in request message is target ARP records, if this connects
ARP records are previously stored with receiving end ARP table, the IP of priority and itself storage during just the ARP newly received is recorded
The priority of address is compared, low with the high original priority of replacement of priority, only stores the high target ARP notes of priority
Record;If the priority of the former ARP records prestored is high after relatively, do not replace, retain former ARP records.
The ARP record management method that the present embodiment provides, by obtaining at least two identical IP address
ARP record, and include the priority of IP address in the ARP records obtained, the equipment of highest priority is most
After can really possess floating IP address.When the present embodiment can solve more collaborative share floating IP address according to the priority of IP address
Caused by there are double main or how main situations the problem of IP address conflict, therefore the service exception caused by IP address conflict can be avoided
Situation.
Fig. 2 is the flow chart of ARP record management embodiment of the method two of the present invention, what the embodiment provided
ARP record management method is the method that sending ending equipment corresponding with above-mentioned embodiment illustrated in fig. 1 is realized,
As shown in Fig. 2 the method for the present embodiment can include:
S201, ARP record is sent, ARP records can include:The IP of itself with mapping relations
The priority of location, MAC Address and the IP address of itself, include the purpose IP address of ARP request;
It is illustrated below:
Specifically, in above-mentioned example, when multiple servers share a floating IP address, multiple servers send request
Message carries the priority of the IP address of each server, MAC Address and IP address, i.e. sending ending equipment to gateway in message
What is carried in request message is the ARP records of itself.
S202, cause the receiving terminal of ARP records when getting at least two ARP records with identical IP address,
The priority for being determined to have highest IP address at least two ARP records according to the priority of IP address is recorded as target
ARP records are stored.
Such as above-mentioned example, server sends request message to gateway so that gateway is being got with identical IP address
At least two-server two ARP record when, according to the priority of the IP address of each server determine obtain ARP record
In have highest IP address priority be recorded as target ARP record stored.For example the priority of server 1 is high, then
The only ARP records of storage server 1.
The ARP record management method that the present embodiment provides, is passed through by least two sending ending equipments
The ARP record of itself is sent, the ARP records the priority that can include respective IP address, and priority is most
High equipment finally can really possess floating IP address.The present embodiment can realize the mapping of the IP address of MAC and highest priority,
Solves service exception situation caused by sharing the IP address conflict easily occurred during Floating IP address.
During the network equipment in the present invention communicates, each equipment is either used as transmitting terminal or receiving terminal, and it is reported
All recorded in text containing respective ARP, the ARP is recorded in addition to transmitting terminal IP address is carried, and also carries the excellent of transmitting terminal IP address
First level.Other side also correspondingly obtains ARP records, not only records MAC Address corresponding to IP address, also records the preferential of IP address
Level.The network equipment and also can carry out described in following each embodiment to the update method of the ARP table stored in equipment,
In examples below, it is described in detail below with the communication scenes of a gateway and two-server:
Fig. 3 is the flow chart of ARP record management embodiment of the method three of the present invention, and Fig. 4 is Fig. 3 of the present invention
Realization principle frame diagram in embodiment, Fig. 5 is the schematic diagram of the ARP frame formats in Fig. 3 embodiments of the present invention, such as Fig. 3-5 institutes
Show, the present embodiment is on the basis of above-described embodiment one, and net is described using a gateway and two-server communication process
The request message of the reception server is closed, and the technical scheme being managed is recorded to the ARP of the request message of reception.
Concrete scene can be the network of specific small range, also may be used as shown in figure 4, wherein, 10 in Fig. 4 be Ethernet
Expand to the network of current routine.Server 1 and server 2 are all configured with identical IP address in Fig. 4, for example,
(1.0.0.1), while being configured with different IP address priority, the IP address priority of server 1 is 0, server 2
The IP address priority be 1, it is assumed that priority 0 is higher than priority 1.
As shown in figure 3, the method for the present embodiment can include:
The ARP request message that S301, gateway the reception server are sent, obtain at least two ARP records;
Wherein ARP records include, and gateway itself storage of the present embodiment records for the first ARP;
After the request message of the reception server, recorded what the first ARP records were got afterwards for the 2nd ARP, the 2nd ARP
Record is carried in the ARP request message that the transmitting terminal received is sent;
For example, the first ARP that itself is stored in gateway is recorded as IP address and is(1.0.0.1)Priority be 1, i.e., it is corresponding
Server 2, the request message of server 1 and server 2 is then received again, corresponds to priority 0 and priority 1 respectively, preferentially
The rank of level 0 is high;After reception, gateway can carry out the management of ARP records according to priority in the following step.
Above-mentioned ARP records are stored in the APR tables of each equipment with ARP record frame formats, first below to the present embodiment
ARP frame formats are described in detail in.
ARP is Internet Engineering Task group(Internet Engineering Task Force, IETF)The address of definition
Analysis protocol, realize and its physical address is obtained by IP address.By taking ethernet environment as an example, in order to correctly be passed to destination host
Deliver newspaper text, it is necessary to which 32 IP address conversions of destination host are turned into the MAC Address of 48 Ethernets.This is just needed in interconnection layer
It by IP address conversion is respective physical address to have one group of service, and this group of agreement is exactly ARP protocol.Communicating pair equipment is using identical
The ARP protocol of ARP frame formats could realize the process being in communication with each other.
As shown in figure 5, ARP frames can include Ethernet stem and data frame part in the embodiment of the present invention.The present embodiment
In, in the ARP frame formats of Ethernet, in addition to original parameter, increase transmitting terminal IP address priority parameters, account for a byte.This
Sample, in addition to Ethernet stem, the new ARP data frames part of the present embodiment is 29 bytes, and existing ARP data frames part is 28
Individual byte.
Specifically, the ethernet address in ARP frame formats is MAC Address, the first two field in Ethernet stem header
It is purpose ethernet address, i.e. MAC Address(6 bytes)And source ethernet address, i.e. source MAC(6 bytes).Destination address
It is broadcast address for complete 1 special address.All Ethernet interfaces on cable will receive the data frame of broadcast.
The ethernet frame type of two byte longs represents the type of subsequent data.For ARP request or response, the word
The value of section is 0x0806.
Hardware(hardware)And agreement(protocol)For describing each field in ARP packets.For example, one
ARP request packet inquiry protocol address(Here it is IP address)Corresponding hardware address(Here it is ethernet mac address).Its
In, type of hardware field represents the type of hardware address.Its value is 1, that is, represents ethernet address.Protocol type field represents
The protocol address type to be mapped.Its value is 0x0800, that is, represents IP address.The field of ensuing two 1 bytes, hardware
Address size and length of protocol address point out the length of hardware address and protocol address respectively, in units of byte.For ether
For the ARP request of online IP address or response, their value is respectively 6 and 4.
Operation field OP points out four kinds of action types, and they are ARP requests(It is worth for 1), arp reply(It is worth for 2), RARP please
Ask(It is worth for 3)With RARP responses(It is worth for 4), wherein RARP(Reverse Address Resolution Protocol)To be inverse
Address resolution protocol.This field is required, because ARP request and the frame type field value of arp reply are identicals.
Ensuing five fields are the hardware address of transmitting terminal(It is ethernet address in this example), transmitting terminal association
Discuss address(IP address), the present invention distinctive transmitting terminal IP address priority, purpose ethernet address and purpose IP address.Here
There are some duplicate messages:There is the hardware address of transmitting terminal in the data frame header of Ethernet and in ARP request data frame.
Wherein, by taking the ARP records carried in the APR request messages that receiving device receives from sending ending equipment as an example,
Also include the priority of the IP address of sending ending equipment in the record.Therefore the transmitting terminal IP address in above-mentioned APR frame formats
Priority is exactly the priority of the IP address included in ARP frames of the embodiment of the present invention, be ARP frames of the present invention be different from it is existing
The place of ARP frame formats.
It is noted that IP address priority is not limited to be only located at Fig. 5 in ARP frame formats in the embodiment of the present invention
Shown position, rank numbering or arbitrary code, level rule are not also limited.
For an ARP request, the every other field in addition to purpose ethernet address has Filling power.When being
After system receives the ARP request message that a destination is the machine, it is just filled into hardware address, then with two destinations
Two transmitting terminal addresses are replaced in location respectively, and operation field is set to 2, and finally it is sent back to.So every equipment just has
The first ARP record of itself initial storage.
The 2nd ARP records in the ARP got records and the first ARP of itself storage are recorded progress by S302, gateway
The comparison of the priority of IP address, it is determined that needing the target ARP records stored;
Specifically, receiving device, which receives request message, can check in the ARP table of storage whether have corresponding ARP to remember
Record, if not then ARP records are stored, and by the priority of the IP address in the 2nd ARP records, with the first ARP records
The priority of IP address be compared;
In above-mentioned example, IP address is during gateway records the 2nd ARP got(1.0.0.1)Priority be 0
2nd ARP of server 1 is recorded and IP address is(1.0.0.1)Priority be 1 server 2 the 2nd ARP record and net
The IP address priority for closing itself storage is compared;To determine that target ARP is recorded, that is, use it to update the first ARP records.
S303, according to comparative result, only store target ARP records;
It is preferential greater than or equal to the IP address in the first ARP records if the priority of the IP address in the 2nd ARP records
Level, it is determined that the 2nd ARP is recorded as target ARP records;Otherwise, it determines the first ARP is recorded as target ARP records;Store excellent
The high ARP records of first level.
Can be specifically that the first ARP is replaced using the 2nd ARP records when the 2nd ARP is recorded as target ARP records
Record.
Specifically, the recipient of ARP request can according to the transmission side mac address in the ARP request received and IP
Whether location and priority, detecting in the ARP table of the machine has record corresponding to the IP address.If so, judge what is recorded in ARP table
Whether IP address priority is higher than sender's IP address priority, if it is, ARP records are not updated, otherwise using sender's
IP address priority update ARP is recorded, and records the MAC Address of sender and the mapping relations of IP address, and IP address is preferential
Level.
For example, in above-mentioned scene, the priority level of server 1 is 0, the priority 1 of the server 2 stored higher than original, that
The 2nd ARP records for being just 0 with the priority level of server 1 replace the first ARP of original and record and stored.
S304, gateway return to arp response message to server, and arp response message carries the ARP records of itself, itself
APR records include:The priority of itself IP address, MAC Address and IP address.
Specifically, the purpose IP address that the recipient of ARP request judges in message is the IP address of the machine, sending ARP should
Message is answered, transmitting terminal ethernet address is the MAC Address of the machine in message, and transmitting terminal IP address is the IP address of the machine, is sent
IP address priority is held as the priority of the IP address set.
For example, gateway is with returning to IP address, MAC Address and the IP of arp response message carrying gateway itself to server
The priority of location, after obtaining so as to server, it can be achieved to be communicated with gateway.
The ARP record management method that the present embodiment provides, at least two identical IP are obtained by gateway
The ARP record of address, and compared with the ARP records of itself storage, it is determined that needing the target ARP stored
Record, so, the priority that gateway can constantly update the IP address of itself storage is highest level, and can be according to the excellent of IP address
First level correctly sends message, solves IP address conflict caused by occurring double main or how main situations during more collaborative share floating IP address
The problem of, therefore the service exception situation caused by IP address conflict can be avoided.
Fig. 6 is the flow chart of ARP record management embodiment of the method four of the present invention, and the present embodiment describes
, it is in the scene shown in Fig. 4, gateway receives response, to obtain after actively request message is sent before ARP records aging
Take the ARP of each server to record, realize the technical scheme that continuous renewal is kept to ARP table.
As shown in Figure 4 and Figure 6, the method for the present embodiment can include:
The arp response message that S601, gateway the reception server are sent, obtain at least two ARP records;
At least two ARP records obtained, including:The first ARP records of itself storage and the
The 2nd ARP records that one ARP records are got afterwards, the 2nd ARP records are the address resolution sent in the transmitting terminal received
Carried in agreement arp response message;
Specifically, to adapt to the change of network, ARP table needs to constantly update.Dynamic mapping in ARP table not has forever
Effect, each record have a life cycle, and the record that reaching cannot still refresh life cycle will be deleted from ARP table
Remove, this life cycle is referred to as ageing time.It is refreshed if noted down before life cycle is reached, when recalculating aging
Between.
Before a Dynamic ARP is recorded into aging, system can be detected first, that is, send the ARP for including the IP address
Request message.
For example, the gateway of ARP request side sends the ARP request message for including own IP address, the first ARP records in Fig. 4
For the ARP records of existing former server in gateway, the 2nd ARP for then receiving server is recorded as what gateway received
The ARP records of the server of response message in arp reply;
The 2nd ARP records in the ARP got records and the first ARP of itself storage are recorded progress by S602, gateway
The comparison of priority, it is determined that needing the target ARP records stored;
It is specific to be to determine at least one analysis protocol arp response message received that there is the excellent of highest IP address
The 2nd ARP records of first level, are recorded for target ARP;
For example, in Fig. 4 server 1 highest priority, then be target ARP record;
This step can specifically include:
If IP address in the 2nd ARP records that first ARP response message receiving carries
Priority, it is default limit priority, it is determined that first the 2nd ARP is recorded as target ARP records.
Specifically, in above-mentioned example, i.e., ARP should for the IP address of opposite end server in the arp reply that gateway judgement receives
The priority of the transmitting terminal IP address in message is answered, to determine the need for continuing waiting for other arp replys.If ARP should
The priority for answering middle peer IP address is highest priority 0, then withouts waiting for, directly using the opposite end in the arp reply
MAC Address and IP address and IP address priority update ARP records.
Or this step can also specifically include:
If IP address in the 2nd ARP records that first ARP response message receiving carries
Priority, it is not default limit priority, then after first arp response message is received, can also includes:
The 2nd ARP records in first arp response message are preserved, and start timer;
If in the range of the timing of timer, first arp response message is only received, it is determined that first ARP
The 2nd ARP in response message is recorded as target ARP records;
If in the range of the timing of timer, at least one ARP is also received after first arp response message
Response message, it is determined that excellent with highest IP address in all arp response messages received in the range of timing
The 2nd ARP records of first level, are recorded as target ARP.
Specifically, in above-mentioned example, if the IP address priority of the opposite end server in response is not that highest is preferential
Level 0, then ARP records are not updated, but preserve the arp reply received, and wait the regular hour, such as 500 milliseconds.If
Arp reply is received again within the stand-by period, whether the IP address priority for judging opposite end in arp reply is limit priority 0, such as
Fruit is directly to update ARP records.If not limit priority 0, judge whether in the arp reply message than currently preserving
Peer IP address priority is higher, if higher, the arp reply currently preserved is updated using this arp reply.Stand-by period surpasses
Shi Hou, directly using the opposite end MAC Address and IP address and IP address priority update of the arp reply Message Record currently preserved
ARP is recorded.
S603, according to comparative result, only store target ARP records;
Such as the 2nd ARP records of the priority with highest IP address can be used, replace the first ARP records.
Within a specified time if can not receive response message, system will be repeated to send, and the number for repeating to send is visited by aging
Number is surveyed to determine.If it exceeds the aging detection number set, refreshes this record, this ARP notes still without response message
Record will be deleted.
Equally, after ARP records aging, main frame sends ARP probe requests therebies, after receiving arp reply, is done using above-mentioned processing
Method renewal ARP records.
In the present embodiment, stand-by period and aging detection number and the number for repeating to send are not limited, can basis
Need to set.
The ARP record management method of the embodiment of the present invention, by gateway in certain time constantly to certainly
The renewal of the ARP record sheets of body, the correctness and availability of ARP table can be kept.
Further, another characteristic of ARP is referred to as gratuitous ARP (gratuitousARP) in the various embodiments described above, and it refers to
Main frame sends ARP and searches the IP address of oneself, i.e., purpose IP address is the IP address of oneself in the ARP request of transmission.Generally,
When it occurs to enter during System guides line interface configuration.The effect of gratuitous ARP has two kinds.The first is exactly declaration broadcast
Effect, to tell whole broadcast domain, what the MAC Address corresponding to this IP address is at present.Second is to look to broadcast
The IP address of oneself is used either with or without other main frame in domain, if used, " IP address conflict " printed words are ejected on interface,
With warning system keeper.In all-network equipment(Including computer network interface card)When upgrading, it can all send such free
ARP is broadcasted, to declare and confirm either with or without conflict.
The processing of gratuitous ARP, main frame or equipment are sent in ARP request, and transmitting terminal IP address is the machine address, purpose IP
Location is also the machine address, and local IP address priority is carried in transmitting terminal IP address priority.Should if receiving ARP
Answer, the IP address of answer party is identical with local terminal IP address, and IP address priority is also identical with local terminal IP address priority, then
Illustrate there is IP address conflict on network, the alarm for having IP address conflict on network can be produced.If receiving arp reply, answer party
Although IP address it is identical from local terminal IP address but IP address priority is different, then the two IP address do not conflict, it is not necessary to produce
There is the alarm of IP address conflict on raw network.
Specific coming into force for IP address is realized by ARP protocol, can still use gratuitous ARP first, that is, possess Floating IP address
The server of address is by sending ARP request, and the purpose IP address in ARP request is the IP address of oneself, transmitting terminal IP address
Also it is the IP address of oneself, the MAC Address of transmitting terminal is the MAC Address of oneself, and the request is gratuitous ARP.Other gateways connect
After receiving the ARP request, according to transmitting terminal IP address in message and transmitting terminal MAC Address, ARP table is updated, establishes the IP address
With the mapping relations of MAC Address.So, when gateway receives the message for being sent to the IP address, ARP table is inquired about, is obtained corresponding
MAC Address, transmit the message to corresponding server.
Further, in the various embodiments described above of the present invention, the step of following heartbeat detections can also be increased, specifically describe such as
Under:
Fig. 7 be ARP record management embodiment of the method for the present invention in heartbeat detection schematic diagram, such as Fig. 7
Shown, the present embodiment is that further the heartbeat detection of increase equipment room, the present embodiment can include on the basis of Fig. 3:
Heartbeat detection itself is carried out between another terminal, another terminal is the terminal with itself sharing Floating IP address.
For example, in Fig. 7, further progress heartbeat detection between the two-server of floating IP address is shared, according to certain
Tactful ruling any platform server should possess Floating IP address.
Specifically, two-server has a numbering, when heartbeat is normal, small server is numbered with possessing the IP automatically
Location, number big server and do not possess the IP address automatically.When there is a server failure, because repeatedly can not receive other side's
Heartbeat message, local terminal server think that opposite end is unavailable, and local terminal can possess the Floating IP address.Numbering therein can be arbitrary code,
Coding rule is also any.
When at least two-server is communicated, at least two equipment carry out a heartbeat detection at regular intervals,
Whether detection connects normal with its other party.Such as client one heartbeat detection data frame of every 5 minutes hairs, service end receive number
Represent to pass through according to frame, i.e. communication is normal, otherwise represents that client disconnects, communication connection is abnormal.
The present embodiment is with the embodiment identical shown in Fig. 3, on server 1 and server 2 with being configured with identical IP
, there is different IP address priority location, and the IP address priority on server 1 is 0, and the IP address priority on server 2 is
1. server 1 is arranged to(IP:1.0.0.1 priority 0), server 2 is arranged to(IP:1.0.0.1 priority 1), it is assumed that it is preferential
0 rank of level is high, unlike embodiment in above-mentioned Fig. 3, has heartbeat detection between server 1 and server 2, is cut out by heartbeat
Certainly which server should possess IP address.The ARP that purpose IP address is the IP address will be responded by possessing the server of IP address
Request, the server that ruling does not possess the IP address are not responding to the ARP request that purpose IP address is the IP address.
For the present embodiment when heartbeat detection server 1 and server 2 communicate normal, gateway obtains the corresponding of server 1
The priority of MAC Address and IP address, respective communication will be carried out with server 1.
In the embodiment, the message of ARP request/response is same as the previously described embodiments, also carries the excellent of sender's IP address
First level, the processing to IP address priority are also same as the previously described embodiments.
The present embodiment can further be possessed by heartbeat detection IP address by a unique station terminal, can be more effective
Avoid producing IP address conflict problem.
Further, the various embodiments described above are only by taking two-server and a gateway device as an example, and only one floating
Dynamic IP address, but the present invention is not limited thereto, for example, when there is a multiple servers, while also multiple shared floating IP address when,
, can be by the preferential of the different respective different IP of IP address setting when every equipment needs to possess multiple floating IP address
Level, the same thought that the present invention can be achieved, is described in detail below in conjunction with Fig. 8.
Fig. 8 be ARP record management embodiment of the method for the present invention in more IP address schematic diagrames, this implementation
Example is one server of increase on the basis of Fig. 3 embodiments, and it is multiple that each server, which needs shared floating IP address,.
As shown in figure 8, in the present embodiment, the message format of ARP request/response is identical with the embodiment in Fig. 3, to IP
The processing of location priority is also identical.Unlike, the multiple servers of more than two share floating IP address, and with having multiple IP
Location, each IP address are corresponding with multiple servers, and simply IP address priority is different.Each server has having for oneself
The IP address of limit priority 0, and the IP using the IP address of the limit priority of other servers as the low priority of oneself
Address.
Specifically, as shown in figure 8, server 1 is arranged to(IP:1.0.0.1 priority 0, IP:1.0.0.2 priority 1,
IP:1.0.0.3 priority 2), server 2 is arranged to(IP:1.0.0.2 priority 0, IP:1.0.0.3 priority 1, IP:
1.0.0.1 priority 2), server 3 is arranged to(IP:1.0.0.3 priority 0, IP:1.0.0.1 priority 1, IP:1.0.0.2
Priority 2), then if in server 1 and abnormal server 2, gateway obtains the corresponding MAC Address of server 3 and more
The priority of individual IP address, respective communication will be carried out with 3 each IP address of server.
The present embodiment sets different priority by same equipment to different IP addresses, can be achieved between multiple servers
Mutual assistance, any server failure all can take over the business of the server by some other normal servers by.
Fig. 9 is the structural representation of ARP record management device embodiment one of the present invention, as shown in figure 9,
The ARP record management device that the present embodiment provides is the device corresponding with the embodiment of the method shown in Fig. 1,
The device can include:
Acquisition module 901, it can include for obtaining at least two ARP records, ARP records:Have
The priority of the IP address of mapping relations, MAC Address and IP address;IP address at least two ARP records is identical;
Memory module 902, for only storing target ARP records, target ARP records are that have at least two ARP records
The record of the priority of highest IP address.
The ARP record management device that the present embodiment provides, at least two phases are obtained by acquisition module
ARP with IP address records, and the priority for including IP address in the ARP records obtained, highest priority
Equipment finally can really possess floating IP address.The present embodiment can solve more collaborative shares according to the priority of IP address and float
Caused by occurring double main or how main situations during IP address the problem of IP address conflict, therefore it can avoid caused by IP address conflict
Service exception situation.
Further, the device in above-described embodiment, at least two ARPs that acquisition module 901 obtains
Record, can include:The first ARP records of itself storage and the 2nd ARP records got afterwards in the first ARP records,
2nd ARP records are carried in the ARP request message that the transmitting terminal received is sent;
Memory module 902, is specifically used for:
The priority of IP address during 2nd ARP is recorded, the priority of the IP address in being recorded with the first ARP are compared
Compared with;
It is preferential greater than or equal to the IP address in the first ARP records if the priority of the IP address in the 2nd ARP records
Level, it is determined that the 2nd ARP is recorded as target ARP records;Otherwise, it determines the first ARP is recorded as target ARP records;
When the 2nd ARP is recorded as target ARP records, is recorded using the 2nd ARP and replace the first ARP records.
Acquisition module 901 in above-described embodiment, specifically at least one analysis protocol arp response for determining to receive
The 2nd ARP records of the priority with highest IP address in message, are recorded for target ARP;
Memory module 902, specifically it is additionally operable to use the 2nd ARP records of the priority with highest IP address, replaces
First ARP is recorded.
Figure 10 is the structural representation of ARP record management device embodiment two of the present invention, such as Figure 10 institutes
Show, the ARP record management device that the present embodiment provides, can be with the basis of said apparatus embodiment one
Including:Respond module 903, is used for:
Arp response message is returned to transmitting terminal, arp response message carries the ARP records of itself, and the APR records of itself can
With including:The priority of itself IP address, MAC Address and IP address.
It is in order to which when upgrading or updating whole network, each equipment is by sending the IP address of itself to set respond module
And the priority of IP address, to avoid occurring the IP address conflict problem of " double masters " in system.
Further, the device in the various embodiments described above, acquisition module 901, is specifically additionally operable to:
If IP address in the 2nd ARP records that first ARP response message receiving carries
Priority, it is default limit priority, it is determined that first the 2nd ARP is recorded as target ARP records.
Device in each embodiment as described above, acquisition module 901, is additionally operable to:
If IP address in the 2nd ARP records that first ARP response message receiving carries
Priority, it is not default limit priority, then:
After first arp response message is received, the 2nd ARP records in first arp response message are preserved, and
Start timer;
If in the range of the timing of timer, first arp response message is only received, it is determined that first ARP
The 2nd ARP in response message is recorded as target ARP records;
If in the range of the timing of timer, at least one ARP is also received after first arp response message
Response message, it is determined that excellent with highest IP address in all arp response messages received in the range of timing
The 2nd ARP records of first level, are recorded as target ARP.
Figure 11 is the structural representation of ARP record management device embodiment three of the present invention, such as Figure 11 institutes
Show, the ARP record management device of the present embodiment offer and the dress of one corresponding opposite end of said apparatus embodiment
Embodiment is put, can be included:
Sending module 1001, for sending ARP record, ARP records can include:With mapping relations
The IP address of itself, the priority of MAC Address and the IP address of itself, include the purpose IP address of ARP request;
Memory module 1002, the receiving terminal for causing ARP to record are getting at least two with identical IP address
When bar ARP is recorded, the priority with highest IP address at least two ARP records is determined according to the priority of IP address
Target ARP records are recorded as to be stored.
The ARP record management device that the present embodiment provides, itself is sent by sending module 1001
ARP records, and makes the equipment of highest priority in network finally can really possess floating IP address.The present embodiment
IP address caused by occurring double main or how main situations when can solve more collaborative share floating IP address according to the priority of IP address
The problem of conflict, therefore the service exception situation caused by IP address conflict can be avoided.
Figure 12 is the structural representation of ARP record management device embodiment four of the present invention, such as Figure 12 institutes
Show, the ARP record management device that the present embodiment provides is on the basis of said apparatus embodiment three, further
, the ARP records that the sending module 1001 is sent, it can include:ARP request message is sent, ARP request message carries itself
The first ARP records, and the purpose IP address of ARP request message is the IP address of itself;
The device can also include:
Collision detection module 1003, is used for:
Receive arp response message, arp response message carries the 2nd ARP records, the IP address and the in the 2nd ARP records
IP address in one ARP records is identical;
The priority of IP address during first ARP is recorded, the priority of the IP address in being recorded with the 2nd ARP are compared
Compared with if both are identical, it is determined that the transmitting terminal of arp response message produces IP address conflict with itself.
Figure 13 is the structural representation of ARP record management device embodiment five of the present invention, such as Figure 13 institutes
Show, the ARP record management device that the present embodiment provides, can be with the basis of said apparatus example IV
Including:
Respond module 1004, for receiving transmitting terminal ARP request message, and determine that the ARP request message is taken
When the purpose IP address of band is the IP address of itself, arp response message is sent to the transmitting terminal, and in the arp response report
Own IP address, MAC Address and IP address priority are carried in text.
Further, the ARP record management device that the present embodiment provides, can also include:Heartbeat is examined
Module 1005 is surveyed, for itself carrying out heartbeat detection between another terminal, another terminal is the end with itself sharing Floating IP address
End.
The present embodiment further increases respond module and terminal room heartbeat detection, may be such that IP address by a unique end
End is possessed, and avoids producing IP address conflict problem.
The device of the various embodiments described above of the present invention, it is also not necessarily limited to same equipment and only shares a floating IP address, can be to upper
Each embodiment is stated further to deform, can be by different IP address when same equipment needs to possess multiple floating IP address
Each different IP priority is set, the same thought that the present invention can be achieved, the communication mutual assistance between more equipment is realized, avoids
The service exception caused by address conflict or equipment fault.
In summary, the embodiment of the present invention is by setting the IP address priority in ARP records to avoid rushing for IP address
It is prominent, specifically in ARP request/response message in addition to transmitting terminal IP address is carried, also carry transmitting terminal IP address priority;Receive
To after IP address analysis request, IP address priority is carried in IP address resolution response message, record IP address is removed in ARP table
With outside the mapping relations of MAC Address, also recording IP address priority.After arp response message is received, for same IP
Location, update ARP table using the arp response of IP address highest priority in the one or more arp responses received.
It can be seen that ARP record management method and apparatus provided in an embodiment of the present invention, are included by obtaining
The ARP record of at least two identical IP address of the priority of IP address, can be achieved MAC and highest priority
IP address mapping, solve service exception situation caused by the IP address conflict that easily occurs during shared Floating IP address.
Further, the embodiment of the present invention is when new business needs to support Floating IP address, it is not necessary to complicated cluster management
Cooperation of the software also without operation layer, it is not necessary to carry out extra software development, directly can be supported by IP layers.
Finally it should be noted that:Various embodiments above is merely illustrative of the technical solution of the present invention, rather than its limitations;To the greatest extent
The present invention is described in detail with reference to foregoing embodiments for pipe, it will be understood by those within the art that:Its according to
The technical scheme described in foregoing embodiments can so be modified, either which part or all technical characteristic are entered
Row equivalent substitution;And these modifications or replacement, the essence of appropriate technical solution is departed from various embodiments of the present invention technology
The scope of scheme.