Fault protection method, node, and storage medium

This application discloses a fault protection method, including: A first node determines that a first cross-domain node is faulty. The first node is a head node of a segment routing best effort SR-BE service tunnel, the SR-BE tunnel is a cross-domain tunnel that passes through a first IGP domain and a second IGP domain, the SR-BE tunnel passes through the first cross-domain node, and the first cross-domain node is a node that crosses the first IGP domain and the second IGP domain. The first node switches a service transmission path from the SR-BE tunnel to a backup tunnel. The backup tunnel does not pass through the first cross-domain node, and the backup tunnel is a tunnel with a strict explicit path.

TECHNICAL FIELD

This application relates to the field of communications technologies, and in particular, to a fault protection method.

BACKGROUND

Segment routing (SR) is a method that a control plane, by using an interior gateway protocol (IGP), transfers a multi-protocol label switching (MPLS) label that corresponds to an SR router and that is of a global node or of a local node. A segment routing best effort (SR-BE) service is one of segment routing methods. An optimal segment routing label switching path (SR LSP) is calculated by the IGP by using a shortest path first (SPF) algorithm.

Currently, for the SR-BE, if nodes on a path are in a same IGP domain, a backup tunnel calculation method may be a topology-independent loop-free alternate (TI-LFA) fast reroute algorithm. The TI-LFA algorithm calculates extended P space, Q space, and a post-convergence shortest path tree based on a protection path, calculates a repair list based on different scenarios, and establishes an SR-BE tunnel between a head node and a PQ node to form a backup path to a next hop for protection. When the node on the path is faulty, the service is automatically switched to the backup tunnel and forwarding continues. This improves network reliability.

However, in a scenario in which the nodes on the path are located in two or more IGP domains, a primary cross-domain node and a secondary cross-domain node are included between every two IGP domains, and a route of one IGP domain is preferentially advertised to the other IGP domain by using the primary cross-domain node. When the primary cross-domain node is faulty, using the TI-LFA algorithm cannot automatically switch packet forwarding to the secondary cross-domain node. Usually, a fault of the primary cross-domain node is detected through IGP convergence. During IGP convergence, a packet is still preferentially forwarded to the primary cross-domain node on a selected forwarding path. This causes packet loss for a long time, and poor network reliability.

SUMMARY

Embodiments of this application provide a fault protection method, a node, and a storage medium. A path that does not pass through a primary cross-domain node is pre-calculated as a backup tunnel, and the backup tunnel is a tunnel with a strict explicit path. When the primary cross-domain node is faulty, a service transmission path is directly switched to the backup tunnel, to improve network reliability.

To resolve the foregoing technical problem, the embodiments of this application provide the following technical solutions.

According to a first aspect of this application, a fault protection method is provided. The method may include: A first node determines that a first cross-domain node is faulty. The first node is a head node of a segment routing best effort SR-BE service tunnel. The SR-BE tunnel is a cross-domain tunnel that passes through a first IGP domain and a second IGP domain, and the first IGP domain is different from the second IGP domain. The SR-BE tunnel passes through the first cross-domain node, and the first cross-domain node is a node that crosses the first IGP domain and the second IGP domain, and is configured to advertise a route of the first IGP domain to the second IGP domain or advertise a route of the second IGP domain to the first IGP domain. The first node switches a service transmission path from the SR-BE tunnel to a backup tunnel. The backup tunnel does not pass through the first cross-domain node, the backup tunnel is a cross-domain tunnel that passes through the first IGP domain and the second IGP domain, and the backup tunnel is a tunnel with a strict explicit path, that is, the backup tunnel is specified by a strict label stack, so that a service packet may be forwarded along the backup tunnel. It can be learned from the foregoing first aspect that, when determining that the first cross-domain node is faulty, the first node may directly switch the service transmission path to the backup tunnel, to improve network reliability.

Optionally, with reference to the first aspect, in a first possible implementation, the method may further include: The first node obtains the backup tunnel based on a first node set. The first node set does not include the first cross-domain node.

Optionally, with reference to the first possible implementation of the first aspect, in a second possible implementation, that the first node obtains the backup tunnel based on a first node set may include: The first node determines a first shortest path from the first node to a tail node based on the first node set. The first shortest path is the backup tunnel. The second possible implementation of the first aspect provides a specific manner of determining a backup tunnel.

Optionally, with reference to the first aspect or the first or the second possible implementation of the first aspect, in a third possible implementation, after the first node switches the service transmission path from the SR-BE tunnel to the backup tunnel, the method may further include: The first node sends a first packet through the backup tunnel. A label stack is encapsulated in the first packet, and the label stack specifies each node that the backup tunnel passes through.

Optionally, with reference to the first possible implementation of the first aspect, in a fourth possible implementation, that the first node obtains the backup tunnel based on a first node set may include: The first node determines a second shortest path from the first node to a second cross-domain node based on the first node set. The second shortest path and a third shortest path from the second cross-domain node to a tail node jointly form the backup tunnel, the third shortest path does not pass through the first cross-domain node, and the second cross-domain node is a node that crosses the first IGP domain and the second IGP domain.

Optionally, with reference to the fourth possible implementation of the first aspect, in a fifth possible implementation, after the first node switches the service transmission path from the SR-BE tunnel to the backup tunnel, the method may further include: The first node sends a second packet through the second shortest path. A label stack is encapsulated in the second packet, and the label stack specifies each node that the second shortest path passes through.

Optionally, with reference to the first aspect or the first to the fifth possible implementations of the first aspect, in a sixth possible implementation, before the first node determines that the first cross-domain node is faulty, the method may further include:

A bidirectional forwarding detection BFD session is established between the first node and the first cross-domain node. That a first node determines that a first cross-domain node is faulty may include: The first node determines, based on the BFD session, that the first cross-domain node is faulty.

