Message sending method, device and storage medium

By utilizing tunnel and flow table mechanisms in the SD-WAN environment, it is ensured that packets of the same application pass through the same device when transmitted in multiple network device environments, solving the problems of interoperability and application identification between devices, and improving communication reliability. sex and efficiency.

CN113098749BActive Publication Date: 2024-10-15HUAWEI TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010019654.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-01-08
Publication Date
2024-10-15
Estimated Expiration
2040-01-08

AI Technical Summary

Technical Problem

In software-defined wide area networks (SD-WAN), it is difficult to ensure interoperability between multiple network devices, especially when packets for the same application are sent and received through the same network device.

Method used

By establishing multiple tunnels between the network equipment at the first site and the network equipment at the second site, the flow table is used to search for the target flow entry to determine the outbound interface of the data packet, ensuring that the packet is transmitted between the same network equipment. , and when necessary, send the data packet to other network devices to find the target flow entry.

Benefits of technology

It ensures that messages of the same application are sent and received through the same network device in an environment of multiple network devices, improving the reliability and efficiency of communication.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113098749B_ABST
    Figure CN113098749B_ABST
Patent Text Reader

Abstract

A message sending method, device and storage medium belong to the field of communication technology. In this method, after a first network device receives a first data message from a second site, it searches for a target flow table entry from a stored flow table. Each flow table entry includes a flow identifier and a corresponding output interface identifier. The target flow table entry is created when the first site sends a reverse data flow of the first data message to the second site. If the target flow table entry is found, the first network device sends the first data message through the interface corresponding to the output interface identifier in the target flow table entry. It can be seen that only when the reverse data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device, and the target flow table entry can be found, and then the first data message is sent through the interface corresponding to the output interface identifier in the target flow table entry. In this way, the present application can ensure that the messages sent and received about the same application pass through the same network device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of communication technology, and in particular to a message sending method, device and storage medium. Background Art

[0002] Software Defined WAN (SD-WAN) is an important practice of software defined networking (SDN). In SD-WAN, a tunnel can usually be established between network devices at two sites through overlay technology, and then messages can be sent through the tunnel. Moreover, these network devices can also identify the application type to which the message belongs through deep packet inspection (DPI), and then send messages according to the application type. However, in order to ensure the reliability of communication, two network devices are often deployed in some important sites. Moreover, for DPI, it is usually necessary for the messages sent and received about the same application to pass through the same network device before the application type can be successfully identified. Therefore, in this case, how to ensure the intercommunication between the two network devices, and how to ensure that the messages sent and received about the same application pass through the same network device, has become a problem that needs to be solved urgently. Summary of the invention

[0003] The present application provides a message sending method, device and storage medium, which can solve the problem that when multiple network devices are deployed in a site, it is impossible to ensure that the messages sent and received by the same application all pass through the same network device. The technical solution is as follows:

[0004] In a first aspect, a method for sending a message is provided, wherein a plurality of network devices are deployed in a first site, and a plurality of tunnels are established between the network devices deployed in the first site and the network devices deployed in a second site, and the second site refers to a site that transmits data with the first site. In this case, the first network device receives a first data message from the second site; the first network device searches for a target flow table entry whose flow identifier is the flow identifier of the first data flow from a flow table stored in the first network device; if the target flow table entry is found, the first network device sends the first data message through an interface corresponding to an outgoing interface identifier in the target flow table entry.

[0005] The first network device is any one of the multiple network devices. The flow table includes multiple flow table entries, and each of the multiple flow table entries includes a flow identifier and a corresponding outbound interface identifier. The first data flow is the data flow to which the first data packet belongs, and the target flow table entry is created when the second data flow is sent from the first site to the second site. The source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow.

[0006] In the present application, when the first network device receives the first data message from the second site, the target flow table entry whose flow identifier is the flow identifier of the first data flow can be searched in the flow table. Since the first data flow is the data flow to which the first data message belongs, the target flow table entry is created when the second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow. Therefore, only when the second data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device. In this way, the first network device can find the target flow table entry, and then send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry. It can be seen from this that the present application can ensure that the messages sent and received about the same application pass through the same network device.

[0007] Optionally, after the first network device searches for a target flow table entry with a flow identifier being the flow identifier of the first data flow from the flow table stored in the first network device, if the target flow table entry is not found, and there are network devices among the multiple network devices that have not found the target flow table entry, the first network device sends the first data packet to a second network device to instruct the second network device to search for the target flow table entry from the flow table stored in the second network device, and the second network device is a network device among the multiple network devices that has not found the target flow table entry; if the target flow table entry is not found, and the multiple network devices have all searched for the target flow table entry, the first network device sends the first data packet via local routing.

[0008] As an example, every two network devices among the multiple network devices in the first site can be connected via a network link, that is, every two network devices can communicate with each other. In this case, the first data packet can carry the device identification of each network device that the first data packet passes through. In this way, when the first network device determines whether there are still network devices in the first site that have not found the target flow table entry, it can determine the network devices in the multiple network devices in the first site that have not found the target flow table entry based on the device identification of the network device carried in the first data packet.

[0009] It should be noted that each network device in the first site stores a local route, and the local route stores the routing information between the corresponding network device and the user terminal in the first site. Therefore, when the first network device receives the first data message, and multiple network devices in the first site have searched for the target flow table entry, the first data message can be sent to the user terminal in the first site according to the local route.

[0010] Optionally, when the first network device sends the first data packet through the interface corresponding to the outgoing interface identifier in the target flow table entry, if the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first network device sends the first data packet to the user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry; if the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first network device sends the first data packet to the third network device through the interface corresponding to the outgoing interface identifier in the target flow table entry, so as to instruct the third network device to search for the target flow table entry from the flow table stored by the third network device.

[0011] Among them, the first type of interface refers to the interface for communicating with the user terminal within the first site, the second type of interface refers to the interface for communicating with other network devices among the multiple network devices, and the third network device refers to the device among the multiple network devices that communicates with the first network device through the interface corresponding to the outgoing interface identifier in the target flow table entry.

[0012] Optionally, before the first network device receives the first data packet from the second site, the first network device receives the second data packet from the user terminal in the first site; the first network device selects a tunnel from the multiple tunnels as the target tunnel according to the destination address; the first network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow; the first network device adds the target flow table entry in the flow table stored in the first network device; if the target tunnel is a tunnel established between the first network device and the network device in the second site, the first network device sends the second data packet through the target tunnel.

[0013] Among them, the second data packet carries a destination address, the second data packet belongs to the second data flow, and the flow identifier in the target flow table entry currently added by the first network device is the flow identifier of the first data flow, the outgoing interface identifier in the target flow table entry currently added is the identifier of the first interface, and the first interface refers to the interface in the first network device for receiving the second data packet from the user terminal in the first site.

[0014] It should be noted that, since the second data message belongs to the second data flow, which is a data flow sent from the user end of the first site to the user end of the second site, the destination address carried by the second data message is the destination address of the user end in the second site.

[0015] It is worth noting that when a user terminal in the first site sends a second data packet to a user terminal in the second site, since the two user terminals belong to different sites, the user terminal in the first site needs to send the second data packet to a network device in the first site, and then the second data packet is sent to a network device in the second site through the network device, and then the network device in the second site sends the second data packet to the user terminal in the second site.

[0016] As an example, a user terminal within the first site can select a network device from multiple network devices within the first site as the first network device based on the networking mode of the first site. After that, the second data packet can be sent to the first network device, and the second data packet can be sent to a network device within the second site through the first network device.

[0017] Optionally, a routing table is stored in the first network device, and the routing table includes multiple routing table items, each of the multiple routing table items includes a site prefix and a corresponding site identifier; in this way, when the first network device selects a tunnel from the multiple tunnels as a target tunnel according to the destination address, the first network device determines the target routing table item from the routing table according to the destination address, and the destination address matches the site prefix included in the target routing table item; the first network device determines one or more tunnel table items according to the site identifier included in the target routing table item, and the one or more tunnel table items refer to the tunnel table items corresponding to the tunnel established between the first site and the second site; the first network device selects a tunnel table item from the one or more tunnel table items as the target tunnel table item, and uses the tunnel corresponding to the target tunnel table item as the target tunnel.

[0018] In the present application, since the site prefix refers to the network segment corresponding to the site, the destination address carried by the second data packet can be matched with the site prefix included in each routing table entry in the routing table, so that the target routing table entry can be determined from the routing table.

[0019] It should be noted that, based on the above description, the target address carried by the second data packet is the address of the user terminal in the second site. Therefore, the site prefix included in the target routing table entry is the site prefix of the second site, and the site identifier included in the target routing table entry is the identifier of the second site.

[0020] In the present application, a tunnel table may be stored in the first network device, and the tunnel table is used to store tunnel table entries corresponding to multiple sites. Of course, the first network device may also store multiple tunnel tables, and the multiple tunnel tables correspond to the multiple sites one by one. Among them, the multiple sites refer to sites with tunnels established between the first site, and the multiple sites include the second site. For these two situations, the first network device determines the above one or more tunnel table entries in different ways, so the following is divided into two situations for explanation.

[0021] In the first case, a tunnel table is stored in the first network device. At this time, the first network device can determine one or more tunnel identifiers according to the site identifier included in the target routing table item, and the one or more tunnel identifiers refer to the identifiers of the tunnels established between the first site and the second site. Afterwards, the first network device can determine the above-mentioned one or more tunnel table items from the tunnel table according to the one or more tunnel identifiers.

[0022] It should be noted that no matter how many tunnel tables are stored in the first network device, each tunnel table may include multiple tunnel table entries, and each tunnel table entry in the multiple tunnel table entries may include a tunnel identifier and corresponding tunnel attribute information. The tunnel attribute information may include tunnel encapsulation mode, source address and destination address of the tunnel, whether the tunnel is available, tunnel bandwidth, and tunnel latency. Moreover, in some cases, the first network device may store a first mapping relationship between a site identifier and a tunnel identifier, that is, the first mapping relationship stores the identifiers of each site that has established a tunnel with the first site, and the identifiers of the tunnels established between each site and the first site. In this way, the first network device can determine one or more tunnel identifiers from the first mapping relationship based on the site identifier included in the target routing table entry. Afterwards, the first network device can determine the tunnel table entry whose tunnel identifier is the same as the one or more tunnel identifiers from the tunnel table, thereby obtaining one or more tunnel table entries.

[0023] In the second case, multiple tunnel tables are stored in the first network device. At this time, the first network device can determine the identifier of the target tunnel table according to the site identifier included in the target routing table item, and the target tunnel table refers to the tunnel table corresponding to the second site in the multiple tunnel tables. Afterwards, the first network device can determine the target tunnel table from the multiple tunnel tables according to the identifier of the target tunnel table, and determine the tunnel table items stored in the target tunnel table as the one or more tunnel table items mentioned above.

[0024] Since different tunnel tables are stored for different sites in the first network device, and the first network device can store a second mapping relationship between a site identifier and a tunnel table identifier, that is, the second mapping relationship stores the identifiers of each site that has established a tunnel with the first site, and the identifiers of the tunnel tables corresponding to each site. In this way, the first network device can determine the identifier of the target tunnel table from the second mapping relationship based on the site identifier included in the target routing table item. Afterwards, the target tunnel table can be determined from the multiple tunnel tables based on the identifier of the target tunnel table, and the tunnel table items in the target tunnel table can be determined as the one or more tunnel table items mentioned above.

[0025] After determining the one or more tunnel table entries, the first network device can select a tunnel table entry from the one or more tunnel table entries as the target tunnel table entry according to the tunnel selection strategy, and then determine the tunnel corresponding to the target tunnel table entry as the target tunnel, that is, the tunnel identified by the tunnel identifier included in the target tunnel table entry is used as the target tunnel.

[0026] Optionally, the flow identifier of the second data flow includes source information and destination information; when the first network device determines the flow identifier of the first data flow based on the flow identifier of the second data flow, the first network device swaps the source information and the destination information in the flow identifier of the second data flow to obtain the flow identifier of the first data flow.

[0027] Among them, the first data stream is a data stream sent from a user terminal in the second site to a user terminal in the first site, and the second data stream is a data stream sent from a user terminal in the first site to a user terminal in the second site. Therefore, the source address of the first data stream is the destination address of the second data stream, and the destination address of the first data stream is the source address of the second data stream.

[0028] In the present application, the first network device may determine the flow identifier of the second data flow according to the second data packet, and further determine the flow identifier of the first data flow according to the flow identifier of the second data flow.

[0029] As an example, the first network device may obtain tuple information of the second data message, the tuple information including at least source information and destination information. The obtained tuple information is used as the flow identifier of the second data flow. Afterwards, the first network device may swap the source information and the destination information in the flow identifier of the second data flow to obtain the flow identifier of the first data flow.

[0030] As another example, the first network device may obtain the tuple information of the second data packet, and obtain the flow identifier of the second data flow from the stored correspondence between the tuple information and the flow identifier according to the tuple information of the second data packet. Thereafter, according to the flow identifier of the second data flow, obtain the flow identifier of the first data flow from the stored correspondence between the first data flow identifier and the second data flow identifier.

[0031] After the first network device determines the flow identifier of the first data flow according to the second data message, a target flow table entry can be added to the flow table stored in the first network device. The flow table may include multiple flow table entries, each of which includes a flow identifier and a corresponding outgoing interface identifier. Therefore, the target flow table entry currently added includes a flow identifier and a corresponding outgoing interface identifier, and the flow identifier in the target flow table entry currently added is the flow identifier of the first data flow, and the outgoing interface identifier in the target flow table entry currently added is the identifier of the first interface, and the first interface refers to the interface in the first network device used to receive the second data message from the user terminal in the first site.

[0032] It should be noted that, since the same data flow may flow into the first network device through the interface for communicating with the user end in the first site, or may flow into the first network device through the interface for communicating with other network devices in the first site, the outgoing interface identifier in the target flow table entry currently added by the first network device may be the interface in the first network device for communicating with the user end in the first site, or may be the interface in the first network device for communicating with other network devices in the first site.

[0033] Optionally, after the first network device adds the target flow table entry in the flow table stored in the first network device, if the target tunnel is a tunnel established between a fourth network device and a network device in the second site, the first network device adds the tunnel identifier of the target tunnel in the second data packet to obtain a third data packet; the first network device sends the third data packet to the fourth network device to instruct the fourth network device to parse the second data packet, determine the flow identifier of the first data flow according to the flow identifier of the second data flow, add the target flow table entry in the flow table stored in the fourth network device, and send the second data packet through the target tunnel.

[0034] Among them, the fourth network device is a network device other than the first network device among the multiple network devices, and the flow identifier included in the target flow table entry currently added by the fourth network device is the flow identifier of the first data flow, and the outgoing interface identifier in the target flow table entry currently added is the identifier of the second interface, and the second interface refers to the interface in the fourth network device for receiving the third data packet.

[0035] It should be noted that, since the tunnel table includes all tunnels established between the network device in the first site and the network device in the second site, the target tunnel determined by the first network device may be the tunnel established between the first network device and the network device in the second site, or it may be the tunnel established between the network devices other than the first network device in the first site and the network device in the second site, that is, the tunnel established between the fourth network device and the network device in the second site.

[0036] In some possible cases, if the target tunnel is a tunnel established between a fourth network device and a network device within the second site, the first network device may add a tunnel index field in the second data packet, which tunnel index field may include the tunnel identifier of the target tunnel, thereby obtaining a third data packet, after which the first network device may send the third data packet to the fourth network device.

[0037] Based on the above description, a network link is established between the first network device and the fourth network device, and the first network device and the fourth network device communicate through the network link. Therefore, the first network device adds the tunnel identifier of the target tunnel to the second data message, and after obtaining the third data message, the third data message can be sent to the fourth network device through the network link between the first network device and the fourth network device.

[0038] After the fourth network device receives the third data packet, since the tunnel index field includes not only the tunnel identifier of the target tunnel, but also the encapsulation method, label, version number, protocol type, etc. of the tunnel index field, the second data packet can be parsed from the third data packet according to the information such as encapsulation method, label, version number, and protocol type.

[0039] In the present application, after parsing the second data message, the fourth network device can determine the flow identifier of the second data flow according to the second data message, and further determine the flow identifier of the first data flow according to the flow identifier of the second data flow.

[0040] As an example, the fourth network device may obtain tuple information of the second data message, the tuple information including at least source information and destination information. The obtained tuple information is used as the flow identifier of the second data flow. Afterwards, the fourth network device may swap the source information and the destination information in the flow identifier of the second data flow to obtain the flow identifier of the first data flow.

[0041] As another example, the fourth network device may obtain the tuple information of the second data packet, and obtain the flow identifier of the second data flow from the stored correspondence between the tuple information and the flow identifier according to the tuple information of the second data packet. Then, according to the flow identifier of the second data flow, obtain the flow identifier of the first data flow from the stored correspondence between the first data flow identifier and the second data flow identifier.

[0042] It should be noted that since the fourth network device receives the third data packet through the network link between the fourth network device and the first network device, the outgoing interface in the target flow table entry currently added by the fourth network device is identified as the interface for communicating with the first network device, that is, the second type interface.

[0043] After the fourth network device adds the target flow table entry in the stored flow table, it can obtain the target tunnel table entry from the stored tunnel table according to the tunnel identifier of the target tunnel, and obtain the tunnel attribute information of the target tunnel from the target tunnel table entry, and then perform tunnel encapsulation on the second data packet according to the obtained tunnel attribute information to obtain the fourth data packet, and send the fourth data packet through the target tunnel.

[0044] Optionally, the first data packet is a data packet received by the first network device through a tunnel established between the first network device and a network device in the second site, or the first data packet is a data packet received by the first network device and sent by a fifth network device, and the fifth network device is a network device among the multiple network devices other than the first network device.

[0045] Optionally, a network link is established between the multiple network devices, and the multiple network devices communicate through the network link. The network link is a physical link or a network tunnel, and the network tunnel includes a Generic Routing Encapsulation (GRE) tunnel.

[0046] It should be noted that when the distance between multiple network devices is short, the network link may be a physical link. When the distance between multiple network devices is long, or they cannot be connected via a physical link, the network link may be a network tunnel, which may include a Generic Routing Encapsulation (GRE) tunnel. Of course, the network tunnel may also be other tunnels.

[0047] In addition, the network link between the two network devices in the first site is mainly used to synchronize the tunnel table entries within the site and the transmission of data packets within the site. It does not need to be published to the network outside the site. Therefore, the network addresses on the interfaces used to establish network links on the network devices in the first site can all be set to private network addresses. Even different sites can use the same address space, which can save the SD-WAN network's consumption of operator network address resources.

[0048] Optionally, in the case where the data message included in the first data flow is sent to the second site through the tunnel between the first network device and the network device in the second site, after the first network device adds the target flow table item in the flow table stored in the first network device, the first network device can send the target flow table item to other network devices in the first site through the network link. After the other network devices receive the target flow table item, the outgoing interface of the target flow table item can be modified to a second-class interface, that is, the interface through which each other network device communicates with the first network device, and the modified target flow table item is stored in the flow table. In this way, when the other network devices receive the first data message, the target flow table item is found in the stored flow table, and the first data message can be sent to the first network device through the interface corresponding to the outgoing interface identifier included in the target flow table item. After that, the first network device can send the first data message to the user end in the first site according to the target flow table item. It can be seen from this that synchronizing the target flow table item to other network devices in the first site can greatly reduce the situation where the first data message is constantly traversed and queried between network devices when the target flow table item is not found, thereby improving the efficiency of sending the first data message.

[0049] According to a second aspect, another method for sending a message is provided, wherein a plurality of network devices are deployed in a first site, a network link is established between the plurality of network devices, a plurality of tunnels are established between the network devices deployed in the first site and the network devices deployed in a second site, the second site refers to a site that transmits data with the first site, the method comprising: a first network device receives a first data message from the second site, the first data message is a data message received by the first network device through the network link between the first network device and the second network device, the first network device is any one of the plurality of network devices, the second network device is a network device among the plurality of network devices that has a network link established with the first network device; the first network device sends the first data message to a user terminal in the first site.

[0050] In the present application, since a network link is established between multiple network devices within the first site, the tunnel table of the first network device includes not only tunnel table entries corresponding to the tunnel between the first network device and the network device within the second site, but also tunnel table entries corresponding to the tunnels between other network devices within the first site and the network devices within the second site. Therefore, when the first network device receives a second data packet from a user terminal within the first site, and the selected target tunnel is a tunnel between a third network device and the network device within the second site, the first network device can send the second data packet to the third network device through the network link between the first network device and the third network device, and then the third network device sends it to the second site through the target tunnel, thereby realizing intercommunication between the first network device and the third network device, and communication between the first site and the second site can be realized without creating too many tunnels.

[0051] In a third aspect, a message sending device is provided, wherein the message sending device has the function of implementing the message sending method in the first aspect. The message sending device includes at least one module, and the at least one module is used to implement the message sending method provided in the first aspect.

[0052] In a fourth aspect, another message sending device is provided, wherein the message sending device has the function of implementing the message sending method in the first aspect. The message sending device includes at least one module, and the at least one module is used to implement the message sending method provided in the second aspect.

[0053] In a fifth aspect, a network device is provided, the network device comprising a processor and a memory, the memory being used to store a program for executing the message sending method provided in the first aspect or the second aspect, and storing data involved in implementing the message sending method provided in the first aspect or the second aspect. The processor is configured to execute the program stored in the memory. The operating device of the storage device may also include a communication bus, which is used to establish a connection between the processor and the memory.

[0054] In a sixth aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the message sending method described in the first aspect or the second aspect above.

[0055] In a seventh aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the message sending method described in the first aspect or the second aspect.

[0056] The technical effects obtained by the above-mentioned second, third, fourth, fifth, sixth and seventh aspects are similar to the technical effects obtained by the corresponding technical means in the first aspect, and will not be repeated here.

[0057] The technical solution provided by this application can at least bring the following beneficial effects:

[0058] In the present application, when the first network device receives the first data message from the second site, the target flow table entry whose flow identifier is the flow identifier of the first data flow can be searched in the flow table. Since the first data flow is the data flow to which the first data message belongs, the target flow table entry is created when the second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow. Therefore, only when the second data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device. In this way, the first network device can find the target flow table entry, and then send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry. It can be seen from this that the present application can ensure that the messages sent and received about the same application pass through the same network device. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] Figure 1 It is a system architecture diagram involved in a message sending method provided in an embodiment of the present application;

[0060] Figure 2 It is a system architecture diagram involved in another message sending method provided in an embodiment of the present application;

[0061] Figure 3 It is a structural diagram of a network device provided in an embodiment of the present application;

[0062] Figure 4 It is a flow chart of a message sending method provided in an embodiment of the present application;

[0063] Figure 5 is a schematic diagram of a tunnel index field provided in an embodiment of the present application;

[0064] Figure 6 is a flowchart of another message sending method provided in an embodiment of the present application;

[0065] Figure 7 is a schematic diagram of deploying a network device in a first site provided by an embodiment of the present application;

[0066] Figure 8 This is a flowchart of another message sending method provided in an embodiment of the present application;

[0067] Fig. 9It is a structural diagram of a message sending device provided in an embodiment of the present application;

[0068] Fig.10 It is a structural diagram of another message sending device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0069] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0070] Figure 1 1 is a system architecture diagram of a message sending method provided in an embodiment of the present application. Figure 1 As shown, the system includes network devices 101, 102, 103 and control device 104. Network devices 101 and 102 are network devices deployed in a first site, and network device 103 is a network device deployed in a second site. Network devices 101, 102 and 103 can be connected to control device 104 wirelessly or wired for communication.

[0071] After the network device is powered on, it can register with the control device 104. After that, a tunnel can be established between two network devices belonging to different sites through the control device 104. Here, the network device 101 and the network device 103 are taken as examples for explanation.

[0072] like Figure 1 As shown, the first interface of network device 101 accesses the Long Term Evolution (LTE) network, the first interface of network device 102 accesses the Multi-Protocol Label Switching (MPLS) network, the first interface of network device 103 accesses the LTE network, and the second interface of network device 103 accesses the MPLS network. It is assumed that before network device 101 is powered on, both network device 102 and network device 103 have completed registration, that is, a tunnel 2 has been established between the first interface of network device 102 and the second interface of network device 103.

[0073] After the network device 101 is powered on, the site prefix and site identifier of the first site, and the transport network port (TNP) information of the first interface of the network device 101 can be sent to the control device 104. Afterwards, the control device 104 determines that the network device 101 can communicate with the network device 103 according to the stored network topology. In this way, the control device 104 can send the site prefix and site identifier of the first site, and the TNP information of the first interface of the network device 101 to the network device 103, and send the site prefix and site identifier of the second site, and the TNP information of the first interface of the network device 103 to the network device 101.

[0074] After the network device 101 receives the site prefix and site identifier of the second site, the site prefix and site identifier of the second site can be added as a routing table item in the stored routing table. Similarly, after the network device 103 receives the site prefix and site identifier of the first site, the site prefix and site identifier of the first site can also be added as a routing table item in the stored routing table. Next, when the network device 101 receives the TNP information of the first interface of the network device 103 sent by the control device 104, and the network device 103 receives the TNP information of the first interface of the network device 101 sent by the control device 104, assuming that the TNP information of the two interfaces can match, then, a tunnel 1 can be established between the first interface of the network device 101 and the first interface of the network device 103. Afterwards, a network link can also be established between the second interface of the network device 101 and the second interface of the network device 102. The network link can be a physical link or a network tunnel, and the network device 101 and the network device 102 can communicate through the network link.

[0075] Based on this, after establishing tunnel 1, network device 101 can store the tunnel identifier and tunnel attribute information of tunnel 1 in the tunnel table, and send the tunnel identifier and tunnel attribute information of tunnel 1 to network device 102 through the network link. Afterwards, network device 101 can receive the tunnel identifier and tunnel attribute information of tunnel 2 sent by network device 102, and store them in the tunnel table. Similarly, the tunnel identifier and tunnel attribute information of tunnel 1, and the tunnel identifier and attribute information of tunnel 2 are also stored in the tunnel tables of network devices 102 and 103.

[0076] It should be noted that the TNP information may include parameter information such as the network address of the interface and the encryption mode for establishing a tunnel with other network devices. In addition, with respect to the same tunnel, the source information and the opposite end information in the tunnel attribute information stored in the devices at both ends of the tunnel are opposite. For example, for tunnel 1, the source information in the tunnel attribute information stored in the network devices 101 and 102 is the destination information of the tunnel attribute information stored in the network device 103, and the destination information in the tunnel attribute information stored in the network devices 101 and 102 is the source information of the tunnel attribute information stored in the network device 103. Among them, the source information of the tunnel may include the source network address of the tunnel, and the destination information of the tunnel may include the destination network address of the tunnel.

[0077] Next, when the network device 101 receives a data message sent from a user terminal in the first site to a user terminal in the second site, it can select tunnel 1 or tunnel 2 from the tunnel table as the target tunnel, and send the data message through the target tunnel. When the target tunnel is tunnel 1, the network device 101 can directly send the data message through tunnel 1. When the target tunnel is tunnel 2, the network device 101 can add the tunnel identifier of tunnel 2 to the data message, and then send the data message with the added tunnel identifier to the network device 102, so as to instruct the network device 102 to send the data message through tunnel 2.

[0078] Similarly, when the network device 102 receives a data packet sent from a user terminal in the first site to a user terminal in the second site, it can select tunnel 1 or tunnel 2 from the tunnel table as the target tunnel, and send the data packet through the target tunnel according to the same method as described above. When the network device 103 receives a data packet sent from a user terminal in the second site to a user terminal in the first site, it can select tunnel 1 or tunnel 2 from the tunnel table as the target tunnel, and send the data packet through the target tunnel.

[0079] Optionally, Figure 1 The illustrated system is illustrated by taking two network devices deployed in the first site and one network device deployed in the second site as an example. Of course, in other possible cases, one network device or more than two network devices may be deployed in the first site, two or more network devices may be deployed in the second site, and the number of network devices deployed in the first site may be the same as or different from the number of network devices deployed in the second site.

[0080] For example, Figure 2 As shown, in Figure 2In the system architecture shown, two network devices are deployed in the first site and the second site, that is, the first site is deployed with network device 101 and network device 102, and the second site is deployed with network device 105 and network device 106. According to the above method, tunnel 1 can be established between network device 101 and network device 105, tunnel 2 can be established between network device 102 and network device 106, and a network link can be established between network device 101 and network device 102.

[0081] Please refer to Figure 3 , Figure 3 is a schematic diagram of a network device according to an embodiment of the present application. The network device may be Figure 1 or Figure 2 The network device shown in . The network device includes at least one processor 301, a communication bus 302, a memory 303 and at least one communication interface 304.

[0082] The processor 301 may be a microprocessor (including a central processing unit (CPU), etc.), a network processor (NP), a microprocessor, or may be one or more integrated circuits for implementing the solution of the present application, for example, an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof. The above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.

[0083] The communication bus 302 is used to transmit information between the above components. The communication bus 302 can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0084] The memory 303 may be a read-only memory (ROM), a random access memory (RAM), an electrically erasable programmable read-only memory (EEPROM), an optical disc (including a compact disc read-only memory (CD-ROM), a compressed optical disc, a laser disc, a digital versatile disc, a Blu-ray disc, etc.), a magnetic disk storage medium or other magnetic storage device, or any other medium that can be used to carry or store the desired program code in the form of instructions or data structures and can be accessed by a network, but is not limited thereto. The memory 303 may exist independently and be connected to the processor 301 via the communication bus 302. The memory 303 may also be integrated with the processor 301.

[0085] The communication interface 304 uses any transceiver-like device for communicating with other devices or communication networks. The communication interface 304 includes a wired communication interface and may also include a wireless communication interface. Among them, the wired communication interface may be, for example, an Ethernet interface. The Ethernet interface may be an optical interface, an electrical interface, or a combination thereof. The wireless communication interface may be a wireless local area network (WLAN) interface, a cellular network communication interface, or a combination thereof, etc.

[0086] In a specific implementation, as an embodiment, the processor 301 may include one or more CPUs, such as Figure 3 CPU0 and CPU1 are shown in the figure.

[0087] In a specific implementation, as an embodiment, the network device may include multiple processors, such as Figure 3 301 and processor 305 shown in FIG. Each of these processors may be a single-core processor or a multi-core processor. The processor herein may refer to one or more devices, circuits, and / or processing cores for processing data (such as network program instructions).

[0088] In some embodiments, the memory 303 is used to store the program code 310 for executing the solution of the present application, and the processor 301 can execute the program code 310 stored in the memory 303. That is, the network device can implement the following by the processor 301 and the program code 310 in the memory 303. Figure 4 , Figure 6 or Figure 8 The embodiment provides a method for sending a message.

[0089] Figure 4 This is a flow chart of a message sending method provided by an embodiment of the present application. In this embodiment of the present application, multiple network devices are deployed in the first site, network links are established between the multiple network devices, and multiple tunnels are established between the network devices deployed in the first site and the network devices deployed in the second site. The second site refers to a site that transmits data with the first site. Please refer to Figure 4 , the method comprises the following steps.

[0090] Step 401: A first network device receives a second data packet from a user terminal in a first site, the second data packet carries a destination address, and the second data packet belongs to a second data flow.

[0091] The first network device is any one of the multiple network devices in the first site. Since the second data message belongs to the second data stream, and the second data stream is a data stream sent from the user end of the first site to the user end of the second site, the destination address carried by the second data message is the destination address of the user end in the second site.

[0092] It should be noted that when a user terminal in the first site sends a second data packet to a user terminal in the second site, since the two user terminals belong to different sites, the user terminal in the first site needs to send the second data packet to a network device in the first site, and then the second data packet is sent to a network device in the second site through the network device, and then the network device in the second site sends the second data packet to the user terminal in the second site.

[0093] As an example, a user terminal within the first site can select a network device from multiple network devices within the first site as the first network device based on the networking mode of the first site. After that, the second data packet can be sent to the first network device, and the second data packet can be sent to a network device within the second site through the first network device.

[0094] It should be noted that the correspondence between the networking mode and the device identifier can be stored in the user terminal. When the user terminal needs to send a data message, it can determine a network device to send the data message according to the networking mode of the site where it is located and the correspondence between the networking mode and the device identifier. For example, for a user terminal in the first site, the user terminal can obtain the corresponding device identifier from the stored correspondence between the networking mode and the device identifier according to the networking mode of the first site, and then determine the network device identified by the device identifier as the first network device.

[0095] Step 402: The first network device selects a tunnel as a target tunnel from multiple tunnels established between the first site and the second site according to the destination address carried by the second data message.

[0096] In an embodiment of the present application, a routing table is stored in the first network device, and the routing table includes multiple routing table items, each of which includes a site prefix and a corresponding site identifier. The site prefix refers to the network segment corresponding to the site, and the site identifier refers to the identifier of the site, which is used to uniquely identify a site.

[0097] Next, the implementation process of the first network device determining the target tunnel will be described through steps (1)-(3).

[0098] (1) The first network device determines a target routing table entry from the routing table according to a destination address carried by the second data packet, where the destination address matches a site prefix included in the target routing table entry.

[0099] Since the site prefix refers to the network segment corresponding to the site, the destination address carried by the second data packet can be matched with the site prefix included in each routing table entry in the routing table, so that the target routing table entry can be determined from the routing table.

[0100] It should be noted that, based on the above description, the target address carried by the second data packet is the address of the user terminal in the second site. Therefore, it can be determined that the site prefix included in the target routing table entry is the site prefix of the second site, and the site identifier included in the target routing table entry is the identifier of the second site.

[0101] (2) The first network device determines one or more tunnel table entries according to the site identifier included in the target routing table entry, where the one or more tunnel table entries refer to tunnel table entries corresponding to the tunnel established between the first site and the second site.

[0102] The first network device may store a tunnel table, which is used to store tunnel table entries corresponding to multiple sites. Of course, the first network device may also store multiple tunnel tables, which correspond to the multiple sites one by one. The multiple sites refer to sites with tunnels established with the first site, and the multiple sites include the second site. For these two situations, the first network device determines the one or more tunnel table entries in different ways. Therefore, the following two situations are described.

[0103] In the first case, a tunnel table is stored in the first network device. At this time, the first network device can determine one or more tunnel identifiers according to the site identifier included in the target routing table item, and the one or more tunnel identifiers refer to the identifiers of the tunnels established between the first site and the second site. Afterwards, the first network device can determine the above-mentioned one or more tunnel table items from the tunnel table according to the one or more tunnel identifiers.

[0104] It should be noted that no matter how many tunnel tables are stored in the first network device, each tunnel table may include multiple tunnel table entries, and each tunnel table entry in the multiple tunnel table entries may include a tunnel identifier and corresponding tunnel attribute information. The tunnel attribute information may include tunnel encapsulation mode, source address and destination address of the tunnel, whether the tunnel is available, tunnel bandwidth, and tunnel latency. Moreover, in some embodiments, the first network device may store a first mapping relationship between a site identifier and a tunnel identifier, that is, the first mapping relationship stores the identifiers of each site that has established a tunnel with the first site, and the identifiers of the tunnels established between each site and the first site. In this way, the first network device can determine one or more tunnel identifiers from the first mapping relationship based on the site identifier included in the target routing table entry. Afterwards, the first network device can determine the tunnel table entry whose tunnel identifier is the same as the one or more tunnel identifiers from the tunnel table, thereby obtaining one or more tunnel table entries.

[0105] In the second case, multiple tunnel tables are stored in the first network device. At this time, the first network device can determine the identifier of the target tunnel table according to the site identifier included in the target routing table item, and the target tunnel table refers to the tunnel table corresponding to the second site in the multiple tunnel tables. Afterwards, the first network device can determine the target tunnel table from the multiple tunnel tables according to the identifier of the target tunnel table, and determine the tunnel table items stored in the target tunnel table as the one or more tunnel table items mentioned above.

[0106] Since different tunnel tables are stored for different sites in the first network device, and the first network device can store a second mapping relationship between a site identifier and a tunnel table identifier, that is, the second mapping relationship stores the identifiers of each site that has established a tunnel with the first site, and the identifiers of the tunnel tables corresponding to each site. In this way, the first network device can determine the identifier of the target tunnel table from the second mapping relationship based on the site identifier included in the target routing table item. Afterwards, the target tunnel table can be determined from the multiple tunnel tables based on the identifier of the target tunnel table, and the tunnel table items in the target tunnel table can be determined as the one or more tunnel table items mentioned above.

[0107] (3) The first network device selects a tunnel table entry from the one or more tunnel table entries as a target tunnel table entry, and determines the tunnel corresponding to the target tunnel table entry as the target tunnel.

[0108] The first network device may select a tunnel entry from the one or more tunnel entries as a target tunnel entry according to the tunnel selection policy, and then determine the tunnel corresponding to the target tunnel entry as the target tunnel, that is, determine the tunnel identified by the tunnel identifier included in the target tunnel entry as the target tunnel.

[0109] Exemplarily, the tunnel selection strategy stored in the first network device is: select the tunnel with the largest bandwidth. In this way, the first network device can obtain the tunnel attribute information included in the one or more tunnel table entries, and obtain the bandwidth of the tunnel from the tunnel attribute information. Afterwards, the first network device can select a tunnel table entry with the largest bandwidth from the one or more tunnel table entries according to the bandwidth of the tunnel.

[0110] Optionally, each tunnel entry also includes a connection identifier, which is used to indicate whether the corresponding tunnel is connected, that is, whether the corresponding tunnel is available. Therefore, before the first network device selects the target tunnel entry according to the tunnel selection policy, it can also filter the tunnel entry with a valid connection identifier from the one or more tunnel entries, and then select the target tunnel entry from the filtered tunnel entries according to the tunnel selection policy.

[0111] Step 403: If the target tunnel is a tunnel established between a third network device and a network device in the second site, the first network device adds the tunnel identifier of the target tunnel to the second data message to obtain a third data message. The third network device is a network device other than the first network device among multiple network devices in the first site.

[0112] It should be noted that, since the tunnel table includes all tunnels established between the network device in the first site and the network device in the second site, the target tunnel determined by the first network device may be a tunnel established between the first network device and the network device in the second site, or it may be a tunnel established between a third network device and the network device in the second site, and the third network device is a network device in the first site other than the first network device.

[0113] In some embodiments, if the target tunnel is a tunnel established between a third network device and a network device within the second site, the first network device may add a tunnel index field in the second data packet, which may include a tunnel identifier of the target tunnel, thereby obtaining a third data packet.

[0114] For example, Figure 5As shown, the tunnel index field may include a tunnel identifier, which may be a tunnel identifier of the target tunnel. Optionally, the tunnel index field may also include an encapsulation method, a label, a version number, a protocol type, etc. Among them, the encapsulation method is the type of tunnel corresponding to the tunnel identifier, the label is a flag bit, which can be used to indicate that the data message is sent from the user side to the tunnel side, or received from the tunnel side, the version number is the version number of the tunnel index field used, and the protocol type is the protocol type of the second data message.

[0115] Step 404: The first network device sends the third data packet to the third network device via the network link between the first network device and the third network device.

[0116] Based on the above description, a network link is established between the first network device and the third network device, and the first network device and the third network device communicate through the network link. Therefore, the first network device adds the tunnel identifier of the target tunnel to the second data message, and after obtaining the third data message, the third data message can be sent to the third network device through the network link between the first network device and the third network device.

[0117] It should be noted that when the distance between the first network device and the third network device is short, the network link may be a physical link. When the distance between the first network device and the third network device is long, or they cannot be connected via a physical link, the network link may be a network tunnel, which may include a Generic Routing Encapsulation (GRE) tunnel. Of course, the network tunnel may also be other tunnels.

[0118] In addition, the network link between the two network devices in the first site is mainly used to synchronize the tunnel table entries within the site and the transmission of data packets within the site. It does not need to be published to the network outside the site. Therefore, the network addresses on the interfaces used to establish network links on the network devices in the first site can all be set to private network addresses. Even different sites can use the same address space, which can save the SD-WAN network's consumption of operator network address resources.

[0119] Step 405: The third network device receives the third data message, parses the third data message to obtain the second data message, and sends the second data message through the target tunnel.

[0120] In some embodiments, since the tunnel index field includes not only the tunnel identifier of the target tunnel, but also the encapsulation method, label, version number, protocol type, etc. of the tunnel index field, the second data packet can be parsed from the third data packet according to the information such as encapsulation method, label, version number, and protocol type, and at the same time, the tunnel identifier of the target tunnel can also be obtained.

[0121] Since the target tunnel table entry is also stored in the third network device, the third network device can obtain the tunnel attribute information of the target tunnel from the target tunnel table entry according to the tunnel identifier of the target tunnel, and then perform tunnel encapsulation on the second data packet according to the obtained tunnel attribute information to obtain the fourth data packet, and send the fourth data packet through the target tunnel.

[0122] The above steps 403-405 are for the case where the target tunnel is a tunnel between the third network device and the network device in the second site. When the target tunnel is a tunnel between the first network device and the network device in the second site, the first network device can directly send the second data message through the target tunnel.

[0123] In this case, the implementation process of the first network device sending the second data packet through the target tunnel may include: the first network device can obtain the tunnel attribute information of the target tunnel from the target tunnel table entry, and then perform tunnel encapsulation on the second data packet according to the obtained tunnel attribute information to obtain the fourth data packet, and send the fourth data packet through the target tunnel.

[0124] It should be noted that after receiving the fourth data message, the network device in the second site can perform tunnel decapsulation on the fourth data message to obtain the second data message.

[0125] It should be noted that the above steps 401-405 are the case where the user terminal in the first site sends a data message to the user terminal in the second site. It should be understood that the user terminal in the second site can also send a data message to the user terminal in the first site. Therefore, the following will introduce the case where the user terminal in the second site sends a data message to the user terminal in the first site through steps 406-407.

[0126] Step 406: The first network device receives a first data packet from the second site, where the first data packet belongs to a first data flow.

[0127] The first data stream is a data stream sent from a user terminal in the second site to a user terminal in the first site, so the source address of the first data stream is the destination address of the second data stream, and the destination address of the first data stream is the source address of the second data stream.

[0128] It should be noted that the implementation process of the network device in the second site receiving the first data message from the user terminal in the second site and sending the first data message to the network device in the first site is similar to the above steps 401-405, which will not be repeated here.

[0129] Step 407: The first network device sends a first data message to a user terminal in the first site.

[0130] In some embodiments, each network device in the first site can communicate with the user terminal in the first site, so after the first network device receives the first data message from the second site, it can directly send the first data message to the user terminal in the first site. That is, the first network device sends the first data message to the user terminal in the first site in the manner of steps 406-407.

[0131] In some other embodiments, multiple network devices in the first site may form a VRRP group according to the Virtual Router Redundancy Protocol (VRRP). The VRRP group includes a master network device and one or more backup network devices. The master network device is used to interact with the user terminal in the first site, and the backup network device may take over the work of the master network device in the event of a failure of the master network device. In this case, when the first network device is the master network device, after the first network device receives the first data packet, it may send the first data packet to the user terminal in the first site. The first data packet may be a data packet received by the first network device through a network link between the first network device and the second network device, and the second network device is a network device among the multiple network devices in the first site that has a network link established with the first network device. Of course, the first data packet may also be a data packet received by the first network device through a tunnel established between the first network device and the network device in the second site.

[0132] It should be noted that after the network device in the second site receives the first data message, it can select a tunnel from the tunnels between the second site and the first site, and send the first data message to the first site through the selected tunnel. When the selected tunnel is the tunnel established between the network device in the second site and the first network device, the first network device can directly receive the first data message through the tunnel. Since the first network device is the main network device, the first network device can directly send the first data message to the user terminal in the first site. When the selected tunnel is the tunnel established between the network device in the second site and the second network device, the second network device can receive the first data message through the tunnel. Since the first network device is the main network device, the second network device also needs to send the first data message to the first network device through the network link, that is, the first network device can receive the first data message sent by the second network device through the network link. Afterwards, the first network device can send the first data message to the user terminal in the first site.

[0133] It should be noted that the first network device stores a local route, which stores routing information between the first network device and the user terminal in the first site. Therefore, after receiving the first data message, the first network device can send the first data message to the user terminal in the first site according to the local route.

[0134] In addition, the second network device and the third network device may be the same network device. Of course, the second network device and the third network device may also be different network devices.

[0135] In an embodiment of the present application, since a network link is established between multiple network devices within the first site, the tunnel table of the first network device includes not only tunnel table entries corresponding to the tunnel between the first network device and the network device within the second site, but also includes tunnel table entries corresponding to the tunnels between other network devices within the first site and the network devices within the second site. Therefore, when the first network device receives a second data packet from a user terminal within the first site, and the selected target tunnel is a tunnel between a third network device and the network device within the second site, the first network device can send the second data packet to the third network device through the network link between the first network device and the third network device, and then the third network device sends it to the second site through the target tunnel, thereby realizing intercommunication between the first network device and the third network device, and communication between the first site and the second site can be realized without creating too many tunnels.

[0136] Figure 6 This is a flow chart of a message sending method provided by an embodiment of the present application. In this embodiment of the present application, multiple network devices are deployed in the first site, and multiple tunnels are established between the network devices deployed in the first site and the network devices deployed in the second site. The second site refers to a site that transmits data with the first site. Please refer to Figure 6 , the method comprises the following steps.

[0137] Step 601: A first network device receives a second data packet from a user terminal in a first site, the second data packet carries a destination address, and the second data packet belongs to a second data flow.

[0138] In the embodiment of the present application, the relevant explanation in step 601 can refer to the relevant explanation in step 401 in the aforementioned embodiment, and will not be repeated here.

[0139] Step 602: The first network device selects a tunnel as a target tunnel from multiple tunnels established between the first site and the second site according to the destination address carried by the second data message.

[0140] In the embodiment of the present application, the relevant explanation in step 602 can refer to the relevant explanation in step 402 in the aforementioned embodiment, and will not be repeated here.

[0141] Step 603: The first network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow.

[0142] Among them, the first data stream is a data stream sent from a user terminal in the second site to a user terminal in the first site, and the second data stream is a data stream sent from a user terminal in the first site to a user terminal in the second site. Therefore, the source address of the first data stream is the destination address of the second data stream, and the destination address of the first data stream is the source address of the second data stream.

[0143] In some embodiments, the first network device may determine the flow identifier of the second data flow according to the second data packet, and further determine the flow identifier of the first data flow according to the flow identifier of the second data flow.

[0144] As an example, the first network device may obtain tuple information of the second data message, the tuple information including at least source information and destination information. The obtained tuple information is used as the flow identifier of the second data flow. Afterwards, the first network device may swap the source information and the destination information in the flow identifier of the second data flow to obtain the flow identifier of the first data flow.

[0145] It should be noted that, in this example, the five-tuple information of the second data packet can be determined as the flow identifier of the second data flow, the three-tuple information of the second data packet can be determined as the flow identifier of the second data flow, or the seven-tuple information of the second data packet can be determined as the flow identifier of the second data flow. The embodiment of the present application is not limited to this. As long as the flow identifier of the second data flow includes at least source information and destination information, the second data flow can be uniquely identified.

[0146] For example, the flow identifier of the second data flow is five-tuple information, and the source address is: 192.168.0.1, the destination address is: 192.168.1.1, the source port is: port 1, the destination port is: port 2, and the protocol number is: protocol number 1. Afterwards, the first network device can swap the source address and the destination address in the flow identifier of the second data flow, and swap the source port and the destination port in the flow identifier of the second data flow, to obtain new five-tuple information, source address: 192.168.1.1, destination address: 192.168.0.1, source port: port 2, destination port: port 1, protocol number: protocol number 1, and use the new five-tuple information as the flow identifier of the first data flow.

[0147] As another example, the first network device may obtain the tuple information of the second data packet, and obtain the flow identifier of the second data flow from the stored correspondence between the tuple information and the flow identifier according to the tuple information of the second data packet. Thereafter, according to the flow identifier of the second data flow, obtain the flow identifier of the first data flow from the stored correspondence between the first data flow identifier and the second data flow identifier.

[0148] For example, the five-tuple information of the second data message is source address: 192.168.0.1, destination address: 192.168.1.1, source port: port 1, destination port: port 2, protocol number: protocol number 1. Afterwards, the first network device can obtain the flow identifier of the second data flow as ID2 from the correspondence between the tuple information and the flow identifier shown in Table 1 below according to the five-tuple information of the second data message. Afterwards, the first network device can obtain the flow identifier of the first data flow as ID1 from the correspondence between the first data flow identifier and the second data flow identifier shown in Table 2 below according to the flow identifier of the second data flow.

[0149] Table 1

[0150]

[0151] Table 2

[0152] Second data stream identifier First data stream identifier ID2 ID1 ID4 ID3 ID6 ID5

[0153] Step 604: The first network device adds a target flow table entry to the flow table stored in the first network device.

[0154] Among them, the flow table may include multiple flow table entries, each of the multiple flow table entries includes a flow identifier and a corresponding output interface identifier. Therefore, the currently added target flow table entry includes a flow identifier and a corresponding output interface identifier, and the flow identifier in the currently added target flow table entry is the flow identifier of the first data flow, and the output interface identifier in the currently added target flow table entry is the identifier of the first interface, and the first interface refers to the interface in the first network device for receiving the second data packet from the user terminal in the first site.

[0155] It should be noted that, since the same data flow may flow into the first network device through the interface for communicating with the user end in the first site, or may flow into the first network device through the interface for communicating with other network devices in the first site, the outgoing interface identifier in the target flow table entry currently added by the first network device may be the interface in the first network device for communicating with the user end in the first site, or may be the interface in the first network device for communicating with other network devices in the first site.

[0156] Step 605: If the target tunnel is a tunnel established between the first network device and a network device in the second site, the first network device sends the second data message through the target tunnel.

[0157] In this case, the first network device can directly send the second data message through the target tunnel. The implementation process of the first network device sending the second data message through the target tunnel may include: the first network device can obtain the tunnel attribute information of the target tunnel from the target tunnel table, and then perform tunnel encapsulation on the second data message according to the obtained tunnel attribute information to obtain the fourth data message, and send the fourth data message through the target tunnel.

[0158] The above step 605 is for the case where the target tunnel is a tunnel established between the first network device and the network device in the second site. In the case where the target tunnel is a tunnel between the fourth network device and the network device in the second site, the first network device can add the tunnel identifier of the target tunnel in the second data message to obtain the third data message, and the fourth network device is a network device other than the first network device among the multiple network devices in the first site. The first network device sends the third data message to the fourth network device. The fourth network device receives the third data message and parses the second data message from the third data message. The fourth network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow, adds the target flow table entry in the flow table stored by the fourth network device, and sends the second data message through the target tunnel, wherein the flow identifier included in the target flow table entry currently added by the fourth network device is the flow identifier of the first data flow, and the outgoing interface identifier in the target flow table entry currently added is the identifier of the second interface, and the second interface refers to the interface in the fourth network device for receiving the third data message.

[0159] Among them, the first network device obtains the third data message and sends the third data message to the fourth network device. The specific implementation method of the fourth network device parsing the second data message after receiving the third data message can refer to the implementation method in steps 403-405 in the aforementioned embodiment, which will not be repeated here.

[0160] In the embodiment of the present application, the specific implementation manner in which the fourth network device determines the flow identifier of the first data flow and adds the target flow table entry in the stored flow table can refer to the implementation manner in the aforementioned steps 603-604, which will not be repeated here.

[0161] It should be noted that since the fourth network device receives the third data packet through the network link between the fourth network device and the first network device, the outgoing interface in the target flow table entry currently added by the fourth network device is identified as the interface for communicating with the first network device, that is, the second type interface.

[0162] It should be noted that the above steps 601-605 are the case where the user terminal in the first site sends a data message to the user terminal in the second site. It should be understood that the user terminal in the second site can also send a data message to the user terminal in the first site. Therefore, the following will introduce the case where the user terminal in the second site sends a data message to the user terminal in the first site through steps 606-608.

[0163] Step 606: The first network device receives a first data packet from the second site, where the first data packet belongs to a first data flow.

[0164] In an embodiment of the present application, the first data packet is a data packet received by the first network device through a tunnel established between the first network device and a network device in the second site, or the first data packet is a data packet sent by a fifth network device and received by the first network device, and the fifth network device is a network device among multiple network devices other than the first network device.

[0165] In order to ensure that the data packets sent and received by the same application pass through the same network device, after a network device in the first site receives the first data packet through the tunnel between the first site and the second site, it is necessary to search for the target flow table entry whose flow identifier is the flow table identifier of the first data flow. If the target flow table entry does not exist in this network device, it can be indicated that the second data flow does not pass through this network device, then this network device needs to send the first data packet to other network devices in the first site, so as to find the network device through which the second data flow passes. Therefore, the first data packet may also be a data packet sent by the fifth network device and received by the first network device.

[0166] It should be noted that the fifth network device may be the same network device as the fourth network device, or may be a different network device from the fourth network device.

[0167] Step 607: The first network device searches for a target flow table entry whose flow identifier is the flow identifier of the first data flow from the flow table stored in the first network device.

[0168] Based on the above description, the flow table includes multiple flow table entries, each of the multiple flow table entries includes a flow identifier and a corresponding output interface identifier, and the first data flow is the data flow to which the first data packet belongs. Therefore, the first network device can compare the flow identifier of the first data flow with the flow identifier included in each flow table entry in the flow table, thereby finding the target flow table entry whose flow identifier is the flow identifier of the first data flow.

[0169] Step 608: If the target flow entry is found, the first network device sends the first data message through the interface corresponding to the outgoing interface identifier in the target flow entry.

[0170] In some embodiments, when the first network device finds the target flow table entry, it can obtain the outgoing interface identifier included in the target flow table entry, and then send the first data message according to the interface corresponding to the outgoing interface identifier. Since the interface corresponding to the outgoing interface identifier included in the target flow table entry may be an interface for communicating with a user terminal in the first site, or may be an interface for communicating with other network devices in the first site, the following describes the method of sending the first data message in these two cases respectively.

[0171] In one possible case, if the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first network device sends the first data packet to the user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry, and the first-class interface refers to the interface for communication with the user terminal in the first site.

[0172] In another possible case, if the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first network device sends the first data packet to the third network device through the interface corresponding to the outgoing interface identifier in the target flow table entry to instruct the third network device to search for the target flow table entry from the flow table stored in the third network device. The second-class interface refers to an interface for communicating with other network devices among the multiple network devices within the first site, and the third network device refers to a device among the multiple network devices within the first site that communicates with the first network device through the interface corresponding to the outgoing interface identifier in the target flow table entry.

[0173] It should be noted that the third network device and the fifth network device may be different network devices, but the third network device may be the same network device as the fourth network device or may be a different network device from the fourth network device.

[0174] In other embodiments, when the first network device fails to find the target flow table entry, the first network device may determine whether there are network devices in the first site that have not found the target flow table entry. If there are network devices in the first site that have not found the target flow table entry, the first network device sends the first data packet to the second network device to instruct the second network device to search for the target flow table entry from the flow table stored in the second network device, and the second network device is a network device in the first site that has not found the target flow table entry. If the multiple network devices in the first site have all found the target flow table entry, the first network device sends the first data packet through local routing.

[0175] As an example, every two network devices among the multiple network devices in the first site can be connected via a network link, that is, every two network devices can communicate with each other. In this case, the first data packet can carry the device identification of each network device that the first data packet passes through. In this way, when the first network device determines whether there are still network devices in the first site that have not found the target flow table entry, it can determine the network devices in the multiple network devices in the first site that have not found the target flow table entry based on the device identification of the network device carried in the first data packet.

[0176] Optionally, in this case, a device identification field may be added to the first data message, and the device identification field may include the device identification of each network device that the first data message passes through. In this way, when the first network device determines whether there are network devices in the first site that have not yet found the target flow table entry, the network device in the first site that has not yet found the target flow table entry may be determined based on the device identification included in the device identification field in the first data message.

[0177] For example, Figure 7 As shown, three network devices are deployed in the first site, namely network device 701, network device 702, and network device 703, and network device 701 has network links with network device 702 and network device 703, respectively, network device 702 has network links with network device 701 and network device 703, respectively, and network device 703 has network links with network device 701 and network device 702, respectively. When network device 701 receives the first data message, if the target flow table entry is not found in the flow table, network device 701 can obtain the device identification field carried by the first data message, and determine the network device in the first site that has not found the target flow table entry according to the device identification of the network device included in the device identification field. Assuming that both network device 702 and network device 703 have not found the target flow table entry, network device 701 can add its own device identification in the device identification field carried by the first data message, and send the first data message to network device 702 or network device 703 through the network link, and take sending to network device 702 as an example. After network device 702 receives the first data packet, if the target flow table entry is not found in the flow table, network device 702 can obtain the device identification field carried in the first data packet, and determine that the network device for which the target flow table entry is not found in the first site is network device 703 based on the device identification of the network device included in the device identification field. Thereafter, network device 702 can add its own device identification in the device identification field carried by the first data packet, and then send the first data packet to network device 703.

[0178] It should be noted that each network device in the first site stores a local route, and the local route stores the routing information between the corresponding network device and the user terminal in the first site. Therefore, when the first network device receives the first data message, and multiple network devices in the first site have searched for the target flow table entry, the first data message can be sent to the user terminal in the first site according to the local route.

[0179] In addition, the second network device and the fifth network device may be different network devices, but the second network device may be the same network device as the third network device and the fourth network device, or may be a different network device from the third network device and the fourth network device.

[0180] Optionally, in the case where the data message included in the first data flow is sent to the second site through the tunnel between the first network device and the network device in the second site, after the first network device adds the target flow table item in the flow table stored in the first network device, the first network device can send the target flow table item to other network devices in the first site through the network link. After the other network devices receive the target flow table item, the outgoing interface of the target flow table item can be modified to a second-class interface, that is, the interface through which each other network device communicates with the first network device, and the modified target flow table item is stored in the flow table. In this way, when the other network devices receive the first data message, the target flow table item is found in the stored flow table, and the first data message can be sent to the first network device through the interface corresponding to the outgoing interface identifier included in the target flow table item. After that, the first network device can send the first data message to the user end in the first site according to the target flow table item. It can be seen from this that synchronizing the target flow table item to other network devices in the first site can greatly reduce the situation where the first data message is constantly traversed and queried between network devices when the target flow table item is not found, thereby improving the efficiency of sending the first data message.

[0181] In an embodiment of the present application, when the first network device receives the first data message from the second site, the target flow table entry whose flow identifier is the flow identifier of the first data flow can be searched in the flow table. Since the first data flow is the data flow to which the first data message belongs, the target flow table entry is created when the second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow. Therefore, only when the second data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device. In this way, the first network device can find the target flow table entry, and then send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry. It can be seen from this that the embodiment of the present application can ensure that the messages sent and received about the same application pass through the same network device.

[0182] The above embodiments are all based on the example of multiple network devices deployed in the first site to introduce the message sending method provided by the embodiment of the present application. Next, the first network device and the second network device deployed in the first site are used as an example to illustrate the message sending method provided by the embodiment of the present application. Please refer to Figure 8 , Figure 8 1 is a flow chart of a message sending method provided in an embodiment of the present application. In the embodiment of the present application, a tunnel is established between the first network device and the second network device and the third network device respectively, and the second site refers to a site that transmits data with the first site. The method includes the following steps.

[0183] Step 801: A first network device receives a second data packet from a user terminal in a first site, the second data packet carries a destination address, and the second data packet belongs to a second data flow.

[0184] In the embodiment of the present application, the relevant explanation in step 801 can refer to the relevant explanation in step 401 in the aforementioned embodiment, and will not be repeated here.

[0185] Step 802: The first network device selects a tunnel as a target tunnel from multiple tunnels established between the first site and the second site according to the destination address carried by the second data message.

[0186] In the embodiment of the present application, the relevant explanation in step 802 can refer to the relevant explanation in step 402 in the aforementioned embodiment, and will not be repeated here.

[0187] Step 803: The first network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow.

[0188] In the embodiment of the present application, the relevant explanation in step 803 can refer to the relevant explanation in step 603 in the aforementioned embodiment, and will not be repeated here.

[0189] Step 804: The first network device adds a target flow table entry to the flow table stored in the first network device.

[0190] In the embodiment of the present application, the relevant explanation in step 804 can refer to the relevant explanation in step 604 in the aforementioned embodiment, and will not be repeated here.

[0191] Step 805: If the target tunnel is a tunnel established between the first network device and a network device in the second site, the first network device sends the second data packet through the target tunnel.

[0192] In the embodiment of the present application, the relevant explanation in step 805 can refer to the relevant explanation in step 605 in the aforementioned embodiment, and will not be repeated here.

[0193] The above step 805 is for the case where the target tunnel is a tunnel established between the first network device and the network device in the second site. In the case where the target tunnel is a tunnel between the second network device and the network device in the second site, the first network device can add the tunnel identifier of the target tunnel in the second data message to obtain a third data message. The first network device sends the third data message to the second network device to instruct the second network device to parse the second data message. The second network device determines the flow identifier of the first data flow based on the flow identifier of the second data flow, adds a target flow table entry to the flow table stored in the second network device, and sends the second data message through the target tunnel, wherein the flow identifier included in the currently added target flow table entry is the flow identifier of the first data flow, and the outgoing interface identifier in the currently added target flow table entry is the identifier of the second interface, and the second interface refers to the interface in the second network device for receiving the third data message.

[0194] Among them, the first network device obtains the third data message and sends the third data message to the second network device. The specific implementation method of the second network device parsing the second data message after receiving the third data message can refer to the implementation method in steps 403-405 in the aforementioned embodiment, which will not be repeated here.

[0195] In the embodiment of the present application, the specific implementation manner in which the second network device determines the flow identifier of the first data flow and adds the target flow table entry in the stored flow table can refer to the implementation manner in steps 603-604 in the aforementioned embodiment, which will not be repeated here.

[0196] It should be noted that the above steps 801-805 are the case where the user terminal in the first site sends a data message to the user terminal in the second site. It should be understood that the user terminal in the second site can also send a data message to the user terminal in the first site. Therefore, the following will introduce the case where the user terminal in the second site sends a data message to the user terminal in the first site through steps 806-808.

[0197] Step 806: The first network device receives a first data packet from the second site, where the first data packet belongs to a first data flow.

[0198] In the embodiment of the present application, the relevant explanation in step 806 can refer to the relevant explanation in step 606 in the aforementioned embodiment, and will not be repeated here.

[0199] Step 807: The first network device searches for a target flow table entry whose flow identifier is the flow identifier of the first data flow from the flow table stored in the first network device.

[0200] In the embodiment of the present application, the relevant explanation in step 807 can refer to the relevant explanation in step 607 in the aforementioned embodiment, and will not be repeated here.

[0201] Step 808: If the target flow entry is found, the first network device sends the first data message through the interface corresponding to the outgoing interface identifier in the target flow entry.

[0202] In some embodiments, when the first network device finds the target flow table entry, it can obtain the outgoing interface identifier included in the target flow table entry, and then send the first data message according to the interface corresponding to the outgoing interface identifier. Since the interface corresponding to the outgoing interface identifier included in the target flow table entry may be an interface for communicating with a user terminal in the first site, or may be an interface for communicating with the second network device, the following describes the method of sending the first data message in these two cases respectively.

[0203] In one possible case, if the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first network device sends the first data packet to the user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry, and the first-class interface refers to the interface for communication with the user terminal in the first site.

[0204] In another possible case, if the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first network device sends the first data packet to the second network device through the interface corresponding to the outgoing interface identifier in the target flow table entry to instruct the second network device to search for the target flow table entry from the flow table stored in the second network device. The second-class interface refers to the interface for communication with the second network device.

[0205] In other embodiments, if the first network device does not find the target flow table entry, and the first data packet is received through a tunnel established between the first network device and a network device in the second site, the first network device may send the first data packet to the second network device to instruct the second network device to search for the target flow table entry from the flow table stored by the second network device. If the second network device finds the target flow table entry from the stored flow table, at this time, the second network device may send the first data packet to the user terminal in the first site according to the interface corresponding to the outgoing interface identifier included in the target flow table entry. If the second network device does not find the target flow table entry from the stored flow table, at this time, the second network device may send the first data packet to the user terminal in the first site according to the interface indicated by the configured local route.

[0206] If the first network device does not find the target flow table entry, and the first data packet is received through the network link between the first network device and the second network device, the first network device can send the first data packet to the user terminal in the first site according to the interface indicated by the configured local route.

[0207] It should be noted that both the first network device and the second network device store local routes, the local routes stored in the first network device store routing information between the first network device and the user terminal in the first site, and the local routes stored in the second network device store routing information between the second network device and the user terminal in the first site. Therefore, when the first network device or the second network device sends a first data message to the user terminal in the first site, the first data message can be sent to the user terminal in the first site according to the local routes stored by each.

[0208] In an embodiment of the present application, when the first network device receives the first data message from the second site, the target flow table entry whose flow identifier is the flow identifier of the first data flow can be searched in the flow table. Since the first data flow is the data flow to which the first data message belongs, the target flow table entry is created when the second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow. Therefore, only when the second data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device. In this way, the first network device can find the target flow table entry, and then send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry. It can be seen from this that the embodiment of the present application can ensure that the messages sent and received about the same application pass through the same network device.

[0209] Fig. 9 This is a structural diagram of a message sending device provided in an embodiment of the present application. The message sending device can be implemented by software, hardware or a combination of both to become part or all of the first network device. Among them, multiple network devices are deployed in the first site, and multiple tunnels are established between the network devices deployed in the first site and the network devices deployed in the second site. The second site refers to a site that transmits data with the first site, and the first network device is any network device among the multiple network devices in the first site. Fig. 9 The device includes: a first receiving module 901, a searching module 902 and a first sending module 903.

[0210] A first receiving module 901, configured to receive a first data message from a second site;

[0211] A search module 902 is used to search for a target flow table entry whose flow identifier is a flow identifier of a first data flow from a flow table stored in a first network device, wherein the flow table includes multiple flow table entries, each of the multiple flow table entries includes a flow identifier and a corresponding outbound interface identifier, the first data flow is a data flow to which the first data packet belongs, the target flow table entry is created when a second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow;

[0212] The first sending module 903 is configured to send the first data message through the interface corresponding to the outgoing interface identifier in the target flow entry if a target flow entry is found.

[0213] Optionally, the device further comprises:

[0214] A second sending module is used to send the first data packet to a second network device if the target flow table entry is not found, and there is a network device among the multiple network devices that has not found the target flow table entry, so as to instruct the second network device to search for the target flow table entry from the flow table stored in the second network device, and the second network device is a network device among the multiple network devices that has not found the target flow table entry;

[0215] The third sending module is configured to send the first data message through a local route if the target flow table entry is not found and the multiple network devices have all searched for the target flow table entry.

[0216] Optionally, the first sending module 903 is mainly used for:

[0217] If the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first data packet is sent to the user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry, where the first-class interface refers to an interface for communicating with the user terminal in the first site;

[0218] If the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first data packet is sent to the third network device through the interface corresponding to the outgoing interface identifier in the target flow table entry to instruct the third network device to search for the target flow table entry from the flow table stored in the third network device. The second-class interface refers to the interface for communicating with other network devices among the multiple network devices, and the third network device refers to the device among the multiple network devices that communicates with the first network device through the interface corresponding to the outgoing interface identifier in the target flow table entry.

[0219] Optionally, the device further comprises:

[0220] A second receiving module, configured to receive a second data message from a user terminal in the first site, the second data message carries a destination address, and the second data message belongs to the second data flow;

[0221] A selection module, configured to select a tunnel from the multiple tunnels as a target tunnel according to a destination address;

[0222] A determination module, configured to determine a flow identifier of the first data flow according to a flow identifier of the second data flow;

[0223] A first adding module, configured to add a target flow table entry in a flow table stored in a first network device, wherein the flow identifier in the target flow table entry currently added is the flow identifier of the first data flow, and the outgoing interface identifier in the target flow table entry currently added is the identifier of the first interface, and the first interface refers to an interface in the first network device for receiving a second data message from a user terminal in the first site;

[0224] The fourth sending module is used to send the second data message through the target tunnel if the target tunnel is a tunnel established between the first network device and the network device in the second site.

[0225] Optionally, a routing table is stored in the first network device, the routing table includes a plurality of routing table items, each of the plurality of routing table items includes a site prefix and a corresponding site identifier;

[0226] The selection module is mainly used for:

[0227] Determine a target routing table entry from the routing table according to the destination address carried by the second data message, wherein the destination address carried by the second data message matches the site prefix included in the target routing table entry;

[0228] Determine one or more tunnel entries according to the site identifier included in the target routing entry, where the one or more tunnel entries refer to tunnel entries corresponding to the tunnel established between the first site and the second site;

[0229] A tunnel entry is selected from the one or more tunnel entries as a target tunnel entry, and a tunnel corresponding to the target tunnel entry is used as a target tunnel.

[0230] Optionally, the flow identifier of the second data flow includes source end information and destination end information;

[0231] The determination module is mainly used for:

[0232] After the source end information and the destination end information in the flow identifier of the second data flow are swapped, the flow identifier of the first data flow is obtained.

[0233] Optionally, the device further comprises:

[0234] a second adding module, configured to add a tunnel identifier of the target tunnel to the second data message to obtain a third data message if the target tunnel is a tunnel established between a fourth network device and a network device in the second site, and the fourth network device is a network device other than the first network device among the multiple network devices;

[0235] A fifth sending module is used to send the third data packet to the fourth network device to instruct the fourth network device to parse the second data packet, determine the flow identifier of the first data flow according to the flow identifier of the second data flow, add a target flow table entry in the flow table stored in the fourth network device, and send the second data packet through the target tunnel, wherein the flow identifier included in the currently added target flow table entry is the flow identifier of the first data flow, the outgoing interface identifier in the currently added target flow table entry is the identifier of the second interface, and the second interface refers to the interface in the fourth network device for receiving the third data packet.

[0236] Optionally, the first data packet is a data packet received by the first network device through a tunnel established between the first network device and a network device in the second site, or the first data packet is a data packet sent by a fifth network device and received by the first network device, and the fifth network device is a network device other than the first network device among the multiple network devices.

[0237] Optionally, a network link is established between the multiple network devices, and the multiple network devices communicate through the network link. The network link is a physical link or a network tunnel, and the network tunnel includes a GRE tunnel.

[0238] In an embodiment of the present application, when the first network device receives the first data message from the second site, the target flow table entry whose flow identifier is the flow identifier of the first data flow can be searched in the flow table. Since the first data flow is the data flow to which the first data message belongs, the target flow table entry is created when the second data flow is sent from the first site to the second site, the source address of the second data flow is the destination address of the first data flow, and the destination address of the second data flow is the source address of the first data flow. Therefore, only when the second data flow passes through the first network device, the target flow table entry exists in the flow table of the first network device. In this way, the first network device can find the target flow table entry, and then send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry. It can be seen from this that the embodiment of the present application can ensure that the messages sent and received about the same application pass through the same network device.

[0239] Fig.10This is a structural diagram of another message sending device provided by an embodiment of the present application. The message sending device can be implemented by software, hardware or a combination of both to become part or all of a first network device, wherein a plurality of network devices are deployed in a first site, a network link is established between the plurality of network devices, a plurality of tunnels are established between the network device deployed in the first site and the network device deployed in the second site, the second site refers to a site that transmits data with the first site, and the first network device is any one of the plurality of network devices. Fig.10 , the device includes: a receiving module 1001 and a sending module 1002.

[0240] The receiving module 1001 is used to receive a first data message from a second site, where the first data message is a data message received by the first network device through a network link between the first network device and the second network device, where the second network device is a network device among the multiple network devices that has a network link established with the first network device;

[0241] The sending module 1002 is used to send a first data message to a user terminal in a first site.

[0242] In an embodiment of the present application, since a network link is established between multiple network devices within the first site, the tunnel table of the first network device includes not only tunnel table entries corresponding to the tunnel between the first network device and the network device within the second site, but also includes tunnel table entries corresponding to the tunnels between other network devices within the first site and the network devices within the second site. Therefore, when the first network device receives a second data packet from a user terminal within the first site, and the selected target tunnel is a tunnel between a third network device and the network device within the second site, the first network device can send the second data packet to the third network device through the network link between the first network device and the third network device, and then the third network device sends it to the second site through the target tunnel, thereby realizing intercommunication between the first network device and the third network device, and communication between the first site and the second site can be realized without creating too many tunnels.

[0243] It should be noted that: the message sending device provided in the above embodiment only uses the division of the above functional modules as an example when sending a message. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device is divided into different functional modules to complete all or part of the functions described above. In addition, the message sending device provided in the above embodiment and the message sending method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, which will not be repeated here.

[0244] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc. It is worth noting that the computer-readable storage medium mentioned in the present application may be a non-volatile storage medium, in other words, a non-transient storage medium.

[0245] In the present application, the terms "first", "second", etc. are used to distinguish between identical or similar items having substantially the same effects and functions. It should be understood that there is no logical or temporal dependency between "first", "second", and "nth", nor is the quantity and execution order limited. It should also be understood that although the following description uses the terms first, second, etc. to describe various elements, these elements should not be limited by the terms. These terms are only used to distinguish one element from another. For example, without departing from the scope of the various described examples, a first image may be referred to as a second image, and similarly, a second image may be referred to as a first image. Both the first image and the second image may be images, and in some cases, may be separate and different images.

[0246] The term "at least one" in this application means one or more, and the term "multiple" in this application means two or more, for example, multiple second messages means two or more second messages. The terms "system" and "network" are often used interchangeably herein.

[0247] It should be understood that the terms used in the description of the various examples herein are only for describing specific examples and are not intended to be limiting. As used in the description of the various examples and the appended claims, the singular forms "a", "an", and "the" are intended to include the plural forms as well, unless the context clearly indicates otherwise.

[0248] It should also be understood that the term "and / or" used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. The term "and / or" is a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.

[0249] It should also be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0250] It should be understood that determining B based on A does not mean determining B only based on A. B can also be determined based on A and / or other information.

[0251] It should also be understood that the term “comprise” (also known as “includes,” “including,” “comprises” and / or “comprising”) when used in this specification specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.

[0252] It should also be understood that the term "and / or" used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items. The term "and / or" is a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this application generally indicates that the associated objects before and after are in an "or" relationship.

[0253] It should also be understood that the term "if" may be interpreted to mean "when" or "upon" or "in response to determining" or "in response to detecting." Similarly, the phrase "if it is determined that ..." or "if [a stated condition or event] is detected" may be interpreted to mean "upon determining that ..." or "in response to determining that ..." or "upon detecting [a stated condition or event]" or "in response to detecting [a stated condition or event]," depending on the context.

[0254] It should be understood that the references to "one embodiment", "an embodiment", or "a possible implementation" throughout the specification mean that specific features, structures, or characteristics related to the embodiment or implementation are included in at least one embodiment of the present application. Therefore, the references to "in one embodiment" or "in an embodiment", or "a possible implementation" appearing throughout the specification do not necessarily refer to the same embodiment. In addition, these specific features, structures, or characteristics may be combined in any suitable manner in one or more embodiments.

[0255] The above-mentioned embodiments are provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A message sending method, characterized in that: A plurality of network devices are deployed in a first site, a plurality of tunnels are established between the network devices deployed in the first site and the network devices deployed in a second site, the second site being a site that transmits data with the first site, and the method comprising: A first network device receives a first data message from the second site, the first network device being any network device among the multiple network devices; The first network device searches for a target flow table entry whose flow identifier is a flow identifier of a first data flow from a flow table stored in the first network device, the flow table comprising a plurality of flow table entries, each of the plurality of flow table entries comprising a flow identifier and a corresponding outbound interface identifier, the first data flow is a data flow to which the first data packet belongs, the target flow table entry is created when a second data flow is sent from the first site to the second site, the source address of the second data flow is a destination address of the first data flow, and the destination address of the second data flow is a source address of the first data flow; If the target flow table entry is found, the first network device sends the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry; The method further comprises: The first network device receives a second data packet from a user terminal in the first site, the second data packet carries a destination address, and the second data packet belongs to the second data flow; The first network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow; The first network device adds the target flow table entry in the flow table stored in the first network device, wherein the flow identifier in the target flow table entry currently added is the flow identifier of the first data flow, and the outbound interface identifier in the target flow table entry currently added is the identifier of the first interface, and the first interface refers to the interface in the first network device for receiving the second data message from the user terminal in the first site; The first network device sends the second data message according to the destination address.

2. The method according to claim 1, characterized in that After the first network device searches for a target flow table entry whose flow identifier is the flow identifier of the first data flow from the flow table stored in the first network device, the method further includes: If the target flow table entry is not found, and there is still a network device among the multiple network devices that has not found the target flow table entry, the first network device sends the first data packet to a second network device to instruct the second network device to search for the target flow table entry from a flow table stored in the second network device, and the second network device is a network device among the multiple network devices that has not found the target flow table entry; If the target flow table entry is not found, and the plurality of network devices have all searched for the target flow table entry, the first network device sends the first data packet through a local route.

3. The method according to claim 1, characterized in that The first network device sending the first data packet through the interface corresponding to the outgoing interface identifier in the target flow table entry includes: If the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first network device sends the first data packet to a user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry, where the first-class interface refers to an interface for communication with a user terminal in the first site; If the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first network device sends the first data packet to the third network device through the interface corresponding to the outgoing interface identifier in the target flow table entry, so as to instruct the third network device to search for the target flow table entry from the flow table stored in the third network device, wherein the second-class interface refers to the interface for communicating with other network devices among the multiple network devices, and the third network device refers to the device among the multiple network devices that communicates with the first network device through the interface corresponding to the outgoing interface identifier in the target flow table entry.

4. The method according to any one of claims 1 to 3, characterized in that: The first network device sending the second data message according to the destination address includes: The first network device selects a tunnel from the multiple tunnels as a target tunnel according to the destination address; If the target tunnel is a tunnel established between the first network device and a network device in the second site, the first network device sends the second data packet through the target tunnel.

5. The method according to claim 4, characterized in that The first network device stores a routing table, the routing table comprising a plurality of routing table entries, each of the plurality of routing table entries comprising a site prefix and a corresponding site identifier; The first network device selects a tunnel from the multiple tunnels as a target tunnel according to the destination address, including: The first network device determines a target routing table entry from the routing table according to the destination address, wherein the destination address matches a site prefix included in the target routing table entry; The first network device determines one or more tunnel table entries according to the site identifier included in the target routing table entry, where the one or more tunnel table entries refer to tunnel table entries corresponding to the tunnel established between the first site and the second site; The first network device selects a tunnel table entry from the one or more tunnel table entries as a target tunnel table entry, and uses a tunnel corresponding to the target tunnel table entry as the target tunnel.

6. The method according to any one of claims 1 to 3, characterized in that: The flow identifier of the second data flow includes source end information and destination end information; The first network device determines the flow identifier of the first data flow according to the flow identifier of the second data flow, including: The first network device obtains the flow identifier of the first data flow after swapping the source end information and the destination end information in the flow identifier of the second data flow.

7. The method according to claim 4, characterized in that After the first network device selects a tunnel from the multiple tunnels as a target tunnel according to the destination address, the method further includes: If the target tunnel is a tunnel established between a fourth network device and a network device in the second site, the first network device adds a tunnel identifier of the target tunnel to the second data message to obtain a third data message, and the fourth network device is a network device among the multiple network devices except the first network device; The first network device sends the third data packet to the fourth network device to instruct the fourth network device to parse the second data packet, determine the flow identifier of the first data flow according to the flow identifier of the second data flow, add the target flow table entry in the flow table stored in the fourth network device, and send the second data packet through the target tunnel, wherein the flow identifier included in the currently added target flow table entry is the flow identifier of the first data flow, the outgoing interface identifier in the currently added target flow table entry is the identifier of the second interface, and the second interface refers to the interface in the fourth network device for receiving the third data packet.

8. The method according to any one of claims 1 to 3, characterized in that: The first data packet is a data packet received by the first network device through a tunnel established between the first network device and a network device in the second site, or the first data packet is a data packet received by the first network device from a fifth network device, where the fifth network device is a network device among the multiple network devices other than the first network device.

9. The method according to any one of claims 1 to 3, characterized in that: A network link is established between the multiple network devices, and the multiple network devices communicate through the network link. The network link is a physical link or a network tunnel, and the network tunnel includes a general routing encapsulation GRE tunnel.

10. A message sending device, applied to a first network device, characterized in that: A plurality of network devices are deployed in a first site, a plurality of tunnels are established between the network devices deployed in the first site and the network devices deployed in a second site, the second site refers to a site that transmits data with the first site, the first network device is any one of the plurality of network devices, and the apparatus comprises: A first receiving module, used for receiving a first data message from the second site; a search module, configured to search, from a flow table stored in the first network device, a target flow table entry whose flow identifier is a flow identifier of a first data flow, the flow table comprising a plurality of flow table entries, each of the plurality of flow table entries comprising a flow identifier and a corresponding outbound interface identifier, the first data flow being a data flow to which the first data packet belongs, the target flow table entry being created when a second data flow is sent from the first site to the second site, the source address of the second data flow being a destination address of the first data flow, and the destination address of the second data flow being a source address of the first data flow; A first sending module, configured to send the first data message through the interface corresponding to the outgoing interface identifier in the target flow table entry if the target flow table entry is found; The device also includes: A second receiving module, configured to receive a second data message from a user terminal in the first site, wherein the second data message carries a destination address and belongs to the second data flow; a determination module, configured to determine a flow identifier of the first data flow according to the flow identifier of the second data flow; A first adding module, configured to add the target flow table entry to the flow table stored in the first network device, wherein the flow identifier in the target flow table entry currently added is the flow identifier of the first data flow, and the outgoing interface identifier in the target flow table entry currently added is the identifier of the first interface, and the first interface refers to the interface in the first network device for receiving the second data message from the user terminal in the first site; And a module that does the following: The second data packet is sent according to the destination address.

11. The device according to claim 10, characterized in that The device also includes: a second sending module, configured to send the first data packet to a second network device, if the target flow table entry is not found, and there is a network device among the multiple network devices that has not found the target flow table entry, so as to instruct the second network device to search for the target flow table entry from the flow table stored in the second network device, wherein the second network device is a network device among the multiple network devices that has not found the target flow table entry; The third sending module is configured to send the first data message through a local route if the target flow table entry is not found and the plurality of network devices have already searched for the target flow table entry.

12. The device according to claim 10, characterized in that The first sending module is used for: If the interface corresponding to the outgoing interface identifier in the target flow table entry is a first-class interface, the first data packet is sent to a user terminal in the first site through the interface corresponding to the outgoing interface identifier in the target flow table entry, where the first-class interface refers to an interface for communicating with a user terminal in the first site; If the interface corresponding to the outgoing interface identifier in the target flow table entry is a second-class interface, the first data packet is sent to the third network device through the interface corresponding to the outgoing interface identifier in the target flow table entry to instruct the third network device to search for the target flow table entry from the flow table stored in the third network device, where the second-class interface refers to an interface for communicating with other network devices among the multiple network devices, and the third network device refers to a device among the multiple network devices that communicates with the first network device through the interface corresponding to the outgoing interface identifier in the target flow table entry.

13. The device according to any one of claims 10 to 12, characterized in that: The module for executing sending the second data message according to the destination address includes: A selection module, configured to select a tunnel from the plurality of tunnels as a target tunnel according to the destination address; A fourth sending module is used to send the second data message through the target tunnel if the target tunnel is a tunnel established between the first network device and the network device in the second site.

14. The device according to claim 13, characterized in that The first network device stores a routing table, the routing table comprising a plurality of routing table entries, each of the plurality of routing table entries comprising a site prefix and a corresponding site identifier; The selection module is used to: Determine a target routing table entry from the routing table according to the destination address, wherein the destination address matches a site prefix included in the target routing table entry; Determine one or more tunnel entries according to the site identifier included in the target routing entry, where the one or more tunnel entries refer to tunnel entries corresponding to the tunnel established between the first site and the second site; A tunnel entry is selected from the one or more tunnel entries as a target tunnel entry, and a tunnel corresponding to the target tunnel entry is used as the target tunnel.

15. The device according to any one of claims 10 to 12, characterized in that: The flow identifier of the second data flow includes source end information and destination end information; The determination module is used for: After the source end information and the destination end information in the flow identifier of the second data flow are swapped, the flow identifier of the first data flow is obtained.

16. The device according to claim 13, characterized in that The device also includes: a second adding module, configured to add a tunnel identifier of the target tunnel to the second data message to obtain a third data message if the target tunnel is a tunnel established between a fourth network device and a network device in the second site, and the fourth network device is a network device among the multiple network devices except the first network device; A fifth sending module is used to send the third data packet to the fourth network device to instruct the fourth network device to parse the second data packet, determine the flow identifier of the first data flow according to the flow identifier of the second data flow, add the target flow table entry in the flow table stored in the fourth network device, and send the second data packet through the target tunnel, wherein the flow identifier included in the currently added target flow table entry is the flow identifier of the first data flow, the outgoing interface identifier in the currently added target flow table entry is the identifier of the second interface, and the second interface refers to the interface in the fourth network device for receiving the third data packet.

17. The device according to any one of claims 10 to 12, characterized in that: The first data packet is a data packet received by the first network device through a tunnel established between the first network device and a network device in the second site, or the first data packet is a data packet received by the first network device from a fifth network device, where the fifth network device is a network device among the multiple network devices other than the first network device.

18. The device according to any one of claims 10 to 12, characterized in that: A network link is established between the multiple network devices, and the multiple network devices communicate through the network link. The network link is a physical link or a network tunnel, and the network tunnel includes a general routing encapsulation GRE tunnel.

19. A computer-readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method described in any one of claims 1 to 9 are implemented.