Communication method, device and equipment based on option list

By automatically performing DNAT in router devices using option lists, the problems of low communication efficiency and poor compatibility in the prior art are solved, and an efficient and compatible communication method is realized, which is suitable for a variety of electronic products.

CN118612310BActive Publication Date: 2024-12-03GUANGZHOU TOZED KANGWEI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411075328.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-07
Publication Date
2024-12-03
Estimated Expiration
2044-08-07

AI Technical Summary

Technical Problem

In the prior art, when external network devices communicate with intranet devices, DMZ or DNAT needs to be manually configured, resulting in low communication efficiency and inability to compatible with early protocols and devices, resulting in low compatibility.

Method used

The communication method based on the option list is adopted to automatically analyze the initial message data through the router device, and automatically use the pre-customized option list to perform automatic DNAT, avoid manual operations, and provide compatible extensions for incompatible early protocols and devices.

Benefits of technology

Improves communication efficiency and compatibility, avoids the complexity of manual configuration, and supports more types of electronic products, enhancing adaptability and applicability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118612310B_ABST
    Figure CN118612310B_ABST
Patent Text Reader

Abstract

The present application provides a communication method, apparatus and device based on an option list, which avoids complex manual operations by matching the initial message data with the option list twice in succession and automatically performing DNAT on the first option list match, thereby improving communication efficiency. If the compatibility is not met or the option list is not matched, the initial message data is matched with the option list for the second time to ensure that the message is normally transmitted to the downstream device of the 5G router device, thereby improving communication compatibility.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of network communication technology, and in particular to a communication method, device and equipment based on an option list. Background Art

[0002] When external network devices communicate with internal network devices, it is necessary to manually configure the DMZ (Demilitarized Zone) or DNAT (Destination Network Address Translation) or port on the router device to map the network address to an IP address of the internal network. When a new service port is added, the port mapping rule needs to be manually configured again, resulting in low communication efficiency. At the same time, the use of port mapping will cause external network devices to be unable to access the ports of the router device. The port mapping is enabled, which means that the network message will be transmitted to the downstream device for processing; and this method can usually serve TCP messages or UDP messages, but is not compatible with early protocols and early network devices. Summary of the invention

[0003] The purpose of this application is to address the deficiencies of the above-mentioned existing related technologies and propose a communication method, device and equipment based on an option list to improve communication efficiency and compatibility at the same time.

[0004] In a first aspect, the present application provides a communication method based on an option list, which is applied to a router device, and the communication method includes:

[0005] Receiving initial message data sent by an external network device, and parsing the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data;

[0006] Extracting a predefined first option list from the first message header, and if the first option list meets a preset condition, extracting a first forwarding destination address from the first option list; the preset condition includes: a compatible condition and a format condition; the format condition includes: conforming to a predefined type;

[0007] Otherwise, determining whether the protocol field of the first message header is a second message type, and if the protocol field is the second message type, parsing the first message data to obtain second parsed data; the second parsed data includes: a second message header;

[0008] extracting a predefined second option list from the second message header, and if the second option list meets the format condition, extracting a second forwarding destination address from the second option list;

[0009] The initial message data is forwarded to an internal network device according to the first forwarding destination address or the second forwarding destination address.

[0010] The present application adopts a method in which the router device automatically analyzes the initial message data, and first analyzes the first option list of the initial message data to automatically perform DNAT on the initial message data that supports the first option list, thereby avoiding complex manual operations and improving communication efficiency. In addition, this automatic DNAT will not modify the router device port, and will not cause a failure in accessing the router device. If the first option list is not compatible or there is no corresponding pre-defined type, the second option list is then analyzed in such a specific order to perform compatible extensions and automatic DNAT for incompatible early protocols and early network devices, thereby further improving communication compatibility while improving communication efficiency.

[0011] Further, extracting a predefined second option list from the second message header includes:

[0012] If the identification field of the second message header is a synchronization message during the first handshake, the second message header is parsed according to the custom hook function to obtain a pre-customized second option list; wherein the custom hook function is a hook function pre-registered with the highest priority on the pre-routing chain of the network address translation table.