Optionally, with reference to the first aspect or the first to the sixth possible implementations of the first aspect, in a seventh possible implementation, before the first node determines that the first cross-domain node is faulty, the method may further include:

The first node sends a third packet through the SR-BE tunnel. An outer label of the third packet is a node label of a next hop to a destination address.

According to a second aspect of this application, a node is provided. The node has a function of implementing the method in any one of the first aspect or the possible implementations of the first aspect. The function may be implemented by hardware, or may be implemented by hardware by executing corresponding software. The hardware or the software includes one or more modules corresponding to the function.

According to a third aspect of this application, a computer-readable storage medium is provided. The computer-readable storage medium stores instructions, and when the instructions are run on a computer, the computer is enabled to perform the fault protection method in any one of the first aspect or the possible implementations of the first aspect.

According to a fourth aspect of this application, a computer program product including instructions is provided. When the computer program product is run on a computer, the computer is enabled to perform the fault protection method in any one of the first aspect or the possible implementations of the first aspect.

According to a fifth aspect of this application, a system is provided. The system may include a first node, a first cross-domain node, and a second cross-domain node. The first node is the first node described in any one of the first aspect or the possible implementations of the first aspect, the first cross-domain node is the first cross-domain node described in any one of the first aspect or the possible implementations of the first aspect, and the second cross-domain node is the second cross-domain node described in any one of the first aspect or the possible implementations of the first aspect.

In the embodiments of this application, a path that does not pass through a primary cross-domain node is pre-calculated as a backup tunnel, and the backup tunnel is a tunnel with a strict explicit path. When the primary cross-domain node is faulty, a service transmission path is directly switched to the backup tunnel, to improve network reliability.

DETAILED DESCRIPTION OF ILLUSTRATIVE EMBODIMENTS

The following describes embodiments of this application with reference to the accompanying drawings. It is clear that the described embodiments are merely a part rather than all of the embodiments of this application. A person of ordinary skill in the art may learn that as a technology evolves and a new scenario emerges, the technical solutions provided in the embodiments of this application are also applicable to a similar technical problem.

The embodiments of this application provide a fault protection method, a node, and a storage medium. A path that does not pass through a primary cross-domain node is pre-calculated as a backup tunnel, and the backup tunnel is a tunnel with a strict explicit path. When the primary cross-domain node is faulty, a service transmission path is directly switched to the backup tunnel, to improve network reliability. The following provides description in detail.

In the specification, claims, and accompanying drawings of this application, the terms “first”, “second”, and so on are intended to distinguish between similar objects but do not necessarily indicate a specific order or sequence. It should be understood that the data termed in such a way is interchangeable in a proper circumstance, so that the embodiments described herein can be implemented in other orders than the order illustrated or described herein. In addition, the terms “include”, “contain”, and any other variants mean to cover the non-exclusive inclusion, for example, a process, method, system, product, or device that includes a list of steps or modules is not necessarily limited to those steps or modules, but may include other steps or modules not expressly listed or inherent to such a process, method, system, product, or device. Names or numbers of steps in this application do not mean that the steps in the method procedure need to be performed in a chronological/logical order indicated by the names or numbers. An execution sequence of the steps in the procedure that have been named or numbered may be changed based on technical objectives to be implemented, provided that a same or similar technical effect can be achieved. Division into modules in this application is logical division and may be another division in an actual implementation. For example, a plurality of modules may be combined or integrated into another system, or some features may be ignored or not performed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections may be implemented through some interfaces. The indirect couplings or communication connections between the modules may be implemented in electronic or another similar form. This is not limited in this application. In addition, modules or sub-modules described as separate components may be or may not be physically separated, or may be or may not be physical modules, or may not be grouped into a plurality of circuit modules. Objectives of the solutions of this application may be achieved by selecting some or all of the modules based on an actual requirement.

Segment routing (SR) is a method that a control plane, by using an interior gateway protocol (IGP), transfers a multi-protocol label switching (MPLS) label that corresponds to an SR router and that is of global significance or of local significance. A segment identifier is added to a packet by using a head node, to control a transmission path of the packet in an entire network. A basic concept of the SR is to divide the network into different segments, and then combine the segments to guide the packet to be forwarded along a specified path. A segment routing best effort (SR-BE) service is one of segment routing methods. An optimal segment routing label switching path (SR LSP) is calculated by the IGP by using a shortest path first (SPF) algorithm. In a same IGP domain, in a forwarding process of an SR-BE tunnel, the head node sends the packet through the SR-BE tunnel. An outer label of the packet is a node label of a next hop to a destination address.FIG.1is a schematic diagram of a forwarding process of an SR-BE tunnel in a same IGP domain. As shown inFIG.1, the IGP domain includes a node A, a node B, a node C, a node D, a node E, a node F, a node G, a node H, and a node I. When the node A sends a packet to the node E, the node E first advertises a prefix segment identifier (SID) of the node E to each router in the IGP domain. Then, each router calculates an identifier of each router to the node E in a local link state database (LSDB) based on a segment routing global block (SRGB) and the prefix SID of the node E. It is assumed that, after calculation, identifiers of the node A to the node E, the node B to the node E, the node C to the node E, and the node D to the node E are respectively5005,4005,3005, and2005. It is assumed that a tunnel generated based on a shortest path of the IGP is from the node A to the node B to the node C to the node D to the node E. During forwarding, the tunnel generated based on the shortest path of the IGP is used for forwarding. Specifically, during forwarding, a node label of a next hop to a destination address is encapsulated to guide forwarding. To be specific, the node A encapsulates a label4005. The node B, after receiving the label4005, learns that the packet is forwarded to the node E, removes the original label, changes the original label to a label3005, and sends the packet to the node C. The node C, after receiving the label3005, learns that the packet is forwarded to the node E, removes the original label, changes the original label to a label2005, and sends the packet to the node E.

