Data forwarding method, device, electronic device and storage medium
By responding to the target data packet in the MAP-E scenario, determining and obtaining the corresponding IP port resource pool and conversion port, port-multiplexable data forwarding is realized, solving the problem that cannot meet the needs of a large number of concurrent traffic in the prior art.
Patent Information
- Application Number
- CN202211478568.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-23
- Publication Date
- 2025-02-28
- Estimated Expiration
- 2042-11-23
AI Technical Summary
In the MAP-E scenario, the prior art is difficult to implement port-multiplexed data forwarding, and cannot meet the normal communication needs under a large number of concurrent traffic.
By responding to the received target data packet, the IP port resource pool is determined according to its first network parameters, the second conversion IP and the second conversion port are obtained, the target conversion IP and the target conversion port are determined in combination with the third network parameters, and data forwarding is performed.
It realizes port-multiplexed data forwarding in MAP-E scenarios, meeting the normal communication needs under a large number of concurrent traffic.
Smart Images

Figure 00000000_0000_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of communications, and in particular, to a data forwarding method, device, electronic device and storage medium. Background Art
[0002] With the rapid development of communication networks, the limited number of source ports has gradually failed to meet the concurrent needs of communication traffic. For example, in scenarios such as MAP-E (Mapping Address and Port-Enclosure, stateless double encapsulation technology), the number of available ports is only 240, resulting in the number of ports being unable to meet communication needs. Therefore, it is particularly important to introduce a port multiplexing technology to ensure normal communication under a large amount of concurrent traffic.
[0003] In addition, in the process of intranet penetration, that is, intranet mapping, mapping the intranet IP port to the external network access, the communication between two independent LANs uses the NAT Hole Punching technology based on SNAPT (Server Network Address and Port Translator) for data forwarding. In order to achieve intranet penetration in the MAP-E scenario, achieving data forwarding with port multiplexing has become an urgent problem to be solved. Summary of the invention
[0004] In order to overcome the above problems existing in the related art, the present disclosure provides a data forwarding method, device, electronic device and storage medium.
[0005] According to a first aspect of an embodiment of the present disclosure, a data forwarding method is provided, the method comprising:
[0006] In response to receiving a target data message, when it is determined that the target data message needs to be parameter converted, an IP port resource pool for performing parameter conversion on the target data message is determined according to a first network parameter of the target data message; wherein the IP port resource pool includes one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message;
[0007] According to the second network parameter of the target data message, obtain the second conversion IP and the second conversion port corresponding to the target data message from the IP port resource pool; wherein the second network parameter is used to characterize the sender information of the target data message;
[0008] Determine the target conversion IP and target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message; wherein the third network parameter is used to characterize the receiving end information of the target data message;
[0009] The target data message is forwarded according to the target conversion IP and the target conversion port.
[0010] In some embodiments, the second network parameter includes a source IP and a source port of the target data message; and obtaining a second conversion IP and a second conversion port corresponding to the target data message from the IP port resource pool according to the second network parameter of the target data message includes:
[0011] According to the source IP of the target data message, determine the second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool;
[0012] According to the source IP and source port of the target data message, a second conversion port corresponding to the target data message is determined from one or more of the first conversion ports corresponding to the second conversion IP.
[0013] In some embodiments, determining the second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool according to the source IP of the target data message includes:
[0014] If there is a first conversion IP corresponding to the source IP in the IP port resource pool, the first conversion IP is used as the second conversion IP; or,
[0015] If there is no first conversion IP corresponding to the source IP in the IP port resource pool, the first conversion IP that meets the preset IP conversion condition is used as the second conversion IP, and the preset IP conversion condition includes that there is an idle and allocatable port in the first conversion port corresponding to the first conversion IP.
[0016] In some embodiments, the third network parameter includes a destination IP, a destination port, and a protocol number of the target data message; and determining a target conversion IP and a target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port, and the third network parameter of the target data message includes:
[0017] When one or more pending receiving end parameters corresponding to the second conversion port do not include parameters identical to the third network parameters of the target data message, the second conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP.
[0018] In some embodiments, the determining the target conversion IP and target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message further comprises:
[0019] In the case where one or more pending receiving end parameters corresponding to the second conversion port include parameters identical to the third network parameters of the target data message, a third conversion port different from the second conversion port and satisfying a preset port conversion condition is determined from one or more of the first conversion ports corresponding to the second conversion IP; the preset port conversion condition is used to indicate that there is no corresponding pending receiving end parameter for the third conversion port, or that one or more pending receiving end parameters corresponding to the third conversion port include parameters identical to the third network parameters;
[0020] The third conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP.
[0021] In some embodiments, the determining the target conversion IP and target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message further comprises:
[0022] In the case where one or more pending receiving end parameters corresponding to the second conversion port include parameters identical to the third network parameters of the target data message, and there is no first conversion port satisfying the preset port conversion condition among the one or more first conversion ports corresponding to the second conversion IP, a third conversion IP satisfying the preset IP conversion condition is determined from the one or more first conversion IPs in the IP port resource pool; the third conversion IP is different from the second conversion IP;
[0023] According to the source IP and source port of the target data message, determine a fourth conversion port corresponding to the target data message from one or more of the first conversion ports corresponding to the third conversion IP;
[0024] The target conversion IP and the target conversion port are determined according to the third conversion IP, the fourth conversion port and the third network parameter of the target data message.
[0025] In some embodiments, determining, according to the first network parameter of the target data message, an IP port resource pool for performing parameter conversion on the target data message comprises:
[0026] Determine a forwarding strategy identifier corresponding to the target data message according to a first network parameter of the target data message;
[0027] According to the preset policy parameter correspondence, the IP port resource pool corresponding to the forwarding policy identifier is determined; the preset policy parameter correspondence includes the correspondence between the forwarding policy identifier and the IP port resource pool.
[0028] In some embodiments, the IP port resource pool includes a first hash table, a second hash table and a third hash table, the first hash table is used to store multiple first conversion IPs, the second hash table is used to store one or more pending forwarding ports corresponding to the first conversion IP, and the third hash table is used to store one or more pending receiving end parameters corresponding to the pending forwarding ports.
[0029] In some embodiments, the first network parameter includes one or more of the source IP, source port, destination IP, destination port and protocol number of the target data packet.
[0030] According to a second aspect of an embodiment of the present disclosure, a data forwarding device is provided, the device comprising:
[0031] A determination module, configured to, in response to receiving a target data message, determine an IP port resource pool for performing parameter conversion on the target data message according to a first network parameter of the target data message when determining that the target data message needs to be converted in parameters; wherein the IP port resource pool includes one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message;
[0032] An acquisition module, configured to acquire, from the IP port resource pool, a second conversion IP and a second conversion port corresponding to the target data message according to the second network parameter of the target data message; and determine, according to the second conversion IP, the second conversion port and a third network parameter of the target data message, a target conversion IP and a target conversion port corresponding to the target data message; wherein the second network parameter is used to characterize the sending end information of the target data message, and the third network parameter is used to characterize the receiving end information of the target data message;
[0033] The forwarding module is used to forward the target data message according to the target conversion IP and the target conversion port.
[0034] In some embodiments, the second network parameters include the source IP and source port of the target data packet; the acquisition module is used to determine the second conversion IP corresponding to the target data packet from one or more first conversion IPs in the IP port resource pool according to the source IP of the target data packet; and determine the second conversion port corresponding to the target data packet from one or more first conversion ports corresponding to the second conversion IP according to the source IP and source port of the target data packet.
[0035] In some embodiments, the acquisition module is used to use the first conversion IP as the second conversion IP if there is a first conversion IP corresponding to the source IP in the IP port resource pool; or, if there is no first conversion IP corresponding to the source IP in the IP port resource pool, use the first conversion IP that meets the preset IP conversion conditions as the second conversion IP, and the preset IP conversion conditions include the existence of an idle allocatable port in the first conversion port corresponding to the first conversion IP.
[0036] In some embodiments, the acquisition module is used to use the second conversion port as the target conversion port and the second conversion IP as the target conversion IP when one or more pending receiving end parameters corresponding to the second conversion port do not include parameters that are identical to the third network parameters of the target data packet.
[0037] In some embodiments, the acquisition module is used to determine, from one or more of the first conversion ports corresponding to the second conversion IP, a third conversion port that is different from the second conversion port and satisfies a preset port conversion condition, when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message; the preset port conversion condition is used to characterize that there is no corresponding pending receiving end parameter for the third conversion port, or that one or more pending receiving end parameters corresponding to the third conversion port include parameters that are the same as the third network parameters; the third conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP.
[0038] In some embodiments, the acquisition module is used to determine a third conversion IP that meets the preset IP conversion condition from one or more first conversion IPs in the IP port resource pool when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message, and there is no first conversion port that meets the preset port conversion condition among the one or more first conversion ports corresponding to the second conversion IP; the third conversion IP is different from the second conversion IP; according to the source IP and source port of the target data message, determine a fourth conversion port that meets the target data message from one or more first conversion ports corresponding to the third conversion IP; and determine the target conversion IP and the target conversion port based on the third conversion IP and the fourth conversion port.
[0039] In some embodiments, the determination module is used to determine the forwarding policy identifier corresponding to the target data packet based on the first network parameter of the target data packet; determine the IP port resource pool corresponding to the forwarding policy identifier based on the preset policy parameter correspondence relationship; the preset policy parameter correspondence relationship includes the correspondence between the forwarding policy identifier and the IP port resource pool.
[0040] In some embodiments, the IP port resource pool includes a first hash table, a second hash table and a third hash table, the first hash table is used to store multiple first conversion IPs, the second hash table is used to store one or more pending forwarding ports corresponding to the first conversion IP, and the third hash table is used to store one or more pending receiving end parameters corresponding to the pending forwarding ports.
[0041] In some embodiments, the first network parameter includes one or more of the source IP, source port, destination IP, destination port and protocol number of the target data packet.
[0042] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a memory on which a computer program is stored; and a processor for executing the computer program in the memory to implement the steps of the method described in the first aspect of the present disclosure.
[0043] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method described in the first aspect of the present disclosure are implemented.
[0044] The technical solution provided by the embodiment of the present disclosure may include the following beneficial effects: in response to receiving a target data message, when it is determined that the target data message needs to be parameter converted, an IP port resource pool for parameter conversion of the target data message is determined according to the first network parameter of the target data message; according to the second network parameter of the target data message, the second conversion IP and the second conversion port corresponding to the target data message are obtained from the IP port resource pool; according to the second conversion IP, the second conversion port and the third network parameter of the target data message, the target conversion IP and the target conversion port corresponding to the target data message are determined; according to the target conversion IP and the target conversion port, the target data message is forwarded. Wherein, the IP port resource pool includes one or more first conversion IPs, and one or more first conversion ports corresponding to each first conversion IP, the first network parameter is used to characterize the data flow information of the target data message, the second network parameter is used to characterize the sending end information of the target data message; the third network parameter is used to characterize the receiving end information of the target data message. In this way, the IP port resource pool can be determined by the first network parameter, the second conversion IP and the second conversion port in the IP port resource pool can be determined by the second network parameter, and the target conversion IP and the target conversion port can be further determined according to the third network parameter, thereby realizing data forwarding with port multiplexing.
[0045] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0047] Figure 1 The figure is a flow chart of a data forwarding method according to an exemplary embodiment.
[0048] Figure 2 It is a schematic diagram showing a corresponding relationship of preset strategy parameters according to an exemplary embodiment.
[0049] Figure 3 The figure is a schematic diagram showing an IP port storage information structure according to an exemplary embodiment.
[0050] Figure 4 The figure is a flow chart showing another data forwarding method according to an exemplary embodiment.
[0051] Figure 5 The invention is a block diagram of a data forwarding device according to an exemplary embodiment.
[0052] Figure 6It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION
[0053] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0054] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.
[0055] In the description of the present disclosure, the terms used, such as "first", "second", etc., are used to distinguish similar objects and are not necessarily understood as a specific order or sequence. In addition, in the description with reference to the accompanying drawings, the same symbols in different drawings represent the same elements unless otherwise stated.
[0056] In the description of the present disclosure, unless otherwise specified, "multiple" means two or more than two, and other quantifiers are similar thereto; "at least one item", "one or more items" or similar expressions refer to any combination of these items, including any combination of single items or plural items. For example, at least one item a can represent any number of a; for another example, one or more items among a, b and c can represent: a, b, c, ab, ac, bc, or abc, where a, b, c can be single or multiple; "and / or" is a kind of association relationship that describes the associated objects, indicating that there can be three relationships, for example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural.
[0057] Although operations or steps are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood that it is required to perform these operations or steps in the specific order shown or in a serial order, or to perform all the operations or steps shown to obtain the desired results. In the embodiments of the present disclosure, these operations or steps can be performed in series; these operations or steps can also be performed in parallel; or some of these operations or steps can be performed.
[0058] The present disclosure is described below in conjunction with specific embodiments.
[0059] Figure 1 is a flow chart of a data forwarding method according to an exemplary embodiment. The method can be applied to an electronic device, which can be any electronic device that supports communication between two independent networks, for example, the electronic device can include a router, a firewall or a server. Figure 1 As shown, the method may include:
[0060] S101. In response to receiving a target data message, when it is determined that the target data message needs to undergo parameter conversion, an IP port resource pool for performing parameter conversion on the target data message is determined according to a first network parameter of the target data message.
[0061] The IP port resource pool may include one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message.
[0062] In some embodiments, the first network parameter may be a five-tuple parameter of the target data message, and the five-tuple parameter may include five parameters, namely, source IP, source port, destination IP, destination port and protocol number of the target data message.
[0063] In other embodiments, the first network parameter may also include one or more of the source IP, source port, destination IP, destination port and protocol number of the target data packet.
[0064] In some embodiments of the present disclosure, a forwarding policy identifier corresponding to a target data packet may be determined based on a first network parameter of the target data packet; and an IP port resource pool corresponding to the forwarding policy identifier may be determined based on a preset policy parameter correspondence.
[0065] By way of example, the above-mentioned IP port resource pool can be stored based on the target data structure of the SNAPT policy information storage technology. By way of example, the target data structure can include a preset policy parameter correspondence, and the preset policy parameter correspondence can include a correspondence between a forwarding policy identifier and an IP port resource pool. The forwarding policy identifier can be determined based on the first network parameter of the target data message. By way of example, a matching strategy can be executed by a policy module based on the first network parameter of the target data message, and for a target data message that hits the strategy (for example, the first network parameter of the target data message meets the preset policy condition), the forwarding policy identifier corresponding to the target data message can be determined by the policy module; for a target data message that does not hit the strategy, it can be directly forwarded.
[0066] S102: According to the second network parameter of the target data message, obtain the second conversion IP and the second conversion port corresponding to the target data message from the above-mentioned IP port resource pool.
[0067] The second network parameter may be used to characterize the sender information of the target data message.
[0068] In some embodiments, the second network parameter may include one or more of a source IP, a source port, and a protocol number.
[0069] In other embodiments, the second network parameter may also include one or more of the source IP, source port, destination IP, destination port and protocol number of the target data packet.
[0070] In some embodiments of the present disclosure, the second conversion IP and the second conversion port corresponding to the target data packet may be determined according to the second network parameter based on a preset hash table and hash algorithm.
[0071] S103: Determine a target conversion IP and a target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message.
[0072] The third network parameter may be used to characterize the receiving end information of the target data message.
[0073] In some embodiments, the third network parameter may include one or more of a destination IP, a destination port, and a protocol number of the target data packet.
[0074] In some embodiments, the second conversion IP may be used as the target conversion IP, and the second conversion port may be used as the target conversion port.
[0075] In other embodiments, when it is determined based on the third network parameter that the second conversion IP and the second conversion port do not have the same pending receiving end parameters as the third network parameter, the second conversion IP is used as the target conversion IP and the second conversion port is used as the target conversion port, thereby achieving port multiplexing.
[0076] S104: forward the target data message according to the target conversion IP and the target conversion port.
[0077] For example, the source IP in the target data message may be updated to the target conversion IP, the source port in the target data message may be updated to the target conversion port, and then the updated target data message may be forwarded to the next hop or destination address.
[0078] Adopting the above method, in response to receiving the target data message, when it is determined that the target data message needs to be parameter converted, according to the first network parameter of the target data message, determine the IP port resource pool for parameter conversion of the target data message; according to the second network parameter of the target data message, obtain the second conversion IP and the second conversion port corresponding to the target data message from the IP port resource pool; according to the second conversion IP, the second conversion port and the third network parameter of the target data message, determine the target conversion IP and the target conversion port corresponding to the target data message; according to the target conversion IP and the target conversion port, forward the target data message. Among them, the IP port resource pool includes one or more first conversion IPs, and one or more first conversion ports corresponding to each first conversion IP, the first network parameter is used to characterize the data flow information of the target data message, the second network parameter is used to characterize the sending end information of the target data message; the third network parameter is used to characterize the receiving end information of the target data message. In this way, the IP port resource pool can be determined by the first network parameter, the second conversion IP and the second conversion port in the IP port resource pool can be determined by the second network parameter, and the target conversion IP and the target conversion port can be further determined according to the third network parameter, thereby realizing data forwarding with port multiplexing.
[0079] Figure 2 FIG. 1 is a schematic diagram showing a correspondence relationship between preset strategy parameters according to an exemplary embodiment. Figure 2As shown, the preset policy parameter correspondence may include a forwarding policy identifier 201, and an IP port resource pool 202 corresponding to the forwarding policy identifier 201, and the IP port resource pool 202 may include one or more first conversion IPs, and one or more. The first conversion IP may be stored in the form of an IP group or an IP segment. For example, the IP port resource pool 202 may include N IP groups, and each IP group may include any number of continuous IPs. For example, the N IP groups may include: IP group one, IP group two, ..., IP group N, wherein the number of IPs corresponding to IP group one is m (for example, IP group one may include 100 continuous IPs within the range of 192.168.1.1 to 192.168.1.100, and m is 100), the number of IPs corresponding to IP group two is n, the number of IPs corresponding to IP group N is s, and the total number of IPs of N IP groups is (m+n+...+s), which can be used to allocate the converted IPs. In addition, the IP port resource pool may also include one or more candidate conversion ports. For example, the IP port resource pool 202 may also include M port groups, each of which may include any number of continuous ports (PORT). For example, it may include port group 1, port group 2, ..., port group N, wherein the number of ports corresponding to port group 1 is x (for example, port group 1 may include 300 continuous ports within the range of PORT2001 to PORT2300, which may be used to allocate the converted port number, i.e., x is 300), the number of ports corresponding to port group 2 is y, the number of ports corresponding to port group N is z, and the total number of ports of the M port groups is (x+y+...+z). The ports in the above-mentioned port groups may all be used as candidate conversion ports.
[0080] Furthermore, the above-mentioned IP port resource pool may also include a first correspondence between the first conversion IP and the first conversion port, and the first correspondence is used to store the above-mentioned one or more first conversion IPs, and one or more first conversion ports corresponding to each first conversion IP, and the first conversion port may be any one of the above-mentioned candidate conversion ports.
[0081] In this way, the IP port resource pool corresponding to the forwarding strategy identifier is determined according to the preset policy parameter correspondence.
[0082] Figure 3 FIG. 1 is a schematic diagram showing an IP port storage information structure according to an exemplary embodiment. Figure 3 As shown, the IP port storage information structure may include a first hash table 301 , a second hash table 302 , and a third hash table 303 .
[0083] It should be noted that the IP port storage information structure may be a storage structure of an IP port resource pool.
[0084] The first hash table may also be referred to as Toip_hash_table. The first hash table may be a resource generated for each first conversion IP. Figure 2 The forwarding policy identifier in can index the range of the assignable first conversion IP. Different forwarding policy identifiers may index the same first conversion IP, and the same first conversion IP will only generate a node on the first hash table, that is, each first conversion IP and the node of the first hash table are in a one-to-one correspondence. The first hash table may include a first key value (also referred to as a first key value), and the first key value may be one or more of the above-mentioned second network parameters. For example, the first key value may be a source IP, and the first key value may also be a source IP and a source port.
[0085] Through the node corresponding to the first conversion IP in the first hash table, the second hash table can be indexed and obtained, and the second hash table can also be called Toport_hash_table. The second hash table can store one or more pending forwarding ports corresponding to the first conversion IP, which is used to characterize the port range that each first conversion IP can allocate. The second hash table may include a second key code value (also referred to as a second key value), and the second key value may be one or more of the above-mentioned second network parameters. For example, the second key value may be a source IP, and the second key value may also be a source IP and a source port, and the second key value may also be a source port. Each hash bucket of the second hash table corresponds to a pending forwarding port, a port number port value, and the number of hash buckets is equal to the number of port numbers that the first conversion IP can allocate. For example, the maximum can be 64511.
[0086] It should be noted that, when the first key value is the source IP and the second key value is the source IP and the source port, the technology of assigning fixed ports can be implemented through the first hash table and the second hash table, that is, for the same source IP and source port, the first forwarding IP and the pending forwarding port allocated by the hash algorithm are the same.
[0087] Further, after the pending forwarding port in the second hash table is allocated, a third hash table can be generated, and the third hash table can also be called dkey_hash_table. The third hash table can be used to store one or more pending receiving end parameters corresponding to the pending forwarding port, and the pending receiving end parameters can be used to characterize the destination information of the target data message. The third hash table may include a third key code value (also referred to as a third key value), and the third key value may be the one or more pending receiving end parameters mentioned above. For example, the pending receiving end parameters may include one or more of the destination IP, the destination port, and the protocol number.
[0088] In this way, through the third hash table, the same pending forwarding port can correspond to multiple pending receiving end parameters, thereby realizing the port multiplexing technology.
[0089] It should be noted that, through the above preset policy parameter correspondence and IP port storage information structure, a many-to-one and one-to-many nested structure network can be formed, which is convenient for quickly and accurately finding the conversion information resources corresponding to the policy, improving efficiency and saving storage space.
[0090] Figure 4 FIG. 1 is a flow chart of another data forwarding method according to an exemplary embodiment. Figure 4 As shown, the data forwarding method may include:
[0091] S1011. In response to receiving a target data message, determine whether the target data message needs to be converted in parameters.
[0092] In some embodiments, a policy module may be used to determine whether the target data message needs parameter conversion. For example, the policy module may execute a matching strategy based on the first network parameter (e.g., a five-tuple parameter) of the target data message. For a target data message that does not hit the strategy, step S1012 may be executed to directly forward the message; for a target data message that hits the strategy (e.g., the first network parameter of the target data message is the same as the preset strategy network parameter, or is within a preset network parameter range), step S1013 may be executed.
[0093] It should be noted that the target data message may be the first message of a data flow. For example, different five-tuple parameters may identify different data flows, and the target data message may be determined to be the first message of a new data flow according to the five-tuple parameters of the target data message.
[0094] S1012: When it is determined that the target data message does not need parameter conversion, directly forward the target data message.
[0095] S1013: When it is determined that the target data message needs to undergo parameter conversion, determine an IP port resource pool for performing parameter conversion on the target data message according to a first network parameter of the target data message.
[0096] For example, the forwarding policy identifier corresponding to the target data message may be first determined according to the first network parameter of the target data message, and then the IP port resource pool corresponding to the forwarding policy identifier may be determined according to a preset policy parameter correspondence relationship.
[0097] S1021. Determine, according to the source IP of the target data message, a second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool.
[0098] It should be noted that, in this embodiment, the second network parameter may include the source IP and source port of the target data message.
[0099] In some embodiments, if there is a first conversion IP mapped to the source IP in the IP port resource pool, the first conversion IP is used as the second conversion IP corresponding to the target data message.
[0100] In one implementation, each first conversion IP in the IP resource pool may be traversed, and if the first conversion IP has been assigned to the source IP and has been used, the first conversion IP may be used as the second conversion IP corresponding to the target data message.
[0101] In another implementation, the fourth hash table can be searched for a conversion IP corresponding to the source IP based on the source IP. If the conversion IP corresponding to the source IP exists in the fourth hash table and the conversion IP exists in the IP port resource pool, the conversion IP can be used as the second conversion IP corresponding to the target data message. Otherwise, if the conversion IP corresponding to the source IP does not exist in the fourth hash table, or the conversion IP does not exist in the IP port resource pool, a new first conversion IP can be allocated from the IP port resource pool. The fourth hash table can be used to store the correspondence between the allocated source IP and the conversion IP. In the case of allocating a new first conversion IP from the IP port resource pool, the correspondence between the source IP and the allocated first conversion IP can be added to the fourth hash table.
[0102] In this way, the mapped first conversion IP can be used preferentially, so that the same source IP can correspond to the same first conversion IP.
[0103] In other embodiments, if there is no first conversion IP corresponding to the source IP in the IP port resource pool, the first conversion IP that meets the preset IP conversion condition is used as the second conversion IP.
[0104] The preset IP conversion condition may include that there is an idle assignable port in the first conversion port corresponding to the first conversion IP. For example, the preset IP conversion condition may include one or more of the following conditions:
[0105] Condition 1: the first conversion IP is in an idle state, wherein the idle state of the conversion IP may indicate that the first conversion IP has not been allocated for use, or one or more sessions after being allocated for use have been released (eg, timed out or actively released).
[0106] Condition 2: The first conversion IP is in an occupied state, and there is an idle conversion port in the first conversion port corresponding to the first conversion IP. The idle state of the conversion port can indicate that the first conversion port has not been allocated for use, or one or more sessions after being allocated for use have been released (for example, timed out or actively released).
[0107] In some implementations, the number of free ports of each first conversion IP may be determined, and the number of free ports is used to represent the number of free conversion ports in the first conversion ports corresponding to the first conversion IP. The first conversion IP with the largest number of free ports is used as the second conversion IP.
[0108] In some embodiments of the present disclosure, the source IP may be used as a first key value to hash the first hash index according to the first hash table, and the first conversion IP corresponding to the first hash index may be used as the second conversion IP.
[0109] S1022. Determine, according to the source IP and source port of the target data message, a second conversion port corresponding to the target data message from one or more first conversion ports corresponding to the second conversion IP.
[0110] For example, according to the second hash table, the source IP and source port of the target data message may be used as the second key value to perform hashing to obtain a second hash index, and the first conversion port corresponding to the second hash index may be used as the second conversion port.
[0111] S103: Determine a target conversion IP and a target conversion port according to the second conversion IP, the second conversion port and a third network parameter of the target data message.
[0112] The third network parameter may be used to characterize the receiving end information of the target data message. For example, the third network parameter may include one or more of the destination IP, destination port and protocol number of the target data message.
[0113] In some embodiments, when one or more pending receiving end parameters corresponding to the second conversion port do not include parameters identical to the third network parameters of the target data message, the second conversion port can be used as the target conversion port, and the second conversion IP can be used as the target conversion IP.
[0114] In some other embodiments, when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message, the target conversion IP and the target conversion port may be determined by the following steps:
[0115] First, a third conversion port different from the second conversion port and satisfying a preset port conversion condition is determined from one or more first conversion ports corresponding to the second conversion IP; then, the third conversion port is used as a target conversion port, and the second conversion IP is used as a target conversion IP.
[0116] In some embodiments, the preset port conversion condition can be used to indicate that the third conversion port does not have a corresponding pending receiving end parameter. For example, if the third conversion port is an idle port, the third conversion port does not have any corresponding pending receiving end parameter.
[0117] In other embodiments, the preset port conversion condition can be used to characterize that one or more pending receiving end parameters corresponding to the third conversion port do not include parameters identical to the third network parameters. For example, although the third conversion port is used, it is not used by the receiving end corresponding to the data message, and therefore, one or more pending receiving end parameters corresponding to the third conversion port do not include parameters identical to the third network parameters.
[0118] In some other embodiments, when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message, and there is no first conversion port that meets the preset port conversion condition among the one or more first conversion ports corresponding to the second conversion IP, the target conversion IP and the target conversion port can be determined by the following steps:
[0119] First, a third conversion IP that meets a preset IP conversion condition is determined from one or more first conversion IPs in the IP port resource pool.
[0120] The third conversion IP is different from the second conversion IP. Similarly, the preset IP conversion condition may include that there is an idle assignable port in the first conversion port corresponding to the first conversion IP.
[0121] Secondly, according to the source IP and source port of the target data message, a fourth conversion port corresponding to the target data message is determined from one or more first conversion ports corresponding to the third conversion IP.
[0122] For example, according to the second hash table, the source IP and source port of the target data message may be used as the second key value to perform hashing to obtain a second hash index, and the first conversion port corresponding to the second hash index may be used as the fourth conversion port.
[0123] Finally, according to the third conversion IP and the fourth conversion port, the target conversion IP and the target conversion port are determined.
[0124] By way of example, the third conversion IP may be used as the target conversion IP, and the fourth conversion port may be used as the target conversion port.
[0125] S104: forward the target data message according to the target conversion IP and the target conversion port.
[0126] By adopting the above method, the IP port resource pool can be determined by the first network parameter, the second conversion IP and the second conversion port in the IP port resource pool can be determined by the second network parameter, and the target conversion IP and the target conversion port can be further determined according to the third network parameter, thereby realizing data forwarding with port multiplexing.
[0127] Figure 5 is a block diagram of a data forwarding device 500 according to an exemplary embodiment. Figure 5 As shown, the apparatus 500 may include:
[0128] The determination module 501 is used for, in response to receiving a target data message, determining an IP port resource pool for performing parameter conversion on the target data message according to a first network parameter of the target data message when determining that the target data message needs to be converted; wherein the IP port resource pool includes one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message;
[0129] The acquisition module 502 is used to acquire the second conversion IP and the second conversion port corresponding to the target data message from the IP port resource pool according to the second network parameter of the target data message; determine the target conversion IP and the target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message; wherein the second network parameter is used to characterize the sending end information of the target data message, and the third network parameter is used to characterize the receiving end information of the target data message;
[0130] The forwarding module 503 is used to forward the target data message according to the target conversion IP and the target conversion port.
[0131] In some embodiments, the second network parameters include the source IP and source port of the target data packet; the acquisition module 502 is used to determine the second conversion IP corresponding to the target data packet from one or more first conversion IPs in the IP port resource pool according to the source IP of the target data packet; and determine the second conversion port corresponding to the target data packet from one or more first conversion ports corresponding to the second conversion IP according to the source IP and source port of the target data packet.
[0132] In some embodiments, the acquisition module 502 is used to use the first conversion IP as the second conversion IP if there is a first conversion IP corresponding to the source IP in the IP port resource pool; or, if there is no first conversion IP corresponding to the source IP in the IP port resource pool, use the first conversion IP that meets the preset IP conversion condition as the second conversion IP, and the preset IP conversion condition includes that there is an idle allocatable port in the first conversion port corresponding to the first conversion IP.
[0133] In some embodiments, the acquisition module 502 is used to use the second conversion port as the target conversion port and the second conversion IP as the target conversion IP when one or more pending receiving end parameters corresponding to the second conversion port do not include parameters that are the same as the third network parameters of the target data packet.
[0134] In some embodiments, the acquisition module 502 is used to determine, from one or more of the first conversion ports corresponding to the second conversion IP, a third conversion port that is different from the second conversion port and satisfies a preset port conversion condition, when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message; the preset port conversion condition is used to characterize that there is no corresponding pending receiving end parameter for the third conversion port, or that one or more pending receiving end parameters corresponding to the third conversion port include parameters that are the same as the third network parameters; the third conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP.
[0135] In some embodiments, the acquisition module 502 is used to determine a third conversion IP that meets the preset IP conversion condition from one or more first conversion IPs in the IP port resource pool when one or more pending receiving end parameters corresponding to the second conversion port include parameters that are the same as the third network parameters of the target data message, and there is no first conversion port that meets the preset port conversion condition among the one or more first conversion ports corresponding to the second conversion IP; the third conversion IP is different from the second conversion IP; according to the source IP and source port of the target data message, determine a fourth conversion port that meets the target data message from one or more first conversion ports corresponding to the third conversion IP; and determine the target conversion IP and the target conversion port according to the third conversion IP, the fourth conversion port and the third network parameter of the target data message.
[0136] In some embodiments, the determination module 501 is used to determine the forwarding policy identifier corresponding to the target data packet based on the first network parameter of the target data packet; determine the IP port resource pool corresponding to the forwarding policy identifier based on the preset policy parameter correspondence relationship; the preset policy parameter correspondence relationship includes the correspondence between the forwarding policy identifier and the IP port resource pool.
[0137] In some embodiments, the IP port resource pool includes a first hash table, a second hash table and a third hash table, the first hash table is used to store multiple first conversion IPs, the second hash table is used to store one or more pending forwarding ports corresponding to the first conversion IP, and the third hash table is used to store one or more pending receiving end parameters corresponding to the pending forwarding ports.
[0138] In some embodiments, the first network parameter includes one or more of the source IP, source port, destination IP, destination port and protocol number of the target data packet.
[0139] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0140] Figure 6 FIG. 2 is a block diagram of an electronic device 2000 according to an exemplary embodiment. Figure 6 As shown, the electronic device 2000 may include: a processor 2001 and a memory 2002. The electronic device 2000 may also include one or more of a multimedia component 2003, an input / output (I / O) interface 2004, and a communication component 2005.
[0141] The processor 2001 is used to control the overall operation of the electronic device 2000 to complete all or part of the steps in the above-mentioned data forwarding method. The memory 2002 is used to store various types of data to support the operation of the electronic device 2000. For example, these data may include instructions for any application or method used to operate on the electronic device 2000, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 2002 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 2003 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the memory 2002 or sent through the communication component 2005. The audio component also includes at least one speaker for outputting audio signals. The input / output interface 2004 provides an interface between the processor 2001 and other interface modules, and the above-mentioned other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 2005 is used for wired or wireless communication between the electronic device 2000 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, 5G, NB-IOT, eMTC, or other 6G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 2005 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0142] In an exemplary embodiment, the electronic device 2000 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned data forwarding method.
[0143] In another exemplary embodiment, there is also provided a computer-readable storage medium, which stores a computer program or program instructions, and when the computer program or program instructions are executed by the processor, the steps of the above-mentioned data forwarding method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 2002 including program instructions, and the above-mentioned program instructions can be executed by the processor 2001 of the electronic device 2000 to complete the above-mentioned data forwarding method. Exemplarily, the computer-readable storage medium can be a non-temporary computer-readable storage medium, for example, the non-temporary computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, and an optical data storage device, etc.
[0144] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program that can be executed by a programmable device. The computer program has a code portion for executing the above data forwarding method when executed by the programmable device.
[0145] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. This application is intended to cover any variations, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure. The specification and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0146] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A data forwarding method, characterized in that: The method comprises: In response to receiving a target data message, when it is determined that the target data message needs to be parameter converted, an IP port resource pool for performing parameter conversion on the target data message is determined according to a first network parameter of the target data message; wherein the IP port resource pool includes one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message; According to the second network parameter of the target data message, obtain the second conversion IP and the second conversion port corresponding to the target data message from the IP port resource pool; wherein the second network parameter is used to characterize the sender information of the target data message; Determine the target conversion IP and target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message; wherein the third network parameter is used to characterize the receiving end information of the target data message; Forwarding the target data message according to the target conversion IP and the target conversion port; The second network parameter includes a source IP and a source port of the target data message; and obtaining a second conversion IP and a second conversion port corresponding to the target data message from the IP port resource pool according to the second network parameter of the target data message includes: According to the source IP of the target data message, determine the second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool; According to the source IP and source port of the target data message, determine the second conversion port corresponding to the target data message from one or more of the first conversion ports corresponding to the second conversion IP; The third network parameter includes the destination IP, destination port and protocol number of the target data message; the step of determining the target conversion IP and target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message includes: In the case where the one or more pending receiving end parameters corresponding to the second conversion port do not include a parameter that is the same as the third network parameter of the target data message, the second conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP; In the case where one or more pending receiving end parameters corresponding to the second conversion port include parameters identical to the third network parameters, determining a third conversion port different from the second conversion port and satisfying a preset port conversion condition from one or more of the first conversion ports corresponding to the second conversion IP; the preset port conversion condition is used to indicate that there is no corresponding pending receiving end parameter for the third conversion port, or that one or more pending receiving end parameters corresponding to the third conversion port include parameters identical to the third network parameters; The third conversion port is used as the target conversion port, and the second conversion IP is used as the target conversion IP.
2. The method according to claim 1, characterized in that Determining the second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool according to the source IP of the target data message includes: If there is a first conversion IP corresponding to the source IP in the IP port resource pool, the first conversion IP is used as the second conversion IP; or, If there is no first conversion IP corresponding to the source IP in the IP port resource pool, the first conversion IP that meets the preset IP conversion condition is used as the second conversion IP, and the preset IP conversion condition includes that there is an idle and allocatable port in the first conversion port corresponding to the first conversion IP.
3. The method according to claim 1, characterized in that The step of determining the target conversion IP and the target conversion port corresponding to the target data message according to the second conversion IP, the second conversion port and the third network parameter of the target data message further comprises: In the case where one or more pending receiving end parameters corresponding to the second conversion port include parameters identical to the third network parameters, and there is no first conversion port satisfying the preset port conversion condition among the one or more first conversion ports corresponding to the second conversion IP, a third conversion IP satisfying the preset IP conversion condition is determined from the one or more first conversion IPs in the IP port resource pool; the third conversion IP is different from the second conversion IP; According to the source IP and source port of the target data message, determine a fourth conversion port corresponding to the target data message from one or more of the first conversion ports corresponding to the third conversion IP; The target conversion IP and the target conversion port are determined according to the third conversion IP, the fourth conversion port and the third network parameter of the target data message.
4. The method according to any one of claims 1 to 3, characterized in that The step of determining, according to the first network parameter of the target data message, an IP port resource pool for performing parameter conversion on the target data message comprises: Determine a forwarding strategy identifier corresponding to the target data message according to a first network parameter of the target data message; According to the preset policy parameter correspondence, the IP port resource pool corresponding to the forwarding policy identifier is determined; the preset policy parameter correspondence includes the correspondence between the forwarding policy identifier and the IP port resource pool.
5. The method according to claim 4, characterized in that The IP port resource pool includes a first hash table, a second hash table and a third hash table. The first hash table is used to store multiple first conversion IPs, the second hash table is used to store one or more pending forwarding ports corresponding to the first conversion IPs, and the third hash table is used to store one or more pending receiving end parameters corresponding to the pending forwarding ports.
6. A data forwarding device, characterized in that: The device comprises: A determination module, configured to, in response to receiving a target data message, determine an IP port resource pool for performing parameter conversion on the target data message according to a first network parameter of the target data message when determining that the target data message needs to be converted in parameters; wherein the IP port resource pool includes one or more first conversion IPs and one or more first conversion ports corresponding to each first conversion IP, and the first network parameter is used to characterize data flow information of the target data message; An acquisition module, configured to acquire, from the IP port resource pool, a second conversion IP and a second conversion port corresponding to the target data message according to the second network parameter of the target data message; and determine, according to the second conversion IP, the second conversion port and a third network parameter of the target data message, a target conversion IP and a target conversion port corresponding to the target data message; wherein the second network parameter is used to characterize the sending end information of the target data message; and the third network parameter is used to characterize the receiving end information of the target data message; A forwarding module, used for forwarding the target data message according to the target conversion IP and the target conversion port; The second network parameter includes the source IP and source port of the target data message; the acquisition module is used to determine the second conversion IP corresponding to the target data message from one or more first conversion IPs in the IP port resource pool according to the source IP of the target data message; according to the source IP and source port of the target data message, determine the second conversion port corresponding to the target data message from one or more first conversion ports corresponding to the second conversion IP; The third network parameters include the destination IP, destination port and protocol number of the target data message; the acquisition module is also used to use the second conversion port as the target conversion port and the second conversion IP as the target conversion IP when one or more pending receiving end parameters corresponding to the second conversion port do not include parameters identical to the third network parameters of the target data message; when one or more pending receiving end parameters corresponding to the second conversion port include parameters identical to the third network parameters of the target data message, determine a third conversion port different from the second conversion port and satisfying a preset port conversion condition from one or more of the first conversion ports corresponding to the second conversion IP; the preset port conversion condition is used to characterize that there is no corresponding pending receiving end parameter for the third conversion port, or that one or more pending receiving end parameters corresponding to the third conversion port include parameters identical to the third network parameters; use the third conversion port as the target conversion port and use the second conversion IP as the target conversion IP.
7. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Method for realizing NAT traversal
CN111131544A
Message forwarding method and device, storage medium and electronic equipment
CN112965824A