A full-stack protocol conversion method, apparatus, electronic device, and storage medium

By using a full-stack protocol conversion method to process the application layer response data from the IPv4 server to the IPv6 client, the problem that the NAT64 scheme cannot resolve IPv4 addresses is solved, enabling IPv6 clients to access IPv4 services without being aware of them, thus ensuring business continuity and user experience.

CN123123467APending Publication Date: 2026-11-17ZHENGZHOU INSPUR DATA TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611544618.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-30
Publication Date
2026-11-17

AI Technical Summary

Technical Problem

The existing NAT64 solution does not parse and process application layer data, causing IPv6 clients to be unable to access IPv4 redirect addresses, affecting user experience and business continuity.

Method used

It provides a full-stack protocol conversion method, which obtains the application layer response data from the IPv4 server, diverts it to the target application layer protocol parsing module, extracts the IPv4 address, converts it according to the IPv4 and IPv6 address mapping rules, adaptively corrects the data length and verification information, and reconstructs the application layer response data to be sent to the IPv6 client.

Benefits of technology

Ensure that IPv6 clients can continue to access the redirected IPv4 server, avoid interruptions in the interaction process, and improve user experience and business continuity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123123467A_ABST
    Figure CN123123467A_ABST
Patent Text Reader

Abstract

This application discloses a full-stack protocol conversion method, apparatus, electronic device, and storage medium, relating to the field of network communication technology. When a NAT64 gateway forwards application-layer response data sent from an IPv4 server to an IPv6 client, it can extract the IPv4 address carried in the data through application-layer protocol parsing and convert it into an IPv6 address recognizable by the IPv6 client. Simultaneously, it adaptively corrects the data length and verification information of the application-layer response data packet to obtain legitimate target application-layer response data. This ensures that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the obtained target application-layer response data, avoiding interruptions in the interaction process and thus guaranteeing the business continuity and user experience of IPv6 clients accessing IPv4 services.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of network communication technology, and in particular to a full-stack protocol conversion method, apparatus, electronic device, and storage medium. Background Technology

[0002] With the development of Internet technology, IPv4 address resources are becoming increasingly scarce, and IPv6, with its larger address space, is gradually being adopted. However, a large number of servers and application services in existing networks are still built on IPv4, making it difficult to complete the IPv6 transformation in the short term. Therefore, enabling access to existing IPv4 services in an IPv6 network environment has become a problem that needs to be solved during the transition from IPv4 to IPv6.

[0003] Existing methods for IPv4 / IPv6 network interoperability include Network Address Translation 64 (NAT64). NAT64 does not require modification of existing IPv4 servers. By deploying a NAT64 gateway in the network, data sent by IPv6 clients is converted into IPv4 data, and data returned by IPv4 servers is converted into IPv6 data, thereby enabling IPv6 clients to access IPv4 services.

[0004] However, existing NAT64 solutions primarily perform translation at the network and transport layers, neglecting to parse and process application layer data. When application layer data returned by an IPv4 server carries IPv4 address information—for example, a redirect address in an HTTP response containing an IPv4 address—existing NAT64 solutions cannot translate this IPv4 address. This prevents IPv6 clients from accessing the corresponding address, interrupting the interaction process and severely impacting user experience and business continuity. Summary of the Invention

[0005] This application provides a full-stack protocol conversion method, apparatus, electronic device, and storage medium to at least solve the problem in the related art where the NAT64 scheme does not parse and process application layer data, causing IPv6 clients to be unable to continue accessing the corresponding IPv4 redirect address.

[0006] This application provides a full-stack protocol conversion method, including: Obtain the application layer response data returned by the IPv4 server in response to the service access request sent by the IPv6 client; The application layer response data is routed to the corresponding target application layer protocol parsing module; The application layer response data is parsed by the target application layer protocol parsing module to extract the IPv4 address carried in the application layer response data; According to the preset IPv4 and IPv6 address mapping rules, the IPv4 address is converted to the corresponding IPv6 address; Replace the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed. Based on the application layer response data to be reconstructed, determine the target data length and target verification information; Based on the target data length and target verification information, the application layer response data to be reconstructed is reconstructed to obtain the target application layer response data. The target application layer response data is sent to the IPv6 client so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