For the SR-BE, if nodes on a path are in a same IGP domain, and an intermediate node is faulty, a backup tunnel calculation method may be a topology-independent loop-free alternate path fast reroute (topology Independent Loop-free-alternate algorithm, TI-LFA) algorithm. The TI-LFA algorithm calculates extended P space, Q space, and a shortest path tree based on a protection path, calculates a repair list based on different scenarios, and establishes an SR-BE tunnel between a head node and a PQ node to form a backup path to a next hop for protection. When a protection link is faulty, a service transmission path is automatically switched to a backup tunnel and forwarding continues. This improves network reliability.

In the embodiments of this application, the “node” may be a device that forwards a service packet. For example, the “node” may be a router, a switch, an optical transport network (OTN) device, a packet transport network (PTN) device, or a wavelength division multiplexing (WDM) device. The following describes an implementation process of a TI-LFA.FIG.2is a schematic diagram of an implementation process of a TI-LFA in a same IGP domain. It is assumed that a service transmission path is from a PE1 to a P1 to a P5 to a PE3. To avoid packet loss caused by a fault of a P1 node, the TI-LFA calculates extended P space, Q space, and a repair list repair list, and finally generates a backup forwarding entry, namely, a backup tunnel. A specific process is as follows: The extended P space is calculated first. In the extended P space, all neighbors of a head node are used as root nodes to establish SPF trees respectively. A node set that includes all reachable nodes starting from the root node and excluding the faulty node is referred to as the extended P space. As shown inFIG.2, the head node is the PE1, and the P1 and a PE2 are the neighbors of the PE1. The P1 is not considered because the P1 is the faulty node. The SPF tree is established by using the PE2 as the root node. A path cost COST value is a ratio of a reference base to a physical bandwidth. The reference base is a specific value, and is usually set to be greater than a maximum link bandwidth. The physical bandwidth is a total bandwidth allocated to a link. After a COST value of each link is calculated according to a formula, the COST values of all the links that arrive at a destination are added to obtain a link set including a minimum COST value. The link set is a shortest path. It is assumed that a COST value between the PE1 and the PE2 is 40, a COST value between the PE1 and the P1 is 10, a COST value between the PE2 and a P2 is 10, a COST value between the P2 and the P1 is 15, a COST value between the P2 and a P3 is 20, a COST value between the P3 and a P4 is 40, a COST value between the P4 and the P5 is 40, a COST value between the P4 and the P1 is 20, a COST value between the P5 and the PE3 is 10, and a COST value between the P5 and the P1 is 39, shortest paths from the P2 to the PE2 and from the P3 to the PE2 do not need to pass through the faulty node, and shortest paths from the P4 to the PE2 and from the P5 to the PE2 need to pass through the faulty node. Therefore, the extended P space includes the PE2, the P2, and the P3. Then, the Q space is calculated by using a tail node as the root node to generate a reverse SPF tree. Shortest paths from the P5 to the PE3 and from the P4 to the PE3 do not need to pass through the faulty node, and shortest paths from the P3 to the PE3, from the P2 to the PE3, and from the PE2 to the PE3 need to pass through the faulty node. Therefore, the Q space includes the P4 and the P5. InFIG.2, the extended P space and the Q space do not overlap, and a P node and a Q node with a shortest path distance are the P3 and the P4 respectively. The repair list is a constrained path, and is used to indicate how to reach the Q node. The repair list includes “a P node label and an adjacent label on a path from the P node to the Q node”. InFIG.2, the repair list includes a node label100of the P3 and an adjacent label9304from the P3 to the P4. In this case, the backup tunnel is generated, namely, the PE1 to the PE2 to the P2 to the P3 to the P4 to the P5 to the PE3.

However, the TI-LFA algorithm is not applicable in some scenarios, for example, a scenario in which a node on a path is in two or more IGPs. To describe the problem, the following provides description by using an example of two IGP domains and a primary cross-domain node and a secondary cross-domain node in two IGP domains.FIG.3is a schematic diagram of a forwarding process of an SR-BE tunnel in two IGP domains. A cell site gateway (CSG) CSG1and a CSG2and an aggregation side gateway (ASG) ASG1and an ASG2belong to a first IGP domain. The ASG1, the ASG2, and a radio network controller site gateway (RSG) RSG1and an RSG2belong to a second IGP domain. The ASG1and the ASG2are cross-domain nodes. Routes of the CSG1and the CSG2is preferentially transmitted to the RSG1and RSG2by using the primary cross-domain node. Selection of the primary cross-domain node and the secondary cross-domain node is determined by a COST value. For example, in a scenario shown inFIG.3, for a COST value of a CSG route in terms of an RSG, a COST value of a route imported by the ASG1is 100+20=120, and a COST value of a route imported by the ASG2is 100+100+10+20=230. Because120is less than 230, the ASG1is determined to be the primary cross-domain node and the ASG2is determined to be the secondary cross-domain node. It may be understood that a scenario with a plurality of IGP domains may be further developed based on the scenario with two IGP domains, that is, a network includes two or more IGP domains, and a primary cross-domain node and a secondary cross-domain node are included between each two IGP domains. For example, if a network includes three IGP domains, namely, a first IGP domain, a second IGP domain, and a third IGP domain. A first node and a second node are nodes that cross the first IGP domain and the second IGP domain, the first node is a primary cross-domain node, and the second node is a secondary cross-domain node. A third node and a fourth node are nodes that cross the second IGP domain and the third IGP domain, the third node is a primary cross-domain node, and the fourth node is a secondary cross-domain node. It should be understood that a scenario with a plurality of IGP domains is similar to the scenario with two IGP domains. Therefore, the scenario with a plurality of IGP domains is an extended application scenario or a specific application mode of the scenario with two IGP domains.

