Local area network communication method and apparatus

CN117061479BActive Publication Date: 2026-10-13CHINA MOBILE COMM LTD RES INST +1
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210487502.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-06
Publication Date
2026-10-13
Estimated Expiration
2042-05-06

AI Technical Summary

Technical Problem

[0004]本发明实施例提供一种局域网通信方法及装置,用于解决现有的通过隧道技术实现局域网之间的通信时,数据包处理时延大,运算资源消耗多,且需要进行复杂的信令交互的问题

Benefits of technology

[0063]第八方面,本发明实施例提供了一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如上述第一方面或第二方面所述的局域网通信方法的步骤。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117061479B_ABST
    Figure CN117061479B_ABST
Patent Text Reader

Abstract

The application provides a kind of LAN communication method and device, it is related to communication technical field, this LAN communication method includes: the first subnet gateway of first subnet receives the first data packet sent by first subnet device, the source IP address and source port of first data packet are respectively the internal network IP address and port of first subnet device, destination IP address and destination port are respectively the internal network IP address and port of second subnet device;First subnet gateway according to NAT port mapping table will be internal network IP address and port of first subnet device and second subnet device in first data packet respectively mapped as corresponding public network IP address and port, form second data packet;First subnet gateway sends second data packet to destination gateway.The application can realize tunnel function by NAT port mapping rule and data packet non-encapsulation transmission mechanism, with the advantages of simple configuration, less bandwidth occupation, small data packet processing delay, less resource consumption etc..
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of communication technology, and in particular to a local area network communication method and apparatus. Background Technology

[0002] The essence of tunneling technology is to use one network layer protocol to transmit another network layer protocol. Its basic functions are encapsulation and encryption, mainly achieved through network tunneling. Tunneling technology is a key technology for building VPNs (virtual private networks). It is used to establish point-to-point virtual pathways in public IP networks, enabling secure communication between two nodes (between VPN gateways, or between a VPN gateway and a VPN remote user), allowing data packets to be transmitted within a dedicated tunnel on the public network.

[0003] Existing solutions for establishing connections between local networks at both ends via tunneling require packet encapsulation and decapsulation frame by frame. This operation introduces latency and consumes computing resources from network forwarding devices (routers or CPEs), impacting data forwarding performance. Furthermore, the two parties establishing the VPN tunnel need to negotiate link-related parameters based on relatively complex tunneling protocols. Summary of the Invention

[0004] This invention provides a local area network (LAN) communication method and apparatus to address the problems of large data packet processing latency, high computational resource consumption, and complex signaling interactions required when using existing tunneling technology to achieve communication between LANs.

[0005] To solve the above-mentioned technical problems, the present invention is implemented as follows:

[0006] In a first aspect, embodiments of the present invention provide a local area network (LAN) communication method, including:

[0007] The first subnet gateway of the first subnet receives the first data packet sent by the first subnet device of the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of the second subnet device, respectively. The second subnet device is the second subnet or the subnet device on the server side.

[0008] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports according to the NAT port mapping table, thus forming the second data packet;

[0009] The first subnet gateway sends the second data packet to the destination gateway, where the destination gateway is either the second subnet gateway of the second subnet or the server gateway.

[0010] Optionally, the NAT port mapping table includes at least one mapping rule, which includes: mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes: the first subnet, the second subnet, and / or the subnet device on the server side.

[0011] Optionally, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, to form the second data packet, which includes:

[0012] If the NAT port mapping table of the first subnet gateway contains a mapping rule corresponding to the first data packet, the first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports, respectively, according to the mapping rule corresponding to the first data packet, thus forming the second data packet.

[0013] Optionally, the method further includes:

[0014] The first subnet gateway stores the mapping rules, which are manually configured by the user or pre-configured by the server gateway through the control channel, that map the internal IP addresses and ports of the subnet devices to the corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

[0015] Optionally, the method further includes:

[0016] If the first subnet gateway determines, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the first subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the first subnet gateway, the first subnet gateway returns a configuration failure message to the server gateway.

[0017] Optionally, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, to form the second data packet, which includes:

[0018] If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port.

[0019] The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device;

[0020] The first subnet gateway sends the mapping request to the destination gateway;

[0021] The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0022] The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

[0023] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

[0024] Optionally, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, to form the second data packet, which includes:

[0025] If the mapping rule corresponding to the first data packet does not exist in the NAT port mapping table of the first subnet gateway, the first subnet gateway generates a mapping request based on the internal IP address and port of the first subnet device and the internal IP address and port of the second subnet device.

[0026] The first subnet gateway sends the mapping request to the network control center;

[0027] The first subnet gateway receives a mapping response sent by the network control center. The mapping response includes: the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port allocated by the network control center for the data stream where the first data packet is located, and the mapping rules for the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0028] The first subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table;

[0029] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

[0030] Secondly, embodiments of the present invention provide a local area network (LAN) communication method, including:

[0031] The second subnet gateway of the second subnet receives the second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0032] The second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, thus forming the first data packet;

[0033] The second subnet gateway sends the first data packet to the second subnet device.

[0034] Optionally, the NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side.

[0035] Optionally, the method further includes:

[0036] The second subnet gateway stores the mapping rules, which are manually configured by the user or pre-configured by the server gateway through the control channel, that map the internal IP addresses and ports of the subnet devices to the corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

[0037] Optionally, if the second subnet gateway determines, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the second subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the second subnet gateway, the second subnet gateway returns configuration failure information to the server gateway.

[0038] Optionally, the source gateway is the first subnet gateway, and the second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports according to the NAT port mapping table. Before forming the first data packet, the following steps are also included:

[0039] The second subnet gateway receives a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port; the internal IP address and port of the first subnet device; and the internal IP address and port of the second subnet device.

[0040] The second subnet gateway assigns mapping rules to the data flow, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0041] The second subnet gateway sends a mapping response to the first subnet gateway, the mapping response including: a mapping rule allocated by the second subnet gateway for the data flow, which includes mappings from the internal IP address and port of the second subnet device to the corresponding public IP address and port;

[0042] The second subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the second subnet gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

[0043] Optionally, the source gateway is the server gateway, and the second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports according to the NAT port mapping table. Before forming the first data packet, the following is also included:

[0044] The second subnet gateway receives a mapping response sent by the server gateway or network control center. The mapping response includes: a mapping allocated by the server gateway for the data flow, which includes the internal IP address and port of the first subnet device to the corresponding public IP address and port, and a mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0045] The second subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table.

[0046] Thirdly, embodiments of the present invention provide a gateway device, including:

[0047] The first receiving module is used to receive a first data packet sent by a first subnet device in the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a second subnet or a subnet device on the server side.

[0048] The mapping module is used to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to the corresponding public IP addresses and ports, respectively, according to the NAT port mapping table, to form the second data packet;

[0049] The first sending module is used to send the second data packet to the destination gateway, which is the second subnet gateway or the server gateway of the second subnet.

[0050] Fourthly, embodiments of the present invention provide a gateway device, comprising:

[0051] The first receiving module is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0052] The mapping module is used to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet;

[0053] The first sending module is used to send the first data packet to the second subnet device.

[0054] Fifthly, embodiments of the present invention provide a gateway device, including: a transceiver and a processor;

[0055] The transceiver is used to receive a first data packet sent by a first subnet device in a first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a subnet device of a second subnet or a server.

[0056] The processor is configured to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, according to the NAT port mapping table, to form the second data packet;

[0057] The transceiver is also used to receive and send the second data packet to a destination gateway, which is either the second subnet gateway or the server gateway of the second subnet.

[0058] In a sixth aspect, embodiments of the present invention provide a gateway device, including: a transceiver and a processor;

[0059] The transceiver is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device or the first subnet device on the server side, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device in the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0060] The processor is configured to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet;

[0061] The transceiver is also used to send the first data packet to the second subnet device.

[0062] In a seventh aspect, embodiments of the present invention provide a network device, including: a processor, a memory, and a program stored in the memory and executable on the processor, or, when the program is executed by the processor, it implements the steps of the local area network communication method as described in the first or second aspect above.

[0063] Eighthly, embodiments of the present invention provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the local area network communication method as described in the first or second aspect above.