[0013] Furthermore, the second option list has the same pre-defined format as the first option list, including: N options; N is an integer; wherein each option includes: the pre-defined type and the first forwarding destination address, or the pre-defined type and the second forwarding destination address.

[0014] Further, the receiving of initial message data sent by the external network device and parsing the initial message data to obtain first parsed data includes:

[0015] If the initial message data sent by the external network device is received, all the hook functions registered on the pre-routing chain are called one by one, and the initial message data is parsed to obtain the first message header and the first message data; all the hook functions include: the custom hook function.

[0016] Further, extracting a pre-defined first option list from the first message header includes:

[0017] According to the custom hook function, determine whether the destination address field of the first message header belongs to the destination address of the local device. If the destination address field belongs to the destination address, extract a pre-defined first option list from the first message header; wherein, if the destination address field does not belong to the destination address, end the processing of the custom hook function.

[0018] Further, forwarding the initial message data to an internal network device according to the second forwarding destination address includes:

[0019] Modify the second forwarding destination address to the destination address field, recalculate and update the first check code of the first message header, and recalculate and update the second check code of the second message header to obtain the message data to be sent, and forward the message data to be sent to the internal network device according to the destination address field.

[0020] Further, forwarding the initial message data to an internal network device according to the first forwarding destination address includes:

[0021] According to the hook function priority from high to low, the first forwarding destination address is recorded in the message auxiliary information of the initial message data by the custom hook function, and a custom address mark is added at the same time. According to the custom address mark, the first forwarding destination address is converted to obtain the first target address, and the initial message data is forwarded to the internal network device with the first target address.

[0022] Furthermore, all the hook functions further include: a default hook function of a low priority; performing address conversion on the first forwarding destination address according to the custom address tag to obtain the first target address includes:

[0023] The custom address tag is extracted from the message auxiliary information, and the target network conversion address corresponding to the custom address tag is matched on the pre-routing chain by the default hook function to perform target network address conversion to obtain a first target address.

[0024] In a second aspect, the present application provides a communication device based on an option list, which is applied to a router device, and the communication device includes: a first message parsing module, a first address extraction module, a second message parsing module, a second address extraction module and a message forwarding module; wherein

[0025] The first message parsing module is used to receive initial message data sent by an external network device, and parse the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data;

[0026] The first address extraction module is used to extract a predefined first option list from the first message header, and if the first option list meets a preset condition, extract a first forwarding destination address from the first option list; the preset condition includes: a compatible condition and a format condition; the format condition includes: conforming to a predefined type;

[0027] The second message parsing module is used to otherwise determine whether the protocol field of the first message header is a second message type, and if the protocol field is the second message type, parse the first message data to obtain second parsed data; the second parsed data includes: a second message header;

[0028] The second address extraction module is used to extract a predefined second option list from the second message header, and if the second option list meets the format condition, extract the second forwarding destination address from the second option list;

[0029] The message forwarding module is used to forward the initial message data to the internal network device according to the first forwarding destination address or the second forwarding destination address.

[0030] In a third aspect, the present application provides an electronic device, the electronic device comprising:

[0031] at least one processor; and,

[0032] a memory communicatively connected to the at least one processor; wherein,

[0033] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the communication method based on the option list as described in the first aspect or further described in the first aspect.

[0034] The present application integrates a communication method based on an option list into an electronic device, and can perform automatic DNAT between external network devices and internal network devices through any electronic device with a gateway function, thereby achieving efficient communication and improving the compatibility of communication devices. It can also be compatible with more different types of electronic products and has higher adaptability and applicability. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 It is a schematic diagram of the network topology of the external network equipment and the internal network equipment provided by this application;

[0036] Figure 2 It is a flowchart of a communication method based on an option list provided by the present application;

[0037] Figure 3 This is a schematic diagram I of capturing initial message data provided by the present application;

[0038] Figure 4 This is a schematic diagram II of capturing the initial message data provided by this application;

[0039] Figure 5 This is a schematic diagram of the analysis of initial message data provided by this application;

[0040] Figure 6 It is a flowchart of another communication method based on an option list provided by the present application;

[0041] Figure 7 It is a flowchart of another communication method based on an option list provided by the present application;

[0042] Figure 8 It is a flow chart of a communication method based on IP messages provided by the present application;

