Message forwarding method and device and computer readable storage medium
By determining whether the packet needs to be translated presetly and the connection record item is generated in the CLAT scenario, the problem of high CPU resources occupancy in the CLAT scenario is solved, and more efficient packet forwarding is achieved, improving performance and reducing maintenance costs.
Patent Information
- Application Number
- CN202411874546.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-18
- Publication Date
- 2025-03-28
AI Technical Summary
In the CLAT scenario, data processing occupies high CPU resources, resulting in poor data transmission rate and system lag, affecting the user experience.
A message forwarding method is proposed. By determining whether the message needs to be translated presetly, first translate and generate a connection record item, and then detect the connection record item when the message is sent again. If it exists, it will be forwarded faster, otherwise it will be forwarded through the protocol stack.
Reduces CPU resource consumption, improves performance, eliminates dependence on driver devices, reduces maintenance costs, and achieves more efficient CLAT message forwarding.
Smart Images

Figure CN119728636A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of network communication technology, and in particular to a message forwarding method, device and computer-readable storage medium. Background Art
[0002] At present, with the gradual deployment of IPv6 and the exhaustion of IPv4 addresses around the world, network operators and service providers need effective methods to ensure that applications and services that rely on IPv4 can still be supported in an IPv6-first network environment. Based on this, the 464XLAT solution is proposed at this stage. This solution is a network conversion mechanism that aims to solve the interoperability problem between IPv4 and IPv6 during the IPv6 transition period.
[0003] Specifically, 464XLAT is implemented by combining CLAT (Customer Edge Translator) and PLAT (Provider Edge Translator). CLAT runs on user devices, such as smartphones, CPE, routers, etc., and is used to convert IPv4 application traffic to IPv6 traffic. It is located at the edge of the user device or local network. Its role is to allow IPv4 applications to work normally in a network that only supports IPv6. By converting IPv4 requests to IPv6, the CLAT translation function is only started when the user device is in IPv6 single stack mode; PLAT runs at the edge of the network provider and is used to convert the converted IPv6 traffic back to IPv4 again to communicate with the IPv4 Internet. It is located at the edge of the service provider's network and is used to ensure that the traffic sent from the user device can be correctly routed to the IPv4 destination and return the response to the user device.
[0004] Please refer to Figure 1 Based on the existing 464XLAT network architecture, the black thick line path represents the normal unaccelerated message forwarding path; the gray thin line path represents the accelerated message fast forwarding path; the black thin line path represents the message forwarding path processed by CLAT. It can be seen that the data message processed by CLAT needs to be converted to CLAT (kernel state or application state) after being processed by the kernel. In terms of data processing flow, there are more paths compared to traditional data flows, and in the data transmission scenario, after CLAT translation, there will be problems such as poor data transmission rate, system freeze, and poor user experience due to excessive system CPU occupancy. Summary of the invention
[0005] In order to overcome the deficiencies in the prior art, the object of the present invention is to provide a message forwarding method, device and computer-readable storage medium to solve the problem that data processing occupies high CPU resources and has poor data transmission rate in the current CLAT scenario.
[0006] The present invention provides a message forwarding method, which comprises:
[0007] When a message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method;
[0008] If the message needs to be translated as preset, the message is translated first, and then the message is processed through the protocol stack, and a connection record item is generated;
[0009] When the message is sent to the kernel receiving main entrance again, detecting whether there is the connection record item corresponding to the message;
[0010] If the connection record entry exists, the message is forwarded in an accelerated manner, and if the connection record entry does not exist, the message is forwarded through the protocol stack.
[0011] Optionally, before the message is sent to the kernel receiving main entrance, the method includes:
[0012] When the user terminal device is in IPv6 single stack mode, a preset user side translation function is started to perform the translation operation.
[0013] Optionally, before the message is sent to the kernel receiving main entrance, the method includes:
[0014] When the user terminal device initiates an IPv4 data request, it is determined that the user terminal device supports a preset fast forwarding function to perform the accelerated forwarding operation.
[0015] Optionally, when the message is sent to the kernel receiving main entrance, determining whether the message needs to be translated by a preset method specifically includes:
[0016] When the message is sent from the driver entry to the kernel receiving main entry and before entering the protocol stack, the protocol type of the message is obtained;
[0017] If the protocol type is IPv4, determining whether the message needs to be translated;
[0018] If the protocol type is IPv6, it is determined that the message does not need to be translated.
[0019] Optionally, the determining whether the message needs to be translated by a preset method further includes:
[0020] If the message does not need to be translated, when the message is sent to the kernel receiving main entrance again, it is detected whether there is the connection record item corresponding to the message.
[0021] Optionally, the generating a connection record item specifically includes:
[0022] After the message is processed by the protocol stack, the connection record item corresponding to the message is generated.
[0023] Optionally, if the connection record item exists, accelerating forwarding of the message specifically includes:
[0024] Obtain current acceleration decision information, wherein the acceleration decision information includes source IP, source MAC, destination IP, destination MAC, and protocol type;
[0025] Determine whether the message meets the current accelerated forwarding condition according to the acceleration decision information.
[0026] Optionally, determining whether the message meets a current accelerated forwarding condition according to the acceleration decision information further includes:
[0027] If the message meets the accelerated forwarding condition, the message is accelerated forwarded, and if the message does not meet the accelerated forwarding condition, the message is forwarded through the protocol stack.
[0028] The present invention also proposes a message forwarding device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the message forwarding method as described in any one of the above items when executed by the processor.
[0029] The present invention also proposes a computer-readable storage medium, on which a message forwarding program is stored. When the message forwarding program is executed by a processor, the steps of the message forwarding method as described in any one of the above items are implemented.
[0030] The message forwarding method, device and computer-readable storage medium of the present invention are implemented. When a message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method; if the message needs to be translated by the preset method, the message is translated first, and then the message is processed by the protocol stack, and a connection record item is generated; when the message is sent to the kernel receiving main entrance again, it is detected whether the connection record item corresponding to the message exists; if the connection record item exists, the message is accelerated forwarded, and if the connection record item does not exist, the message is forwarded by the protocol stack. The present invention realizes a more efficient CLAT (Customer Edge Translator) message forwarding solution, which reduces CPU resource consumption and improves performance by adding CLAT data to the acceleration data, and determines whether CLAT translation is required before acceleration, removes the dependence on the driver device, and reduces maintenance costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0031] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:
[0032] Figure 1 It is a schematic diagram of the existing message forwarding data flow;
[0033] Figure 2 is a first flow chart of the message forwarding method of the present invention;
[0034] Figure 3 This is the second flow chart of the message forwarding method of the present invention. DETAILED DESCRIPTION
[0035] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0036] In the subsequent description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module", "component" or "unit" can be used in a mixed manner.
[0037] Figure 2 This embodiment provides a message forwarding method, which includes:
[0038] S1. When a message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method;
[0039] Specifically, in this embodiment, the preset translation refers to translating a message that meets the IPv4 requirement into a message that meets the IPv6 requirement, that is, implementing the mapping of the IPv4 address to the IPv6 address through CLAT.
[0040] S2. If the message needs to be translated as preset, the message is translated first, and then the message is processed through the protocol stack, and a connection record item is generated;
[0041] Specifically, in this embodiment, considering the differences in length and format of IPv4 and IPv6 addresses, CLAT needs to be converted according to certain rules. There are two common mapping methods: one is to use embedded IPv6 addresses, that is, embed IPv4 addresses into IPv6 addresses. A common practice is to embed IPv4 addresses into the suffix part of IPv6 addresses. For MAP-T (Mapping of Address and Port with Translation) protocol, a special IPv6 prefix is usually used to identify this mapping. For example, if a specific prefix 2001:db8:: / 32 is used, the IPv4 address 192.168.1.1 is mapped to an IPv6 address similar to 2001:db8::192.168.1.1. The IPv6 prefix 2001:db8:: / 32 is used to identify the converted address, and 192.168.1.1 is directly embedded into the low-order part of the IPv6 address. The second is to use dedicated IPv6 address blocks. Optionally, CLAT carries multiple IPv4 address mappings by allocating specific IPv6 address blocks. For example, using RFC The IPv6 address format specified in 6052, in which the first 96 bits are fixed (for example, 64:ff9b:: / 96), followed by the converted IPv4 address, allows the IPv4 address to be embedded in the IPv6 address.
[0042] Optionally, in this embodiment, the protocol stack applies the RFC6145 protocol, which includes version number mapping, IPv4 service type and IPv6 traffic level mapping, IPv4 total length and IPv6 payload length mapping, IPv4 lifetime and IPv6 forwarding count mapping, IPv4 transport layer protocol and IPv6 next header mapping, IPv4 address and IPv6 address mapping, etc.
[0043] S3, when the message is sent to the kernel receiving main entrance again, detecting whether there is the connection record item corresponding to the message;
[0044] In this embodiment, for the same message, when the message enters the kernel receiving entrance for the first time, it is forwarded through the protocol stack, and at the same time, a forwarding record (i.e., a connection record item) is generated. When the message enters the kernel receiving entrance for the second time again, the above-mentioned forwarding record will be queried, that is, it will be checked whether there is a connection record item corresponding to the message.
[0045] S4. If the connection record entry exists, the message is forwarded in an accelerated manner; if the connection record entry does not exist, the message is forwarded through the protocol stack.
[0046] In this embodiment, considering the existing CLAT data transmission scenario, especially when processing CLAT messages based on the RFC6145 protocol, after being processed by the kernel, it is handed over to the CLAT module for translation, which increases the data processing process compared to the traditional data flow, increases the CPU resource consumption, and the CLAT scenario performance is very poor; at the same time, the existing CLAT fast forwarding method performs CLAT translation before the driver sends the packet. This solution requires the driver layer code to be re-adapted every time the ETH / USB / WIFI chip is replaced, and the maintenance cost is high. Therefore, this embodiment proposes a technical solution of adding CLAT data to the data to be accelerated and judging whether CLAT translation is required before acceleration. On the one hand, it reduces CPU resource consumption and improves performance. On the other hand, it removes the dependence on the driver device and reduces maintenance costs.
[0047] In this embodiment, the specific scheme is as follows: first, when the message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method; if the message needs to be translated, the translation is performed first, and then the message is processed through the protocol stack, and a connection record item is generated; then, when the message is sent to the kernel receiving main entrance again, it is detected whether there is a connection record item corresponding to the message; if so, the message is forwarded at an accelerated speed, and if not, the message is forwarded through the protocol stack.
[0048] It can be seen that this embodiment implements a more efficient CLAT (Customer Edge Translator) message forwarding solution, which reduces CPU resource consumption and improves performance by adding CLAT data to acceleration data. It also determines whether CLAT translation is required before acceleration, removes dependence on driver devices, and reduces maintenance costs.
[0049] In this embodiment, before the message is sent to the kernel receiving main entrance, the method further includes: when the user terminal device is in IPv6 single stack mode, starting a preset user side translation function to perform the translation operation.
[0050] In this embodiment, before the message is sent to the kernel receiving main entrance, the method further includes: when the user terminal device initiates an IPv4 data request, determining that the user terminal device supports a preset fast forwarding function to perform the accelerated forwarding operation.
[0051] In this embodiment, when a message is sent to the kernel receiving entrance, it is determined whether the message needs to be translated by a preset method. This step specifically includes: when the message is sent from the driver entrance to the kernel receiving entrance and before entering the protocol stack, the protocol type of the message is obtained; if the protocol type is IPv4, it is determined whether the message needs to be translated; if the protocol type is IPv6, it is determined that the message does not need to be translated. It can be seen that in this embodiment, when the current data message needs to be translated by CLAT, the message that meets the IPv4 requirement is first translated into a message that meets the IPv6 requirement, and then processed by the protocol stack, thereby avoiding the data message that has been processed by CLAT and needs to be converted by CLAT again after being processed by the kernel.
[0052] In this embodiment, the step of determining whether the message needs to be translated by a preset method further includes: if the message does not need to be translated, when the message is sent to the kernel receiving entrance again, detecting whether there is a connection record item corresponding to the message.
[0053] In this embodiment, the step of generating a connection record item specifically includes: after the message is processed by the protocol stack, generating the connection record item corresponding to the message.
[0054] In this embodiment, if the connection entry exists, the message is accelerated forwarded, and this step specifically includes: obtaining current acceleration decision information, wherein the acceleration decision information includes source IP, source MAC, destination IP, destination MAC and protocol type; determining whether the message meets the current accelerated forwarding conditions according to the acceleration decision information. It can be seen that in this embodiment, combined with the above-mentioned connection entry, when the data message is subsequently sent to the kernel receiving entrance, the generated record (Conntrack) can be identified, and then the accelerated processing can be performed differentially.
[0055] In this embodiment, the step of determining whether the message meets the current accelerated forwarding condition based on the acceleration decision information further includes: if the message meets the accelerated forwarding condition, the message is accelerated forwarded, and if the message does not meet the accelerated forwarding condition, the message is forwarded through the protocol stack.
[0056] Please refer to Figure 3The second flow chart of the message forwarding method of the present invention is shown. In this embodiment, the user terminal device (for example, CPE / ROUTER / MOBILE PHONE, etc.) supports the acceleration function and starts the CLAT function only when IPv6 dials up. Based on this, the terminal device initiates an IPv4 data request, specifically: Step S10, sending the data message to the driver entry; Step S20, the data message is forwarded by the driver to the kernel netif_rx receiving general entry; Step S30, before the data message enters the protocol stack for forwarding, the protocol type of the data message is determined. If the protocol type of the data message is IPv4, it is determined that the data message needs to be converted to CLAT. If the protocol type of the data message is IPv6, the data message is forwarded through the preset protocol stack; Step S40, if the protocol type of the data message is IPv4, the data message is determined. Whether CLAT translation is needed, wherein if there is a connection record item in the data message, it is handed over to the acceleration module for processing, and if there is no connection record item in the data message, it is handed over to the acceleration module for processing; step S50, if there is no connection record item in the data message, CLAT translation is performed, and after translation, it is handed over to the acceleration module for processing; step S60, the acceleration module determines whether the data message meets the current acceleration conditions; step S70, if it meets, the data message is accelerated forwarded; step S80, if it does not meet, the data message is forwarded through the protocol stack; step S90, the data message is sent via the WAN network; step S100, the data message arrives at the ISP (Internet Service Provider). Among them, steps S40 to S60, and steps S60 to S70 are the CLAT message processing flow after accelerated processing, and the others are the CLAT message processing flow without acceleration.
[0057] In this embodiment, when CLAT translation is required for the current data message, CLAT translation is performed first and then processed by the protocol stack; further, in this embodiment, a record (Conntrack) is generated after the data message is processed by the protocol stack, and a new connection record item (Connection entry) is generated for each data packet passing through the network stack through the Linux system; based on this, in this embodiment, considering that when the data message is subsequently sent to the kernel receiving main entrance, a record (Conntrack) has been generated, and therefore, the acceleration module can implement differentiated processing by judging the five-tuple (including source IP, source MAC, destination IP, destination MAC and protocol type), that is, the data message that meets the acceleration requirements is no longer processed by the protocol stack, and is directly forwarded by acceleration.
[0058] The beneficial effect of this embodiment is that when a message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method; if the message needs to be translated, it is translated first, and then the message is processed through the protocol stack, and a connection record item is generated; when the message is sent to the kernel receiving main entrance, it is detected whether there is a connection record item corresponding to the message; if there is a connection record item, the message is accelerated and forwarded, and if there is no connection record item, the message is forwarded through the protocol stack. A more efficient CLAT message forwarding solution is implemented, CLAT data is added to the acceleration data, CPU resource consumption is reduced, performance is improved, and whether CLAT translation is required before acceleration is determined, the dependence on the driver device is removed, and maintenance costs are reduced.
[0059] Based on the above embodiments, the present invention also proposes a message forwarding device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the message forwarding method as described in any one of the above items when executed by the processor.
[0060] It should be noted that the above-mentioned device embodiment and method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, and the technical features in the method embodiment are correspondingly applicable in the device embodiment, which will not be repeated here.
[0061] Based on the above embodiments, the present invention further proposes a computer-readable storage medium, on which a message forwarding program is stored. When the message forwarding program is executed by a processor, the steps of the message forwarding method as described in any one of the above items are implemented.
[0062] It should be noted that the above-mentioned medium embodiment and method embodiment belong to the same concept, and the specific implementation process is detailed in the method embodiment, and the technical features in the method embodiment are correspondingly applicable in the medium embodiment, which will not be repeated here.
[0063] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, a magnetic disk, or an optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, a computer, a server, an air conditioner, or a network device, etc.) to execute the methods described in each embodiment of the present invention.
[0064] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0065] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.
Claims
1. A message forwarding method, characterized in that: The method comprises: When a message is sent to the kernel receiving main entrance, it is determined whether the message needs to be translated by a preset method; If the message needs to be translated as preset, the message is translated first, and then the message is processed through the protocol stack, and a connection record item is generated; When the message is sent to the kernel receiving main entrance again, detecting whether there is the connection record item corresponding to the message; If the connection record entry exists, the message is forwarded in an accelerated manner, and if the connection record entry does not exist, the message is forwarded through the protocol stack.
2. The message forwarding method according to claim 1, characterized in that: Before the message is sent to the kernel receiving main entrance, the method includes: When the user terminal device is in IPv6 single stack mode, a preset user side translation function is started to perform the translation operation.
3. The message forwarding method according to claim 1, characterized in that: Before the message is sent to the kernel receiving main entrance, the method includes: When the user terminal device initiates an IPv4 data request, it is determined that the user terminal device supports a preset fast forwarding function to perform the accelerated forwarding operation.
4. The message forwarding method according to claim 1, characterized in that: When the message is sent to the kernel receiving main entrance, determining whether the message needs to be translated by a preset method specifically includes: When the message is sent from the driver entry to the kernel receiving main entry and before entering the protocol stack, the protocol type of the message is obtained; If the protocol type is IPv4, determining whether the message needs to be translated; If the protocol type is IPv6, it is determined that the message does not need to be translated.
5. The message forwarding method according to claim 1, characterized in that: The determining whether the message needs to be translated by a preset method further includes: If the message does not need to be translated, when the message is sent to the kernel receiving main entrance again, it is detected whether there is the connection record item corresponding to the message.
6. The message forwarding method according to claim 1, characterized in that: The generating of the connection record item specifically includes: After the message is processed by the protocol stack, the connection record item corresponding to the message is generated.
7. The message forwarding method according to claim 1, characterized in that: If the connection record item exists, the message is accelerated forwarding, specifically including: Obtain current acceleration decision information, wherein the acceleration decision information includes source IP, source MAC, destination IP, destination MAC, and protocol type; Determine whether the message meets the current accelerated forwarding condition according to the acceleration decision information.
8. The message forwarding method according to claim 4, characterized in that: The determining, according to the acceleration decision information, whether the message meets the current accelerated forwarding condition further includes: If the message meets the accelerated forwarding condition, the message is accelerated forwarded, and if the message does not meet the accelerated forwarding condition, the message is forwarded through the protocol stack.
9. A message forwarding device, characterized in that: The device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, the steps of the message forwarding method according to any one of claims 1 to 8 are implemented.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a message forwarding program, and when the message forwarding program is executed by the processor, the steps of the message forwarding method according to any one of claims 1 to 8 are implemented.
Citation Information
Cited By
Internet of Things module gateway collaborative IPv4 (Internet Protocol Version 4) service transparent transmission system and method
CN121037338A