[0064] In this embodiment of the invention, the existing tunnel function can be replaced by NAT port mapping rules and packet unencapsulated pass-through mechanism to realize communication between local area networks. This implementation method has the advantages of simple configuration (based on the development and extension of the existing NAT function, the NAT function itself is also simple to configure), low bandwidth consumption (no need for complex signaling interaction), low packet processing latency, and low resource consumption (no need to perform packet decapsulation operation). Attached Figure Description

[0065] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of preferred embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the invention. Furthermore, the same reference numerals denote the same parts throughout the drawings. In the drawings:

[0066] Figure 1 This is a schematic diagram of a 5G-integrated industrial internet communication network architecture.

[0067] Figure 2 This is a schematic diagram of the tunneling protocol structure;

[0068] Figure 3 This is one of the flowcharts illustrating a local area network communication method according to an embodiment of the present invention;

[0069] Figure 4 This is a network framework diagram of a local area network communication method according to an embodiment of the present invention;

[0070] Figure 5 This is a schematic diagram of a NAT port mapping table according to an embodiment of the present invention;

[0071] Figure 6 This is a schematic diagram illustrating packet forwarding using a NAT port mapping table according to an embodiment of the present invention;

[0072] Figure 7 A schematic diagram of the structure of the data packet sent by host a1;

[0073] Figure 8The data packet generated after gateway a looks up the NAT port mapping table and performs IP address and port mapping;

[0074] Figure 9 The data packet is generated after gateway b receives the data packet, looks up the NAT port mapping table, and performs IP address and port mapping.

[0075] Figure 10 A flowchart illustrating the process of allocating negotiation strategies for NAT mapping rules in the peer-to-peer mode according to an embodiment of the present invention;

[0076] Figure 11 This is a flowchart illustrating the process of allocating negotiation strategies for NAT mapping rules in a point-to-point master-slave mode triggered by a local subnet in an embodiment of the present invention.

[0077] Figure 12 This is a schematic diagram illustrating the process of allocating negotiation strategies for NAT mapping rules in a point-to-point master-slave mode triggered by the server in an embodiment of the present invention.

[0078] Figure 13 A flowchart illustrating the process of allocating negotiation strategies for NAT mapping rules uniformly coordinated by the network control center in this embodiment of the invention;

[0079] Figure 14 A second schematic flowchart of the local area network communication method according to an embodiment of the present invention;

[0080] Figure 15 A flowchart illustrating the local area network communication method according to an embodiment of the present invention (Part 3);

[0081] Figure 16 The fourth flowchart of the local area network communication method according to an embodiment of the present invention;

[0082] Figure 17 One of the structural schematic diagrams of the gateway device according to an embodiment of the present invention;

[0083] Figure 18 A second schematic diagram of the gateway device according to an embodiment of the present invention;

[0084] Figure 19 The third schematic diagram of the gateway device according to an embodiment of the present invention;

[0085] Figure 20 One of the structural schematic diagrams of the network device according to an embodiment of the present invention;

[0086] Figure 21 Fourth schematic diagram of the gateway device according to an embodiment of the present invention;

[0087] Figure 22 Fifth schematic diagram of the gateway device according to an embodiment of the present invention;

[0088] Figure 23 Sixth schematic diagram of the gateway device according to an embodiment of the present invention;

[0089] Figure 24 A second schematic diagram of the network device according to an embodiment of the present invention;

[0090] Figure 25 Seventh schematic diagram of the network device structure according to an embodiment of the present invention;

[0091] Figure 26 The third schematic diagram of the network device in this embodiment of the invention. Detailed Implementation

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

[0093] The relevant technical points involved in this invention will be briefly explained below.

[0094] (1) 5G combined with industrial internet communication network architecture

[0095] In some industrial scenarios, such as Figure 1 As shown, AR router 1 is connected to a 5G CPE (Customer Premise Equipment) and accesses a 5G base station through the 5G CPE; AR router 2 is connected to the back-end switch of MEC (Edge Computing) and establishes a route between AR router 1 and AR router 2; the tunneling protocol commonly used between AR router 1 and AR router 2 is L2TP (Layer Two Tunneling Protocol), so that AR router 1 to AR router 2 presents a Layer 2 network to the outside world.

[0096] L2TP is a link-layer tunneling protocol that uses UDP (User Datagram Protocol) on port 1701 over TCP (Transmission Control Protocol) or IP (Internet Protocol). Once a tunnel is established, several independent sessions can be established within the channel. L2TP messages are divided into two categories: control messages and data messages. Control messages are responsible for establishing, tearing down, and maintaining the channel and sessions, while data messages are responsible for transmitting PPP (Point-to-Point Protocol) data.

[0097] (2) Introduction to Tunnel Technology

[0098] The essence of tunneling technology is to use one network layer protocol to transmit another network layer protocol. Its basic functions are encapsulation and encryption, mainly achieved through network tunneling. Tunneling technology is a key technology for building VPNs (virtual private networks). It is used to establish point-to-point virtual pathways in public IP networks, enabling secure communication between two nodes (between VPN gateways, or between a VPN gateway and a VPN remote user), allowing data packets to be transmitted within a dedicated tunnel on the public network.

[0099] Encapsulation is a fundamental technique for constructing tunnels. From the perspective of both ends of a tunnel, encapsulation is used to create, maintain, and destroy a tunnel to achieve information concealment and abstraction.

[0100] Network tunneling technology involves three network protocols: the network tunneling protocol, the bearer protocol under the tunneling protocol, and the protocol carried by the tunneling protocol. For example... Figure 2 As shown, the tunneling protocol, as the underlying layer of the VPN IP layer, encapsulates and packages VPN IP packets. Simultaneously, as a special form of public IP network, the tunneling protocol transmits the encapsulated VPN packets using the public network's IP protocol stack to achieve the functions within the tunnel. The tunneling protocol plays a crucial role in this protocol suite, bridging the gap between the layers.

[0101] (3) NAT

[0102] In computer networks, NAT (Network Address Translation), also known as network masking or IP masquerading, is a technique that rewrites the source or destination IP address of IP packets as they pass through routers or firewalls. This technique is commonly used in private networks where multiple hosts access the Internet through a single public IP address.

[0103] In a typical configuration, a local network uses a designated subnet of a private network (e.g., 192.168.xx or 10.xxx) and a router connected to this network. This router occupies a private address in the network's address space (e.g., 192.168.0.1) and also connects to the Internet via public IP addresses provided by one or more Internet Service Providers. When information is transmitted from the local network to the Internet, the source IP address is translated from the private address to a public address. The router tracks basic data on each connection, primarily the destination IP address and port. When a reply returns to the router, it uses the connection tracking data recorded in the output phase to determine which host on the intranet to forward the packet to; if multiple public addresses are available, the port number of the TCP or UDP client can be used to break down the packet when it returns.

[0104] There are three types of NAT: Static NAT, Pooled NAT, and Network Address Port Translation (NAPT). NAPT maps internal addresses to different ports of a single IP address on the external network. It can hide small to medium-sized networks behind a legitimate IP address. Unlike Pooled NAT, NAPT maps internal connections to a single IP address on the external network, while adding a port number selected by the NAT device to that address.

[0105] NAPT is the most commonly used conversion method, and it includes two conversion methods: SNAT and DNAT.

[0106] (1) SourceNAT (SNAT): Modifies the source address of a data packet. SourceNAT changes the source address of the first data packet. It is always completed before the data packet is sent to the network. Packet masquerading is an example of SNAT.

[0107] (2) Destination NAT (DNAT): Modifies the destination address of a data packet. Destination NAT is the opposite of SNAT; it changes the destination address of the first data packet. Load balancing, port forwarding, and transparent proxy are examples of DNAT.

[0108] Existing NAT technology only supports multiple internal network devices under a NAT proxy to access a public network server by sharing a single public IP address. The public network server cannot directly access the internal network devices under the NAT proxy. Therefore, existing NAT technology cannot achieve end-to-end tunnel bidirectional communication between two local subnets (or between a local subnet and a public network server).

[0109] The local area network communication method and apparatus provided in this application will be described in detail below with reference to the accompanying drawings and through some embodiments and application scenarios.

[0110] Please refer to Figure 3 This invention provides a local area network communication method, including:

[0111] Step 1: The first subnet gateway of the first subnet receives the first data packet sent by the first subnet device of the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively. The destination IP address and destination port are the internal network IP address and port of the second subnet device, respectively. The second subnet device is the second subnet or a subnet device on the server side.