[0007] This application also provides a full-stack protocol conversion device, including: The acquisition module is used to acquire application layer response data returned by the IPv4 server in response to the service access request sent by the IPv6 client; The routing module is used to route application layer response data to the corresponding target application layer protocol parsing module. The address extraction module is used to parse the application layer response data through the target application layer protocol parsing module in order to extract the IPv4 address carried in the application layer response data. The address translation module is used to translate IPv4 addresses into corresponding IPv6 addresses according to preset IPv4 and IPv6 address mapping rules. The address replacement module is used to replace the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed. The determination module is used to determine the target data length and target verification information based on the response data of the application layer to be reconstructed; The reconstruction module is used to reconstruct the application layer response data to be reconstructed based on the target data length and target verification information, so as to obtain the target application layer response data. The sending module is used to send the target application layer response data to the IPv6 client, so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

[0008] This application also provides an electronic device, including: a memory for storing a computer program; and a processor for implementing the steps of any of the above-described full-stack protocol conversion methods when executing the computer program.

[0009] This application also provides a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of any of the above-described full-stack protocol conversion methods.

[0010] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of any of the above-described full-stack protocol conversion methods.

[0011] Through this application, when forwarding application layer response data sent from an IPv4 server to an IPv6 client, the NAT64 gateway can extract the IPv4 address carried in the data through application layer protocol parsing and convert it into an IPv6 address that the IPv6 client can recognize. At the same time, it adaptively corrects the data length and checksum of the application layer response data packet to obtain a legitimate target application layer response data. This ensures that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the obtained target application layer response data, avoiding interruption of the interaction process and thus guaranteeing the business continuity and user experience of IPv6 clients accessing IPv4 services. Attached Figure Description

[0012] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 This is a schematic diagram of the structure of the full-stack protocol conversion system on which the embodiments of this application are based; Figure 2 A flowchart illustrating the full-stack protocol conversion method provided in this application embodiment; Figure 3 A flowchart illustrating an exemplary full-stack protocol conversion method provided in this application embodiment; Figure 4 This is a schematic diagram of the structure of the full-stack protocol conversion device provided in the embodiments of this application; Figure 5 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0014] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.

[0015] It should be noted that, in the description of this application, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. The terms "first," "second," etc., in this application are used to distinguish similar objects and are not used to describe a specific order or sequence.

[0016] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0017] The specific application environment architecture or specific hardware architecture on which the execution of the full-stack protocol conversion method depends is described here.

[0018] First, the structure of the full-stack protocol conversion system on which this application is based will be described: The full-stack protocol conversion method, apparatus, electronic device, and storage medium provided in this application embodiment are applicable to performing full-stack protocol conversion on application layer response data sent from an IPv4 server to an IPv6 client at a NAT64 gateway. For example... Figure 1 The diagram shown is a structural schematic of the full-stack protocol conversion system based on the embodiments of this application. It mainly includes an IPv4 server, an IPv6 client, and a NAT64 gateway. The NAT64 gateway performs full-stack protocol conversion on the application layer response data sent from the IPv4 server to the IPv6 client based on the full-stack protocol conversion method provided in the embodiments of this application.

[0019] This application provides a full-stack protocol conversion method for performing full-stack protocol conversion on application layer response data sent from an IPv4 server to an IPv6 client. The execution subject of this application embodiment is an electronic device, such as a server, desktop computer, laptop computer, tablet computer, or other electronic devices capable of implementing NAT64 gateway functionality.

[0020] like Figure 2 The diagram shown is a flowchart of a full-stack protocol conversion method provided in an embodiment of this application. The method includes: Step 201: Obtain the application layer response data returned by the IPv4 server in response to the service access request sent by the IPv6 client.

[0021] It should be noted that the method provided in this application can be applied to NAT64 gateways. NAT64 technology, as a mainstream transition solution from IPv4 to IPv6, does not require modification of IPv4 services; simply deploying a NAT64 gateway in the network is sufficient to enable IPv6 clients to access IPv4 services. However, existing NAT64 solutions (such as the open-source tool Jool) only support network layer L3 to transport layer L4 translation and cannot handle application layer L7 protocol data, resulting in significant defects in application layer interactions.