[0043] Fig. 9 It is a flow chart of a communication method based on TCP message provided by the present application;

[0044] Fig.10 It is a structural diagram of a communication device based on an option list provided by the present application. DETAILED DESCRIPTION

[0045] The following will be combined with the drawings in this application to clearly and completely describe the technical solutions in this application. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0046] It is worth noting that the existing related technologies require manual configuration of DMZ or DNAT or port mapping on the router device when conducting intranet and extranet communications, and mapping the destination communication address of the external network to the intranet IP address. However, it is necessary to manually configure the DMZ or DNAT or port mapping on the router device to an IP address of the intranet. When a new TCP service port is added to the intranet, it is necessary to add port mapping rules on the router device again. Moreover, if the router enables port mapping to the service port of the intranet, external network devices will be unable to access the port of the router device (port mapping is enabled, which means that the message will be transmitted to the downstream device for processing).

[0047] See also Figure 1, is a schematic diagram of the networking topology of the external network device and the internal network device provided by this application. The downstream devices A1-A3 and the downstream devices B1-B3 use the same LAN IP address through different 5G routing devices. When the external network device A wants to actively initiate a TCP or UDP connection to the service port of the downstream device A1-A3 or the downstream device B1-B3 of the router device, it cannot be directly realized. The existing related solution technology is to manually enable port mapping on the 5G router, map it to the service port of the downstream device, and the network device A sends a TCP or UDP message with the destination address being the IP address of the router device. The DMZ function of the router device is used to transfer the TCP or UDP message of the network device A to the downstream device, thereby completing the TCP or UDP communication of the network device A to the downstream device A. However, this method requires complex manual configuration, and if a new port is needed to provide services, it needs to be reconfigured. It relies heavily on complex manual operations, resulting in low network communication efficiency, and is incompatible with early protocols and early network devices, resulting in low compatibility.

[0048] Based on this, the present application avoids complicated manual operations by matching the option list twice on the initial message data and performing automatic DNAT on the first option list match. If the compatibility is not met or the option list is not matched, the initial message data is matched with the option list for the second time to ensure that the message is normally transmitted to the downstream device of the 5G router device.

[0049] In order to describe the communication method, apparatus and device based on the option list provided in the present application in more detail, the following embodiments will be described respectively.

[0050] Example 1

[0051] See also Figure 2 , is a flow chart of a communication method based on an option list provided by the present application, comprising: steps S11 to S115, specifically:

[0052] Step S11, receiving initial message data sent by an external network device, and parsing the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data.

[0053] It is worth noting that the initial message data may be an IP message. The first parsed data obtained by parsing the IP message may include: the message header and message data of the IP message, that is: the message header and message data after the IP message is parsed may correspond to the first message header and the first message data respectively.

[0054] In some embodiments, the IP message can add an IP message header to the UDP message or TCP message for encapsulation, that is, the first message data can be a UDP message or a TCP message; or, the IP message can also add an IP message header to the message of other transport layer protocols for encapsulation.

[0055] In some embodiments, receiving initial message data sent by an external network device, and parsing the initial message data to obtain first parsed data includes: if receiving initial message data sent by an external network device, calling all hook functions registered on the pre-routing chain one by one, and parsing the initial message data to obtain a first message header and first message data; all hook functions include: custom hook functions.

[0056] In some embodiments, before receiving the initial message data sent by the external network, the router device system is initialized, and a highest priority custom hook function is registered on the pre-routing chain of the data packet filtering framework of the network subsystem.

[0057] In some embodiments, the data packet filtering framework may be a netfilter framework, which is a general architecture of the Linux 2.4 kernel firewall and operates in the kernel space. The netfilter framework mainly includes hook functions with packet filtering functions.

[0058] It is worth noting that when receiving the initial message data sent by the external network device, all the hook functions registered on the pre-routing chain, including the custom hook functions, are called and run one by one.

[0059] Step S12: extracting a predefined first option list from the first message header. If the first option list meets preset conditions, extracting a first forwarding destination address from the first option list; the preset conditions include: compatible conditions and format conditions; the format conditions include: conforming to a predefined type.