[0112] In this embodiment of the application, a subnet can also be referred to as a local area network (LAN) or a local network. A public network can also be referred to as an external network or a WAN.

[0113] Step 2: The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports according to the NAT port mapping table, thus forming the second data packet;

[0114] In this embodiment of the invention, the internal network IP address and port can also be referred to as the local IP address and port. The public network IP address and port can also be referred to as the public network IP address and port.

[0115] Step 3: The first subnet gateway sends the second data packet to the destination gateway, where the destination gateway is the second subnet gateway or the server gateway of the second subnet.

[0116] In this embodiment of the invention, the existing tunnel function can be replaced by NAT port mapping rules and packet unencapsulated pass-through mechanism to realize communication between local area networks. This implementation method has the advantages of simple configuration (based on the development and extension of the existing NAT function, the NAT function itself is also simple to configure), low bandwidth consumption (no need for complex signaling interaction), low packet processing latency (reducing the latency introduced by traditional VPN tunnels), and low resource consumption (no need to perform packet decapsulation operation).

[0117] In this embodiment of the invention, optionally, the NAT port mapping table includes at least one mapping rule. The mapping rule includes mapping the internal IP address and port of a subnet device to its corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the server-side subnet device. Through the above NAT port mapping table, the internal IP addresses and ports of the first subnet, the second subnet, and / or the server-side subnet devices can be mapped to their corresponding public IP addresses and ports, enabling data packet transmission over the public network.

[0118] In this embodiment of the invention, optionally, the first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to corresponding public IP addresses and ports according to the NAT port mapping table, forming a second data packet. This includes: if the NAT port mapping table of the first subnet gateway contains a mapping rule corresponding to the first data packet, the first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to corresponding public IP addresses and ports according to the mapping rule corresponding to the first data packet, forming a second data packet. In this embodiment of the invention, through the above-mentioned NAT port mapping table, the internal IP addresses and ports of the first subnet, the second subnet, and / or the first subnet device and the second subnet device on the server side can be mapped to corresponding public IP addresses and ports, realizing the transmission of data packets on the public network. At the same time, there is no need to perform encapsulation and decapsulation operations on data packets. The transmission of data packets between local area networks can be realized by using a data packet unencapsulated transparent transmission mechanism, which has the advantages of low data packet processing latency (reducing the latency introduced by traditional VPN tunnels) and low resource consumption (no need to perform data packet decapsulation operations).

[0119] The following example illustrates the local area network communication method of this invention.

[0120] Please refer to Figure 4 Gateway a is connected to local network A, which belongs to the 192.168.1.0 / 24 network segment. Gateway a's public (or external network, or WAN) IP address is 30.31.20.69, and it is connected to gateway b via a public IP network. Gateway b's public IP address is 30.31.20.71, and its connected local network B belongs to the 192.168.2.0 / 24 network segment.

[0121] Gateway a and gateway b maintain their respective NAT port mapping tables, and the NAT port mapping tables at both ends can be synchronized in real time through NAT proxy interaction control connection transmission signaling.

[0122] In this embodiment of the invention, the NAT port mapping tables maintained at both ends bind the source and destination mapping rules to the same mapping rule. Please refer to [reference needed]. Figure 5 Each mapping rule has a number and includes: a mapping from the source IP address and port to the corresponding public IP address and port, and a mapping from the destination IP address and port to the corresponding public IP address and port. Of course, in some other embodiments of the present invention, a mapping rule may only include the mapping from the internal IP address and port of a subnet device to the corresponding public IP address and port. In this case, it is necessary to look up the public IP address and port corresponding to the source IP address and port and the destination IP address and port separately.

[0123] In this embodiment of the invention, optionally, the NAT port mapping table may also include the transport protocol used, such as TCP or UDP. Furthermore, optionally, the NAT port mapping table may also include the time-to-live (TTL) of the mapping rules, i.e., how long the mapping rules are valid.

[0124] Please refer to Figures 6-9 In this embodiment of the invention, the communication process between host a1 (subnet device) of local network A and host b1 (subnet device) of local network B across an external IP network is as follows:

[0125] When subnet device a1 needs to establish a transmission connection with subnet device b1 through a public IP network (UDP / TCP, and the public IP network does not have routes between the two subnets), subnet device a1 uses the internal IP address and port of subnet device b1 as the destination IP address and port of the data packet, and its own internal IP address and port as the source IP address and port of the data packet. When the data packet arrives at subnet gateway a, subnet gateway a uses the NAT port mapping table to map the source IP address and port (subnet device a1) and the destination IP address and port (subnet device b1) to the corresponding public IP address and port (the public IP address and port belong to the WAN (Wide Area Network) ports of both gateways). When the data packet arrives at subnet gateway B, subnet gateway B uses the same mapping rules to map the public source IP address and port and the public destination IP address and port to local addresses (a1's internal IP address and port are the source IP address and port, and b1's internal IP address and port are the destination IP address and port). The subnet B gateway then sends the mapped data packet as a local data packet to the subnet device b1.

[0126] In this embodiment of the invention, in order to achieve synchronization of NAT port mapping rules between the sending and receiving gateways, the allocation and negotiation of NAT port mapping rules can be carried out in various ways, which will be described in detail below.

[0127] Example 1: NAT Mapping Rule Allocation Negotiation Strategy in Peer-to-Peer Mode

[0128] The NAT mapping rule allocation negotiation strategy in peer-to-peer mode has two sub-modes: manual configuration mode on both ends and dynamic configuration mode triggered by data flow.

[0129] In the dual-end manual configuration mode, the NAT port mapping tables of the gateways at both ends can be manually configured (the parameters that need to be configured are: the mapping of the internal IP address and port of the first subnet device in the first subnet to the public IP address and port, and the mapping of the internal IP address and port of the second subnet device in the second subnet to the public IP address and port; in some cases, the transport layer protocol also needs to be configured) to achieve the interconnection of specific data flows between the first and second subnets.

[0130] At this point, the method further includes: the first subnet gateway storing the mapping rules manually configured by the user, which include mappings from the internal IP addresses and ports of subnet devices to their corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: subnet devices of the first subnet and the second subnet. Manual configuration is convenient, simple, and low-cost, and can fully meet user needs.

[0131] In the dynamic configuration mode triggered by data flow, the gateways of both subnets share their local NAT port mapping rules with the peer in real time (achieving real-time synchronization of the NAT port mapping tables of the two gateways). For example, when subnet device a1 of local subnet A initiates a new service communication request to subnet device b1 of peer subnet B, the data packet (including the IP data flow five-tuple information used for data flow authentication: source IP address, destination IP address; source port, destination port; transport layer protocol) is forwarded to the gateway of subnet A through the local forwarding function. If the NAT port mapping table does not include the mapping rules for the data flow containing this data packet, the gateway of subnet A first allocates a new public IP address and port mapping for the source IP address and port of this new data flow, and then sends this mapping information and mapping request to the gateway of peer subnet B. The gateway of subnet B receives the mapping request, allocates a public IP address and port mapping for the destination IP address and port of this data flow on the gateway side of subnet B, and finally returns the mapping rules to the gateway of subnet A. The gateway of subnet A then updates the mapping rules to its local NAT port mapping table. At this point, a new data flow mapping rule is established at both ends, and the subnet devices at both ends can achieve direct communication similar to a VPN tunnel environment by using their respective internal network IP addresses and ports.

[0132] That is, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes:

[0133] If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port.

[0134] The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device;

[0135] The first subnet gateway sends the mapping request to the destination gateway;

[0136] The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0137] The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

[0138] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

[0139] The first subnet gateway assigns internal IP addresses and corresponding public IP addresses and ports to its own subnet devices, which can greatly reduce the chance of assignment failure.

[0140] Please refer to Figure 10 The following example illustrates the process information for a dynamic configuration mode triggered by a data stream: (Communication between the gateway of subnet A and the gateway of subnet B is carried through a control channel connection on a specific port).

[0141] Step 1: Device a1 in local subnet A prepares an IP packet (the source IP address and port are local values ​​of device a1, and the destination IP address and port are local values ​​of device b1 in local subnet B) and forwards it to the gateway of local subnet A.

[0142] Step 2a: If the NAT port mapping table contains a mapping rule for this IP packet, then the subnet A gateway directly performs a four-tuple information translation on the IP packet (the source IP and source port are mapped to the corresponding public IP address and port, and the destination IP and destination port are mapped to the corresponding public IP address and port).

[0143] Step 3a: Subnet A gateway forwards the converted data packet to subnet B gateway;

[0144] Step 4a: Subnet B gateway performs four-tuple information translation on the converted data packets according to the NAT port mapping table (source IP and source port are mapped to the internal IP address and port of device a1, and destination IP and destination port are mapped to the internal IP address and port of device b1).

[0145] Step 5a: Subnet B gateway sends the converted data packet to subnet device b1;

[0146] Step 2b: If the NAT port mapping table of subnet A gateway does not contain a mapping rule corresponding to this IP packet, the port mapping rule request process will be triggered. Subnet A gateway will assign a mapping from its internal network address IP and port to the public network IP address and port for this new data flow.

[0147] Step 3b: Subnet A gateway puts the assigned mapping rule and the five-tuple information of the data packet into the NewRuleDemade message, and assigns a unique sequence ID to this message (to distinguish different mapping requests; the message ID pool is used repeatedly in cycles), and sends it to subnet B gateway through the control channel;

[0148] Step 4b: Subnet B gateway reads the NewRuleDemand message and compares the IP address of the requested subnet device b1 in the message with the IP address of the locally registered device;

[0149] Step 5c: If the requested local subnet device b1 does not exist, the subnet B gateway returns the corresponding NewRuleDemandFailed message (its sequence ID is the same as the corresponding NewRuleDemand), notifying the subnet gateway A that the mapping request failed and the mapping negotiation request was interrupted;

[0150] Step 5b: If the requested local subnet device b1 exists, the subnet B gateway assigns a mapping from the IP address and port of its local subnet device b1 to the public IP address and port for the new data stream;

[0151] Step 6b: Subnet B gateway stores the newly generated complete mapping rules into the NAT port mapping table, and at the same time prepares a NewRuleDemandSucceed message (whose sequence ID is the same as the corresponding NewRuleDemand) (which contains the mapping rules on the subnet B gateway side and the mapping rules on the subnet A gateway side) and sends it to subnet A gateway.

[0152] Step 7b: After receiving the NewRuleDemandSucceed message, the gateway of subnet A stores the mapping rules of the two gateways contained therein into the NAT port mapping table. At this point, the link between LAN subnet device a1 and LAN subnet device b1 based on NAT port mapping is successfully established, and communication begins.

[0153] In the above embodiments, both the sending and receiving ends share their respective NAT port mapping rules with the peer in real time. The two devices synchronize the network port mapping information of their local subnets with the peer through a specific negotiation mechanism and corresponding special control signaling. After the two ends synchronize the NAT port mapping rules in real time, in order for the downstream sub-devices of the two subnets to achieve VPN-like tunnel communication, the subnet gateway needs to perform NAT mapping on both the source and destination addresses of the data stream.

[0154] Example 2: NAT Mapping Rule Allocation Negotiation Strategy in Point-to-Multipoint Master-Slave Mode

[0155] The NAT mapping rule allocation negotiation strategy for point (server gateway) to multi-point (subnet gateway) master-slave mode has three sub-modes: dual-end manual configuration mode, server-side pre-configuration mode, and data flow triggered dynamic configuration mode.

[0156] In the dual-end manual configuration mode, the NAT port mapping tables of the server-side gateway and subnet gateway can be manually configured (the parameters that need to be configured are: mapping of the internal IP address and port of the subnet device to the public IP address and port, mapping of the internal IP address and port of the server-side subnet device to the public IP address and port, and the transport layer protocol), so that specific data flows between the server and the subnet can be interconnected.

[0157] At this time, the method further includes: the first subnet gateway stores the mapping rules manually configured by the user, which include the mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port, in the NAT port mapping table, wherein the subnet device includes: the subnet and the subnet device on the server side.

[0158] In server-side pre-configuration mode, NAT port mapping rules for the server and corresponding subnet gateways can be manually set on the server side for specific data flows (the rule parameters to be configured include: mapping of the internal IP address and port of the server's subnet device to the public IP address and port, mapping of the internal IP address and port of the subnet device to the public IP address and port, and the transport layer protocol). The server sends a mapping request (containing the NAT port mapping configuration parameters for the corresponding data flow at both ends) through the control channel to configure the NAT port mapping rules of the subnet gateway. If the corresponding port of the configured subnet gateway is already in use or the internal IP address and port of the data flow have been assigned to other public IP addresses and ports, the subnet gateway will return a mapping request failure message (containing the available port or the internal IP address and port of the data flow having been assigned to a public IP address and port) to notify the server that the gateway policy configuration has failed and needs to be reconfigured.

[0159] At this point, the method further includes: receiving pre-configured mapping rules, which include mappings from the internal IP addresses and ports of subnet devices to their corresponding public IP addresses and ports, sent by the server gateway through a control channel, and storing them in the NAT port mapping table. The subnet devices include both subnets and server-side subnet devices. Pre-configuring corresponding public IP addresses and ports for the internal IP addresses and ports of each subnet and its own subnet devices by the server gateway can reduce the operational load on the subnet gateway.

[0160] Optionally, after receiving the pre-configured mapping rules containing the mapping of the internal IP addresses and ports of the subnet devices to the corresponding public IP addresses and ports sent by the server gateway through the control channel, the method further includes: if the first subnet gateway determines, based on its own NAT port mapping table, that the internal IP addresses and ports of the subnet devices of the first subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the first subnet gateway, the first subnet gateway returns configuration failure information to the server gateway, thereby enabling the server gateway to reassign the corresponding public IP addresses and ports to the internal IP addresses and ports of the subnet devices of the subnet.

[0161] In the dynamic configuration mode triggered by data flow, the NAT port mapping rules of the data flow are updated synchronously in real time between the server and the subnet gateway (achieving real-time synchronization of the NAT port mapping tables of the two gateways). There are two triggering methods as follows: 1) and 2):

[0162] 1) When subnet device a1 in local subnet A initiates a new service communication request to subnet device b1 on the server side, the data packet is forwarded locally to the subnet A gateway. If the NAT port mapping table does not contain a mapping rule for this new data flow, the subnet A gateway first allocates a new public IP address and port mapping for this new data flow, and then sends this mapping information to the server gateway. The server gateway receives the mapping request, allocates a new public IP address and port mapping for the destination IP address and port of this data flow on the server gateway side, and finally returns this mapping rule to the subnet A gateway, which then updates the NAT port mapping table accordingly. Thus, a new data flow mapping rule is established at both ends, and the subnet devices at both ends can achieve direct communication similar to a VPN tunnel environment using their respective local IP addresses and port numbers.

[0163] That is, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes:

[0164] If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port.

[0165] The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device;

[0166] The first subnet gateway sends the mapping request to the destination gateway;

[0167] The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0168] The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

[0169] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

[0170] The first subnet gateway assigns internal IP addresses and corresponding public IP addresses and ports to its own subnet devices, which can greatly reduce the chance of assignment failure.

[0171] 2) When subnet device b1 on the server side initiates a new service communication request to subnet device a1 on local subnet A, the data packet is forwarded to the server gateway via the local forwarding function. If the NAT port mapping table does not contain a mapping rule for this new data flow, the server gateway allocates public IP addresses and port mappings for both ends (the server and the subnet A gateway) for this new data flow, and then sends this mapping to the subnet A gateway. If there is no conflict, the subnet A gateway updates the new mapping rule to the NAT port mapping table. If a port conflict occurs, the subnet gateway A will independently determine the local mapping rule for the corresponding data flow and update the mapping rule to the NAT port mapping table. Finally, the subnet gateway A returns the new mapping rule to the server gateway, and the server gateway updates the rule to the NAT port mapping table. Thus, a new data flow mapping rule is established at both ends, and the subnet devices at both ends can achieve direct communication similar to a VPN tunnel environment using their respective local IP addresses and port numbers.

[0172] Please refer to Figure 11 The following example illustrates the dynamic configuration mode process for data flow triggered by a new service in local subnet A. The specific process information is as follows: (Policy negotiation information between the subnet A gateway and the server gateway is carried through a control channel connection on a specific port).