[0022] It should be further explained that Jool is implemented based on Linux kernel modules and mainly supports IPv4 / IPv6 protocol conversion at the L3-L4 layers. Specifically, it includes: mapping IPv6 client request packets (destination address 64:ff9b:: / 96) to IPv4 addresses through a preset IPv6 prefix (e.g., 64:ff9b:: / 96), converting IPv6 client request packets (destination address 64:ff9b::192.168.1.100) to IPv4 packets (destination address 192.168.1.100) and forwarding them to the IPv4 server; managing the mapping of TCP / UDP port numbers, supporting multiple IPv6 clients to access different ports of the same IPv4 service through the same NAT64 gateway; supporting packet format conversion of TCP, UDP, and ICMP protocols, solving the adaptation problem of IP version field in L4 layer protocol headers; and maintaining an IPv6-IPv4 session state table to ensure the correct forwarding of bidirectional packets (e.g., the IPv4 server's response packets can be accurately sent back to the corresponding IPv6 client).

[0023] In this embodiment of the application, the application layer response data obtained is a data packet converted by the L3-L4 layer protocol. The data packet converted by the L3-L4 layer protocol generally includes IPv4 server response data packets and IPv6 client request data packets.

[0024] Step 202: Distribute the application layer response data to the corresponding target application layer protocol parsing module.

[0025] The target application layer protocol parsing module is a functional unit designed for specific application layer protocols (such as HTTP, HTTPS, FTP, etc.) to deeply parse the protocol payload and extract key information.

[0026] Specifically, based on the protocol type corresponding to the application layer response data, a corresponding target application layer protocol parsing module can be selected to parse the application layer response data based on that target application layer protocol parsing module.

[0027] Step 203: The application layer response data is parsed by the target application layer protocol parsing module to extract the IPv4 address carried in the application layer response data.

[0028] Specifically, the target application layer protocol parsing module can perform syntactic and semantic analysis on the application layer response data according to the format specifications of the corresponding protocol, and identify the IPv4 address information explicitly or implicitly carried in the data. For example, for the HTTP protocol, the parsing module will check the response header or response body for fields that may contain IP addresses in order to extract the IPv4 address carried in the application layer response data.

[0029] Step 204: Convert the IPv4 address to the corresponding IPv6 address according to the preset IPv4 and IPv6 address mapping rules.

[0030] It should be noted that IPv4 addresses are 32-bit addresses of Internet Protocol version 4, and are usually in dotted decimal notation (e.g., 192.168.1.100). IPv6 addresses are 128-bit addresses of Internet Protocol version 6, providing a massive address space, and are in colon-separated hexadecimal notation.

[0031] Specifically, the preset IPv4 and IPv6 address mapping rules refer to the predefined rules for embedding IPv4 addresses into the IPv6 address space. This can be done by concatenating a specific prefix (such as 64:ff9b::) into the IPv6 address and combining it with the IPv4 address. For example, 192.168.1.100 can be converted to 64:ff9b::192.168.1.100.

[0032] Step 205: Replace the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed.

[0033] Specifically, the extracted IPv4 address string can be replaced with the converted IPv6 address string to change the application layer response data to the application layer response data to be reconstructed. During address replacement, it is necessary to ensure that the address format conforms to the standard of the corresponding protocol. For example, IPv6 addresses must be enclosed in square brackets in the URL, and the SNI field of HTTPS must remain in string format.

[0034] Step 206: Determine the target data length and target verification information based on the application layer response data to be reconstructed.

[0035] Specifically, because the text length of an IPv6 address is greater than that of an IPv4 address, the total length of the application layer data packet will change after the replacement. Therefore, it is necessary to recalculate the data length and checksum of the data packet to obtain the target data length and target checksum information, which is used to ensure the validity of the reconstructed data packet format.

[0036] Step 207: Based on the target data length and target verification information, perform data reconstruction on the application layer response data to be reconstructed to obtain the target application layer response data.

[0037] Specifically, the length field and checksum in the application layer protocol header can be updated based on the target data length and target verification information, and finally encapsulated into a complete target application layer response data packet that conforms to the protocol specification.

[0038] Step 208: Send the target application layer response data to the IPv6 client so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

[0039] Specifically, the NAT64 gateway sends the target application layer response data to the IPv6 client. After receiving the target application layer response data, the IPv6 client parses the IPv6 address within it, such as the IPv6 address in the redirect URL, and initiates subsequent access requests to the IPv4 server to be accessed after the redirection. This achieves seamless access to the IPv4 server by the IPv6 client throughout the entire process, and can automatically adapt even in complex scenarios such as application layer redirection, improving user experience and business continuity.

[0040] Based on the above embodiments, as an implementable approach, in one embodiment, the application layer response data is diverted to the corresponding target application layer protocol parsing module, including: Step 2021: Determine the application layer protocol type corresponding to the application layer response data based on the input port of the application layer response data. Step 2022: Based on the application layer protocol type corresponding to the application layer response data, call the corresponding traffic splitting callback function; Step 2023: Based on the routing callback function, the application layer response data is routed to the corresponding target application layer protocol parsing module.

[0041] It should be noted that the full-stack protocol conversion method provided in this application embodiment is developed based on the Jool open-source code framework and adopts a hybrid deployment architecture of kernel mode and user mode: the kernel mode module includes packet splitting service and session state synchronization service, which is deployed in the Linux kernel mode and interacts directly with Jool's original L3-L4 conversion module (kernel mode) to ensure low latency in packet processing (avoiding data copying overhead between user mode and kernel mode); the user mode module includes application layer protocol parsing service, address translation rule engine, application layer data reconstruction service, and exception handling service, which is deployed in user mode and communicates with the kernel mode module through the netlink protocol, which facilitates flexible expansion of protocol parsing logic (such as adding support for HTTPS and FTP protocols).

[0042] Specifically, for packet splitting services, splitting can be performed based on the protocol type corresponding to the L4 layer port number (incoming port) of the packet (application layer response data), using a pre-defined port-protocol mapping table (e.g., port 80 corresponds to HTTP, port 443 to HTTPS, and port 21 to FTP). If the L4 layer port number of the current packet matches the pre-defined port-protocol mapping table, meaning the mapping table records the protocol type corresponding to that port number, then it is forwarded to the corresponding L7 layer parsing submodule (the target application layer protocol parsing module). Specifically, a splitting hook can be inserted into the kernel-mode forwarding function of Jool. By parsing the destination port field (incoming port) of the TCP / UDP header, the corresponding splitting callback function is called, passing the packet's skb (socket buffer) structure to the user-mode parsing module, thus splitting the application layer response data to the corresponding target application layer protocol parsing module.

[0043] Among them, the dedicated parsing module that transmits data packets from kernel space to user space through the diversion callback function not only utilizes the high performance of kernel space processing, but also leverages the flexible parsing capabilities of user space protocols, achieving a balance between processing performance and functional scalability.

[0044] Based on the above embodiments, as an implementable approach, in one embodiment, the application layer response data is parsed by the target application layer protocol parsing module to extract the IPv4 address carried in the application layer response data, including: Step 2031: According to the protocol parsing rules corresponding to the target application layer protocol parsing module, perform field parsing on the application layer response data to determine the target field carrying address information from the application layer response data; Step 2032: Perform address identification on the target field to determine the IPv4 address in the target field.

[0045] Specifically, regarding the protocol parsing rules corresponding to the target application layer protocol parsing module, taking HTTP and HTTPS as examples: HTTP Protocol Parsing: Based on the HTTP message format (request / response line, header fields, entity content), it extracts target fields containing IP addresses (such as Location, Content-Location, and domain / IP in Set-Cookie) through string matching; it supports HTTP versions 1.0 / 1.1 / 2.0 and handles chunked transmission encoding scenarios; HTTPS protocol parsing: The SNI (ServerName Indication) field in the TLS handshake process is identified through deep packet inspection (DPI) technology. If the SNI is in IPv4 address format (such as 192.168.1.100), the IPv4 address in the target field (SNI field) is extracted, thereby triggering address translation.

[0046] Based on the above embodiments, as an implementable approach, in one embodiment, the IPv4 address is converted to the corresponding IPv6 address according to a preset IPv4 to IPv6 address mapping rule, including: Step 2041: Determine the target NAT64 prefix according to the preset IPv4 and IPv6 address mapping rules; Step 2042: Concatenate the NAT64 prefix with the IPv4 address to convert the IPv4 address to the corresponding IPv6 address.

[0047] Specifically, the conversion from IPv4 to IPv6 addresses can be achieved using prefix concatenation. The concatenation formula is: IPv6 address = NAT64 prefix + IPv4 address (e.g., 64:ff9b:: + 192.168.1.100 = 64:ff9b::192.168.1.100). For the conversion from IPv6 to IPv4 addresses (e.g., the IPv6 URL carried in an IPv6 client request), the corresponding IPv4 address can be extracted using prefix stripping.

[0048] The target NAT64 prefix can be determined according to the preset IPv4 and IPv6 address mapping rules. The preset IPv4 and IPv6 address mapping rules are kept in real time synchronized with Jool's L3-L4 layer address mapping rules. The target NAT64 prefix (e.g., 64:ff9b:: / 96) is obtained by reading Jool's kernel-mode configuration (e.g., / proc / sys / net / ipv6 / conf / all / Jool), ensuring that the IPv6 address translated by the L7 layer is consistent with that of the L3-L4 layer.

[0049] Furthermore, the method provided in this application embodiment also supports adjusting the conversion strategy based on the application layer protocol type. For example, the URL conversion of the HTTP protocol needs to add square brackets [] to conform to the IPv6 URL standard, while the IP address field of the FTP protocol does not need to be added.

[0050] Based on the above embodiments, as an implementable approach, in one embodiment, determining the target data length and target verification information according to the application layer response data to be reconstructed includes: Step 2061: Determine the target data length based on the change in data length before and after address replacement in the application layer response data to be reconstructed; Step 2062: Based on the application layer response data to be reconstructed, recalculate the transport layer verification information and the application layer verification information to obtain the target verification information.

[0051] Specifically, a string replacement and length adaptation mechanism can be used to replace the resolved IPv4 address with the corresponding IPv6 address. At the same time, the total length of the application layer data packet is adjusted. For example, if the IPv4 address is 15 bytes and the IPv6 address is 39 bytes, an additional 24 bytes are needed. That is, the change in the data length before and after the address replacement in the application layer response data to be reconstructed is an increase of 24 bytes. Therefore, the target data length is determined to be 39 bytes, which is 24 bytes added to the 15 bytes.

[0052] Furthermore, in order to strictly adhere to application layer protocol specifications and ensure the legality of the reconstructed data packet format, the application layer response data to be reconstructed is re-verified. For example, the Content-Length field of the HTTP message is recalculated, and the TCP checksum is updated to obtain the target verification information and avoid communication errors caused by changes in data length.

[0053] Based on the above embodiments, as an implementable approach, in one embodiment, the method further includes: Step 301: Establish the mapping relationship between network layer-transport layer session identifiers and application layer protocol states; Step 302: In response to the change in session state represented by the network layer-transport layer session identifier, a corresponding session state change event is triggered; wherein, the session state change event is transmitted between kernel space and user space through the netlink protocol; Step 303: Determine the corresponding target application layer protocol state based on the session state change event, so as to synchronize and update the application layer protocol state.

[0054] The application layer protocol status includes protocol parsing progress and a list of converted address information.

[0055] It should be noted that the network layer Transport layer session identifiers are used to uniquely identify an L3 session. The identifier for an L4 layer communication session is generated by Jool based on the source IPv6 address, source port, destination IPv6 prefix, destination IPv4 address, and destination port. The application layer protocol state records a set of information about the context of a given application layer protocol interaction, including at least the protocol resolution progress and a list of translated addresses.

[0056] Specifically, during the initial stage of establishing a communication session between an IPv6 client and an IPv4 server through a NAT64 gateway, the session state synchronization service creates and maintains a mapping table. Jool then generates a unique network layer based on the source IPv6 address, source port, destination IPv6 prefix, destination IPv4 address, destination port, and transport layer protocol type. When identifying a transport layer session, the session state synchronization service simultaneously initializes an application layer protocol state object for this session. This object initially contains the protocol parsing progress, such as a list of addresses marked as not started and converted; the list is initially empty. Subsequently, a one-to-one binding relationship is established between the aforementioned session identifier and this state object in a mapping table, so that the corresponding L7 processing context can be quickly indexed through the session identifier later.

[0057] Furthermore, the NAT64 gateway continuously monitors L3. During the lifecycle of an L4 session, when the session state changes—for example, from the establishment of a TCP connection to its closure, or Jool dynamically updating the address mapping rules—the kernel-mode session state synchronization service captures this change and triggers a session state change event. This event includes the changed session identifier and the specific state change type, such as session creation, session closure, or mapping update. Subsequently, this event is encapsulated as a netlink message and efficiently sent from kernel mode to the user-mode L7 processing module (protocol parsing and address translation modules, etc.) via the socket interface provided by the netlink protocol. This achieves cross-mode asynchronous notification, enabling real-time and efficient transmission of L3 state changes perceived by the kernel. L4 session changes are notified to the L7 module in user space, avoiding polling overhead and ensuring timely state synchronization.

[0058] Furthermore, the method provided in this application embodiment is actually an extended function module of Jool. This extended function module is fully compatible with the original functions and configuration methods of Jool. Users do not need to modify the existing Jool deployment environment; they only need to load the extended module to enable the L7 layer translation function. It supports seamless integration with existing IPv4 services and IPv6 clients. Moreover, it adopts a plug-in design. The L7 layer protocol parsing submodule (application layer protocol parsing module) supports adding new protocol plugins, such as adding support for SMTP and DNS protocols. New plugins can be enabled through configuration files without modifying the core code. The address translation rule engine supports custom mapping rules (such as users can specify a dedicated NAT64 prefix) to adapt to different scenario requirements.

[0059] Furthermore, in one embodiment, exception handling operations can also be performed in the event of application layer protocol parsing failure or address translation failure.

[0060] The exception handling operations include returning preset error messages to IPv6 clients, and may also include temporarily enabling dual-stack compatibility mode to ensure communication stability.

[0061] Among them, the dual-stack compatibility mode is a temporary communication guarantee mode that allows the client to switch or fall back to the IPv4 protocol stack for communication in the event of IPv6 single-stack conversion failure, or to complete access by using the temporary IPv4 reachable path provided by the gateway, thereby achieving a smooth degradation of the protocol stack.

[0062] Specifically, the execution status of each functional module can be monitored in real time during the L7 layer protocol parsing or address translation process performed by the NAT64 gateway. When an application layer protocol parsing failure is detected, such as a corrupted data packet format, encountering an unsupported encryption algorithm that prevents field extraction, or an invalid address translation, such as the extracted IPv4 address not belonging to the configured NAT64 prefix range or a missing mapping rule, the exception handling module is triggered to intervene and perform exception handling operations.

[0063] For example, such as Figure 3The diagram shows a flowchart of an exemplary full-stack protocol conversion method provided in this application embodiment. For L3-L4 layer conversion (based on the original Jool function), it first receives an HTTP request sent by an IPv6 client (target address is 64:ff9b::192.168.1.100:80). Jool converts it into an IPv4 request (target address is 192.168.1.100:80) and forwards it to the IPv4 server. The IPv4 server returns an HTTP 302 response (server redirect response), with the Location field in the response header being http: / / 192.168.1.100:8080 / newpage (including the IPv4 address). Jool forwards the response data packet from the IPv4 server to the data packet splitting module (implementing data packet splitting service) newly added in this application embodiment. This module identifies the protocol type as HTTP and splits the data packet to the HTTP protocol parsing submodule (target application layer protocol parsing module). The HTTP protocol parsing submodule extracts the URL from the Location field and identifies the IPv4 address 192.168.1.100. The address translation rule engine, based on a preset mapping relationship, converts this IPv4 address to the IPv6 address 64:ff9b::192.168.1.100. The data reconstruction submodule (implementing data reconstruction business logic) modifies the URL in the Location field to http: / / [64:ff9b::192.168.1.100]:8080 / newpage (standard IPv6 URL format), reconstructs the HTTP response data packet, and obtains the target application layer response data. The reconstructed HTTP response data packet is then converted (IPv4→IPv6) by Jool's L3-L4 layer and sent back to the IPv6 client. The client recognizes the IPv6 URL and initiates subsequent access requests to continue accessing the redirected IPv4 server based on the IPv6 address in the target application layer response data, completing full-stack communication.

[0064] The full-stack protocol conversion method provided in this application embodiment can extract the IPv4 address carried in the application layer response data sent by the IPv4 server to the IPv6 client through application layer protocol parsing and convert it into an IPv6 address that the IPv6 client can recognize. At the same time, it adaptively corrects the data length and verification information of the application layer response data packet to obtain a legitimate target application layer response data. This ensures that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the obtained target application layer response data, avoiding interruption of the interaction process and thus ensuring the business continuity and user experience of the IPv6 client accessing IPv4 services.

[0065] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods according to the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method.

[0066] The embodiments of this application also provide a full-stack protocol conversion apparatus for executing the full-stack protocol conversion method provided in the above embodiments.

[0067] like Figure 4 The diagram shown is a structural schematic of a full-stack protocol conversion device provided in an embodiment of this application. The full-stack protocol conversion device 40 includes: an acquisition module 401, a splitting module 402, an address extraction module 403, an address conversion module 404, an address replacement module 405, a determination module 406, a reconstruction module 407, and a sending module 408.

[0068] The system comprises the following modules: an acquisition module for acquiring application layer response data returned by an IPv4 server in response to a service access request sent by an IPv6 client; a diversion module for diverting the application layer response data to the corresponding target application layer protocol parsing module; an address extraction module for parsing the application layer response data through the target application layer protocol parsing module to extract the IPv4 address carried in the application layer response data; an address translation module for converting the IPv4 address to the corresponding IPv6 address according to a preset IPv4 to IPv6 address mapping rule; an address replacement module for replacing the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed; a determination module for determining the target data length and target verification information based on the application layer response data to be reconstructed; a reconstruction module for reconstructing the application layer response data based on the target data length and target verification information to obtain the target application layer response data; and a sending module for sending the target application layer response data to the IPv6 client so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

[0069] Specifically, in one embodiment, the traffic splitting module is specifically used for: Determine the application layer protocol type corresponding to the application layer response data based on the input port of the application layer response data; Based on the application layer protocol type corresponding to the application layer response data, the corresponding routing callback function is invoked; Based on the routing callback function, the application layer response data is routed to the corresponding target application layer protocol parsing module.

[0070] Specifically, in one embodiment, the address extraction module is specifically used for: Based on the protocol parsing rules corresponding to the target application layer protocol parsing module, the application layer response data is parsed to determine the target field carrying address information from the application layer response data; Address identification is performed on the target field to determine the IPv4 address within it.

[0071] Specifically, in one embodiment, the address translation module is specifically used for: The target NAT64 prefix is ​​determined based on the preset IPv4 and IPv6 address mapping rules; The NAT64 prefix is ​​concatenated with the IPv4 address to convert the IPv4 address to the corresponding IPv6 address.

[0072] Specifically, in one embodiment, the determining module is specifically used for: The target data length is determined based on the change in data length before and after address replacement, as represented by the application layer response data to be reconstructed. Based on the application layer response data to be reconstructed, the transport layer verification information and application layer verification information are recalculated to obtain the target verification information.

[0073] Specifically, in one embodiment, the device further includes: The state synchronization module is used to establish the mapping relationship between the network layer-transport layer session identifier and the application layer protocol state; in response to the session state change represented by the network layer-transport layer session identifier, it triggers the corresponding session state change event; wherein, the session state change event is transmitted between kernel space and user space through the netlink protocol; based on the session state change event, the corresponding target application layer protocol state is determined so as to synchronize and update the application layer protocol state.

[0074] The application layer protocol status includes protocol parsing progress and a list of converted address information.

[0075] Specifically, in one embodiment, the device further includes: The exception handling module is used to perform exception handling operations in the event of application layer protocol parsing failure or address translation failure.

[0076] The exception handling operation includes returning a preset error message to the IPv6 client.

[0077] For a description of the features in the embodiment corresponding to the full-stack protocol conversion device, please refer to the relevant description of the embodiment corresponding to the full-stack protocol conversion method, which will not be repeated here.

[0078] Embodiments of this application also provide an electronic device, such as... Figure 5The diagram shown is a schematic diagram of the structure of an electronic device provided in an embodiment of this application, including a processor 10 and a memory 20. The memory 20 stores a computer program, and the processor 10 is configured to run the computer program to execute the steps in any of the above-described full-stack protocol conversion method embodiments.

[0079] Embodiments of this application also provide a computer-readable storage medium storing a computer program, wherein the computer program is configured to execute the steps in any of the above-described full-stack protocol conversion method embodiments at runtime.

[0080] In one exemplary embodiment, the aforementioned computer-readable storage medium may include, but is not limited to, various media capable of storing computer programs, such as a USB flash drive, read-only memory (ROM), random access memory (RAM), portable hard disk, magnetic disk, or optical disk.

[0081] Embodiments of this application also provide a computer program product, which includes a computer program that, when executed by a processor, implements the steps in any of the above-described full-stack protocol conversion method embodiments.

[0082] Embodiments of this application also provide another computer program product, including a non-volatile computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps in any of the above-described full-stack protocol conversion method embodiments.

[0083] Any of the components, modules, units, parts, methods, and operations described herein can be implemented using software, firmware, hardware (e.g., fixed logic circuitry), manual processing, or any combination thereof. Alternatively or additionally, any functionality described herein can be executed at least in part by one or more hardware logic components, such as, but not limited to, a central processing unit (CPU), a field-programmable gate array (FPGA), an application-specific integrated circuit (ASIC), an application-specific standard product (ASSP), a system-on-a-chip (SoC), a complex programmable logic device (CPLD), a microprocessor (MCU), etc. The terms "system," "computing device," or "apparatus" as used herein encompass various means, devices, and machines for processing data, including, for example, one or more programmable processors, computers, SoCs, or combinations thereof. The apparatus may also include code that creates an execution environment for the computer program in question, such as code constituting processor firmware, a protocol stack, a database management system, an operating system, a cross-platform runtime environment, a virtual machine, or one or more combinations thereof. The aforementioned computer program (also known as a program, software, software application, app, script, or code) can be written in any form of programming language, including compiled or interpreted languages, declarative or procedural languages, and can be deployed in any form, including as a standalone program or as a module, component, subroutine, object, or other unit suitable for a computing environment.

[0084] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0085] The foregoing has provided a detailed description of the full-stack protocol conversion method, apparatus, electronic device, and storage medium provided in this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the embodiments above are only intended to aid in understanding the method and core ideas of this application. It should be noted that those skilled in the art can make various improvements and modifications to this application without departing from its principles, and these improvements and modifications also fall within the protection scope of the claims of this application.