With reference toFIG.3, the following describes the TI-LFA algorithm applicable to the scenario with two IGP domains. It is assumed that a packet is sent from the RSG1to the CSG1, that is, a head node is the RSG1and a tail node is the CSG1. To avoid packet loss caused by a fault of the primary cross-domain node ASG1, extended P space is calculated according to the TI-LFA algorithm. As shown inFIG.3, the head node is the RSG1, and the ASG1and the RSG2are the neighbors of the RSG1. The ASG1is not considered because the ASG1a faulty node. An SPF tree is established by using the RSG2as a root node. Shortest paths from the ASG2to the RSG2, from the CSG2to the RSG2, and from the CSG1to the RSG2do not need to pass through the faulty node. Therefore, the extended P space includes the ASG2, the CSG2, the CSG1, and the RSG2. Then, Q space is calculated by using the tail node as a root node to generate a reverse SPF tree. Shortest paths from the CSG2to the CSG1, from the ASG2to the CSG1, and from the RSG2to the CSG1do not need to pass through the faulty node. Therefore, the Q space includes the ASG2, the CSG2, and the RSG2. InFIG.3, the extended P space overlaps the Q space. The RSG2is a PQ node. The PQ node is a node in both the extended P space and the Q space. The PQ node is a destination end to protect a tunnel. According to the TI-LFA algorithm, an SR-BE tunnel is established between the head node and the PQ node to form a backup path to a next hop for protection, and the faulty node is the primary cross-domain node ASG1. For the RSG2, the ASG1is a remote fault, and the RSG2may detect that the ASG1is faulty only through IGP convergence. Convergence is a process of determining an alternative path when a path is unavailable, and is a process that all routers determine that a path is an optimal path. When a network event causes a route to be available or unavailable, the router sends update information. The route update information is transmitted in the entire network, causing recalculation of an optimal path, to obtain the optimal path determined by all routers. In the scenario corresponding toFIG.3, the RSG2notifies all nodes in the domain of fault information hop by hop by using an IGP update message. During IGP convergence, a packet is always preferentially forwarded on a path selected by the RSG2, instead of the ASG1, and the packet is forwarded to the ASG1for a period of time, causing packet loss for a long time.

To resolve the foregoing problem, the embodiments of this application provide a fault protection method.FIG.4is a schematic flowchart of a fault protection method400according to an embodiment of this application.

As shown inFIG.4, the fault protection method400provided in this embodiment of this application may include the following steps.

401: A head node determines that a primary cross-domain node is faulty.

The head node is a head node of an SR-BE tunnel. A network in which the SR-BE tunnel is located includes two IGP domains. The SR-BE tunnel is a cross-domain tunnel that passes through the two IGP domains. Routes of every two IGP domains may notify with each other by using a cross-domain node, and the SR-BE tunnel passes through the cross-domain node. For example, in the scenario corresponding toFIG.3, the ASG1and the ASG2are cross-domain nodes, and the routes of the CSG1and the CSG2may be transmitted to the RSG1and the RSG2by using the ASG1or the ASG2respectively, and routes of the RSG1and the RSG2may also be transmitted to the CSG1and the CSG2by using the ASG1or the ASG2respectively. In this embodiment of this application, the head node obtains node fault information of the primary cross-domain node. The following provides further description with reference toFIG.3. If a service transmission path is from the RSG1to the CSG1, the head node obtains the node fault information of the primary cross-domain node, in other words, the RSG1obtains fault information of the ASG1. For a process of selecting the primary cross-domain node and the secondary cross-domain node from the ASG1and the ASG2, refer to the foregoing descriptions. Details are not described herein and below again. It should be noted that the head node may also be referred to as a first node or a source node, and a name of the node is not limited in this application.

In a specific implementation, the head node may obtain the fault information of the primary cross-domain node by using a bidirectional forwarding detection (BFD) protocol. Specifically, the head node may establish in advance BFD for detecting a node fault, for example, seamless bidirectional forwarding detection (S-BFD), with the primary cross-domain node, to determine that the primary cross-domain node is faulty.

402: The head node switches the service transmission path to a backup tunnel. The backup tunnel is a tunnel with a strict explicit path.

After obtaining that the primary cross-domain node is faulty, the head node switches to the backup tunnel. The backup tunnel is a tunnel that is pre-generated by the head node and that does not pass through the primary cross-domain node. The backup tunnel is also a tunnel that passes through two IGP domains. The backup tunnel is the tunnel with a strict explicit path, in other words, the backup tunnel is specified by the strict label stack, so that a service packet can be forwarded along the backup tunnel.

It can be learned from the method400that the backup tunnel needs to be pre-stored in the head node, so that the head node may directly switch to the backup tunnel after determining that the primary cross-domain node is faulty. It should be noted that the backup tunnel may be determined by using different methods. In some embodiments, the backup tunnel is a shortest path from the head node to a tail node. In some embodiments, the backup tunnel is a path including a shortest path from the head node to the secondary cross-domain node and a shortest path from the secondary cross-domain node to the tail node. In addition, in terms of different backup tunnel calculation methods, packet forwarding processes after switching to the backup tunnel are different. In some embodiments, after switching to the backup path, the head node sends a packet in which a label stack is encapsulated. The packet specifies, by using the label stack, each node that the backup tunnel passes through from the head node to the tail node. In some embodiments, after switching to the backup path, the head node sends a packet in which a label stack is encapsulated. The packet specifies, by using the label stack, each node that the backup tunnel passes through from the head node to the secondary cross-domain node. The following describes the foregoing several cases in detail.

In a first case, the backup tunnel is the shortest path from the head node to the tail node.

FIG.5is a schematic flowchart of a fault protection method500according to an embodiment of this application.

As shown inFIG.5, the fault protection method500provided in this embodiment of this application may include the following steps.

501: A head node determines a shortest path from the head node to a tail node without passing through a primary cross-domain node.

The head node calculates the shortest path from the head node to the tail node in a first set, and the first set includes other nodes than the primary cross-domain node in an SR-BE network, in other words, the first set does not include the primary cross-domain node. The shortest path is a backup tunnel, and the backup tunnel is specified by using a strict label stack, so that a packet is forwarded to the tail node along the backup tunnel.

In a specific implementation, the head node may calculate the shortest path from the head node to the tail node in the first set according to an SPF algorithm. The following provides description with reference to the scenario shown inFIG.3. It is assumed that the packet is forwarded from the RSG1to the CSG1, in other words, the RSG1is the head node, and the CSG1is the tail node. It is assumed that a COST value between the RSG1and the RSG2is 20, a COST value between the RSG2and the ASG2is 20, a COST value between the ASG2and the CSG2is 100, a COST value between the CSG2and the CSG1is 100, a COST value between the RSG1and the ASG1is 20, a COST value between the CSG1and the ASG1is 100, and a COST value between the ASG1and the ASG2is 110. A method of calculating the shortest path may include the following steps.

Step 1: All nodes are divided into two sets, namely, an S set and a U set. The head node RSG1is selected into the S set. In this case, the S set includes the RSG1. The primary cross-domain node ASG1is deleted, and other nodes are selected into the U set, to be specific, the U set includes four nodes: the RSG2, the ASG2, the CSG2, and the CSG1. The COST value from the head node RSG1to the RSG2is 20, a COST value from the RSG1to the ASG2is 40, and a COST value from the RSG1to any other node in the network is greater than the COST value from the RSG1to the RSG2. It is determined that the COST value from the RSG1to the RSG2is the smallest.

Step 2: The RSG2is selected into the S set, to be specific, the S set includes two nodes: the RSG1and the RSG2. The RSG2is deleted from the U set, to be specific, the U set includes three nodes: the ASG2, the CSG2, and the CSG1. Because in step1, the COST value from the RSG1to the RSG2is the smallest, searching continues along the path. A COST value from the RSG1to the RSG2to the ASG2is 100, and a COST value from the RSG1to the RSG2to any other node is greater than 100. It is determined that the COST value from the RSG1to the RSG2to the ASG2is the smallest.

Step 3: The ASG2is selected into the S set, to be specific, the S set includes three nodes: the RSG1, the RSG2, and the ASG2. The ASG2is deleted from the U set, to be specific, the U set includes two nodes: the CSG2and the CSG1. Because in step2, the COST value from the RSG1to the RSG2to the ASG2is the smallest, searching continues along the path. A COST value from the RSG1to the RSG2to the ASG2to the CSG2is 140, and a COST value from the RSG1to the RSG2to the ASG2to any other node is greater than 140. It is determined that the COST value from the RSG1to the RSG2to the ASG2to the CSG2is the smallest.

Step 4: The CSG2is selected into the S set, to be specific, the S set includes four nodes: the RSG1, the RSG2, the ASG2, and the CSG2. The CSG2is deleted from the U set, to be specific, the U set includes the CSG1. Because in step3, the COST value from the RSG1to the RSG2to the ASG2to the CSG2is the smallest, searching continues along the path. It is determined that a COST value from the RSG1to the RSG2to the ASG2to the CSG2to the CSG1is the smallest.

Step 5: The CSG1is selected into the S set, to be specific, the S set includes the RSG1, the RSG2, the ASG2, the CSG2, and the CSG1. It is determined that the shortest path from the head node RSG1to the tail node CSG1is found, namely, from the RSG1to the RSG2to the ASG2to the CSG2to the CSG1. Searching ends.

Based on the foregoing searching process, it is determined that the backup tunnel is from the RSG1to the RSG2to the ASG2to the CSG2to the CSG1. The backup tunnel is a path with a strict explicit path and is specified by using the strict label stack, namely, [adj (RSG1→RSG2), adj(RSG2→ASG2), adj(ASG2→CSG2), adj(CSG2→CSG1)].

502: The head node determines that the primary cross-domain node is faulty.

503: The head node switches a service transmission path to the backup tunnel. The backup tunnel is the tunnel with a strict explicit path.

In a specific implementation, step504may be further included: The head node sends the packet through the backup tunnel, and a label stack is encapsulated in the packet. Further, the packet specifies, by using the label stack, each node that the backup tunnel passes through from the head node to the tail node.

For understanding of step502and step503in this embodiment, refer to step401and step402in the embodiment corresponding toFIG.4. Details are not described herein again.

In a second case, the backup tunnel is the path including the shortest path from the head node to the secondary cross-domain node and the shortest path from the secondary cross-domain node to the tail node.

FIG.6is a schematic diagram of a fault protection method60oaccording to an embodiment of this application.

As shown inFIG.6, the fault protection method60oprovided in this embodiment of this application may include the following steps.

601: A head node determines a shortest path from the head node to a secondary cross-domain node without passing through a primary cross-domain node.

The head node calculates the shortest path from the head node to the secondary cross-domain node in a second set, and the second set includes all nodes except the primary cross-domain node in an IGP domain in which the head node is located, or the second set includes other nodes than the primary cross-domain node in an SR-BE network, in other words, the second set does not include the primary cross-domain node. The backup tunnel is specified by using a strict label stack, so that a packet is forwarded to the secondary cross-domain node along the backup tunnel.

In a specific implementation, the head node may calculate the shortest path from the head node to the secondary cross-domain node in the second set according to an SPF algorithm. The following provides description with reference to the scenario shown inFIG.3and by using an example in which the second set includes all nodes except the primary cross-domain node in the IGP domain in which the head node is located. It is assumed that the ASG1is the primary cross-domain node and the ASG2is the secondary cross-domain node. It is assumed that a COST value between the RSG1and the RSG2is 20, a COST value between the RSG2and the ASG2is 20, a COST value between the RSG1and the ASG1is 20, and a COST value between the ASG1and the ASG2is 110. A method of calculating the shortest path may include the following steps.