[0173] Step 1: Device a1 in local subnet A prepares IP packets (the source IP address and port are local values ​​of device a1, and the destination IP address and port are local values ​​of device b1 on the server side) and forwards them to the gateway of local subnet A;

[0174] Step 2a: If the NAT port mapping table contains a mapping rule for this IP packet, then the subnet A gateway directly performs a four-tuple information translation on the IP packet (the source IP and source port are mapped to the corresponding public IP address and port, and the destination IP and destination port are mapped to the corresponding public IP address and port).

[0175] Step 3a: Subnet A gateway forwards the converted data packet to the server gateway;

[0176] Step 4a: The server gateway performs four-tuple information translation based on the NAT port mapping table (the source IP and source port are mapped to the internal IP address and port of device a1, and the destination IP and destination port are mapped to the internal IP address and port of device b1).

[0177] Step 5a: The server gateway sends the converted data packet to device b1;

[0178] Step 2b: If the NAT port mapping table of subnet A gateway does not contain a mapping rule corresponding to this IP packet, the port mapping rule request process will be triggered. Subnet A gateway will assign a mapping from its internal network address IP and port to the public network IP address and port for this new data flow.

[0179] Step 3b: Subnet A gateway puts the assigned mapping rule and the five-tuple information of the data packet into the NewRuleDemade message, assigns a unique sequence ID to this message (to distinguish different mapping requests, the message ID pool is reused cyclically), and sends it to the server gateway through the control channel;

[0180] Step 4b: The server gateway reads the NewRuleDemand message and compares the IP address of the requested subnet device b1 in the message with the IP address of the locally registered device;

[0181] Step 5c: If the requested subnet device b1 does not exist, the server gateway returns the corresponding NewRuleDemandFailed message (its sequence ID is the same as the corresponding NewRuleDemand), notifying the subnet gateway A that the mapping request failed and the mapping negotiation request was interrupted;

[0182] Step 5b: If the requested subnet device b1 exists, the server gateway assigns a mapping from the IP address and port of its local subnet device b1 to the public IP address and port for the new data stream;

[0183] Step 6b: The server gateway stores the newly generated complete port mapping rules into the port mapping table, and at the same time prepares a NewRuleDemandSucceed message (whose sequence ID is the same as the corresponding NewRuleDemand) (which contains the mapping rules on the server gateway side and the mapping rules on the subnet A gateway side) and sends it to the subnet A gateway.

[0184] Step 7b: After receiving the NewRuleDemandSucceed message, the gateway of subnet A stores the mapping rules of both gateways contained therein into the port mapping table. At this point, the link between LAN subnet device a1 and server device b1 based on NAP port mapping conversion is successfully established, and communication begins.

[0185] Please refer to Figure 12The following example illustrates the dynamic configuration mode process triggered by a new service on the server-side gateway. The specific process information is as follows: (Policy negotiation information between subnet A gateway and server gateway is carried through a control channel connection on a specific port.)

[0186] Step 1: On the server side, device b1 prepares IP packets (the source IP address and port are local values ​​of device b1, and the destination IP address and port are local values ​​of device a1 in subnet A), and forwards them to the server gateway first.

[0187] Step 2a: If the NAT port mapping table contains a mapping rule for this IP packet, the server gateway will directly perform a four-tuple information translation on the IP packet (the source IP and source port are mapped to the corresponding public IP address and port, and the destination IP and destination port are mapped to the corresponding public IP address and port).

[0188] Step 3a: The server gateway forwards the converted data packet to the subnet A gateway;

[0189] Step 4a: Subnet A gateway performs four-tuple information translation based on the NAT port mapping table (source IP and source port are mapped to the internal IP address and port of device a1, and destination IP and destination port are mapped to the internal IP address and port of device b1);

[0190] Step 5a: Subnet A gateway sends the converted data packet to subnet device a1;

[0191] Step 2b: If the server gateway's NAT port mapping table does not contain a mapping rule corresponding to this IP packet, a port mapping rule request process will be triggered. The server gateway will allocate mappings from the local source IP address and port at both ends (server end and subnet A end) to the public IP address and port for this new data flow.

[0192] Step 3b: The server gateway puts the assigned mapping rule and the five-tuple information of the data packet into the NewRuleDemade message, assigns a unique sequence ID to this message (to distinguish different mapping requests, the message ID pool is reused cyclically), and sends it to the subnet A gateway through the control channel;

[0193] Step 4b: Subnet gateway A reads the NewRuleDemand message and compares the IP address of the requested subnet device a1 in the message with the IP address of the locally registered device;

[0194] Step 5c: If the requested local subnet device a1 does not exist, the subnet A gateway returns the corresponding NewRuleRequestFailed message (its sequence ID is the same as the corresponding NewRuleRequest), notifying the server gateway that the mapping request failed and the mapping negotiation request was interrupted;

[0195] Step 5b: If the requested local subnet device a1 exists, the subnet A gateway stores the mapping rules of the two gateways contained in NewRuleRequest into the NAT port mapping table.

[0196] Step 6b: Subnet A gateway returns a successful ACK confirmation to the server gateway. At this point, the link between LAN subnet device a1 and the server based on NAT port mapping is successfully established, and communication begins.

[0197] By having the server gateway assign corresponding public IP addresses and ports to the internal IP addresses and ports of each subnet and its own subnet devices, the operating pressure on the subnet gateway can be reduced.

[0198] Example 3: NAT mapping rule negotiation strategy coordinated by the control center

[0199] In this embodiment of the invention, a network control center can be established to manage and distribute port mapping rules for all gateway devices in the network. When subnet device a1 of subnet A initiates a new service communication request to subnet device b1 of subnet B, if the data flow mapping rule is not in the NAT port mapping table, the subnet A gateway initiates a mapping request to the network control center. The network control center allocates mapping ports for both ends of this new data flow and distributes them to the subnet A gateway and the subnet B gateway. After the subnet A gateway and the subnet B gateway receive and update their respective NAT port mapping tables, they return ACK confirmation information to the network control center. Thus, a new data flow mapping rule is established at both ends, and the subnet devices at both ends can achieve direct communication similar to a VPN tunnel environment using their respective local IP addresses and port numbers.

[0200] That is, the first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes:

[0201] If the mapping rule corresponding to the first data packet does not exist in the NAT port mapping table of the first subnet gateway, the first subnet gateway generates a mapping request based on the internal IP address and port of the first subnet device and the internal IP address and port of the second subnet device.

[0202] The first subnet gateway sends the mapping request to the network control center;

[0203] The first subnet gateway receives a mapping response sent by the network control center. The mapping response includes: the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port allocated by the network control center for the data stream where the first data packet is located, and the mapping rules for the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0204] The first subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table;

[0205] The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

[0206] Assigning public IP addresses and ports to the subnet devices of each subnet in the network control center, based on their internal IP addresses and ports, can reduce the operational pressure on the subnet gateways.

[0207] Please refer to Figure 13 The following example illustrates the process of negotiating NAT mapping rules in a unified manner by the network control center. The specific process information is as follows:

[0208] Step 1: Device a1 in subnet A prepares an IP packet (the source IP address and port are local values ​​of device a1, and the destination IP address and port are local values ​​of device b1 in subnet B), and forwards it to the gateway of subnet A.

[0209] Step 2a: If the NAT port mapping table contains a mapping rule for this IP packet, then the subnet A gateway directly performs a four-tuple information translation on the IP packet (the source IP and source port are mapped to the corresponding public IP address and port, and the destination IP and destination port are mapped to the corresponding public IP address and port).

[0210] Step 3a: Subnet A gateway forwards the converted data packet to subnet B gateway;

[0211] Step 4a: Subnet B gateway performs four-tuple information translation based on the NAT port mapping table (source IP and source port are mapped to the internal IP address and port of device a1, and destination IP and destination port are mapped to the internal IP address and port of device b1).

[0212] Step 5a: Subnet B gateway sends the converted data packet to subnet device b1;

[0213] Step 2b: If the NAT port mapping table does not have a mapping rule corresponding to this IP packet, the port mapping rule request process will be triggered. The gateway of subnet A prepares a NewRuleDemade message (containing the source IP address and port (of device a1), the destination IP address and port (of device b1) and the transport layer communication protocol identifier) ​​and sends it to the network control center.

[0214] Step 3c: If the requested subnet device b1 of subnet B does not exist, the network control center returns the corresponding NewRuleDemandFailed message to notify the subnet A gateway that the mapping request has failed and the mapping negotiation request is interrupted.

[0215] Step 3b: If the requested subnet device b1 of subnet B exists, the network control center assigns a mapping of the local source IP address and port of subnet device a1 to the public IP address and port of gateway A, and a mapping of the local destination IP address and port of subnet device b1 to the public IP address and port of gateway B for the new data flow.

[0216] Step 4b: The network control center stores the new mapping rule in the database, then embeds the new mapping rule in the NewRuleUpdate message and sends it to the gateways of subnet A and subnet B at the same time;

[0217] Step 5b: Subnet A gateway and Subnet B gateway store the mapping rules in the NewRuleUpdate message into the NAT port mapping table and send an ACK confirmation message back to the network control center;

[0218] Step 6b: Subnet A gateway and subnet B gateway send ACK confirmation messages to the network control center. At this point, the link between LAN subnet device a1 and LAN subnet device b1 based on NAT port mapping is successfully established, and communication begins.

[0219] In the above embodiments, all state interaction information and mapping requests (such as NewRuleDemand, NewRuleDemandFailed, NewRuleDemandSucceed, NewRuleRequest, and NewRuleRequestFailed messages) involved in the real-time synchronization of the NAT port mapping tables of the two gateways need to establish an encrypted communication connection through technologies such as HTTPS (Hypertext Transfer Protocol) and be transmitted through this encrypted connection, which is called the NAT proxy interaction control connection.

[0220] Please refer to Figure 14 This invention also provides a local area network communication method, including:

[0221] Step 1: The second subnet gateway of the second subnet receives the second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0222] Step 2: The second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports according to the NAT port mapping table, thus forming the first data packet;

[0223] Step 3: The second subnet gateway sends the first data packet to the second subnet device.

[0224] In this embodiment of the invention, the existing tunnel function can be replaced by NAT port mapping rules and packet unencapsulated pass-through mechanism to realize communication between local area networks. This implementation method has the advantages of simple configuration (based on the development and extension of the existing NAT function, the NAT function itself is also simple to configure), low bandwidth consumption (no need for complex signaling interaction), low packet processing latency (reducing the latency introduced by traditional VPN tunnels), and low resource consumption (no need to perform packet decapsulation operation).

[0225] In this embodiment of the invention, optionally, the NAT port mapping table includes at least one mapping rule, the mapping rule including: the mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port, the subnet device including: the first subnet, the second subnet and / or the subnet device on the server side.

[0226] In this embodiment of the invention, optionally, the method further includes: storing the mapping rules manually configured by the user, which include mappings from the internal IP address and port of the subnet device to the corresponding public IP address and port, into the NAT port mapping table, wherein the subnet device includes: the first subnet, the second subnet, and / or the subnet device on the server side.

[0227] In this embodiment of the invention, optionally, the source gateway is the first subnet gateway, and the second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports according to the NAT port mapping table. Before forming the first data packet, the method further includes:

[0228] The second subnet gateway receives a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port; the internal IP address and port of the first subnet device; and the internal IP address and port of the second subnet device.

[0229] The second subnet gateway assigns mapping rules to the data flow, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0230] The second subnet gateway sends a mapping response to the first subnet gateway, the mapping response including: a mapping rule allocated by the second subnet gateway for the data flow, which includes mappings from the internal IP address and port of the second subnet device to the corresponding public IP address and port;

[0231] The second subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the second subnet gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

[0232] In this embodiment of the invention, optionally, the method further includes: the second subnet gateway receiving a mapping rule sent by the server gateway through a control channel, which includes mapping rules from the internal IP address and port of the subnet device to the corresponding public IP address and port, and storing it in the NAT port mapping table, wherein the subnet device includes: the first subnet, the second subnet, and / or the subnet device on the server side.

[0233] In this embodiment of the invention, optionally, after receiving the mapping rules containing the mapping from the internal IP address and port of the subnet device to the corresponding public IP address and port sent by the receiving server gateway through the control channel, the method further includes:

[0234] If the second subnet gateway determines, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the second subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the second subnet gateway, the second subnet gateway returns a configuration failure message to the server gateway.

[0235] In this embodiment of the invention, optionally, the source gateway is the server gateway, and the second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports according to the NAT port mapping table. Before forming the first data packet, the method further includes:

[0236] The second subnet gateway receives a mapping response sent by the server gateway or network control center. The mapping response includes: a mapping allocated by the server gateway for the data flow, which includes the internal IP address and port of the first subnet device to the corresponding public IP address and port, and a mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0237] The second subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table.

[0238] Please refer to Figure 15 This invention also provides a local area network communication method, including:

[0239] Step 1: The server gateway assigns mapping rules to the subnet devices of the subnet, which include mappings from the internal IP address and port of the subnet device to the corresponding public IP address and port;

[0240] Step 2: The server gateway sends the mapping rule to the subnet gateway of the subnet.

[0241] In some embodiments of the present invention, the server gateway may be a pre-configured mapping rule, which is then sent to the subnet gateway.

[0242] In some embodiments of the present invention, the server gateway may allocate mapping rules for the subnet according to the mapping request of the subnet gateway and send them to the subnet gateway.

[0243] In some embodiments of the present invention, the server gateway may allocate mapping rules to both the subnet and the server based on the mapping request of the subnet gateway, and send them to the subnet gateway.

[0244] Please refer to Figure 16 This invention also provides a local area network communication method, including:

[0245] Step 1: The network control center receives a mapping request sent by the device in the first subnet of the first subnet. The mapping request includes the internal network IP address and port of the device in the first subnet and the internal network IP address and port of the device in the second subnet of the second subnet.

[0246] Step 2: The network control center generates a mapping response based on the mapping request. The mapping response includes: the mapping of the internal IP address and port of the first subnet device allocated by the network control center to the corresponding public IP address and port, and the mapping rules for the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0247] Step 3: The network control center sends the mapping response to the first subnet gateway of the first subnet and the second subnet gateway of the second subnet.

[0248] Please refer to Figure 17 This invention also provides a gateway device 170, comprising:

[0249] The first receiving module 171 is used to receive a first data packet sent by a first subnet device in the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a second subnet or a subnet device on the server side.

[0250] The mapping module 172 is used to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to the corresponding public IP addresses and ports according to the NAT port mapping table, so as to form the second data packet;

[0251] The first sending module 173 is used to send the second data packet to the destination gateway, which is the second subnet gateway or the server gateway of the second subnet.

[0252] Optionally, the NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side.

[0253] Optionally, the mapping module 172 is used to map the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, forming a second data packet, if the NAT port mapping table of the first subnet gateway contains a mapping rule corresponding to the first data packet.

[0254] Optionally, the gateway device 170 further includes:

[0255] The storage module is used to store the mapping rules, which are manually configured by the user and include mappings from the internal IP addresses and ports of subnet devices to the corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

[0256] Optionally, the mapping module 172 is configured to: if the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, allocate a mapping rule containing the internal IP address and port of the first subnet device to the corresponding public IP address and port for the data stream containing the first data packet; generate a mapping request based on its allocated mapping rule, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device; send the mapping request to the destination gateway; and receive a mapping response sent by the destination gateway, the mapping response including: the mapping rule allocated by the destination gateway for the data stream containing the internal IP address and port of the second subnet device. The mapping rules for mapping addresses and ports to corresponding public IP addresses and ports are defined; the mapping rules allocated by the first subnet gateway to the data flow, which include mappings of the internal IP addresses and ports of the first subnet devices to corresponding public IP addresses and ports, and the mapping rules allocated by the destination gateway to the data flow, which include mappings of the internal IP addresses and ports of the second subnet devices to corresponding public IP addresses and ports, are stored in the NAT port mapping table; according to the mapping rules corresponding to the first data packet in the NAT port mapping table, the internal IP addresses and ports of the first subnet devices and the second subnet devices are mapped to their corresponding public IP addresses and ports, respectively, to form the second data packet.

[0257] Optionally, the gateway device 170 further includes:

[0258] The second receiving module is used to receive the pre-configured mapping rules, which include mappings from the internal IP addresses and ports of subnet devices to their corresponding public IP addresses and ports, sent by the server gateway through the control channel, and store them in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

[0259] Optionally, the gateway device 170 further includes:

[0260] The second sending module is used to determine, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the first subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the first subnet gateway, and the first subnet gateway returns configuration failure information to the server gateway.

[0261] Optionally, the mapping module 172 is configured to: generate a mapping request based on the internal IP address and port of the first subnet device and the internal IP address and port of the second subnet device if there is no mapping rule corresponding to the first data packet in the NAT port mapping table of the first subnet gateway; send the mapping request to the network control center; receive a mapping response sent by the network control center, the mapping response including: the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port allocated by the network control center for the data stream where the first data packet is located, and the mapping rule of the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port; store the mapping rule carried in the mapping response to the NAT port mapping table; and map the internal IP address and port of the first subnet device and the second subnet device to the corresponding public IP address and port according to the mapping rule corresponding to the first data packet in the NAT port mapping table, thereby forming the second data packet.

[0262] Please refer to Figure 18 This invention also provides a gateway device 180, comprising:

[0263] The first receiving module 181 is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0264] The mapping module 182 is used to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet;

[0265] The first sending module 183 is used to send the first data packet to the second subnet device.

[0266] Optionally, the NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side.

[0267] Optionally, the gateway device 180 further includes:

[0268] The first storage module stores the mapping rules, manually configured by the user, which map the internal IP addresses and ports of subnet devices to their corresponding public IP addresses and ports in the NAT port mapping table. The first subnet gateway returns a configuration failure message to the server gateway.

[0269] Optionally, the source gateway is the first subnet gateway, and the gateway device 180 further includes:

[0270] The second receiving module is used to receive a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal network IP address and port of the first subnet device to the corresponding public network IP address and port; the internal network IP address and port of the first subnet device; and the internal network IP address and port of the second subnet device.

[0271] The allocation module is used to allocate mapping rules to the data stream, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port;

[0272] The second sending module is used to send a mapping response to the first subnet gateway. The mapping response includes: a mapping rule allocated by the second subnet gateway for the data stream, which includes mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port.

[0273] The second storage module is used to store the mapping rules allocated by the first subnet gateway for the data flow, which include mappings from the internal IP addresses and ports of the first subnet device to their corresponding public IP addresses and ports, and the mapping rules allocated by the second subnet gateway for the data flow, which include mappings from the internal IP addresses and ports of the second subnet device to their corresponding public IP addresses and ports, into the NAT port mapping table.

[0274] Optionally, the gateway device 180 further includes:

[0275] The third receiving module is used to receive the mapping rules, which contain the mapping between the internal IP addresses and ports of the subnet devices and their corresponding public IP addresses and ports, sent by the server gateway through the control channel, and store them in the NAT port mapping table. The first subnet gateway returns a configuration failure message to the server gateway.

[0276] Optionally, the gateway device 180 further includes:

[0277] The third sending module is used to determine, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the second subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the second subnet gateway, and the second subnet gateway returns configuration failure information to the server gateway.

[0278] Optionally, the source gateway is the server gateway, and the gateway device 180 further includes:

[0279] The fourth receiving module is used to receive a mapping response sent by the server gateway or network control center. The mapping response includes: a mapping allocated by the server gateway for the data flow, which includes the internal network IP address and port of the first subnet device to the corresponding public network IP address and port, and a mapping of the internal network IP address and port of the second subnet device to the corresponding public network IP address and port.

[0280] The third storage module is used to store the mapping rules carried in the mapping response into the NAT port mapping table.

[0281] Please refer to Figure 19 This invention also provides a gateway device 190, comprising:

[0282] The allocation module 191 is used to allocate mapping rules to subnet devices of a subnet, which include mappings from the internal network IP address and port of the subnet device to the corresponding public network IP address and port;

[0283] The first sending module 192 is used to send the mapping rule to the subnet gateway of the subnet.

[0284] Please refer to Figure 20 This invention also provides a network device 200, comprising:

[0285] The first receiving module 201 is used to receive a mapping request sent by a first subnet device in a first subnet, wherein the mapping request includes the internal network IP address and port of the first subnet device and the internal network IP address and port of the second subnet device in a second subnet.

[0286] The allocation module 202 is used to generate a mapping response according to the mapping request. The mapping response includes: the mapping of the internal network IP address and port of the first subnet device allocated by the network control center to the corresponding public network IP address and port to the data flow, and the mapping rules for the mapping of the internal network IP address and port of the second subnet device to the corresponding public network IP address and port.

[0287] The first sending module 203 is used to send the mapping response to the first subnet gateway of the first subnet and the second subnet gateway of the second subnet.

[0288] Please refer to Figure 21 The present invention also provides a gateway device 210, a transceiver 211, and a processor 212;

[0289] The transceiver 211 is used to receive a first data packet sent by a first subnet device in a first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a second subnet or a subnet device on the server side.

[0290] The processor 212 is configured to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, according to the NAT port mapping table, to form the second data packet;

[0291] The transceiver 211 is also used to receive and send the second data packet to the destination gateway, which is the second subnet gateway or server gateway of the second subnet.

[0292] Please refer to Figure 22 The present invention also provides a gateway device 220, a transceiver 221, and a processor 222;

[0293] The transceiver 221 is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device or the first subnet device on the server side, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device in the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway.

[0294] The processor 222 is configured to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet;

[0295] The transceiver 221 is also used to send the first data packet to the second subnet device.

[0296] Please refer to Figure 23 The present invention also provides a gateway device 230, a transceiver 231, and a processor 232;

[0297] The processor 232 is used to assign mapping rules to subnet devices of a subnet, which include mappings from the internal IP address and port of the subnet device to the corresponding public IP address and port;

[0298] The transceiver 231 is used to send the mapping rules to the subnet gateway of the subnet.

[0299] Please refer to Figure 24 The present invention also provides a network device 240, a transceiver 241, and a processor 242;

[0300] The transceiver 241 is used to receive a mapping request sent by a device in the first subnet of the first subnet, the mapping request including the internal network IP address and port of the device in the first subnet and the internal network IP address and port of the device in the second subnet of the second subnet;

[0301] The processor 242 is configured to generate a mapping response according to the mapping request. The mapping response includes: the mapping of the internal IP address and port of the first subnet device allocated by the network control center to the corresponding public IP address and port to the data flow, and the mapping rules for the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port.

[0302] The transceiver 241 is also used to send the mapping response to the first subnet gateway of the first subnet and the second subnet gateway of the second subnet.

[0303] Please refer to Figure 25 The present invention also provides a gateway device 250, including a processor 251, a memory 252, and a computer program stored in the memory 252 and executable on the processor 251. When the computer program is executed by the processor 251, it implements the various processes of the above-described embodiments of the local area network communication method applied to the first subnet gateway, the second subnet gateway, or the server gateway, and can achieve the same technical effect. To avoid repetition, it will not be described again here.

[0304] Please refer to Figure 26 The present invention also provides a network device 260, including a processor 261, a memory 262, and a computer program stored in the memory 262 and executable on the processor 261. When the computer program is executed by the processor 261, it implements the various processes of the above-described embodiment of the local area network communication method applied to the network control center and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0305] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the above-described local area network communication method embodiments and achieves the same technical effects. To avoid repetition, it will not be described again here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, etc.

[0306] It should be noted that, in this document, 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. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0307] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of 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. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0308] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

Claims

1. A local area network (LAN) communication method, characterized in that, include: The first subnet gateway of the first subnet receives the first data packet sent by the first subnet device of the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of the second subnet device, respectively. The second subnet device is the second subnet or the subnet device on the server side. The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports according to the NAT port mapping table, thus forming the second data packet; The first subnet gateway sends the second data packet to the destination gateway, where the destination gateway is the second subnet gateway of the second subnet or the server gateway. The NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes: If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port. The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device; The first subnet gateway sends the mapping request to the destination gateway; The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table. The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

2. The method according to claim 1, characterized in that, The first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes: If the NAT port mapping table of the first subnet gateway contains a mapping rule corresponding to the first data packet, the first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports, respectively, according to the mapping rule corresponding to the first data packet, thus forming the second data packet.

3. The method according to claim 1, characterized in that, Also includes: The first subnet gateway stores the mapping rules, which are manually configured by the user or pre-configured by the server gateway through the control channel, that map the internal IP addresses and ports of the subnet devices to the corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

4. The method according to claim 3, characterized in that, Also includes: If the first subnet gateway determines, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the first subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the first subnet gateway, the first subnet gateway returns a configuration failure message to the server gateway.

