Disclosure of Invention
In order to solve the above technical problems, the present invention provides a link processing method and apparatus, so as to solve the problem that in the link detection method in the prior art, the link reliability is poor due to the fact that one end of the link may not sense the abnormal state of the opposite end and the phenomenon of single traffic occurs.
In a first aspect, the present invention provides a link processing method, including:
a first terminal device conducts a first member interface of the first terminal device and a second member interface which is physically connected with the first member interface in a second terminal device by executing a negotiation process, and the first terminal device and the second terminal device which finish the negotiation process both have first negotiation information of the first member interface and second negotiation information of the second member interface;
the first terminal device receives a first extended keep-alive message which is repeatedly sent by the second terminal device according to a preset time interval, wherein the first extended keep-alive message comprises first negotiation information and second negotiation information in the second terminal device, and the content of the second negotiation information changes when the second member interface is abnormal;
and the first terminal equipment closes the first member interface when determining that the received first negotiation information and second negotiation information are different from the first negotiation information and the second negotiation information in the first terminal equipment.
In a first possible implementation manner of the first aspect, after the first terminal device sets a first timer, and the first terminal device conducts a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of a second terminal device by executing a negotiation procedure, the method further includes:
the first terminal equipment starts the first timer;
after the first terminal device receives the first extended keep-alive message sent by the second terminal device, the method further includes:
and the first terminal equipment sets the first timer to start timing from zero when determining that the received first negotiation information and second negotiation information are the same as the first negotiation information and the second negotiation information in the first terminal equipment.
In a second possible implementation manner of the first aspect, the first terminal device repeatedly sends a second extended keep-alive message to the second terminal device according to a preset time interval, where the second extended keep-alive message includes first negotiation information and second negotiation information in the first terminal device, a content of the first negotiation information changes when the first member interface is abnormal, and the second extended keep-alive message is used to instruct the second terminal device to close the second member interface when it is determined that the received first negotiation information and second negotiation information are different from the first negotiation information and second negotiation information in the second terminal device.
According to a second possible implementation manner of the first aspect, in a third possible implementation manner, a second timer is set in the second terminal device, the second timer starts to count time after the second member interface is turned on, and the second extended keep-alive message is further used to instruct the second terminal device to set the second timer to count time from zero when it is determined that the received first negotiation information and second negotiation information are the same as the first negotiation information and second negotiation information in the second terminal device.
According to the first possible implementation manner of the first aspect, in a fourth possible implementation manner, the method further includes:
the first terminal equipment closes the first member interface when detecting that the timing value of the first timer is larger than a first threshold value;
the first terminal device sends a third extended keep-alive message to the second terminal device, the third extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the third extended keep-alive message is used for indicating the second terminal device to close the second member interface;
and the first terminal equipment and the second terminal equipment execute the negotiation process again.
According to the first aspect and any one of the first to fourth possible implementation manners of the first aspect, in a fifth possible implementation manner, the receiving, by the first terminal device, the first extended keep-alive message further includes a third timer, the third timer starts timing when the first extended keep-alive message is sent, and after the receiving, by the first terminal device, the first extended keep-alive message that is repeatedly sent by the second terminal device according to a preset time interval, the method further includes:
when the timing value of the third timer is less than or equal to the second threshold value and the received first negotiation information and second negotiation information are determined to be the same as the first negotiation information and the second negotiation information in the first terminal device, the first terminal device maintains the current state of the first member interface; or,
the first terminal equipment closes the first member interface when the timing value of the third timer is larger than a second threshold value;
the first terminal device sends a fourth extended keep-alive message to the second terminal device, the fourth extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the fourth extended keep-alive message is used for indicating the second terminal device to close the second member interface;
and the first terminal equipment and the second terminal equipment execute the negotiation process again.
According to the first aspect and any one of the first to fourth possible implementation manners of the first aspect, in a sixth possible implementation manner, the conducting, by the first terminal device, a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of the second terminal device by performing a negotiation procedure includes:
the first terminal equipment sends the first negotiation information to the second terminal equipment and indicates the second terminal equipment to store the first negotiation information;
the first terminal equipment receives and stores the second negotiation information sent by the second terminal equipment;
the first terminal device sends a first negotiation message to the second terminal device, the first negotiation message includes first negotiation information and second negotiation information in the first terminal device, the first negotiation message is used for indicating the second terminal device to conduct the second member interface when the fact that the received first negotiation information and second negotiation information are the same as the first negotiation information and the second negotiation information in the second terminal device is determined;
the first terminal equipment receives a second negotiation message sent by the second terminal equipment, wherein the second negotiation message comprises second negotiation information and first negotiation information in the second terminal equipment;
and the first terminal equipment conducts the first member interface when determining that the received first negotiation information and second negotiation information are the same as the first negotiation information and the second negotiation information in the first terminal equipment.
According to a sixth possible implementation manner of the first aspect, in a seventh possible implementation manner, a third member interface in the first terminal device is physically connected to a fourth member interface in the second terminal device, and third negotiation information of the third member interface is the same as the first negotiation information;
after the first terminal device conducts the first member interface of the first terminal device and the second member interface, which is physically connected with the first member interface, of the second terminal device by executing a negotiation process, the method further includes:
the first terminal device executes the negotiation process to conduct the third member interface and the fourth member interface when fourth negotiation information of the fourth member interface is the same as the second negotiation information; or,
and the first terminal equipment fails to execute the negotiation process when the fourth negotiation information of the fourth member interface is different from the second negotiation information.
In a second aspect, the present invention provides a link processing apparatus, provided in a first terminal device, the link processing apparatus including:
the negotiation module is used for conducting a first member interface of the first terminal device and a second member interface which is physically connected with the first member interface in the second terminal device by executing a negotiation process, and the first terminal device and the second terminal device which finish the negotiation process both have first negotiation information of the first member interface and second negotiation information of the second member interface;
a receiving module, configured to receive a first extended keep-alive message that is repeatedly sent by the second terminal device according to a preset time interval, where the first extended keep-alive message includes first negotiation information and second negotiation information in the second terminal device, and a content of the second negotiation information changes when the second member interface is abnormal;
and the processing module is used for closing the first member interface when the first negotiation information and the second negotiation information received by the receiving module are determined to be different from the first negotiation information and the second negotiation information in the first terminal equipment.
In a first possible implementation manner of the second aspect, a first timer is provided in the first terminal device, and the link processing apparatus further includes: a starting module 18, configured to start the first timer after the negotiation module conducts a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of the second terminal device by executing a negotiation process;
the processing module is further configured to set the first timer to start timing from zero when it is determined that the first negotiation information and the second negotiation information received by the receiving module are the same as the first negotiation information and the second negotiation information in the first terminal device.
In a second possible implementation manner of the second aspect, the link processing apparatus further includes: a sending module, configured to repeatedly send a second extended keep-alive packet to the second terminal device according to a preset time interval, where the second extended keep-alive packet includes first negotiation information and second negotiation information in the first terminal device, a content of the first negotiation information changes when the first member interface is abnormal, and the second extended keep-alive packet is used to instruct the second terminal device to close the second member interface when it is determined that the received first negotiation information and second negotiation information are different from the first negotiation information and second negotiation information in the second terminal device.
According to a second possible implementation manner of the second aspect, in a third possible implementation manner, a second timer is set in the second terminal device, the second timer starts to count time after the second member interface is turned on, and the second extended keep-alive message is further used to instruct the second terminal device to set the second timer to count time from zero when it is determined that the received first negotiation information and second negotiation information are the same as the first negotiation information and second negotiation information in the second terminal device.
In a fourth possible implementation manner, according to the first possible implementation manner of the second aspect, the processing module is further configured to close the first member interface when detecting that a count value of the first timer is greater than a first threshold;
the link processing apparatus further includes: a sending module, configured to send a third extended keep-alive message to the second terminal device, where the third extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the third extended keep-alive message is used to instruct the second terminal device to close the second member interface;
the negotiation module is further configured to execute the negotiation process with the second terminal device again.
According to the second aspect and any one of the first to fourth possible implementation manners of the second aspect, in a fifth possible implementation manner, the first extended keep-alive message received by the receiving module further includes a third timer, the third timer starts timing when the first extended keep-alive message is sent out, and the processing module is further configured to keep a current state of the first member interface when a timing value of the third timer is less than or equal to the second threshold, and it is determined that the first negotiation information and the second negotiation information received by the receiving module are the same as the first negotiation information and the second negotiation information in the first terminal device; or,
the processing module is further configured to close the first member interface when the timing value of the third timer is greater than a second threshold;
the sending module is further configured to send a fourth extended keep-alive message to the second terminal device, where the fourth extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the fourth extended keep-alive message is used to instruct the second terminal device to close the second member interface;
the negotiation module is further configured to execute the negotiation process with the second terminal device again.
According to the second aspect and any one of the first to fourth possible implementation manners of the second aspect, in a sixth possible implementation manner, the negotiation module includes:
a sending unit, configured to send the first negotiation information to the second terminal device, and instruct the second terminal device to store the first negotiation information;
a receiving unit, configured to receive and store the second negotiation information sent by the second terminal device;
the sending unit is further configured to send a first negotiation packet to the second terminal device, where the first negotiation packet includes first negotiation information and second negotiation information in the first terminal device, and the first negotiation packet is used to instruct the second terminal device to turn on the second member interface when it is determined that the received first negotiation information and second negotiation information are the same as the first negotiation information and second negotiation information in the second terminal device;
the receiving unit is further configured to receive a second negotiation packet sent by the second terminal device, where the second negotiation packet includes second negotiation information and first negotiation information in the second terminal device;
and the processing unit is used for conducting the first member interface when the first negotiation information and the second negotiation information received by the receiving unit are determined to be the same as the first negotiation information and the second negotiation information in the first terminal equipment.
According to a sixth possible implementation manner of the second aspect, in a seventh possible implementation manner, a third member interface in the first terminal device is physically connected to a fourth member interface in the second terminal device, and third negotiation information of the third member interface is the same as the first negotiation information;
the processing module is further configured to execute a negotiation process to conduct a third member interface and a fourth member interface after the negotiation module conducts a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of the second terminal device by executing the negotiation process, and when fourth negotiation information of the fourth member interface is the same as the second negotiation information; or,
the processing module is further configured to, after the negotiation module conducts a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of the second terminal device by executing a negotiation process, and when fourth negotiation information of the fourth member interface is different from the second negotiation information, execute the negotiation process and fail.
According to the link processing method and device provided by the invention, the first terminal device conducts the first member interface and the second member interface which are physically connected through executing the negotiation process with the second terminal device, and determines whether the state of the second member interface of the second terminal device is abnormal or not by receiving the first extended keep-alive message repeatedly sent by the second terminal device after the negotiation process is finished, so that whether the member interface of the opposite terminal is abnormal or not can be sensed in real time after the two terminal devices establish the link connection, and the member interface of the local terminal is closed when the link connection is abnormal, thereby avoiding the phenomenon of single pass of link flow; the method provided by the invention solves the problem that the link reliability is poor due to the phenomenon of single flow caused by the fact that one end of the link can not sense the abnormal state of the opposite end in the link detection method in the prior art.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
The technical solution of the present invention is described in detail below by specific embodiments, where the first terminal device and the second terminal device in the following embodiments of the present invention may be, for example, routers, and a member interface of any terminal device may be a Packet Over SONET/SDH (POS) interface carried by a Synchronous Optical Network (SONET)/Synchronous Digital Hierarchy (SDH). The following specific embodiments of the present invention may be combined, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 3 is a flowchart of a link processing method according to an embodiment of the present invention. The link processing method provided by this embodiment is suitable for the case of performing link detection through the HDLC protocol, and the method may be executed by a link processing apparatus, where the link processing apparatus may be implemented by combining hardware and software, and the link processing apparatus may be integrated in a processor of the first terminal device for being invoked by the processor. As shown in fig. 3, the method of this embodiment may include:
s110, the first terminal device conducts a first member interface of the first terminal device and a second member interface physically connected to the first member interface in the second terminal device by executing a negotiation process, and both the first terminal device and the second terminal device completing the negotiation process have first negotiation information of the first member interface and second negotiation information of the second member interface.
As shown in fig. 4, which is an application scenario diagram of the link processing method provided in the embodiment shown in fig. 3, a router a in fig. 4 is a first terminal device, a router B is a second terminal device, a1 is a first member interface, and B1 is a second member interface, where a1 and B1 are both the POS interfaces, and a1 and B1 are physically connected. In this embodiment, the first terminal device conducts the first member interface and the second member interface by executing the negotiation process, and at this time, a link between the first member interface and the second member interface is conducted, so that data transmission may be performed.
Fig. 5 is a schematic diagram of a negotiation flow in the link processing method according to the embodiment shown in fig. 3; that is, S110 in this embodiment specifically includes:
s1101, the first terminal device sends first negotiation information to the second terminal device, and instructs the second terminal device to store the first negotiation information.
S1102, the first terminal device receives and stores the second negotiation information sent by the second terminal device.
In this embodiment, the first negotiation information may be Local negotiation information (LCI) of the first member interface, and if the LCI is not configured for the first member interface, the first negotiation information may also be a host name (hostname) or an interface name (interface name) of the first member interface; similarly, the second negotiation information may also be the LCI of the second member interface, or the host name or interface name of the first member interface.
S1103, the first terminal device sends a first negotiation packet to the second terminal device, where the first negotiation packet includes first negotiation information and second negotiation information in the first terminal device, and the first negotiation packet is used to instruct the second terminal device to turn on the second member interface when it is determined that the received first negotiation information and second negotiation information are the same as the first negotiation information and second negotiation information in the second terminal device.
S1104, the first terminal device receives a second negotiation packet sent by the second terminal device, where the second negotiation packet includes second negotiation information and first negotiation information in the second terminal device.
S1105, the first terminal device turns on the first member interface when it is determined that the received first negotiation information and the second negotiation information are the same as the first negotiation information and the second negotiation information in the first terminal device.
In this embodiment, taking the first terminal device as an example for description, after receiving the second negotiation packet, but when the second negotiation information fails to be stored, the first terminal device may restart to execute the negotiation process. In addition, in the above steps, the execution sequence of S1101 and S1102, and S1103 and S1104 to S1105 is not limited, that is, the negotiation information or the negotiation packet is sent by which terminal device first, as long as it is possible to realize that each terminal device has the first negotiation information and the second negotiation information, and the member interface of the local terminal can be turned on after receiving the negotiation packet sent by the other terminal, the negotiation process can be completed.
It should be noted that, the on member interface or the off member interface in each embodiment of the present invention refers to protocol on (Up) or protocol off (Down), and performs protocol on or protocol off based on physical connection.
S120, the first terminal device receives a first extended keep-alive message which is repeatedly sent by the second terminal device according to a preset time interval, the first extended keep-alive message comprises first negotiation information and second negotiation information in the second terminal device, and the content of the second negotiation information changes when the second member interface is abnormal.
S130, the first terminal device closes the first member interface when determining that the received first negotiation information and the second negotiation information are different from the first negotiation information and the second negotiation information in the first terminal device.
In this embodiment, after the link protocol between the first member interface and the second member interface is turned on, interaction of the extended keep-alive messages needs to be performed to detect whether the member interfaces of the two-end devices have an abnormal state in real time. In a specific implementation, if the second member interface is in an abnormal state, for example, the sending is normal and the receiving is abnormal as described in the background art, the first terminal device cannot sense the abnormal state of the second member interface in the second terminal device through a link detection mode in the prior art, and the link has a single traffic, that is, data sent from the first terminal device to the second terminal device cannot be received; in contrast, in this embodiment, when the second member interface is abnormal, the content of the second negotiation information may be changed, that is, at this time, the second negotiation information in the first extended keep-alive message sent by the second terminal is different from the content of the second negotiation information stored in the first terminal device, and at this time, the first terminal device may close the first member interface, that is, disconnect the link. After the link is disconnected, the first terminal device may perform the negotiation procedure shown in fig. 5 with the second terminal device again.
Similarly, the first terminal device may also make the second terminal device know the state of the first member interface by sending a second extended keep-alive message to the second terminal device, and the specific manner is: the first terminal device repeatedly sends a second extended keep-alive message to the second terminal device according to a preset time interval, where the second extended keep-alive message includes first negotiation information and second negotiation information in the first terminal device, the content of the first negotiation information changes when the first member interface is abnormal, and the second extended keep-alive message is used to instruct the second terminal device to close the second member interface, that is, disconnect the link, after the link is disconnected, the first terminal device may also execute the negotiation process shown in fig. 5 with the second terminal device again.
In the link processing method provided by this embodiment, the first terminal device conducts the first member interface and the second member interface which are physically connected through executing the negotiation process with the second terminal device, and determines whether the state of the second member interface of the second terminal device is abnormal or not by receiving the first extended keep-alive message repeatedly sent by the second terminal device after the negotiation process is completed, so that it is realized that after the link connection is completed, the two terminal devices can sense whether the member interface of the opposite terminal is abnormal or not in real time, and the member interface of the local terminal is closed when the link connection is abnormal, thereby avoiding the phenomenon of single pass of link traffic; the method provided by the embodiment solves the problem that in the link detection method in the prior art, one end of the link may not sense the abnormal state of the opposite end, so that the flow single pass phenomenon occurs, and the reliability of the link is poor.
Further, fig. 6 is a flowchart of another link processing method according to an embodiment of the present invention, where the first terminal device in this embodiment is further provided with a first timer, and on the basis of the embodiment shown in fig. 3, after S110, the method further includes: s111, the first terminal equipment starts a first timer; s120 may further include: s140, the first terminal device sets the first timer to start timing from zero when determining that the received first negotiation information and the second negotiation information are the same as the first negotiation information and the second negotiation information in the first terminal device. It should be noted that in the present embodiment, S130 and S140 are selectively executed.
The first timer in this embodiment is used for starting timing from zero when the first terminal device receives the first extended keep-alive message and determines that the state of the second member interface is normal, that is, as long as the first timer executes the above steps circularly, a timing value of the first timer will be within a certain range; correspondingly, when the state of the second member interface is abnormal, the state can also be represented by the timing value of the first timer, and the specific implementation manner may be as follows: s150, when detecting that the timing value of the first timer is greater than a first threshold value, the first terminal equipment closes the first member interface; s160, the first terminal device sends a third extended keep-alive message to the second terminal device, wherein the third extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the third extended keep-alive message is used for indicating the second terminal device to close the second member interface; s170, the first terminal device performs the negotiation process with the second terminal device again. In this embodiment, the first threshold may be, for example, 3 timing periods of a timer, where the timing period may be set by a designer according to sensitivity requirements on a link, and if the timing period is not set, the timing period may default to be the same as the timing period of a protection packet in the HDLC protocol, and is usually 10 seconds(s).
When the first terminal device in this embodiment does not receive the first extended keep-alive message sent by the second terminal device for a long time, it is considered that an abnormal problem occurs in the link, and when the first terminal device sends the third extended keep-alive message to the second terminal device, the first negotiation information may not be carried or the content of the first negotiation information may be changed. In this embodiment, after the link negotiation between the first member interface and the second member interface is successful and the first member interface is in the closed state for some reason, the first timer set in the terminal device may notify the second terminal device of the state, and the second member interface may be closed, so that the states of the two ends of the physically connected member interfaces are ensured to be consistent, and further, the single-pass phenomenon of the link is avoided; and when the member interfaces at both ends of the link are in the closed state, the initial negotiation process can be re-entered.
It should be noted that S150 to S170 in this embodiment may be executed after S111, and the first terminal device may check that the timing value of the first timer is overtime after repeatedly receiving the first extended keep-alive packet for multiple times, or may execute S150 to S170 after completing the negotiation process and starting the first timer and not receiving the first extended keep-alive packet. The embodiment shown in fig. 6 is illustrated as S150 to S170 performed after S140. And S130, S140 and S150 to S170 in the embodiment shown in fig. 6 are selectively performed, and S170 may be performed after S130.
Further, on the basis of the foregoing embodiments, the state of the link may also be notified to the terminal device by extending the content of the keep-alive message, as shown in fig. 7, which is a flowchart of another link processing method provided in the embodiment of the present invention, where fig. 7 is shown by taking the embodiment shown in fig. 3 as an example, in S120 of this embodiment, the first extended keep-alive message received by the first terminal device further includes a third timer, and the third timer starts to count time from when the first extended keep-alive message is sent out, and in a possible implementation manner, the method provided in this embodiment further includes, after S120: s140, when the timing value of the third timer is less than or equal to the second threshold, and it is determined that the received first negotiation information and the second negotiation information are the same as the first negotiation information and the second negotiation information in the first terminal device, the first terminal device maintains the current state of the first member interface, and if the first terminal device has the first timer and the first timer is started, the first timer may also be set to start timing from zero; in another possible implementation manner, after S120, the method provided in this embodiment further includes: s150, when the timing value of the third timer is greater than a second threshold value, the first terminal equipment closes the first member interface; s160, the first terminal device sends a fourth extended keep-alive message to the second terminal device, the fourth extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the fourth extended keep-alive message is used for indicating the second terminal device to close the second member interface; s170, the first terminal device performs the negotiation process with the second terminal device again.
As shown in fig. 8, a format schematic diagram of a first extended keep-alive message of the link processing method provided in the embodiment shown in fig. 7 is shown, where the first extended keep-alive message in this embodiment includes local end negotiation information (i.e., second negotiation information), opposite end negotiation information (i.e., first negotiation information), and a timer, where each item of content is composed of a Type (Type), a Length (Length), and a Value (Value) (abbreviated as: TLV), for example, the local end negotiation information is preset in the second terminal device, the opposite end negotiation information is filled when the second terminal device executes a negotiation process, and if the filling is not successful, the opposite end negotiation information is 0, and the timer starts to time when the second terminal device sends the first extended keep-alive message; meanwhile, the first extended keep-alive message further includes a standard format of the keep-alive message in a standard protocol, that is, the content shown in fig. 2.
It should be noted that the implementation and technical effects of S150 to S170 in this embodiment are the same as those of S150 to S170 in the embodiment shown in fig. 6, and therefore, no further description is provided herein; in addition, S130, S140, and S150 to S170 in this embodiment are selectively performed, specifically, different selections are made by the first terminal device according to the content in the first extended keep-alive message, and S170 may also be performed after S130.
Similarly, the second terminal device in this embodiment may be provided with a second timer, where the second timer starts timing after the second member interface is turned on, and the second extended keep-alive message sent by the first terminal device is further used to instruct the second terminal device to set the second timer to start timing from zero when it is determined that the received first negotiation information and the second negotiation information are the same as the first negotiation information and the second negotiation information in the second terminal device. In addition, the second terminal device in this embodiment may also determine whether the link is in an abnormal state according to a timing value of the second timer, and the second extended keep-alive message may also be provided with a timer.
In the specific implementation of the present invention, in order to improve the communication capability of the link, a plurality of POS interfaces may be bundled into one interface, which is called a member Group (POS-Group) interface (hereinafter, referred to as a PG interface for short), and the sum of the PG interfaces is the sum of the bandwidths of the member interfaces, and in this way, the bandwidth of the interface may be increased; for example, the first terminal device further has a third member interface, the fourth member interface in the second terminal device is physically connected to the third member interface, and the third negotiation information of the third member interface is the same as the first negotiation information, then on the basis that the links of the first member interface and the second member interface have been established in the above embodiment, if the fourth negotiation information of the fourth member interface is the same as the second negotiation information, the first terminal device may execute the negotiation process again to conduct the third member interface and the fourth member interface; and if the fourth negotiation information is different from the second negotiation information, the establishment of the link between the third member interface and the fourth member interface cannot be realized.
It should be noted that, in this embodiment, the first member interface and the third member interface are a bundled PG interface, and the second member interface and the fourth member interface are a bundled PG interface, and load sharing can be implemented through the PG interface, and the PG interface disperses traffic on different links and finally reaches a unified destination, so that traffic congestion caused by traffic all traveling along the same path can be avoided. In addition, the PG interface can also improve the reliability of the link, and in the PG interface, if a certain member interface is abnormal in state, the flow can be transmitted by depending on other member interfaces.
The application of the PG interface is specifically described below by some specific examples. For example, as shown in fig. 9, an application scenario diagram of the link processing method provided by the embodiment of the present invention is shown, for example, in fig. 9, a router a is a first terminal device, a router B is a second terminal device, a bundling port PG1 of an HDLC of the router a includes three member interfaces a1, a2, and A3, a bundling port PG2 of an HDLC of the router B includes three member interfaces B1, B2, and B3, and physical connection relations are a1 to B1, a2 to B2, and A3 to B3, where LCI information of the member interfaces a1, a2, and A3 are the same, LCI information of the B1 and B2 are the same, and LCI information of the B3 is not equal to LCI information of the B1. On the one hand, assuming that the link between a1 and B1 is successfully negotiated first, the LCI information sent by B2 to a2 is equal to the LCI information of activated member interface B1, the link negotiation between a2 and B2 is successful, the LCI information sent by B3 to A3 is not equal to the LCI information of activated member interface B1, and the link negotiation between A3 and B3 is failed. On the other hand, in the application scenario, the LCI information of the B2 member interface is modified to be LCI information not equal to B1, and thereafter, the LCI information of the B2 end in the first extended keep-alive message sent by the B2 received by the a2 is different from the LCI information of the B2 stored in the router a, the router a protocol closes the member interface a2, and clears the stored LCI information of the B2; similarly, if the LCI information sent from a2 and received by B2 is different from the LCI information of a2 and stored in router B, the router B protocol closes the member interface B2, clears the stored LCI information of a2, and then enters the initial negotiation process to re-perform the link negotiation.
For another example, as shown in fig. 10, for another application scenario of the link processing method provided by the embodiment of the present invention, for example, the router a in fig. 10 is a first terminal device, the router B and the router C are both second terminal devices, the binding port PG1 of the HDLC of the router a includes four member interfaces a1, a2, A3, and A4, the binding port PG2 of the HDLC of the router B includes two member interfaces B1 and B2, the binding port PG3 of the HDLC of the router C includes two member interfaces C1 and C2, the physical connection relationships are that a1 connects to B1, a2 connects to B2, A3 connects to C1, A4 connects to C2, and LCI information of a1, a2, A3, and A4 are the same, LCI information of B1 and B2 is the same, LCI information of C1 and C2 is the same, but the router information is different from the router C information of the router B. If three devices perform link negotiation through the negotiation process provided by the present invention at the same time, the router a receives LCI information sent by the router B and the router C, and a contention mechanism is adopted, the sub-link of which device completes the negotiation process in fig. 5 first, and the member interface of which device completes negotiation first, for example, the router C completes the negotiation process with the router a first, the link of the router B cannot successfully negotiate.
It should be noted that, the link processing method provided in each embodiment of the present invention may set an extension protocol switch for a member interface or a PG interface of a terminal device, execute the link processing method described in each embodiment when the extension protocol switch is turned on, and perform link establishment and detection by using a method in the prior art when the extension protocol switch is turned off. In addition, the second terminal device in each embodiment of the present invention executes the negotiation process, and the manner of performing link detection after the link negotiation is successful is the same as the manner of executing the first terminal device, which is not described herein again.
Fig. 11 is a schematic structural diagram of a link processing apparatus according to an embodiment of the present invention. The link processing apparatus provided in this embodiment is suitable for use in the case of performing link detection through the HDLC protocol, and the link processing apparatus is implemented by combining hardware and software, and the apparatus may be integrated in a processor of the first terminal device for being invoked by the processor. As shown in fig. 11, the link processing apparatus of this embodiment specifically includes: a negotiation module 11, a receiving module 12, a processing module 13 and a sending module 14.
The negotiation module 11 is configured to conduct a first member interface of the first terminal device and a second member interface, which is physically connected to the first member interface, of the second terminal device by executing a negotiation process, and both the first terminal device and the second terminal device that complete the negotiation process have first negotiation information of the first member interface and second negotiation information of the second member interface.
In this embodiment, after the negotiation process is executed, a link between the first member interface and the second member interface is protocol-conducted, and data transmission may be performed, and a specific process of the negotiation process in this embodiment is specifically described in the following embodiments.
It should be noted that, turning on or turning off the member interface in each embodiment of the present invention refers to protocol turning on or protocol turning off, and the protocol turning on or protocol turning off is performed on the basis of physical connection.
A receiving module 12, configured to receive a first extended keep-alive message repeatedly sent by a second terminal device according to a preset time interval, where the first extended keep-alive message includes first negotiation information and second negotiation information in the second terminal device, and a content of the second negotiation information changes when a second member interface is abnormal.
A processing module 13, configured to close the first member interface when it is determined that the first negotiation information and the second negotiation information received by the receiving module 12 are different from the first negotiation information and the second negotiation information in the first terminal device.
In this embodiment, when the second member interface is abnormal, the content of the second negotiation information may be changed, that is, at this time, the content of the second negotiation information in the first extended keep-alive message sent by the second terminal is different from the content of the second negotiation information stored in the first terminal device, and at this time, the first terminal device may close the first member interface, that is, disconnect the link. After the link is disconnected, the negotiation module 11 may perform the negotiation procedure shown in fig. 5 with the second terminal device again.
Similarly, the first terminal device may also make the second terminal device know the state of the first member interface by sending a second extended keep-alive message to the second terminal device, and the specific manner is: the link processing apparatus provided in this embodiment further includes: a sending module 14, configured to repeatedly send a second extended keep-alive message to the second terminal device according to a preset time interval, where the second extended keep-alive message includes first negotiation information and second negotiation information in the first terminal device, a content of the first negotiation information changes when the first member interface is abnormal, and the second extended keep-alive message is used to instruct the second terminal device to close the second member interface when it is determined that the received first negotiation information and second negotiation information are different from the first negotiation information and second negotiation information in the second terminal device.
The link processing apparatus provided in the embodiment of the present invention is configured to execute the link processing method provided in the embodiment shown in fig. 3 of the present invention, and has corresponding functional modules, which implement similar principles and technical effects, and are not described herein again.
Fig. 12 is a schematic structural diagram of another link processing apparatus according to an embodiment of the present invention, which illustrates an execution process of a negotiation flow in each embodiment of the present invention through the embodiment shown in fig. 12, where the negotiation module 11 includes: a sending unit 15, configured to send the first negotiation information to the second terminal device, and instruct the second terminal device to store the first negotiation information.
And a receiving unit 16, configured to receive and store the second negotiation information sent by the second terminal device.
The sending unit 15 is further configured to send a first negotiation message to the second terminal device, where the first negotiation message includes first negotiation information and second negotiation information in the first terminal device, and the first negotiation message is used to instruct the second terminal device to turn on the second member interface when it is determined that the received first negotiation information and second negotiation information are the same as the first negotiation information and second negotiation information in the second terminal device.
The receiving unit 16 is further configured to receive a second negotiation packet sent by the second terminal device, where the second negotiation packet includes second negotiation information and first negotiation information in the second terminal device.
The processing unit 17 is configured to determine that the first negotiation information and the second negotiation information received by the receiving unit 16 are the same as the first negotiation information and the second negotiation information in the first terminal device, and turn on the first member interface.
In this embodiment, after receiving the second negotiation packet, the first terminal device may restart to execute the negotiation procedure when the second negotiation information is failed to be stored. In the process of the negotiation process, it is not limited which terminal device sends the negotiation information or the negotiation message first, and the negotiation process can be completed as long as it can be realized that each terminal device has the first negotiation information and the second negotiation information, and the member interface of the local terminal can be conducted after the negotiation message sent by the opposite side is received.
It should be noted that the modules and units in the embodiments of the present invention are all virtual modules and units that implement specific functions, and the sending unit 15 in this embodiment may be implemented by the same physical device as the sending module 14, the receiving unit 16 and the receiving module 12 in fig. 11, and the processing unit 17 and the processing module 13 may be implemented by different physical devices; for example, the transmitting unit 15 and the transmitting module 14 may be the same transmitter, the receiving unit 16 and the receiving module 12 may be the same receiver, and the processing unit 17 and the processing module 13 may be the same processor.
Further, fig. 13 is a schematic structural diagram of another link processing apparatus according to an embodiment of the present invention, where a first terminal device in this embodiment is further provided with a first timer, and on the basis of the embodiment shown in fig. 11, the link processing apparatus in this embodiment further includes: the starting module 18 is configured to start the first timer after the negotiation module 11 conducts the first member interface of the first terminal device and the second member interface, which is physically connected to the first member interface, of the second terminal device by executing the negotiation process; the processing module 13 is further configured to set the first timer to start timing from zero when it is determined that the first negotiation information and the second negotiation information received by the receiving module 12 are the same as the first negotiation information and the second negotiation information in the first terminal device. It should be noted that, in this embodiment, the processing module 13 turns off the first member interface and the processing module 13 sets the first timer to be selectively executed from zero.
The first timer in this embodiment is used for starting timing from zero when the first terminal device receives the first extended keep-alive message and determines that the state of the second member interface is normal, that is, as long as the first timer executes the above steps circularly, a timing value of the first timer will be within a certain range; correspondingly, when the state of the second member interface is abnormal, the state can also be represented by the timing value of the first timer, and the specific implementation manner may be as follows: the processing module 13 is further configured to close the first member interface when detecting that the timing value of the first timer is greater than a first threshold value; a sending module 14, configured to send a third extended keep-alive message to the second terminal device, where the third extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the third extended keep-alive message is used to instruct the second terminal device to close the second member interface; and the negotiation module 11 is further configured to perform a negotiation procedure with the second terminal device again. It should be noted that the above processing procedure is specifically executed after the first timer is started.
The link processing apparatus provided in the embodiment of the present invention is configured to execute the link processing method provided in the embodiment shown in fig. 6 of the present invention, and has corresponding functional modules, which implement similar principles and technical effects, and are not described herein again.
Further, on the basis of the foregoing embodiments, the state of the link may also be notified to the terminal device by extending the content of the keep-alive message, specifically, the first extended keep-alive message received by the receiving module 12 further includes a third timer, and the third timer starts timing when the third extended keep-alive message is sent out; in a first possible implementation manner, the processing module 13 is further configured to, when the timing value of the third timer is less than or equal to a second threshold, and it is determined that the first negotiation information and the second negotiation information received by the receiving module 12 are the same as the first negotiation information and the second negotiation information in the first terminal device, maintain the current state of the first member interface, and in a case that the first terminal device has the first timer, the first timer may also be set to start timing from zero; in a second possible implementation manner, the processing module 13 is further configured to close the first member interface when the timing value of the third timer is greater than a second threshold; at this time, the sending module 14 is further configured to send a fourth extended keep-alive message to the second terminal device, where the fourth extended keep-alive message does not carry the first negotiation information or carries the first negotiation information after content change, and the fourth extended keep-alive message is used to instruct the second terminal device to close the second member interface; and the negotiation module 11 is further configured to perform a negotiation procedure with the second terminal device again. It should be noted that, the format of the first extended keep-alive packet in this embodiment may also refer to the format shown in fig. 8, and the content and the function of the first extended keep-alive packet are the same as those in the foregoing embodiment, and therefore, the description is not repeated here.
The link processing apparatus provided in the embodiment of the present invention is configured to execute the link processing method provided in the embodiment shown in fig. 7 of the present invention, and has corresponding functional modules, which implement similar principles and technical effects, and are not described herein again.
Similarly, the second terminal device in this embodiment may be provided with a second timer, where the second timer starts timing after the second member interface is turned on, and the second extended keep-alive message sent by the first terminal device is further used to instruct the second terminal device to set the second timer to start timing from zero when it is determined that the received first negotiation information and the second negotiation information are the same as the first negotiation information and the second negotiation information in the second terminal device. In addition, the second terminal device in this embodiment may also determine whether the link is in an abnormal state according to a timing value of the second timer, and the second extended keep-alive message may also be provided with a timer.
In the specific implementation of the invention, in order to improve the communication capacity of the link, a plurality of POS interfaces can be bound into one PG interface; for example, the first terminal device further has a third member interface, the fourth member interface in the second terminal device is physically connected to the third member interface, and the third negotiation information of the third member interface is the same as the first negotiation information, so that on the one hand, the processing module 13 is further configured to execute a negotiation process to conduct the third member interface and the fourth member interface when the fourth negotiation information of the fourth member interface is the same as the second negotiation information on the one hand, on the basis that the links of the first member interface and the second member interface have been established in the above embodiment; on the other hand, the processing module 13 is further configured to fail to execute the negotiation process when the fourth negotiation information of the fourth member interface is different from the second negotiation information. The specific application of the PG interface in this embodiment may refer to the application scenarios and execution manners shown in fig. 9 and fig. 10, and therefore, details are not described herein again.
Although the embodiments of the present invention have been described above, the above description is only for the convenience of understanding the present invention, and is not intended to limit the present invention. It will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims.