Disclosure of Invention
An object of the embodiments of the present application is to provide a message sending method and an apparatus, so as to solve a problem that a central node cannot acquire a tunnel destination address of a GRE message of an asymmetric IP service, and thus cannot send the GRE message. The specific technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a packet sending method, which is applied to a central node, and the method includes:
inquiring a first tunnel table by using a destination address of a message to be sent;
if the first tunnel table item matched with the destination address of the message to be sent does not exist, determining the target application type of the message to be sent;
querying a second tunnel table by using the target application type, wherein the second tunnel table is established according to the application type of an inner layer message in the GRE message sent by the branch node and a tunnel source address for sending the GRE message;
and if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item.
Optionally, the method further comprises:
receiving a GRE message sent by a branch node, and judging whether the GRE message meets a preset condition;
if yes, acquiring the application type of an inner layer message in the GRE message and a tunnel source address for sending the GRE message;
and establishing a corresponding tunnel table entry according to the acquired application type and the tunnel source address, setting aging time for the tunnel table entry, and maintaining the aging time in a second tunnel table.
Optionally, when the message to be sent is sent by using the second tunnel table entry, the method further includes:
and resetting the aging time of the second tunnel table entry matched with the target application type to a preset default value.
Optionally, the step of determining whether the GRE packet meets a preset condition includes:
acquiring a destination address of an inner layer message in the received GRE message;
judging whether the obtained destination address is any one of the address of the central node, a multicast address matched with the address of the central node and a broadcast address;
if yes, the received GRE message is determined to meet the preset condition.
Optionally, the step of sending the message to be sent by using the second tunnel table entry includes:
if the number of the second tunnel table entries is multiple, GRE encapsulation is respectively carried out on the message to be sent by using the tunnel address in each second tunnel table entry, so as to obtain each GRE message with different tunnel destination addresses;
and respectively sending each GRE message obtained after encapsulation through a corresponding GRE tunnel.
In a second aspect, an embodiment of the present application provides a packet sending apparatus, which is applied to a central node, where the apparatus includes:
the first query module is used for querying a first tunnel table by using a destination address of a message to be sent;
the first determining module is used for determining the target application type of the message to be sent if a first tunnel table item matched with the destination address of the message to be sent does not exist;
the second query module is used for querying a second tunnel table by using the target application type, wherein the second tunnel table is established according to the application type of an inner layer message in the GRE message sent by the branch node and a tunnel source address for sending the GRE message;
and the sending module is used for sending the message to be sent by utilizing a second tunnel table item if the second tunnel table item matched with the target application type exists.
Optionally, the apparatus further comprises:
the judging module is used for receiving the GRE message sent by the branch node and judging whether the GRE message meets a preset condition;
the obtaining module is used for obtaining the application type of the inner layer message in the GRE message and the tunnel source address for sending the GRE message when the judgment result of the judging module is yes;
and the establishing module is used for establishing a corresponding tunnel table entry according to the acquired application type and the tunnel source address, setting aging time for the tunnel table entry and maintaining the tunnel table entry in a second tunnel table.
Optionally, the apparatus further comprises:
and the resetting module is used for resetting the aging time of the second tunnel table entry matched with the target application type to a preset default value.
Optionally, the determining module is specifically configured to:
acquiring a destination address of an inner layer message in the received GRE message, and judging whether the acquired destination address is any one of the address of the central node, a multicast address matched with the address of the central node and a broadcast address; if yes, the received GRE message is determined to meet the preset condition.
Optionally, the sending module is specifically configured to:
if the number of the second tunnel table entries is multiple, GRE encapsulation is respectively carried out on the message to be sent by using the tunnel address in each second tunnel table entry, so as to obtain each GRE message with different tunnel destination addresses; and respectively sending each GRE message obtained after encapsulation through a corresponding GRE tunnel.
In a third aspect, embodiments provide an electronic device comprising a processor and a machine-readable storage medium storing machine-executable instructions executable by the processor, the processor being caused by the machine-executable instructions to: implementing any of the above message sending method steps.
In a fourth aspect, embodiments of the present application provide a machine-readable storage medium storing machine-executable instructions that, when invoked and executed by a processor, cause the processor to: implementing any of the above message sending method steps.
In the technical scheme provided by the embodiment of the application, a first tunnel table is inquired by using a destination address of a message to be sent; if the first tunnel table item matched with the destination address of the message to be sent does not exist, determining the target application type of the message to be sent; querying a second tunnel table with the target application type; and if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item.
According to the technical scheme provided by the embodiment of the application, the second tunnel table is established by the center node according to the application type of the inner layer message in the received GRE message sent by the branch node and the tunnel source address sending the GRE message, and when the center node receives the GRE message of the asymmetric IP service, the mapping relation between the application type of the asymmetric IP service message in the GRE message and the source address of the GRE tunnel sending the GRE message is recorded in the second tunnel table, namely the corresponding tunnel table entry is established. For the central node, for a response packet of a service packet, the application types of the response packet sent by the central node and the received service packet are the same, so that when the central node responds to the received service packet, a packet to be sent of an asymmetric IP service needs to be sent, based on the unchanged application type, a second tunnel table entry matched with the application type of the packet to be sent can be queried from the second tunnel table, and the packet to be sent is sent by using the second tunnel table entry.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In order to solve the problem that a central node cannot acquire a tunnel destination address of a GRE packet of an asymmetric IP service, embodiments of the present application provide a packet sending method and apparatus, which are applied to the central node, where the packet sending method provided by the embodiments of the present application includes:
inquiring a first tunnel table by using a destination address of a message to be sent;
if the first tunnel table item matched with the destination address of the message to be sent does not exist, determining the target application type of the message to be sent;
querying a second tunnel table by using the target application type, wherein the second tunnel table is established according to the application type of an inner layer message in the GRE message sent by the branch node and a tunnel source address for sending the GRE message;
and if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item.
According to the technical scheme provided by the embodiment of the application, the second tunnel table is established by the center node according to the application type of the inner layer message in the received GRE message sent by the branch node and the tunnel source address sending the GRE message, and when the center node receives the GRE message of the asymmetric IP service, the mapping relation between the application type of the asymmetric IP service message in the GRE message and the source address of the GRE tunnel sending the GRE message is recorded in the second tunnel table, namely the corresponding tunnel table entry is established. For the central node, for a response packet of a service packet, the application types of the response packet sent by the central node and the received service packet are the same, so that when the central node responds to the received service packet, a packet to be sent of an asymmetric IP service needs to be sent, based on the unchanged application type, a second tunnel table entry matched with the application type of the packet to be sent can be queried from the second tunnel table, and the packet to be sent is sent by using the second tunnel table entry.
First, a method for sending a message provided in an embodiment of the present application is described below. The message sending method provided by the embodiment of the application is applied to a central node, the central node is configured with a GRE P2MP (point 2multiple point, point-to-multipoint master station) tunnel interface, and based on the GRE P2MP tunnel interface, the central node can establish a plurality of GRE tunnels with a plurality of branch nodes, that is, the GRE P2MP tunnel is established between the central node and the branch nodes. It can be considered that the central node is the P2MP side, i.e. one central node corresponds to a plurality of branch nodes, and the branch nodes are the P2P side, i.e. one branch node corresponds to only one central node.
The central node and the branch nodes can transmit GRE messages through the established GRE tunnels. The central node and the branch node can encapsulate the data message to be sent according to the GRE protocol to obtain the GRE message, and then the GRE message is sent through the GRE tunnel.
As shown in fig. 1, a message sending method provided in the embodiment of the present application includes the following steps.
S101, inquiring a first tunnel table by using a destination address of a message to be sent;
the message to be sent is a message sent from the center node to the branch node. It can be considered that the message received by the central node from the branch node corresponds to the message sent to the branch node, for example, the correspondence between the request message and the response message. Therefore, the message to be sent is a response message corresponding to the request message received by the central node from the branch node.
The first tunnel table is established according to the source address of the inner layer message in the GRE message sent by the branch node and the tunnel source address for sending the GRE message. The first tunnel table may include a plurality of first tunnel table entries, and each tunnel table entry records a correspondence between a source address of an inner layer packet in a GRE packet sent by the branch node and a tunnel source address of the GRE packet.
For example, if the source address of the inner layer message in the GRE message sent by the branch node is 10.1.1.2, and the source address of the tunnel sending the GRE message is 11.1.1.2, the following table 1 is recorded in the first tunnel table for the source address and the tunnel source address:
TABLE 1
Wherein, the first tunnel table may be stored in the central node in advance. For each first tunnel table entry, besides recording the corresponding relation, the aging time can be set. The aging time of the first tunnel table entry is used for representing the time length required for the first tunnel table entry to age, and the aging time is continuously reduced along with the time until the aging time becomes 0. When the aging time becomes 0, the first tunnel table entry is deleted from the first tunnel table. And the aging time is counted from the establishment of the first tunnel table entry.
For example, if the aging time of a first tunnel entry is 10 seconds, the aging time is counted from the establishment of the first tunnel entry, the aging time is continuously decreased from 10 seconds, and when the aging time becomes 0 second, the first tunnel entry is deleted.
By setting the aging time for the first tunnel table entries, each first tunnel table entry is only stored in the first tunnel table within the corresponding aging time, and once the aging time becomes 0, the first tunnel table entry is deleted, thereby releasing a certain storage space. Therefore, the storage space resources of the central node are saved.
S102, if the first tunnel table item matched with the destination address of the message to be sent does not exist, determining the target application type of the message to be sent.
There is no first tunnel table item matching with the destination address of the message to be sent, that is, the first tunnel table does not record the address identical to the destination address of the message to be sent, so that the corresponding tunnel source address cannot be found.
The implementation manner of determining the application type of the Message to be sent may be determined by port information in a TCP (Transmission Control Protocol) header or a UDP (User data Protocol) header, may also be determined by a type field or a code field of an ICMP (Internet Control Message Protocol) Message, and may also be determined by Protocol information of an IP (Internet Protocol) header.
For example, when the protocol information of the IP header of the message to be sent is 89, the determined application type is OSPF (Open short Path First, Open Shortest Path First); when the protocol information of the IP header of the message to be sent is 58 and the ICMP TYPE field is 135, the determined application TYPE is an ND (Neighbor Discovery protocol) protocol.
The determination method for the application type is not limited to the above three methods, and may also be determined by other methods, which are not described herein again.
S103, querying a second tunnel table by using the target application type.
The second tunnel table is established according to the application type of the inner layer message in the GRE message sent by the branch node and the tunnel source address for sending the GRE message. The second tunnel table may include a plurality of second tunnel table entries, where each second tunnel table entry records a corresponding relationship between an application type of an inner layer packet in a GRE packet sent by the branch node and a tunnel source address for sending the GRE packet.
For example, if the application type of the inner layer packet in the GRE packet received by the central node and sent by the branch node is OSPF, and the tunnel source address for sending the GRE packet is 2.0.0.1, the corresponding relationship between the application type recorded in the second tunnel table entry and the tunnel source address is as follows: OSPF corresponds to 2.0.0.1.
In the second tunnel table, there may be one second tunnel entry for the same application type, or there may be multiple second tunnel entries, that is, there are one or more second tunnel entries containing the same application type. Thus, one application type may correspond to one tunnel source address, and may also correspond to multiple tunnel source addresses.
For example, in the second tunnel table, the second tunnel table entry based on the application type OSPF includes: OSPF and the second tunnel entry of 2.0.0.1, OSPF and the second tunnel entry of 11.1.1.2, OSPF and the second tunnel entry of 11.1.1.24.
In an implementation manner of querying the second tunnel table by using the target application type, whether the target application type exists in the second tunnel table is queried, and if the target application type exists, it can be considered that a second tunnel table entry containing the target application type in the second tunnel table matches the target application type.
And S104, if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item.
And a second tunnel table entry matched with the target application type exists, namely the second tunnel table entry contains the target application type.
Specifically, a second tunnel table entry matched with the target application type is obtained from the second tunnel table, a tunnel source address is obtained from the second tunnel table entry, the obtained tunnel source address is used as a tunnel destination address for encapsulating the message to be sent, and the message to be sent is encapsulated by using the tunnel destination address.
And after the message to be sent is packaged, a GRE message based on the message to be sent can be obtained, and the tunnel destination address of the transmission protocol message header of the GRE message is the tunnel source address obtained from the second tunnel table. After obtaining the GRE message, the central node sends the GRE message to a tunnel destination address through a GRE tunnel. Thus, the central node completes sending the message to be sent through the GRE tunnel.
In one embodiment, if a plurality of second tunnel table entries matched with the target application type exist, GRE encapsulation is respectively performed on the message to be sent by using the tunnel address in each second tunnel table entry, so as to obtain GRE messages with different tunnel destination addresses; and respectively sending each GRE message obtained after encapsulation through a corresponding GRE tunnel.
For example, there are two second tunnel entries in the second tunnel table that match the target application type OSPF, and the tunnel addresses included in the two second tunnel entries are: 2.0.0.1 and 11.1.1.2. Then, GRE encapsulation is performed on the message to be sent by using 2.0.0.1, so that a GRE message based on the message to be sent can be obtained, and GRE encapsulation is performed on the message to be sent by using 11.1.1.2, so that another GRE message based on the message to be sent can be obtained. The central node sends a first GRE message through a GRE tunnel with 2.0.0.1 and a second GRE message through a GRE tunnel with 11.1.1.2.
The second tunnel table is established according to the application type of the inner layer message in the GRE message sent by the branch node and the tunnel source address sending the GRE message, and aiming at the establishment of the second tunnel table entry in the second tunnel table, in one implementation manner, the center node can receive the GRE message sent by the branch node, and the branch node sending the GRE message can be any branch node.
After receiving the GRE message, the central node can determine whether the GRE message meets a preset condition. The preset condition may be set by a user.
In one embodiment, the central node may obtain a destination address of an inner layer packet in the received GRE packet, and determine whether the obtained destination address is any one of an address of the central node, a multicast address and a broadcast address matched with the address of the central node; if so, the received GRE message can be determined to meet the preset condition, otherwise, the received GRE message can be determined to not meet the preset condition, and at the moment, the central node can forward the GRE message according to the destination address.
When the destination address of the inner layer message in the received GRE message is the address of the central node, it can be determined that the GRE message received by the central node meets the preset condition.
When the destination address of the inner layer message in the received GRE message is the multicast address matched with the address of the central node, the central node can be determined to be one of the devices receiving the inner layer message. The multicast address is a group of addresses for receiving the inner layer message, and the address of the central node is matched with the multicast address, namely the address of the central node is one of the multicast addresses.
For example, the destination address of the inner layer message in the received GRE message is ff02::1: ff00:1111, and the destination address is the multicast address of Ipv6, and as long as the last 24 bits of the address are 00:1111, the address can be regarded as one of the multicast addresses. When the address of the central node is 1111: 1111, it can be determined that 1111: 1111 is matched with ff02: 1: ff00:1111, that is, the address of the central node is one of the multicast addresses, and the GRE message received by the central node is determined to satisfy the preset condition.
When the destination address of the inner layer message in the received GRE message is a broadcast address, the address where the inner layer message is received can be considered to be one of the broadcast addresses, and it is further determined that the GRE message received by the central node meets the preset condition.
If the GRE message is judged to meet the preset condition, the central node can acquire the application type of the inner layer message in the GRE message and the tunnel source address for sending the GRE message.
Specifically, the central node decapsulates the GRE packet to obtain a tunnel source address of the GRE packet, where the tunnel source address is a tunnel interface address of a branch node that sends the GRE packet. And an inner layer message in the GRE message can be obtained, and the application type of the inner layer message can be determined according to the inner layer message.
After the application type of the inner layer message in the GRE message and the tunnel source address of the GRE message are obtained, a corresponding tunnel table entry is established according to the obtained application type and the tunnel source address, the aging time is set for the tunnel table entry, and the tunnel table entry is maintained in a second tunnel table.
And setting aging time for the tunnel table entry to indicate the aging duration of the tunnel table entry. Thus, each tunnel entry in the second tunnel table includes an application type, a tunnel source address, and an aging time.
Taking table 2 below as an example, table 2 is a tunnel table entry in the second tunnel table, and the corresponding relationship in the tunnel table entry is: OSPF is corresponding to 2.0.0.1, and the aging time of the tunnel table entry is 60 seconds.
TABLE 2
The aging time of the tunnel table entry may be timed from the establishment of the tunnel table entry, and when the aging time of one tunnel table entry becomes 0 second, the one tunnel table entry may be deleted from the second tunnel table.
For example, if the aging time of one tunnel entry in the second tunnel table is 60 seconds, the aging time is continuously decreased from 60 seconds when the tunnel entry is established, and the tunnel entry is deleted from the second tunnel table when the aging time becomes 0 second.
The aging time may be custom set. In one implementation, the aging time may be set according to a service type of the packet, and specifically, the set aging time is greater than a time interval between two consecutive transmissions of the packet belonging to the same service type. For example, for a message of a service type, the time interval between two consecutive transmissions of the message is 50 seconds, and the aging time for the service type should be greater than 50 seconds.
By setting the aging time for the tunnel table entries in the second tunnel table, each tunnel table entry is only maintained in the second tunnel table within the corresponding aging time, and once the aging time becomes 0, the tunnel table entry is deleted from the second tunnel table, thereby releasing a certain storage space. Thus, the storage space resource of the central node is saved.
In an embodiment, when the message to be sent is sent by using the second tunnel table entry, the aging time of the second tunnel table entry matching the target application type may also be reset to a preset default value.
Wherein the default value can be set by self. And after the aging time of the second tunnel table entry is reset to the default value, changing the aging time of the second tunnel table entry into the default value, and restarting timing. And after the aging time with the duration as the default value becomes 0 and the second tunnel table entry is not successfully matched in the process that the aging time becomes 0, deleting the corresponding relation.
Taking the above table 2 as an example, the default value is 60 seconds, the aging time in the above table 1 is continuously decreased, when the aging time is decreased to 10 seconds, and when the central node matches the target application type of OSPF, the central node successfully matches the tunnel table entry in the table 2, the aging time in the table 2 is reset to 60 seconds, and the aging time is counted from 60 seconds again.
An embodiment of the present application further provides a message sending method, as shown in fig. 2, where the message sending method includes the following steps.
S201, receiving GRE message sent by the branch node.
The description will be made by taking fig. 3 as an example. A is the central node, B is the branch node, and GRE tunnel is established between A and B. The IPv6 address configured by the A is 1111::1111, the tunnel address is 1.0.0.1, when the IPv6 address required to be configured by the B is 1111::1111, according to the requirement of an IPv6 protocol, before the configured IPv6 address takes effect, the NS message is sent to carry out repeated address detection, and the NS message carries the required detection address, namely 1111:: 1111. The tunnel address of B is 2.0.0.1, B utilizes the tunnel address to encapsulate NS message, namely NS message is inner layer message, obtains GRE message based on NS message, and sends GRE message to A.
For the GRE packet, as shown in table 3 below, the tunnel source address of the encapsulation layer IP header is 2.0.0.1, and the tunnel destination address is: 1.0.0.1, the source IP address of the inner layer IP header is ff02::1: ff00: 1111.
TABLE 3
| Source address | Destination address |
| Encapsulation layer IP header | 2.0.0.1 | 1.0.0.1 |
| Inner IP head | :: | ff02::1:ff00:1111 |
S202, the destination address of the inner layer message in the received GRE message is obtained, and whether the obtained destination address is any one of the address of the central node, the multicast address matched with the address of the central node and the broadcast address is judged. If yes, the received GRE message is determined to meet the preset condition.
After the A receives the GRE message, decapsulating the GRE message to obtain that the destination address of the NS message is ff02: 1: ff00:1111, the destination address is a multicast address and is matched with the IPv6 address 1111: 1111 of the A, and then the GRE message can be determined to meet the preset condition.
In addition, after receiving the GRE packet, a may establish a first tunnel entry according to the GRE packet, as shown in table 4 below.
TABLE 4
Wherein the aging time of the established first tunnel table entry is 10 seconds, and the first tunnel table entry is maintained in the first tunnel table.
S203, obtaining the application type of the inner layer message in the GRE message and the tunnel source address for sending the GRE message.
After decapsulating the GRE message, the a may obtain an NS message, obtain protocol information from a message IP header of the NS message, and determine that the application type of the NS message is an IPv6DAD (Duplicate address detection) application type according to the protocol information and the ICMP message information. In addition, a can also obtain the tunnel source address from the GRE message as 2.0.0.1.
And S204, establishing a corresponding tunnel table entry according to the acquired application type and the tunnel source address, setting aging time for the tunnel table entry, and maintaining the tunnel table entry in a second tunnel table.
The established tunnel table entry comprises: IPv6DAD corresponds to 2.0.0.1, and aging time 10 seconds. The tunnel table entries established are shown in table 5 below.
TABLE 5
S205, the destination address of the message to be sent is used for inquiring the first tunnel table, and if the first tunnel table item matched with the destination address of the message to be sent does not exist, the target application type of the message to be sent is determined.
When the A performs repeated address detection processing on the NA message, and finds that the detected address is 1111:, the A can determine the address conflict with the A itself, and then the A needs to send the NA message to the B to report the address conflict to the B. When A sends NA message to B, it is sent in multicast mode, so for NA message, the source address is 1111::1111, and the destination address is ff02:: 1.
A queries whether a first tunnel table item matched with ff02::1 exists in a first tunnel table by using a destination address (ff02::1) of the NA message, if the first tunnel table item matched with ff02::1 is not queried, the target application type of the NA message can be determined, and whether a second tunnel table item matched with the target application type of the NA message exists is queried in a second tunnel table. If the application type of the NA message is determined to be IPv6DAD, and IPv6DAD is taken as the target application type.
S206, the second tunnel table is inquired by the target application type.
And A inquires whether a second tunnel table entry matching with the IPv6DAD exists in the second tunnel table, namely, whether a second tunnel table entry matching with the IPv6DAD exists in all tunnel table entries included in the second tunnel table.
And S207, if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item. And resetting the aging time of the second tunnel table entry matched with the target application type to a preset default value.
When only the tunnel table entry in the table 5 in the second tunnel table matches with the target application type IPv6DAD, the tunnel source address corresponding to the IPv6DAD is obtained from the tunnel table entry in the table 5 and is 2.0.0.1, and the address 2.0.0.1 is used as the tunnel destination address to encapsulate the NA packet, so as to obtain a GRE packet based on the NA packet. For the GRE packet based on the NA packet, as shown in table 6 below, the tunnel source address of the encapsulation layer IP header is 1.0.0.1, and the tunnel destination address is: 2.0.0.1, the source IP address of the inner layer IP header is 1111::1111, and the destination address is ff02:: 1.
TABLE 6
| Source address | Destination address |
| Encapsulation layer IP header | 1.0.0.1 | 2.0.0.1 |
| Inner IP head | 1111::1111 | ff02::1 |
And the A adopts the second tunnel table item to package the NA message to obtain a corresponding GRE message, and then sends the GRE message to the B through the corresponding GRE tunnel. Therefore, for the message to be sent, even if the tunnel destination address cannot be obtained from the first tunnel table, the tunnel destination address can be obtained from the second tunnel table by the technical scheme provided by the embodiment of the application, and then the message to be sent is encapsulated by using the tunnel destination address, and the GRE message obtained after encapsulation is sent to the branch node.
Corresponding to the foregoing message sending method embodiment, an embodiment of the present application further provides a message sending apparatus, which is applied to a central node, and as shown in fig. 4, the message sending apparatus includes:
afirst query module 410, configured to query a first tunnel table by using a destination address of a message to be sent;
a first determiningmodule 420, configured to determine a target application type of a message to be sent if there is no first tunnel entry matching a destination address of the message to be sent;
asecond query module 430, configured to query a second tunnel table by using the target application type, where the second tunnel table is established according to the application type of the inner layer packet in the GRE packet sent by the branch node and the tunnel source address for sending the GRE packet;
the sendingmodule 440 is configured to send a message to be sent by using a second tunnel table entry if the second tunnel table entry exists, where the second tunnel table entry matches the target application type.
In one embodiment, the message sending apparatus may further include:
the judging module is used for receiving the GRE message sent by the branch node and judging whether the GRE message meets a preset condition;
the obtaining module is used for obtaining the application type of the inner layer message in the GRE message and the tunnel source address for sending the GRE message when the judgment result of the judging module is yes;
and the establishing module is used for establishing a corresponding tunnel table entry according to the acquired application type and the tunnel source address, setting aging time for the tunnel table entry and maintaining the tunnel table entry in a second tunnel table.
In one embodiment, the message sending apparatus may further include:
and the resetting module is used for resetting the aging time of the second tunnel table entry matched with the target application type to a preset default value.
In one embodiment, the determining module is specifically configured to:
acquiring a destination address of an inner layer message in the received GRE message, and judging whether the acquired destination address is any one of the address of a central node, a multicast address matched with the address of the central node and a broadcast address; if yes, the received GRE message is determined to meet the preset condition.
In one embodiment, the sendingmodule 440 is specifically configured to:
if the number of the second tunnel table entries is multiple, GRE encapsulation is respectively carried out on the message to be sent by utilizing the tunnel address in each second tunnel table entry, so as to obtain each GRE message with different tunnel destination addresses; and respectively sending each GRE message obtained after encapsulation through a corresponding GRE tunnel.
According to the technical scheme provided by the embodiment of the application, the second tunnel table is established by the center node according to the application type of the inner layer message in the received GRE message sent by the branch node and the tunnel source address sending the GRE message, and when the center node receives the GRE message of the asymmetric IP service, the mapping relation between the application type of the asymmetric IP service message in the GRE message and the source address of the GRE tunnel sending the GRE message is recorded in the second tunnel table, namely the corresponding tunnel table entry is established. For the central node, for a response packet of a service packet, the application types of the response packet sent by the central node and the received service packet are the same, so that when the central node responds to the received service packet, a packet to be sent of an asymmetric IP service needs to be sent, based on the unchanged application type, a second tunnel table entry matched with the application type of the packet to be sent can be queried from the second tunnel table, and the packet to be sent is sent by using the second tunnel table entry.
An electronic device is also provided in the embodiments of the present application, as shown in fig. 5, and includes aprocessor 510 and a machine-readable storage medium 520, where the machine-readable storage medium 520 stores machine-executable instructions that can be executed by theprocessor 510.
In addition, as shown in fig. 5, the electronic device may further include: acommunication interface 530 and acommunication bus 540; theprocessor 510, the machine-readable storage medium 520, and thecommunication interface 530 are configured to communicate with each other via acommunication bus 540, and thecommunication interface 530 is configured to communicate with other devices.
Processor 510 causes execution of any of the embodiments of messaging methods described above, wherein the messaging methods include:
inquiring a first tunnel table by using a destination address of a message to be sent;
if the first tunnel table item matched with the destination address of the message to be sent does not exist, determining the target application type of the message to be sent;
querying a second tunnel table by using the target application type, wherein the second tunnel table is established according to the application type of an inner layer message in the GRE message sent by the branch node and a tunnel source address for sending the GRE message;
and if a second tunnel table item matched with the target application type exists, transmitting the message to be transmitted by using the second tunnel table item.
According to the technical scheme provided by the embodiment of the application, the second tunnel table is established by the center node according to the application type of the inner layer message in the received GRE message sent by the branch node and the tunnel source address sending the GRE message, and when the center node receives the GRE message of the asymmetric IP service, the mapping relation between the application type of the asymmetric IP service message in the GRE message and the source address of the GRE tunnel sending the GRE message is recorded in the second tunnel table, namely the corresponding tunnel table entry is established. For the central node, for a response packet of a service packet, the application types of the response packet sent by the central node and the received service packet are the same, so that when the central node responds to the received service packet, a packet to be sent of an asymmetric IP service needs to be sent, based on the unchanged application type, a second tunnel table entry matched with the application type of the packet to be sent can be queried from the second tunnel table, and the packet to be sent is sent by using the second tunnel table entry.
Thecommunication bus 540 may be a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. Thecommunication bus 540 may be divided into an address bus, a data bus, a control bus, and the like. For ease of illustration, only one thick line is shown in FIG. 5, but this is not intended to represent only one bus or type of bus.
The machine-readable storage medium 520 may include a RAM (Random Access Memory) and may also include a NVM (Non-Volatile Memory), such as at least one disk Memory. Additionally, the machine-readable storage medium 520 may also be at least one memory device located remotely from the aforementioned processor.
TheProcessor 510 may be a general-purpose Processor including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also DSPs (Digital Signal Processing), ASICs (Application Specific Integrated circuits), FPGAs (Field Programmable Gate arrays) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.
Corresponding to the above embodiment of the message sending method, an embodiment of the present application further provides a machine-readable storage medium, storing machine-executable instructions, which, when invoked and executed by a processor, cause the processor to implement the message sending method.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the embodiments of the message sending apparatus, the electronic device and the machine-readable storage medium, since they are basically similar to the embodiments of the message sending method, the description is relatively simple, and for the relevant points, refer to the partial description of the embodiments of the method.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.