Claims

1. A full-stack protocol conversion method, characterized in that, include: Obtain the application layer response data returned by the IPv4 server in response to the service access request sent by the IPv6 client; The application layer response data is then routed to the corresponding target application layer protocol parsing module. The target application layer protocol parsing module parses the application layer response data to extract the IPv4 address carried in the application layer response data. According to the preset IPv4 and IPv6 address mapping rules, the IPv4 address is converted into the corresponding IPv6 address; Replace the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed. Based on the application layer response data to be reconstructed, determine the target data length and target verification information; Based on the target data length and target verification information, the application layer response data to be reconstructed is reconstructed to obtain the target application layer response data; The target application layer response data is sent to the IPv6 client so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

2. The full-stack protocol conversion method according to claim 1, characterized in that, The step of routing the application layer response data to the corresponding target application layer protocol parsing module includes: The application layer protocol type corresponding to the application layer response data is determined based on the input port of the application layer response data. Based on the application layer protocol type corresponding to the application layer response data, the corresponding traffic routing callback function is invoked; Based on the aforementioned routing callback function, the application layer response data is routed to the corresponding target application layer protocol parsing module.

3. The full-stack protocol conversion method according to claim 1, characterized in that, The step of parsing the application layer response data through the target application layer protocol parsing module to extract the IPv4 address carried in the application layer response data includes: According to the protocol parsing rules corresponding to the target application layer protocol parsing module, the application layer response data is parsed to determine the target field carrying address information from the application layer response data; The target field is subjected to address identification to determine the IPv4 address in the target field.

