A kind of topology discovery method and system
Technical field
The present invention relates to network communication technology field, particularly relate to a kind of topology discovery method and system.
Background technology
Along with the development of network technology, network size constantly expands, and complexity strengthens increasingly, promotes user to network management
Requirement more and more higher.
The redundancy of network has become as the key characteristic of current network.Such as redundancy backup server, it is simply that 2 services
Device backups each other, and when a station server breaks down, another station server takes over the server broken down at once.But in redundancy
During backup, when master server and standby server are out of touch, it is impossible to judge the Link State at place.
In the prior art, the Link State in using Datalink Layer Topology Discovery to may determine that network, but need to utilize
Layer protocol realizes, such as IP (Internet Protocol, the agreement of interconnection between network) agreement, is not opening IP agreement
The Link State in network just cannot be determined on equipment.
Summary of the invention
In view of this, the present invention proposes a kind of topology discovery method and system, must utilize solving topology discovery method
Upper-layer protocol just can determine that the technical problem of link in network state.
For reaching this purpose, the present invention by the following technical solutions:
A kind of topology discovery method, including:
Reception equipment receives the neighbor uni-cast message that transmission equipment sends;
Reception equipment is according to the first neighbor entry of the equipment of reception, it is judged that whether transmission equipment is neighbours;
If so, receive equipment and transmission equipment receives topology list item and sets up message, set according to the first neighbor entry and transmission
The second standby neighbor entry sets up line, line is passed in the first neighbor entry and the second neighbor entry except reception equipment and
Neighbor device beyond transmission equipment, building topology list item;
Receive plant maintenance, update topology list item.
Preferably, according to the first neighbor entry of the equipment of reception, it is judged that whether transmission equipment is neighbours, including:
Judge whether transmission equipment is neighbours according to the first neighbor entry, the most then abandon neighbor uni-cast message;
If it is not, then adding transmission equipment is neighbours, and abandon neighbor uni-cast message;
Reception equipment sends neighbor uni-cast response message;
Transmission equipment receives neighbor uni-cast response message, and allows reception equipment to be added to neighbours.
Preferably, also include: if reception equipment and transmission equipment are neighbours, then within the default time period, according to receiving
Whether equipment less for MAC in equipment and transmission equipment sends neighbours' maintenance request message, it is judged that neighbor state;
If it is not, then delete the less equipment of MAC;
The most then receive device replied neighbours bigger for MAC in equipment and transmission equipment and safeguard reply message, keep neighbours
Relation.
Preferably, set up line according to the first neighbor entry and the second neighbor entry, including
Line is set up according to the destination node of the source node in the first neighbor entry and the second neighbor entry.
Preferably, receive plant maintenance topology list item to include:
If reception equipment does not receives topological list item establishment message, the neighbours' maintenance that transmission equipment sends within the default time
Request message and neighbours safeguard any one replied in message, then delete transmission equipment in the first neighbor entry, and send
Topology table entry deletion message is to neighbor device in addition to transmission equipment in the first neighbor entry;
Neighbor device in addition to transmission equipment in first neighbor entry, deletes transmission equipment in neighbor entry, and deletes
Except topology list item device-dependent with transmission.
A kind of topology discovery system, including,
Reception equipment, is used for receiving neighbor uni-cast message, according to the first neighbor entry of the equipment of reception, it is judged that send equipment
Whether it is neighbours;
If so, receive topology list item and set up message, build according to the second neighbor entry of the first neighbor entry and the equipment of transmission
Vertical line, passes to the neighbor device in addition to transmission equipment in the first neighbor entry, building topology list item by line, safeguard,
Update topology list item;
Transmission equipment, is used for sending neighbor uni-cast message;
Receive topology list item and set up message, set up even according to the first neighbor entry of the second neighbor entry and the equipment of reception
Line, passes to the neighbor device in addition to reception equipment in the second neighbor entry by line.
Preferably, reception equipment includes:
Neighbours' judge module, for judging in the first neighbor entry whether transmission equipment is neighbours, the most then abandons neighbour
Occupy and find message;
If it is not, then adding transmission equipment is neighbours, and abandon neighbor uni-cast message;
Reception equipment sends neighbor uni-cast response message.
Preferably, send equipment, including:
Add neighbours' module, be used for receiving neighbor uni-cast response message, and allow reception equipment to be added to neighbours.
Preferably, also including: neighbor entry maintenance module, within the default time period, foundation receives equipment and sends out
Send whether equipment less for MAC in equipment sends neighbours' maintenance request message, it is judged that neighbor state;
If it is not, then delete the less equipment of MAC;
The most then bigger for MAC device replied neighbours safeguard reply message, keep neighborhood.
Preferably, reception equipment includes: topology list item maintenance module, if not receiving within the default time for reception equipment
The topological list item sent to transmission equipment creates message, neighbours' maintenance request message and neighbours safeguard reply in message any one
Individual, then in the first neighbor entry, delete transmission equipment, and send topology table entry deletion message in the first neighbor entry except sending out
Send the neighbor device beyond equipment.
By a kind of topology discovery method disclosed by the invention and system, it is possible to realize being independent of upper-layer protocol, find whole
The Link State of miscellaneous equipment is checked on Link State in individual network, and any one equipment in a network.
Accompanying drawing explanation
For the technical scheme being illustrated more clearly that in the embodiment of the present application, in embodiment being described below required for make
Accompanying drawing be briefly described, it should be apparent that, the accompanying drawing in describing below is only some embodiments of the application, for
From the point of view of those of ordinary skill in the art, on the premise of not paying creative work, it is also possible to obtain it according to these accompanying drawings
His accompanying drawing.
Fig. 1 is a kind of topology discovery method schematic flow sheet that the embodiment of the present invention one provides;
Fig. 2 is a kind of topology discovery method schematic flow sheet that the embodiment of the present invention two provides;
Fig. 3 is a kind of Topology Discovery apparatus structure schematic diagram that the embodiment of the present invention three provides;
Fig. 4 is a kind of Topology Discovery apparatus structure schematic diagram that the embodiment of the present invention four provides.
Detailed description of the invention
Below in conjunction with the accompanying drawing in the embodiment of the present application, the technical scheme in the embodiment of the present application is carried out clear, complete
Describe, it is clear that described embodiment is only some embodiments of the present application rather than whole embodiments wholely.Based on
Embodiment in the application, it is every other that those of ordinary skill in the art are obtained under not making creative work premise
Embodiment, broadly falls into the scope of the application protection.
Illustrating for cheer and bright, the english abbreviation implication that the present embodiments relate to and message are as follows:
SrcPoint: source node, including with properties: MAC (Media Access Control address), Name (title), Vlan
(Virtual Local Area Network, VLAN), IP (Internet Protocol, the association of interconnection between network
View), Port (port);
Source MAC: source Media Access Control address;
Destnation MAC: purpose Media Access Control address;
TYPE: type;
LEN: string length;
RESERVED: reserved;
Value: contents value;
DstPoint: destination node, including with properties: MAC, Name, Vlan, IP, Port;
OPTIONS: option;
Neighbor uni-cast message is: topology-neighbor-discover-request;
Neighbor uni-cast response message is: topology-neighbor-discover-reply;
Neighbours' maintenance request message is: neighbor-keep-alive-request;
Neighbours safeguard that reply message is: neighbor-keep-alive-reply;
Topology list item sets up message: topology-line-create;
Topology table entry deletion message: topology-link-delete.
In below example one to four of the present invention, reception equipment and transmission equipment are to open Topology Discovery Protocol
Switch.
Embodiment one
Refering to accompanying drawing 1, the embodiment of the present invention one discloses a kind of topology discovery method, including:
Step S101, the equipment that receives receives the neighbor uni-cast message that transmission equipment sends;
Step S102, receives the equipment the first neighbor entry according to the equipment of reception, it is judged that whether transmission equipment is neighbours;
Step S103, if so, receives equipment and transmission equipment receives topology list item and sets up message, according to the first neighbor entry
Set up line (Line) with the second neighbor entry of the equipment of transmission, line is passed to the first neighbor entry and the second neighbor entry
In neighbor device in addition to reception equipment and transmission equipment, building topology list item;
Step S104, receives plant maintenance, updates topology list item.
In step S102 of the embodiment of the present invention one, according to the first neighbor entry of the equipment of reception, it is judged that send equipment
Whether it is neighbours, including:
In the first neighbor entry, judge whether transmission equipment is neighbours, the most then abandon neighbor uni-cast message;
If it is not, then adding transmission equipment is neighbours, and abandon neighbor uni-cast message;
Reception equipment sends neighbor uni-cast response message;
Transmission equipment receives neighbor uni-cast response message, and allows reception equipment to be added to neighbours.
It should be noted that in the embodiment of the present invention one, use Layer 2 Multicast message carrying neighbor uni-cast message.
Concrete, topology-neighbor-discover-request message structure is as follows:
Decimal number 0,8,16,24 in above-mentioned message structure is first, second, third, fourth byte respectively
(Byte) start bit (bit).
Wherein, OPTIONS includes TYPE, LEN and Value.
TYPE (01): represent MAC, length is 6 bytes, and the structure of TYPE (01) is as follows:
TYPE (02): represent IP, length is 4 bytes, and the structure of TYPE (02) is as follows:
TYPE (03): represent Vlan, length is not fixed;TYPE (03) structure is as follows
TYPE (04): represent Port, length is not fixed, and the structure of TYPE (04) is as follows:
TYPE (05): represent Name, length is not fixed, and the structure of TYPE (05) is as follows:
Concrete, topology-neighbor-discover-reply message structure is as follows:
It should be noted that the option of topology-neighbor-discover-reply message compares topology-
Neighbor-discover-request message, many TYPE (10).
TYPE (10): represent purpose MAC, length is 6 characters, and TYPE (10) structure is as follows:
In step s 103, set up line according to the first neighbor entry and the second neighbor entry, including
Line (Line) is set up according to the destination node of the source node in the first neighbor entry and the second neighbor entry.Specifically
, except output port in neighbor entry) (OutPort, for the purpose of node (DstPoint).In neighbor entry
OutPort, and the Vlan at OutPort place, (VLAN is assisted for Vlan MAC (virtual local area network address), Vlan IP
View), the Name of equipment constitutes SrcPoint.SrcPoint Yu DstPoint constitutes a line, it is simply that line (Line).
After setting up neighbor entry, all of line can be notified to neighbours unrelated with line in neighbor entry, this
Sample just allows all of neighbours in neighbor entry all learn to topology list item.If equipment learns to crossing certain from certain neighbor device
Bar line, then this equipment should not reinform the information of this line to this neighbor device.
Same, Topology-line-create message, also use Layer 2 Multicast message to carry.
Concrete, the structure of Topology-line-create message is as follows:
Shown in OPTIONS is classified as follows:
TYPE (01): representative is srcPoint, and length is unknown, and TYPE (01) includes following sub-option.
SubTYPE (source option) (01), representative is srcMAC (source address), a length of 6 bytes;SubTYPE (select by source
) structure of (01) is as follows:
SubTYPE (02): representative is srcIP (source protocol), a length of 4 bytes, and structure is as follows:
SubTYPE (03): representative is srcName (source name), and length is unknown;SubTYPE (03) structure is as follows:
SubTYPE (04): representative is srcVlan (source VLAN), and length is unknown, and SubTYPE (04) structure is such as
Under:
SubTYPE (05): representative is srcPort (source port), and length is unknown;SubTYPE (05) structure is as follows:
That TYPE (02) represents is DstPoint, and length is unknown, including following sub-option.
SubTYPE (06), representative is dstMAC (destination address), a length of 6, structure is as follows:
SubTYPE (07): representative is dstIP (purpose agreement), and a length of 4 bytes, SubTYPE (07) structure is such as
Under:
SubTYPE (08): representative is dstName (purpose title), and length is unknown;SubTYPE (08) structure is as follows:
SubTYPE (09): representative is dstVlan (purpose VLAN), and length is unknown, the knot of SubTYPE (09)
Structure is as follows:
SubTYPE (10): representative is dstPort (destination interface), and length is unknown, SubTYPE (10): structure is as follows:
What TYPE (03) represented is the equipment sending topology-line-create message, and type is MAC, and structure is such as
Under:
In step S104, receive plant maintenance topology list item and include:
Reception equipment does not receives the topological list item establishment message of transmission equipment transmission within the default time, neighbours safeguard please
Ask message and neighbours to safeguard any one replied in message, then in the first neighbor entry, delete transmission equipment, and transmission is opened up
Flutter list item and delete message to neighbor device in addition to transmission equipment in the first neighbor entry;
Neighbor device in addition to transmission equipment in first neighbor entry, deletes transmission equipment in neighbor entry, and deletes
Except topology list item device-dependent with transmission.
Concrete, when the interface certain neighbour in network being detected disconnects, then these neighbours are set to unreachable neighbours.If
Within the default time, this port does not connect, then delete these neighbours and send topology-link-delete message notifying its
Its neighbour deletes the topological list item relevant with these neighbours.
If this port couples together within the default time, then these neighbours it is set to up to neighbours and sends
These neighbours of neighbor-keep-alive-request packet check are the most normal, if the most do not received
Neighbor-keep-alive-reply message, then delete these neighbours and send topology-link-delete message notifying
Other neighbours delete the topological list item relevant with these neighbours.
When receiving topology-link-delete message within the default time, check that oneself is with or without this topology table
, if had, detecting the legitimacy of this message, if legal, then deleting corresponding topology list item, then send
Other neighbours of topology-link-delete message notifying delete this list item.Without changing topology list item, then abandon this report
Literary composition.If this message is illegal, then abandon this message.
It should be noted that in step S104, owing to including when reception plant maintenance topology list item:
Reception equipment does not receives the topological list item establishment message of transmission equipment transmission within the default time, neighbours safeguard please
Ask message and neighbours to safeguard reply in message one or more, then in the first neighbor entry, delete transmission equipment, and send
Topology table entry deletion message is to neighbor device in addition to transmission equipment in the first neighbor entry;
Neighbor device in addition to transmission equipment in first neighbor entry, deletes transmission equipment in neighbor entry, and deletes
Except topology list item device-dependent with transmission.
When topology list item lost efficacy, then learn to carry out deletion action on all devices of this topology list item, so being not required to
Topology list item is carried out other attended operation.
By topology discovery method a kind of disclosed in the embodiment of the present invention one, it is possible to realize being independent of upper-layer protocol, find
The Link State of miscellaneous equipment is checked on Link State in whole network, and any one equipment in a network.
Embodiment two
The embodiment of the present invention one discloses a kind of topology discovery method, and the embodiment of the present invention two discloses a kind of Topology Discovery
Method, on the basis of a kind of topology discovery method that the embodiment of the present invention one discloses, also includes:
Step S201, if reception equipment and transmission equipment are neighbours;
Step S202, then, within the default time period, whether foundation receives equipment less for MAC in equipment and transmission equipment
Send neighbours' maintenance request message, it is judged that neighbor state;
Step S203, if it is not, then delete the less equipment of MAC;
Step S204, the most then receive device replied neighbours bigger for MAC in equipment and transmission equipment and safeguard reply report
Literary composition, keeps neighborhood.
Same, neighbours' maintenance request message is carried by Layer 2 Multicast message.
It should be noted that be provided with an intervalometer in neighbor entry, within the default time period, do not receive neighbour
Occupying maintenance request message, the neighbours sending neighbours' maintenance request message will be deleted in neighbor list, the time period preset
It it is 30 seconds.
Reply after in reception equipment and transmission equipment, equipment bigger for MAC receives neighbours' maintenance request message
Neighbor-keep-alive-reply message.
Wherein, Layer 2 Multicast message is used to carry neighbours' maintenance request message.
The structure of Neighbor-keep-alive-request message is as follows:
Wherein, OPTIONS classification:
TYPE 01, represents srcMAC (source address), and length is 6 characters, and TYPE 01 structure is as follows:
TYPE04: representing srcPort (source port), length is not fixed;The structure of TYPE04 is as follows:
TYPE11: represent dstMAC, length is not fixed, and structure is as follows:
TYPE12 represents dstPort, and length is not fixed, and structure is as follows:
Concrete, the structure of Neighbor-keep-alive-reply message is as follows:
Wherein, neighbours safeguard and occupy the many TYPE (10) of maintenance request message near the OPTIONS replying message:
TYPE (10), represents purpose MAC, and length is 6 bytes;TYPE (10) structure is as follows:
A kind of topology discovery method is disclosed, it is possible to realize being independent of upper-layer protocol, find by the embodiment of the present invention two
The Link State of miscellaneous equipment is checked on Link State in whole network, and any one equipment in a network.
Embodiment three
The embodiment of the present invention one discloses a kind of topology discovery method, corresponds, and the embodiment of the present invention three discloses
A kind of Topology Discovery device, as shown in Figure 3.
A kind of Topology Discovery device, including, receive equipment 1, be used for receiving neighbor uni-cast message, according to the of the equipment of reception
One neighbor entry, it is judged that whether transmission equipment 2 is neighbours;
If so, receive topology list item and set up message, build according to the second neighbor entry of the first neighbor entry and transmission equipment 2
Vertical line, passes to the neighbor device in addition to transmission equipment in the first neighbor entry, building topology list item by line, safeguard,
Update topology list item;
Transmission equipment 2, is used for sending neighbor uni-cast message;
Receive topology list item and set up message, set up even according to the first neighbor entry of the second neighbor entry and reception equipment 1
Line, passes to the neighbor device in addition to reception equipment 1 in the second neighbor entry by line.
In the embodiment of the present invention three, reception equipment 1 includes:
Neighbours' judge module 11, for judging in the first neighbor entry whether transmission equipment 2 is neighbours, the most then lose
Abandon neighbor uni-cast message;
If it is not, then adding transmission equipment 2 is neighbours, and abandon neighbor uni-cast message;
Reception equipment 1 sends neighbor uni-cast response message.
In the embodiment of the present invention three, send equipment 2, including:
Add neighbours' module 21, be used for receiving neighbor uni-cast response message, and allow reception equipment 1 to be added to neighbours.
In the embodiment of the present invention three, reception equipment 1 includes: topology list item maintenance module 12, is used for the equipment that receives 1 in advance
If time in do not receive that the topological list item that transmission equipment 2 sends creates message, neighbours' maintenance request message and neighbours safeguard back
Any one in multiple message, then delete transmission equipment in the first neighbor entry, and sends topology table entry deletion message to the
Neighbor device in addition to transmission equipment 2 in one neighbor entry.
By Topology Discovery device a kind of disclosed in the embodiment of the present invention three, it is possible to realize being independent of upper-layer protocol, find
The Link State of miscellaneous equipment is checked on Link State in whole network, and any one equipment in a network.
Embodiment four
Shown in Fig. 4, the embodiment of the present invention four discloses a kind of Topology Discovery device, discloses one in the embodiment of the present invention three
On the basis of planting Topology Discovery device, also include:
Also include: neighbor entry maintenance module 3, within the default time period, according to the equipment of reception 1 and the equipment of transmission
Neighbours' maintenance request message that equipment less for MAC in 2 sends, it is judged that neighbor state;
If it is not, then delete the less equipment of MAC;
The most then bigger for MAC device replied neighbours safeguard reply message, keep neighborhood.
By Topology Discovery device a kind of disclosed in the embodiment of the present invention four, it is possible to realize being independent of upper-layer protocol, find
The Link State of miscellaneous equipment is checked on Link State in whole network, and any one equipment in a network.
Obviously, it will be understood by those skilled in the art that each module or each step of the above-mentioned present invention can be with general
Calculating device to realize, they can concentrate on single calculating device, or is distributed in the net that multiple calculating device is formed
On network, alternatively, they can realize with the executable program code of computer installation, such that it is able to be stored in depositing
Storage device is performed by calculating device, or they are fabricated to respectively each integrated circuit modules, or by them
Multiple modules or step are fabricated to single integrated circuit module and realize.So, the present invention is not restricted to any specific hardware
Combination with software.
These are only the preferred embodiments of the present invention, be not limited to the present invention, to those skilled in the art,
The present invention can have various change and change.All made within spirit and principles of the present invention any amendment, equivalent,
Improve, should be included within the scope of the present invention.