Step 1: All nodes are divided into two sets, namely, an S set and a U set. The head node RSG1is selected into the S set. In this case, the S set includes the RSG1. The primary cross-domain node ASG1is deleted, and other nodes are selected into the U set, to be specific, the U set includes two nodes: the RSG2and the ASG2. The COST value from the head node RSG1to the RSG2is 20, and a COST value from the RSG1to the ASG2is 40. It is determined that the COST value from the RSG1to the RSG2is the smallest.

Step 2: The RSG2is selected into the S set, to be specific, the S set includes two nodes: the RSG1and the RSG2. The RSG2is deleted from the U set, to be specific, the U set includes one node: the ASG2. Because in step1, the COST value from the RSG1to the RSG2is the smallest, searching continues along the path. A COST value from the RSG1to the RSG2to the ASG2is 100.

Step 3: The ASG2is selected into the S set, to be specific, the S set includes the RSG1, the RSG2, and the ASG2. It is determined that the shortest path from the head node RSG1to the secondary cross-domain node ASG2is found, namely, from the RSG1to the RSG2to the ASG2. Searching is ended.

Based on the foregoing searching process, it is determined that the backup tunnel is from the RSG1to the RSG2to the ASG2. The backup tunnel is specified by using the strict label stack, namely, [adj(RSG1→RSG2), adj(RSG2→ASG2)].

602: The head node determines that the primary cross-domain node is faulty.

For understanding of step602, refer to step401in the embodiment corresponding toFIG.4. Details are not described herein again.

603: The head node switches a service transmission path to the backup tunnel. The backup tunnel is a tunnel with a strict explicit path.

In a specific implementation, step604may be further included: The head node sends the packet through the backup tunnel, and a label stack is encapsulated in the packet. Further, the packet specifies, by using the label stack, each node that the backup tunnel passes through from the head node to the secondary cross-domain node.

In a specific implementation, step6o5may be further included: The secondary cross-domain node determines that the primary cross-domain node is faulty.

Further, the secondary cross-domain node may obtain fault information of the primary cross-domain node through BFD. The head node may establish in advance BFD for detecting a node fault, for example, seamless bidirectional forwarding detection (S-BFD), with the primary cross-domain node, to determine that the primary cross-domain node is faulty. In some embodiments, if the packet has been forwarded to the secondary cross-domain node, and the shortest path from the secondary cross-domain node to the tail node does not need to pass through the primary cross-domain node, the secondary cross-domain node may reliably forward the packet to the tail node. When the shortest path from the secondary cross-domain node to the tail node still needs to pass through the primary cross-domain node, the BFD may be established in advance between the primary cross-domain node and the secondary cross-domain node. When the packet is forwarded to the secondary cross-domain node, the secondary cross-domain node may obtain, through the BFD, whether the primary cross-domain node is faulty. If the secondary cross-domain node obtains, through the BFD, that the primary cross-domain node is faulty, when the secondary cross-domain node forwards the packet to the tail node, the packet does not pass through the primary cross-domain node. In a specific implementation, after determining that the primary cross-domain node is faulty, the secondary cross-domain node may forward the packet to the tail node based on a backup tunnel pre-established by the secondary cross-domain node.

To better describe the backup tunnel calculation algorithm provided in this application, the following provides description with reference toFIG.7. As shown inFIG.7, it is assumed that an SR-BE network includes a router node A, a router node B, a router node C, a router node D, a router node E, and a router node F. It is assumed that a COST value between the node A and the node B is 6, a COST value between the node A and the node C is 3, a COST value between the node B and the node C is 2, a COST value between the node B and the node F is 6, a COST value between the node B and the node D is 5, a COST value between the node B and the node E is 1, a COST value between the node C and the node D is 3, a COST value between the node C and the node E is 4, a COST value between the node D and the node E is 2, a COST value between the node D and the node F is 3, and a COST value between the node E and the node F is 5. It is assumed that a target path that needs to be calculated is from the node A to the node E without passing through the node D, and the target path is equivalent to the shortest path that is from the head node to the tail node without passing through the primary cross-domain node in the embodiment corresponding toFIG.5. Alternatively, the target path is equivalent to the shortest path that is from the head node to the secondary cross-domain node without passing through the primary cross-domain node in the embodiment corresponding toFIG.6. A method used by the secondary cross-domain node to calculate a shortest path from the secondary cross-domain node to the tail node is similar to the method used by the head node to calculate the shortest path. Details are not described herein again. The following steps may be included.

Step 1: All nodes are divided into two sets, namely, an S set and a U set. The head node, namely, the node A, is selected into the S set. In this case, the S set includes the node A. The node D is deleted, and other nodes are selected into the U set. In this case, the U set includes four nodes: the node B, the node C, the node E, and the node F. The COST value from the node A to the node C is 3, and the COST value from the node A to the node B is 6. Therefore, the COST value from the node A to the node C is the smallest.

Step 2: The node C is selected into the S set, to be specific, the S set includes two nodes: the node A and the node C. Searching continues along a path from the node A to the node C. The node C is deleted, to be specific, the U set includes three nodes: the node B, the node E, and the node F. A COST value from the node A to the node C to the node B is 5, and is less than the COST value6from the node A to the node B in step1. In this case, a shortest path is updated, namely, from the node A to the node C to the node B. A COST value from the node A to the node C to the node E is 7, and a COST value from the node A to the node C to any other node in the U set is infinite. Therefore, it is determined that the COST value from the node A to the node C to the node B is the smallest.