4. The full-stack protocol conversion method according to claim 1, characterized in that, The step of converting the IPv4 address to the corresponding IPv6 address according to the preset IPv4 and IPv6 address mapping rules includes: The target NAT64 prefix is ​​determined according to the preset IPv4 and IPv6 address mapping rules; The NAT64 prefix is ​​concatenated with the IPv4 address to convert the IPv4 address into the corresponding IPv6 address.

5. The full-stack protocol conversion method according to claim 1, characterized in that, The step of determining the target data length and target verification information based on the application layer response data to be reconstructed includes: The target data length is determined based on the change in data length before and after address replacement, as represented by the application layer response data to be reconstructed. Based on the application layer response data to be reconstructed, the transport layer verification information and application layer verification information are recalculated to obtain the target verification information.

6. The full-stack protocol conversion method according to claim 1, characterized in that, The method further includes: Establish a mapping relationship between network layer-transport layer session identifiers and application layer protocol states; In response to a change in session state represented by a network layer-transport layer session identifier, a corresponding session state change event is triggered; wherein, the session state change event is transmitted between kernel space and user space via the netlink protocol; Based on the session state change event, determine the corresponding target application layer protocol state, and then synchronize and update the application layer protocol state. The application layer protocol status includes protocol parsing progress and a list of converted address information.