[0060] In some embodiments, extracting a pre-defined first option list from a first message header includes: determining, according to a custom hook function, whether a destination address field in the first message header belongs to a destination address of a local device; if the destination address field belongs to the destination address, extracting the pre-defined first option list from the first message header; wherein, if the destination address field does not belong to the destination address, terminating the processing of the custom hook function.

[0061] In some embodiments, if the "destination IP address" field carried by the first message header of the initial message data (hereinafter referred to as: message A) is judged in the custom hook function, if it is an IP address belonging to the local system, a pre-customized first option list is extracted from the first message header.

[0062] In some embodiments, extracting a pre-defined first option list from a first message header includes: interpreting a first option list carried by the first message header according to a custom hook function, and if there is an option type that conforms to the pre-defined type, extracting a "forwarding destination address" corresponding to the pre-defined type from the option list as the first forwarding destination address.

[0063] It is worth noting that the first forwarding destination address is the forwarding destination address in the first option list in the first message header, which can be the forwarding destination IP address, and the second forwarding destination address is the forwarding destination address in the second option list in the second message header, which can also be the forwarding destination IP address.

[0064] In some embodiments, the second option list has the same pre-defined format as the first option list, including: N options; N is an integer; wherein each option includes: a pre-defined type and a first forwarding destination address, or a pre-defined type and a second forwarding destination address.

[0065] In some embodiments, the first option list may include: N options, each option including: a pre-defined type (type) and a first forwarding destination address (value).

[0066] In some embodiments, each option in the first option list may further include: option length (length), and the option length may include: the total length of the custom type, the option length, and the first forwarding destination address.

[0067] In some embodiments, the pre-defined type of each option in the first option list may be a type not defined by RFC-related standards, for example, the option type (1 byte) may have a value of 251.

[0068] In some embodiments, the option length of each option in the first option list may be 6 bytes.

[0069] In some embodiments, the first forwarding destination address of each option in the first option list may be (4 bytes) a 32-bit IPv4 address, where the IPv4 address is the "forwarding destination IP address".

[0070] In some embodiments, if N is 0, the external network device can maintain communication with the router device; if N is not 0, or the first option list does not meet the preset conditions, the external network device can communicate with the downstream device of the router device (i.e., the internal network device), and the situation of being unable to access the router device can also be avoided.

[0071] See also Figure 3, is a schematic diagram I of capturing the initial message data provided by the present application. Figure 3 In the figure, the initial packet data captured by the network packet capture tool Wireshark is used as an example. The value of the pre-defined type in the first option list of the first packet header is converted from hexadecimal to decimal to an IP packet of 251, the value of the option length is converted from hexadecimal to decimal to 6 bytes, and the value of the first forwarding destination address is converted from hexadecimal to decimal to 192.168.0.20.

[0072] Step S13: Otherwise, determine whether the protocol field of the first message header is the second message type. If the protocol field is the second message type, parse the first message data to obtain second parsed data; the second parsed data includes: a second message header.

[0073] In some embodiments, the second message type may be a TCP type pre-agreed for the second message data, or may be a UDP type, or a type of other protocols at the transport layer.

[0074] Step S14: extracting a predefined second option list from the second message header, and if the second option list meets the format condition, extracting a second forwarding destination address from the second option list.

[0075] In some embodiments, extracting a pre-defined second option list from a second message header includes: if the identification field of the second message header is a synchronization message during the first handshake, parsing the second message header according to a custom hook function to obtain a pre-defined second option list; wherein the custom hook function is a hook function pre-registered with the highest priority on the pre-routing chain of the network address translation table.

[0076] In some embodiments, the custom hook function determines the "protocol" field carried by the first message header in message A. If the "protocol" field is of TCP type, it further determines whether the "flag" field in the second message header is a synchronization message of the first handshake. If the "flag" field is a synchronization message of the first handshake, the second forwarding destination address is extracted from the second option list.

[0077] In some embodiments, the synchronization message may be a SYN (Synchronization) identifier. During the first handshake, the SYN identifier takes a value of 1.

[0078] In some embodiments, if the protocol field is not the second message type, or the flag field is not a synchronous message, the processing of the custom hook function is terminated.

[0079] In some embodiments, if the second option list does not meet the format condition, the processing of the custom hook function is terminated.