Step 3: The node B is selected into the S set, to be specific, the S set includes three nodes: the node A, the node C, and the node B. Searching continues along the path from the node A to the node C to the node B. The node B is deleted, to be specific, the U set includes two nodes: the node E and the node F. A COST value from the node A to the node C to the node B to the node E is 6, and is less than the COST value from the node A to the node C to the node E in step2. Then, a shortest path is updated to a path from the node A to the node C to the node B to the node E. A COST value from the node A to the node C to the node B to the node F is 11, and a COST value from the node A to the node C to the node B to any other node in the U set is infinite. Therefore, it is determined that the COST value from the node A to the node C to the node B to the node E is the smallest.

Step 4: The node E is selected into the S set, to be specific, the S set includes four nodes: the node A, the node C, the node B, and the node E. In this case, a shortest path from the node A as the head node to the node E as the tail node without passing through the node D, namely, from the node A to the node C to the node B to the node E. Searching ends.

Based on the foregoing searching process, it is determined that the target path is from the node A to the node C to the node B to the node E, and the target path is specified by using a strict label stack, namely, [adj(node A→node C), adj(node C→node B), adj(node B→node E)].

FIG.8is a schematic flowchart of a fault protection method700according to an embodiment of this application.

As shown inFIG.8, the fault protection method700provided in this embodiment of this application is applicable to the scenario corresponding toFIG.3and may include the following steps.

701: A first node determines that a first cross-domain node is faulty.

The first node is a head node of a segment routing best effort SR-BE service tunnel, the SR-BE tunnel is a cross-domain tunnel that passes through a first IGP domain and a second IGP domain, the SR-BE tunnel passes through the first cross-domain node, and the first cross-domain node is a node that crosses the first IGP domain and the second IGP domain. When the method700is used to perform the method400, the method500, or the method600, the first node is equivalent to the head node in the method400, the method500, or the method600, the first cross-domain node is equivalent to the primary cross-domain node in the method400, the method500, or the method600, and the first IGP domain and the second IGP domain may be equivalent to the first IGP domain and the second IGP domain in the scenario corresponding toFIG.3. Details are not described below again.

702: The first node switches a service transmission path from the SR-BE tunnel to a backup tunnel.

The backup tunnel does not pass through the first cross-domain node, the backup tunnel is a cross-domain tunnel that passes through the first IGP domain and the second IGP domain, and the backup tunnel is a tunnel with a strict explicit path. When the method700is used to perform the method400, the method500, or the method600, the backup tunnel is equivalent to the backup tunnel in the method400, the method500, or the method600. Details are not described below again.

In a specific implementation, the method700further includes703: The first node obtains the backup tunnel based on a first node set. The first node set does not include the first cross-domain node. When the method700is used to perform the method500or the method600, the first node set is equivalent to the first set in the method500or is equivalent to the second set in the method600. Details are not described below again.

In a specific implementation, that the first node obtains the backup tunnel based on a first node set specifically includes: The first node determines a first shortest path from the first node to a tail node based on the first node set. The first shortest path is the backup tunnel.

In a specific implementation, after the first node switches the service transmission path from the SR-BE tunnel to the backup tunnel, the method700further includes704: The first node sends a first packet through the backup tunnel. A label stack is encapsulated in the first packet, and the label stack specifies each node that the backup tunnel passes through. When the method700is used to perform the method500or the method600, the first packet is equivalent to the packet described in step504in the method500.

In a specific implementation, that the first node obtains the backup tunnel based on a first node set specifically includes: The first node determines a second shortest path from the first node to a second cross-domain node based on the first node set. The second shortest path and a third shortest path from the second cross-domain node to a tail node jointly form the backup tunnel, the third shortest path does not pass through the first cross-domain node, and the second cross-domain node is a node that crosses the first IGP domain and the second IGP domain. When the method700is used to perform the method500or the method600, the second cross-domain node is equivalent to the secondary cross-domain node in the method400, the method500, or the method600. The second shortest path is equivalent to the shortest path from the head node to the secondary cross-domain node without passing through the primary cross-domain node in the method600, and the third shortest path is equivalent to the path from the secondary cross-domain node to the tail node without passing through the primary cross-domain node in the method600, or is equivalent to the backup tunnel pre-established by the secondary cross-domain node in the method600.

In a specific implementation, after the first node switches the service transmission path from the SR-BE tunnel to the backup tunnel, the method700further includes705: The first node sends a second packet through the second shortest path. A label stack is encapsulated in the second packet, and the label stack specifies each node that the second shortest path passes through. When the method700is used to perform the method500or the method600, the second packet is equivalent to the packet described in step604in the method600.

In a specific implementation, before the first node determines that the first cross-domain node is faulty, the method700further includes706: A bidirectional forwarding detection BFD session is established between the first node and the first cross-domain node. That a first node determines that a first cross-domain node is faulty may specifically include: The first node determines, based on the BFD session, that the first cross-domain node is faulty.

In a specific implementation, before the first node determines that the first cross-domain node is faulty, the method700further includes the following.

707: The first node sends a third packet through the SR-BE tunnel. An outer label of the third packet is a node label of a next hop to a destination address.

The foregoing mainly describes the solutions provided in the embodiments of this application from a perspective of interaction between nodes. It may be understood that, to implement the foregoing functions, the foregoing head node includes a corresponding hardware structure and/or a software module for performing the function. A person skilled in the art should be easily aware that, in combination with example modules and algorithm steps described in the embodiments disclosed in this specification, this application can be implemented by hardware or a combination of hardware and computer software. Whether a function is performed by hardware or hardware driven by computer software depends on particular applications and design constraints of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.

From a perspective of a hardware structure, the head node inFIG.4toFIG.6and the first node inFIG.8may be implemented by a physical device or jointly implemented by a plurality of physical devices, or may be a logical function module inside a physical device. This is not specifically limited in the embodiments of this application.

For example, the head node may be implemented by using a communications device inFIG.9.FIG.9is a schematic diagram of a hardware structure of a communications device according to an embodiment of this application. The communications device includes a communications interface901and a processor902, and may further include a memory903.

The communications interface901may use any apparatus such as a transceiver, to communicate with another device or a communications network, such as the Ethernet, a radio access network (RAN), or a wireless local area network (WLAN).

The processor902includes but is not limited to one or more of a central processing unit (CPU), a network processor (NP), an application-specific integrated circuit (ASIC), or a programmable logic device (PLD). The PLD may be a complex programmable logic device (CPLD), a field programmable gate array (FPGA), generic array logic (GAL), or any combination thereof. The processor902is responsible for management of a communications line904and general processing, may be a peripheral interface, and may further provide various functions, including timing, voltage regulation, power management, and another control function. The memory903may be configured to store data used by the processor902when the processor902performs an operation.

The memory903may include but is not limited to a content-addressable memory (CAM), for example, a ternary content-addressable memory (TCAM), or a random access memory (RAM).

The memory903may alternatively be integrated into the processor902. If the memory903and the processor902are components independent of each other, the memory903is connected to the processor902. For example, the memory903may communicate with the processor902by using the communications line. The network interface901may communicate with the processor902by using the communications line, or the network interface901may be directly connected to the processor902.

The communications line904may include any quantity of interconnected buses and bridges, and the communications line904links together various circuits that include one or more processors902represented by the processor902and a memory represented by the memory903. The communications line904may further links together other circuits such as a peripheral device, a voltage regulator, and a power management circuit. These are well known in the art, and therefore are not further described in this application.

In a specific implementation, the first node includes the memory903and the processor902connected to the memory903.

The processor902is configured to execute a computer-readable instruction in the memory903, to perform the following operation: determining that a first cross-domain node is faulty. The first node is a head node of a segment routing best effort SR-BE service tunnel, the SR-BE tunnel is a cross-domain tunnel that passes through a first IGP domain and a second IGP domain, the SR-BE tunnel passes through the first cross-domain node, and the first cross-domain node is a node that crosses the first IGP domain and the second IGP domain.

The processor902is further configured to execute a computer-readable instruction in the memory903, to perform the following operation: switching a service transmission path from the SR-BE tunnel to a backup tunnel. The backup tunnel does not pass through the first cross-domain node, the backup tunnel is a cross-domain tunnel that passes through the first IGP domain and the second IGP domain, and the backup tunnel is a tunnel with a strict explicit path.

In a specific implementation, the processor902is further configured to execute a computer-readable instruction in the memory903, to perform the following operation: obtaining the backup tunnel based on a first node set. The first node set does not include the first cross-domain node.

In a specific implementation, the processor902is specifically configured to execute a computer-readable instruction in the memory903, to perform the following operation: determining a first shortest path from the first node to a tail node based on the first node set. The first shortest path is the backup tunnel.

In a specific implementation, the communications interface901is configured to send a first packet through the backup tunnel, after the processor902switches the service transmission path from the SR-BE tunnel to the backup tunnel. A label stack is encapsulated in the first packet, and the label stack specifies each node that the backup tunnel passes through.

In a specific implementation, the processor902is specifically configured to execute a computer-readable instruction in the memory903, to perform the following operation: determining a second shortest path from the first node to a second cross-domain node based on the first node set. The second shortest path and a third shortest path from the second cross-domain node to the tail node jointly form the backup tunnel, the third shortest path does not pass through the first cross-domain node, and the second cross-domain node is a node that crosses the first IGP domain and the second IGP domain.

In a specific implementation, the communications interface901is further configured to send a second packet through the second shortest path, after the processor902switches the service transmission path from the SR-BE tunnel to the backup tunnel. A label stack is encapsulated in the second packet, and the label stack specifies each node that the second shortest path passes through.

In a specific implementation, the processor902is further configured to execute a computer-readable instruction in the memory903, to perform the following operations: before determining that the first cross-domain node is faulty, establishing a bidirectional forwarding detection BFD session between the first node and the first cross-domain node, and determining that the first cross-domain node is faulty based on the BFD session.

In a specific implementation, the communications interface901is further configured to send a third packet through the SR-BE tunnel, before the processor902determines that the first cross-domain node is faulty. An outer label of the third packet is a node label of a next hop to a destination address.

For example, when the function modules are obtained through division in an integrated manner,FIG.10is a schematic structural diagram of a head node.

As shown inFIG.10, the node provided in this embodiment of this application may include a determining unit1001and a switching module1002.

The determining unit1001is configured to perform step401in the method400, steps501and502in the method500, steps601and602in the method600, and steps701,703, and706in the method700.

The switching unit1002is configured to perform step402in the method400, step503in the method500, step603in the method600, and step702in the method700.

In a specific implementation, the head node may further include a sending unit1003, configured to perform step504in the method500, step604in the method600, and steps704,705, and707in the method700.

In the foregoing embodiment, the head node is presented in a form in which function modules are obtained through division in an integrated manner. It is clearly that, in this embodiment of this application, function modules of the head node corresponding to the functions may be obtained through division. This is not specifically limited in this embodiment of this application.

In a specific implementation, this embodiment of this application provides a chip system. The chip system includes a processor, configured to support the head node to implement the foregoing fault protection method. In a possible design, the chip system further includes a memory. The memory is configured to store a program instruction and data that are necessary for the head node. The chip system may include a chip, or may include a chip and another discrete component. This is not specifically limited in this embodiment of this application.

All or some of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When the software is used to implement the embodiments, all or some of the embodiments may be implemented in a form of a computer program product.

The foregoing describes in detail a fault protection method, a node, and a storage medium provided in the embodiments of this application. The principle and implementation of this application are described herein through specific examples. The description about the embodiments is merely provided to help understand the method and core ideas of this application. In addition, persons of ordinary skill in the art can make variations and modifications to this application in terms of the specific implementations and application scopes according to the ideas of this application. Therefore, the content of specification shall not be construed as a limit to this application.