7. The full-stack protocol conversion method according to claim 1, characterized in that, The method further includes: In the event of application layer protocol parsing failure or address translation failure, perform exception handling operations; The exception handling operation includes returning a preset error message to the IPv6 client.

8. A full-stack protocol conversion device, characterized in that, include: The acquisition module is used to acquire application layer response data returned by the IPv4 server in response to the service access request sent by the IPv6 client; The diversion module is used to divert the application layer response data to the corresponding target application layer protocol parsing module. The address extraction module is used to parse the application layer response data through the target application layer protocol parsing module in order to extract the IPv4 address carried in the application layer response data. The address translation module is used to convert the IPv4 address into the corresponding IPv6 address according to the preset IPv4 and IPv6 address mapping rules; The address replacement module is used to replace the IPv4 address in the application layer response data with the corresponding IPv6 address to obtain the application layer response data to be reconstructed. The determination module is used to determine the target data length and target verification information based on the application layer response data to be reconstructed; The reconstruction module is used to reconstruct the application layer response data to be reconstructed based on the target data length and target verification information to obtain the target application layer response data. The sending module is used to send the target application layer response data to the IPv6 client, so that the IPv6 client can continue to access the redirected IPv4 server based on the IPv6 address in the target application layer response data.

9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the full-stack protocol conversion method as described in any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, wherein when the computer program is executed by a processor, it implements the steps of the full-stack protocol conversion method as described in any one of claims 1 to 7.