[0080] In some embodiments, the second list of options is in the same pre-customized format as the first list of options.

[0081] In some embodiments, the second option list may include: N options, each option including: a pre-defined type and a second forwarding destination address.

[0082] In some embodiments, if N is 0, the external network device can maintain communication with the router device; if N is not 0, or the second option list does not meet the format condition, the external network device can communicate with the downstream device of the router device (i.e., the internal network device), and the situation of being unable to access the router device can also be avoided.

[0083] In some embodiments, each option in the second option list may further include: option length, and the option length may include: a user-defined type, an option length, and a total length of the second forwarding destination address.

[0084] In some embodiments, the option length of each option in the second option list may be 6 bytes.

[0085] In some embodiments, the first forwarding destination address of each option in the second option list may be (4 bytes) a 32-bit IPv4 address, wherein the IPv4 address is the “forwarding destination IP address”.

[0086] In some embodiments, the pre-defined type of each option in the second option list may be a type not defined by RFC-related standards, for example, a kind type (1 byte) having a value of 250.

[0087] See also Figure 4 , is a schematic diagram II of capturing the initial message data provided by the present application, and an example is given by capturing the initial message data through the network packet capture tool wireshark. The corresponding kind type is 250, and the second forwarding destination address converted from hexadecimal to decimal is also 192.168.0.20.

[0088] In some embodiments, if the custom hook function parses the second option list carried in the second message header, if the type of one of the options conforms to the custom type, the "forwarding destination IP address" in the corresponding option is extracted as the second forwarding destination address.

[0089] Step S15: forwarding the initial message data to the internal network device according to the first forwarding destination address or the second forwarding destination address.

[0090] In some embodiments, the initial message data is forwarded to an internal network device according to a second forwarding destination address, including: modifying the second forwarding destination address to the destination address field, recalculating and updating the first check code of the first message header, and recalculating and updating the second check code of the second message header to obtain the message data to be sent, and forwarding the message data to be sent to the internal network device according to the destination address field.

[0091] In some embodiments, the custom hook function modifies the "forwarding destination IP address" obtained by the user to the "destination IP address" field of the first message header of message A, and recalculates the IP header check code and updates the "check code" field, and further calculates and updates the TCP header check code to obtain the message data to be sent.

[0092] It is worth noting that the second message header check code depends on the source address and destination IP address of the first message header. Therefore, when the destination IP address of the first message header changes, the second message header check code needs to be recalculated.

[0093] In some embodiments, the initial message data is forwarded to the internal network device according to the first forwarding destination address, including: recording the first forwarding destination address into the message auxiliary information of the initial message data with a custom hook function according to the hook function priority from high to low, and marking it with a custom address mark; according to the custom address mark, performing address conversion on the first forwarding destination address to obtain the first target address, and forwarding the initial message data to the internal network device with the first target address.

[0094] In some embodiments, all hook functions also include: a default hook function with a low priority.

[0095] In some embodiments, the default hook function may be a default hook function set according to an iptables command. The iptables command may be used to configure firewall rules, implement filtering and management of network traffic, and protect servers from network attacks. Users may configure iptables rules through command line operations, or may simplify the configuration process through graphical tools such as firewalld. By setting different rules, users may implement operations such as forwarding, discarding, or rejecting data packets, thereby effectively protecting server security. iptables may also detect, modify, forward, redirect, and discard IPv4 data packets. The code for filtering IPv4 data packets is already built into the kernel and is organized into a collection of tables for different purposes.

[0096] In some embodiments, according to the custom address tag, the first forwarding destination address is converted to obtain the first target address, including: extracting the custom address tag from the message auxiliary information, and matching the target network conversion address corresponding to the custom address tag on the pre-routing chain with the default hook function to perform target network address conversion to obtain the first target address.

[0097] In some embodiments, the custom hook function records the "forwarding destination IP address" obtained in the "auxiliary information of the message" of network message A (maintained by the structure sk_buff in the Linux kernel, usually called skb, used to save network messages and auxiliary information, etc.), and at the same time adds a custom address mark value equal to the preset value to the "auxiliary information of the message".

[0098] Exemplarily, the custom address mark is mark, and the value is 123456.

[0099] In some embodiments, since the custom hook function has a higher priority than the iptables processing, after the custom hook function marks the value of the custom address tag, the system executes the kernel module corresponding to the low-priority iptables to perform processing rules, that is, DNAT conversion is performed according to the default hook function. The DNAT module will extract the "forwarding destination IP address" through the "auxiliary information of the message" to perform destination address conversion.

[0100] It is worth noting that the custom hook function has a high priority when it is registered to the system, that is, the priority of the custom hook function is higher than the priority of the corresponding kernel module of iptables. The system executes according to the priority, so the custom hook function is executed first after marking the value of the custom address mark, and then the default hook function of the corresponding kernel module of iptables is executed (iptables also registers a hook to the kernel).

[0101] In some embodiments, see Figure 5 , is a schematic diagram of the analysis of initial message data provided by this application. Figure 5 After the initial message data is parsed, a first message header is obtained, and after the first message header is parsed, it includes: other data and a first option list, and the other data in the first message header includes: a destination IP address and a first check code of the first message header, etc. Similarly, after the first message data is parsed, a second message header and second message data are obtained, and the second message header includes: other data and a second option list, and the other data in the second message header includes: a destination IP address and a second check code of the second message header, etc.

[0102] In some embodiments, see Figure 6, is a flowchart of another communication method based on an option list provided by the present application, in Figure 6 In the process, either only the first option list in the first message header is extracted for the destination address, and then the message is forwarded after DNAT, or only the second option list in the second message header is extracted for the destination address, and then the message is forwarded after DNAT; wherein, when step S23, step S27 and step S28 enter step S26, at this time, the operation of the custom function is terminated, and the external network device can communicate (IP) with the router device; if step S25 or S29 enters step S26, at this time, the operation of the custom function is still terminated, and the message is forwarded to the internal network device for communication. In some embodiments, see Figure 7 , is a flowchart of another communication method based on an option list provided by the present application, in Figure 7 In the example, the destination address can be extracted from both option lists at the same time, but only the last address is used as the destination address, and then the message is forwarded after DNAT.

[0103] In some embodiments, see Figure 8 and Fig. 9 , is a flow chart of a communication method based on IP packets provided by the present application and is a flow chart of a communication method based on TCP packets provided by the present application, in Figure 8 In the example, you can extract only the destination address from the second option list and then forward the message after DNAT, or Fig. 9 In the example, only the destination address of the second option list is extracted, and then the message is forwarded after DNAT.

[0104] In some embodiments, if the network topology is relatively simple and there are few or no intermediate network devices that support processing of the extension header, the Figure 8 The communication method can be used to implement DNAT, which can further improve the communication efficiency based on avoiding complex manual operations.

[0105] In some embodiments, if there are early network devices or very old network devices in the network topology, these network devices may be designed and developed to be incompatible with the extension header of the option list in the first message header (although the IP protocol specification allows the option field to be carried). When the initial message data is routed and forwarded by these early or old network devices, it may be abnormally discarded. Therefore, the second option list should also be used to ensure that the message is normally transmitted to the downstream device of the 5G router device. In this case, Figure 6 , 7 Or 9's communication method, compatible with early or old network equipment to improve communication compatibility.

[0106] Example 2

[0107] See also Fig.10 , is a structural diagram of a communication device based on an option list provided in the present application, comprising: a first message parsing module 31, a first address extraction module 32, a second message parsing module 33, a second address extraction module 34 and a message forwarding module 35.

[0108] The first message parsing module 31 is used to receive initial message data sent by an external network device, and parse the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data.

[0109] In some embodiments, receiving initial message data sent by an external network device, and parsing the initial message data to obtain first parsed data includes: if receiving initial message data sent by an external network device, calling all hook functions registered on the pre-routing chain one by one, and parsing the initial message data to obtain a first message header and first message data; all hook functions include: custom hook functions.

[0110] The first address extraction module 32 is used to extract a pre-defined first option list from the first message header, and if the first option list meets the preset conditions, the first forwarding destination address is extracted from the first option list; the preset conditions include: compatible conditions and format conditions; the format conditions include: conforming to the pre-defined type.

[0111] In some embodiments, extracting a pre-defined first option list from a first message header includes: determining, according to a custom hook function, whether a destination address field in the first message header belongs to a destination address of a local device; if the destination address field belongs to the destination address, extracting the pre-defined first option list from the first message header; wherein, if the destination address field does not belong to the destination address, terminating the processing of the custom hook function.

[0112] The second message parsing module 33 is used to determine whether the protocol field of the first message header is the second message type. If the protocol field is the second message type, the first message data is parsed to obtain second parsed data; the second parsed data includes: the second message header.

[0113] The second address extraction module 34 is used to extract a predefined second option list from the second message header, and if the second option list meets the format condition, extract the second forwarding destination address from the second option list.

[0114] In some embodiments, extracting a pre-defined second option list from a second message header includes: if the identification field of the second message header is a synchronization message during the first handshake, parsing the second message header according to a custom hook function to obtain a pre-defined second option list; wherein the custom hook function is a hook function pre-registered with the highest priority on the pre-routing chain of the network address translation table.

[0115] In some embodiments, the second option list has the same pre-defined format as the first option list, including: N options; N is an integer; wherein each option includes: a pre-defined type and a first forwarding destination address, or a pre-defined type and a second forwarding destination address.

[0116] The message forwarding module 35 is used to forward the initial message data to the internal network device according to the first forwarding destination address or the second forwarding destination address.

[0117] In some embodiments, the initial message data is forwarded to an internal network device according to a second forwarding destination address, including: modifying the second forwarding destination address to the destination address field, recalculating and updating the first check code of the first message header, and recalculating and updating the second check code of the second message header to obtain the message data to be sent, and forwarding the message data to be sent to the internal network device according to the destination address field.

[0118] In some embodiments, the initial message data is forwarded to the internal network device according to the first forwarding destination address, including: recording the first forwarding destination address into the message auxiliary information of the initial message data with a custom hook function according to the hook function priority from high to low, and marking it with a custom address mark; according to the custom address mark, performing address conversion on the first forwarding destination address to obtain the first target address, and forwarding the initial message data to the internal network device with the first target address.

[0119] In some embodiments, all hook functions also include: a default hook function with a low priority.

[0120] In some embodiments, according to the custom address tag, the first forwarding destination address is converted to obtain the first target address, including: extracting the custom address tag from the message auxiliary information, and matching the target network conversion address corresponding to the custom address tag on the pre-routing chain with the default hook function to perform target network address conversion to obtain the first target address.

[0121] The present application adopts a method in which the router device automatically analyzes the initial message data, and first analyzes the first option list of the initial message data to automatically perform DNAT on the initial message data that supports the first option list, thereby avoiding complex manual operations and improving communication efficiency. In addition, this automatic DNAT will not modify the router device port, and will not cause a failure in accessing the router device. If the first option list is not compatible or there is no corresponding pre-defined type, the second option list is then analyzed in such a specific order to perform compatible extensions and automatic DNAT for incompatible early protocols and early network devices, thereby further improving communication compatibility while improving communication efficiency.

[0122] Example 3

[0123] An electronic device provided in an embodiment of the present application includes: at least one processor; and a memory connected to the at least one processor in communication; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the communication method based on the option list as described in Example 1.

[0124] The present application integrates a communication method based on an option list into an electronic device, and can perform automatic DNAT between external network devices and internal network devices through any electronic device with a gateway function, thereby achieving efficient communication and improving the compatibility of communication devices. It can also be compatible with more different types of electronic products and has higher adaptability and applicability.

[0125] Those skilled in the art will appreciate that the embodiments of the present application may also provide computer program products. Therefore, the present application may adopt the form of complete hardware embodiments, complete software embodiments, or embodiments in combination with software and hardware. Moreover, the present application may adopt the form of computer program products implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable program codes.

[0126] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus), and computer program products according to the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1A device that provides the functions specified in a block or multiple blocks.

[0127] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0128] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0129] The above is only a preferred implementation of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.

Claims