5. The method according to claim 1, characterized in that, The first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes: If the mapping rule corresponding to the first data packet does not exist in the NAT port mapping table of the first subnet gateway, the first subnet gateway generates a mapping request based on the internal IP address and port of the first subnet device and the internal IP address and port of the second subnet device. The first subnet gateway sends the mapping request to the network control center; The first subnet gateway receives a mapping response sent by the network control center. The mapping response includes: the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port allocated by the network control center for the data stream where the first data packet is located, and the mapping rules for the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port. The first subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table; The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

6. A local area network communication method, characterized in that, include: The second subnet gateway of the second subnet receives the second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway. The second subnet gateway maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, thus forming the first data packet; The second subnet gateway sends the first data packet to the second subnet device; The NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The source gateway is the first subnet gateway. The second subnet gateway, according to the NAT port mapping table, maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively. Before forming the first data packet, the following is also included: The second subnet gateway receives a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port; the internal IP address and port of the first subnet device; and the internal IP address and port of the second subnet device. The second subnet gateway assigns mapping rules to the data flow, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The second subnet gateway sends a mapping response to the first subnet gateway, the mapping response including: a mapping rule allocated by the second subnet gateway for the data flow, which includes mappings from the internal IP address and port of the second subnet device to the corresponding public IP address and port; The second subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the second subnet gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

7. The method according to claim 6, characterized in that, Also includes: The second subnet gateway stores the mapping rules, which are manually configured by the user or pre-configured by the server gateway through the control channel, that map the internal IP addresses and ports of the subnet devices to the corresponding public IP addresses and ports, in the NAT port mapping table. The subnet devices include: the first subnet, the second subnet, and / or the subnet devices on the server side.

8. The method according to claim 7, characterized in that, Also includes: If the second subnet gateway determines, based on its own NAT port mapping table, that the internal IP address and port of the subnet device of the second subnet pre-configured by the server gateway have been assigned to other public IP addresses and ports by the second subnet gateway, the second subnet gateway returns a configuration failure message to the server gateway.

9. The method according to claim 6, characterized in that, The source gateway is the server gateway. The second subnet gateway, according to the NAT port mapping table, maps the public IP addresses and ports of the first and second subnet devices in the second data packet to their corresponding internal IP addresses and ports, respectively. Before forming the first data packet, the following is also included: The second subnet gateway receives a mapping response sent by the server gateway or network control center. The mapping response includes: a mapping allocated by the server gateway for the data flow, which includes the internal IP address and port of the first subnet device to the corresponding public IP address and port, and a mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port. The second subnet gateway stores the mapping rules carried in the mapping response into the NAT port mapping table.

10. A gateway device, characterized in that, include: The first receiving module is used to receive a first data packet sent by a first subnet device in the first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a second subnet or a subnet device on the server side. The mapping module is used to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to the corresponding public IP addresses and ports, respectively, according to the NAT port mapping table, to form the second data packet; The first sending module is used to send the second data packet to the destination gateway, wherein the destination gateway is the second subnet gateway of the second subnet or the server gateway. The NAT port mapping table includes at least one mapping rule, which includes the mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes: If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port. The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device; The first subnet gateway sends the mapping request to the destination gateway; The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table. The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

11. A gateway device, characterized in that, include: The first receiving module is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device of the first subnet or the server, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device of the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway. The mapping module is used to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet; wherein, the NAT port mapping table includes at least one mapping rule; The first sending module is used to send the first data packet to the second subnet device; The NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The source gateway is the first subnet gateway. The second subnet gateway, according to the NAT port mapping table, maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively. Before forming the first data packet, the following is also included: The second subnet gateway receives a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port; the internal IP address and port of the first subnet device; and the internal IP address and port of the second subnet device. The second subnet gateway assigns mapping rules to the data flow, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The second subnet gateway sends a mapping response to the first subnet gateway, the mapping response including: a mapping rule allocated by the second subnet gateway for the data flow, which includes mappings from the internal IP address and port of the second subnet device to the corresponding public IP address and port; The second subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the second subnet gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

12. A gateway device, characterized in that, include: Transceiver and processor; The transceiver is used to receive a first data packet sent by a first subnet device in a first subnet. The source IP address and source port of the first data packet are the internal network IP address and port of the first subnet device, respectively, and the destination IP address and destination port are the internal network IP address and port of a second subnet device, respectively. The second subnet device is a subnet device of a second subnet or a server. The processor is configured to map the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, according to the NAT port mapping table, to form the second data packet; The transceiver is also used to receive and send the second data packet to the destination gateway, which is the second subnet gateway or the server gateway of the second subnet. The NAT port mapping table includes at least one mapping rule, which includes the mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The first subnet gateway, based on the NAT port mapping table, maps the internal IP addresses and ports of the first subnet device and the second subnet device in the first data packet to their corresponding public IP addresses and ports, respectively, forming the second data packet, which includes: If the NAT port mapping table in the first subnet gateway does not contain a mapping rule corresponding to the first data packet, the first subnet gateway assigns a mapping rule to the data stream containing the internal IP address and port of the first subnet device to the corresponding public IP address and port. The first subnet gateway generates a mapping request based on its own assigned mapping rules, the internal IP address and port of the first subnet device, and the internal IP address and port of the second subnet device; The first subnet gateway sends the mapping request to the destination gateway; The first subnet gateway receives a mapping response sent by the destination gateway, the mapping response including: a mapping rule allocated by the destination gateway for the data flow, which includes the mapping from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The first subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the destination gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table. The first subnet gateway maps the internal IP addresses and ports of the first subnet device and the second subnet device to the corresponding public IP addresses and ports respectively, according to the mapping rules corresponding to the first data packet in the NAT port mapping table, thus forming the second data packet.

13. A gateway device, characterized in that, include: Transceiver and processor; The transceiver is used to receive a second data packet sent by the source gateway. The source IP address and source port of the second data packet are the public IP address and port of the first subnet device or the first subnet device on the server side, respectively. The destination IP address and destination port are the public IP address and port of the second subnet device in the second subnet, respectively. The source gateway is the first subnet gateway of the first subnet or the server gateway. The processor is configured to map the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively, according to the NAT port mapping table, to form the first data packet; The transceiver is also used to send the first data packet to the second subnet device; The NAT port mapping table includes at least one mapping rule, which includes mapping of the internal IP address and port of the subnet device to the corresponding public IP address and port. The subnet device includes the first subnet, the second subnet, and / or the subnet device on the server side. The source gateway is the first subnet gateway. The second subnet gateway, according to the NAT port mapping table, maps the public IP addresses and ports of the first subnet device and the second subnet device in the second data packet to their corresponding internal IP addresses and ports, respectively. Before forming the first data packet, the following is also included: The second subnet gateway receives a mapping request sent by the first subnet gateway. The mapping request includes: a mapping rule allocated by the first subnet gateway for the data flow, which includes the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port; the internal IP address and port of the first subnet device; and the internal IP address and port of the second subnet device. The second subnet gateway assigns mapping rules to the data flow, which include mappings from the internal network IP address and port of the second subnet device to the corresponding public network IP address and port; The second subnet gateway sends a mapping response to the first subnet gateway, the mapping response including: a mapping rule allocated by the second subnet gateway for the data flow, which includes mappings from the internal IP address and port of the second subnet device to the corresponding public IP address and port; The second subnet gateway stores the mapping rules allocated by the first subnet gateway for the data flow, which include the mapping of the internal IP address and port of the first subnet device to the corresponding public IP address and port, and the mapping rules allocated by the second subnet gateway for the data flow, which include the mapping of the internal IP address and port of the second subnet device to the corresponding public IP address and port, into the NAT port mapping table.

14. A gateway device, characterized in that, include: A processor, a memory, and a program stored in the memory and executable on the processor, or, when the program is executed by the processor, implementing the steps of the local area network communication method as described in any one of claims 1 to 5, or when the program is executed by the processor, implementing the steps of the local area network communication method as described in any one of claims 6 to 9.

15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the local area network communication method as described in any one of claims 1 to 5; or, when executed by a processor, the computer program implements the steps of the local area network communication method as described in any one of claims 6 to 9.

Citation Information

Patent Citations

  • Data communication method and device and electronic equipment

    CN113595891A