1. A communication method based on an option list, applied to a router device, characterized in that: The communication method comprises: Receiving initial message data sent by an external network device, and parsing the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data; Extracting a predefined first option list from the first message header, and if the first option list meets a preset condition, extracting a first forwarding destination address from the first option list; the preset condition includes: a compatible condition and a format condition; the format condition includes: conforming to a predefined type; Otherwise, determining whether the protocol field of the first message header is a second message type, and if the protocol field is the second message type, parsing the first message data to obtain second parsed data; the second parsed data includes: a second message header; extracting a predefined second option list from the second message header, and if the second option list meets the format condition, extracting a second forwarding destination address from the second option list; The initial message data is forwarded to an internal network device according to the first forwarding destination address or the second forwarding destination address.

2. The communication method based on the option list according to claim 1, characterized in that: The extracting a predefined second option list from the second message header includes: If the identification field of the second message header is a synchronization message during the first handshake, the second message header is parsed according to the custom hook function to obtain a pre-customized second option list; wherein the custom hook function is a hook function pre-registered with the highest priority on the pre-routing chain of the network address translation table.

3. The communication method based on the option list according to claim 2, characterized in that: The second option list has the same predefined format as the first option list, including: N options; N is an integer; wherein each option includes: the predefined type and the first forwarding destination address, or the predefined type and the second forwarding destination address.

4. The communication method based on the option list according to claim 2, characterized in that: The receiving of initial message data sent by the external network device and parsing the initial message data to obtain first parsed data includes: If the initial message data sent by the external network device is received, all the hook functions registered on the pre-routing chain are called one by one, and the initial message data is parsed to obtain the first message header and the first message data; all the hook functions include: the custom hook function.

5. The communication method based on the option list according to claim 4, characterized in that: The step of extracting a predefined first option list from the first message header includes: According to the custom hook function, determine whether the destination address field of the first message header belongs to the destination address of the local device. If the destination address field belongs to the destination address, extract a pre-defined first option list from the first message header; wherein, if the destination address field does not belong to the destination address, end the processing of the custom hook function.

6. The communication method based on the option list according to claim 5, characterized in that: Forwarding the initial message data to an internal network device according to the second forwarding destination address includes: Modify the second forwarding destination address to the destination address field, recalculate and update the first check code of the first message header, and recalculate and update the second check code of the second message header to obtain the message data to be sent, and forward the message data to be sent to the internal network device according to the destination address field.

7. The communication method based on the option list according to claim 4, characterized in that: Forwarding the initial message data to an internal network device according to the first forwarding destination address includes: According to the hook function priority from high to low, the first forwarding destination address is recorded in the message auxiliary information of the initial message data by the custom hook function, and a custom address mark is added at the same time. According to the custom address mark, the first forwarding destination address is converted to obtain the first target address, and the initial message data is forwarded to the internal network device with the first target address.

8. The communication method based on the option list according to claim 7, characterized in that: All the hook functions also include: a default hook function with a low priority; performing address conversion on the first forwarding destination address according to the custom address tag to obtain the first target address, including: The custom address tag is extracted from the message auxiliary information, and the target network conversion address corresponding to the custom address tag is matched on the pre-routing chain by the default hook function to perform target network address conversion to obtain a first target address.

9. A communication device based on an option list, applied to a router device, characterized in that: The communication device comprises: a first message parsing module, a first address extraction module, a second message parsing module, a second address extraction module and a message forwarding module; wherein The first message parsing module is used to receive initial message data sent by an external network device, and parse the initial message data to obtain first parsed data; the first parsed data includes: a first message header and first message data; The first address extraction module is used to extract a predefined first option list from the first message header, and if the first option list meets a preset condition, extract a first forwarding destination address from the first option list; the preset condition includes: a compatible condition and a format condition; the format condition includes: conforming to a predefined type; The second message parsing module is used to otherwise determine whether the protocol field of the first message header is a second message type, and if the protocol field is the second message type, parse the first message data to obtain second parsed data; the second parsed data includes: a second message header; The second address extraction module is used to extract a predefined second option list from the second message header, and if the second option list meets the format condition, extract the second forwarding destination address from the second option list; The message forwarding module is used to forward the initial message data to the internal network device according to the first forwarding destination address or the second forwarding destination address.

10. An electronic device, characterized in that: The electronic device comprises: at least one processor; and, a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the communication method based on the option list according to any one of claims 1 to 8.