Method, apparatus, device and medium for providing services for terminals in a local network
By assigning a unique port number to each home broadband account on the cloud gateway device and using the protocol stack of the virtual network port device to parse network layer packets, the problem of the cloud gateway device being unable to distinguish terminals within the local area network is solved, enabling the ability to provide personalized services for different home broadband accounts.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN GREENET INFORMATION SERVICE
- Filing Date
- 2022-12-30
- Publication Date
- 2026-06-26
AI Technical Summary
Cloud gateway devices cannot distinguish between terminals in different local area networks because they cannot obtain VLAN and VXLAN identification numbers after parsing packets, which makes it impossible to provide personalized services for terminals with the same private network IP address.
By pre-assigning a unique port number to each home broadband account and using a virtual network port device and a physical network port receiver driven by DPDK for data transmission, a virtual network port device is created. The protocol stack of the virtual network port device parses network layer packets and their upper-layer packet data to provide services to terminals within the local area network.
This enables cloud gateway devices to distinguish between terminals with different home broadband accounts, providing personalized services and avoiding service confusion caused by the same private network IP address.
Smart Images

Figure CN116389555B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent transportation technology, and in particular to a method, apparatus, cloud gateway device, and computer-readable storage medium for providing services to terminals within a local area network. Background Technology
[0002] A typical home broadband account connects to multiple devices, which together form a local area network (LAN). Different home broadband accounts can form multiple LANs. The network segments of devices within multiple LANs can be configured as private network segments, and different devices within different LANs can have the same private network IP address.
[0003] A gateway maintains a certain number of home broadband accounts. Each home broadband account has a set of Virtual Local Area Network (VLAN) and Virtual eXtensible Local Area Network (VXLAN) identifiers to uniquely identify the home broadband account. When a terminal within the same local area network sends a packet, it encapsulates the VLAN and VXLAN identifiers corresponding to the home broadband account. The gateway uses the Data Plane Development Kit (DPDK) to drive the physical network port to obtain the packet, parse it to obtain the VLAN and VXLAN identifiers, and thus determine which home broadband account the terminal under sent the packet.
[0004] However, cloud gateways differ from ordinary gateways. The cloud gateway software runs in a Docker container and primarily forwards terminal packets through transparent transmission. Cloud gateways also face the need to provide services to terminals under different home bandwidth accounts, assuming the cloud gateway device already provides this service. However, when the cloud gateway device provides services, because the packets have already been parsed using DPDK at the underlying physical network interface, when the upper layers of the cloud gateway (such as the network layer, like the TCP / IP layer) obtain the packets, the packets have already been restored to the original packets of the internal network terminals. The upper layers cannot obtain the VLAN and VXLAN identification numbers. Therefore, when different terminals in different LANs have the same private IP address, the cloud gateway cannot distinguish between different terminals in different LANs and cannot provide services to them. Summary of the Invention
[0005] This application provides a method, apparatus, cloud gateway device, cloud gateway system, and computer-readable storage medium for providing services to terminals within a local area network. Different port numbers can be pre-assigned to different home broadband accounts. The cloud gateway device uses different port numbers to partition request messages from terminals in the local area network corresponding to different home broadband accounts and responds to the request messages, so that the cloud gateway device can provide services to terminals in the local area network corresponding to different home broadband accounts.
[0006] This application provides a method for providing services to terminals within a local area network (LAN), applied in a cloud gateway device. The method for providing services to terminals within a LAN includes:
[0007] The cloud gateway device receives a request message for a service from a terminal in the local area network corresponding to the home broadband account through the physical network port of the cloud gateway device. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for the service.
[0008] The request message is decapsulated by the cloud gateway process to obtain the network layer request message;
[0009] The network layer request message is sent to the virtual network port device of the cloud gateway device, where the virtual network port device is a virtual TUN port device.
[0010] The virtual network port device triggers the listening of the destination port number to read the network layer request message, and the service responds to the network layer request message to generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0011] The response message is sent to the terminal through the virtual network port device to provide the service to the terminal.
[0012] Meanwhile, this application also provides an apparatus for providing services to terminals within a local area network, applied in a cloud gateway device, including:
[0013] The receiving module is used to receive, through the physical network port of the cloud gateway device, a request message sent by a terminal in the local area network corresponding to the home broadband account to request a certain service. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for the service.
[0014] The process decapsulation module is used to decapsulate the request message through the cloud gateway process to obtain the network layer request message;
[0015] The writing module is used to write the network layer request message to the virtual network port device of the cloud gateway device, wherein the virtual network port device is a virtual TUN port device.
[0016] The reading module is used to read the network layer request packet by triggering the listening destination port number through the virtual network port device;
[0017] The response module is used to respond to the network layer request message through the service and generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0018] The sending module is used to send the response message to the terminal through the virtual network port device, so as to provide the service to the terminal.
[0019] Meanwhile, this application also provides a cloud gateway device, which includes one or more processors; a memory; and one or more computer programs, wherein the processors and the memory are connected, the one or more computer programs are stored in the memory, and are configured to be executed by the processors using the session management method described above.
[0020] Meanwhile, embodiments of this application provide a computer-readable storage medium storing multiple instructions, which are loaded by a processor to execute the steps in the method for providing services to terminals within a local area network.
[0021] This application provides a method, apparatus, cloud gateway device, cloud gateway system, and computer-readable storage medium for providing services to terminals within a local area network (LAN). The cloud gateway device assigns different port numbers to different home broadband accounts and receives request messages from terminals within the LAN corresponding to those home broadband accounts, requesting a specific service from the cloud gateway device. The destination IP address in the request message is the IP address of the cloud gateway device, and the destination port number is the pre-assigned port number corresponding to the home broadband account of the terminal. Thus, the cloud gateway device can distinguish request messages from different home broadband accounts using the port number corresponding to the home broadband account and respond to the request messages to provide services to terminals within the LAN corresponding to different home accounts. This avoids the situation where terminals within the LAN corresponding to different home accounts have the same private IP address, making it impossible to identify messages from terminals within the LAN corresponding to different home accounts, thus preventing the inability to respond to the corresponding terminals and provide services. Attached Figure Description
[0022] The technical solution and other beneficial effects of this application will become apparent from the following detailed description of specific embodiments in conjunction with the accompanying drawings.
[0023] Figure 1 This is a schematic diagram illustrating an application scenario provided in an embodiment of this application.
[0024] Figure 2 This is a flowchart illustrating a method for providing services to terminals within a local area network, as provided in an embodiment of this application.
[0025] Figure 3 This is a schematic diagram illustrating the process of establishing a TCP connection in a method for providing services to terminals within a local area network, as provided in an embodiment of this application.
[0026] Figure 4 This is a schematic diagram of the structure of an apparatus for providing services to terminals within a local area network, as provided in an embodiment of this application.
[0027] Figure 5 This is a schematic diagram of the structure of the cloud gateway device provided in the embodiments of this application. Detailed Implementation
[0028] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. All other embodiments obtained by those skilled in the art based on the embodiments of this application without creative effort are within the scope of protection of this application.
[0029] This application provides a method, apparatus, cloud gateway device, cloud gateway system, and computer-readable storage medium for providing services to terminals within a local area network (LAN). Any of the methods and apparatuses for providing services to terminals within a LAN provided in this application can be integrated into a cloud gateway device. The cloud gateway device includes containers that provide corresponding services, such as automatic port mapping services, like those based on the Universal Plug and Play (UPnP) protocol.
[0030] The cloud gateway system in this embodiment includes a cloud gateway device, an intermediate network device, and a local area network (LAN) corresponding to at least one home broadband account. The intermediate network device can be an Optical Line Terminal (OLT, a terminal device used to connect to an optical fiber trunk), an Optical Network Unit (ONU), a switch, etc. Terminals within the LAN corresponding to a home broadband account send request messages to the cloud gateway device via the intermediate network device, requesting a specific service from the cloud gateway device. The cloud gateway device responds to the request messages, receives a response message, and sends the response message to the terminals within the LAN corresponding to the home broadband account via the intermediate network device.
[0031] The terminal can be a smartphone, tablet, laptop, touch screen, game console, personal computer (PC), smart robot, smart TV, or other terminal device.
[0032] It is important to note that the cloud gateway device in this application embodiment differs from ordinary / traditional home gateway devices such as optical modems and routers. Traditional home gateway devices are generally developed based on Linux systems. These home gateway devices integrate a kernel protocol stack, supporting most common protocols. Developers do not need to implement any specific protocol separately, allowing them to focus on their application area.
[0033] The cloud gateway device in this application embodiment is also a currently popular cloud gateway device, which is different from traditional home gateway devices. The cloud gateway software of the cloud gateway device is often used in the edge node server of the operator. It can basically realize the functions of traditional home gateway devices and can also bring more scalability on this basis. The underlying data transmission and reception performance of the cloud gateway device is the most critical of the entire cloud gateway device. If a mature Linux kernel protocol stack is directly used, the packet parsing and copying from kernel mode to user mode will greatly affect the protocol parsing efficiency. Therefore, some manufacturers use the DPDK method to drive. The DPDK method can bypass the kernel protocol stack to achieve fast packet transmission and reception. However, this method is equivalent to the cloud gateway device being an intermediate device, transmitting packets through a transparent method to achieve the purpose of fast packet transmission and reception. The drawback of this is that the cloud gateway device cannot use the existing mature Linux kernel protocol stack to provide services to the terminals in the local area network corresponding to the home broadband account.
[0034] The services provided by cloud gateway devices involve application layer or network layer protocols, which need to run on top of the TCP / IP protocol. For example, the automatic port mapping service is based on the Universal Plug and Play (UPnP) protocol module. This UPnP protocol module involves the interaction of HTTP messages. However, cloud gateway software running in Docker containers does not have the ability to interact with the TCP / IP protocol. If it is necessary to implement the interaction and state maintenance of each stage of the TCP protocol in order to provide one or more services, it is obviously not something that can be achieved in a short time. Even if it is achieved, it is difficult to reach the level of a mature kernel protocol stack.
[0035] Therefore, this application embodiment designs a method for cloud gateway devices that do not have kernel protocol stack functionality, i.e., cloud gateway devices that use transparent transmission to transmit packets, to provide one or more services to terminals within the local area network corresponding to a home broadband account. Specifically, a virtual network port device is created, and network parameters are assigned to the virtual network port device. The virtual network port device is a virtual TUN port device or a virtual network card device, which is a virtual network device in the operating system kernel. It can manipulate network layer packets and is responsible for transferring data between the network protocol stack in kernel space and the program in user space. The virtual network port device is created to use the protocol stack of the virtual TUN port device to parse and generate packets.
[0036] One feature is that after the cloud gateway device starts up, a virtual network port device can be created and network parameters similar to those of a regular real network port can be set. This means setting network parameters for the virtual network port device, such as IP address, subnet mask, and routing information.
[0037] This application is based on a pre-created virtual network port device, which uses the protocol stack of the virtual network port device to parse network layer packets and data of packets above it, in order to provide services to terminals within the local area network.
[0038] Please see Figure 1 , Figure 1 This is an application diagram of the cloud gateway device provided in the embodiments of this application, which can also be referred to as a diagram of a cloud gateway system. The cloud gateway system includes a cloud gateway device (hereinafter referred to as the cloud gateway), which stores multiple home broadband accounts, also simply referred to as home broadband accounts, such as account1, account2, ..., accountN. The cloud gateway device includes physical network ports. The cloud gateway system includes at least one local area network corresponding to a home broadband account, such as... Figure 1The LAN includes LAN1 (account1), LAN2 (account2), LAN3 (account3), etc. Each LAN includes at least one terminal device. For example, LAN1 includes terminal 1 (192.168.2.2) and terminal 2 (192.168.2.3), LAN2 includes terminal 1 (192.168.2.2) and terminal 2 (192.168.2.4), and LAN3 includes terminal 1 (192.168.2.3) and terminal 2 (192.168.2.5).
[0039] In local area networks (LANs) corresponding to different family accounts, because private IP addresses within private address ranges are used, terminals with the same private IP address may exist. For example, terminal 1 in LAN1 and terminal 1 in LAN2, or terminal 2 in LAN1 and terminal 1 in LAN3, although they share the same private IP address, are different terminals. Therefore, when a request packet is generated using a private IP address to access the cloud gateway, the cloud gateway's physical network port receives the request packet, parses out the VLAN and VXLAN identifiers, and then forwards the parsed packet to higher layers such as the network layer. However, since the cloud gateway software runs in a container, such as a Docker container, when the cloud gateway's virtual network port receives the parsed packet, it can no longer obtain the VLAN and VLAN identifiers because the packet has already been parsed. Furthermore, because the private IP addresses are the same, the cloud gateway cannot identify which LAN the terminal corresponding to the same private IP address belongs to, and thus cannot provide services to different terminals within different LANs.
[0040] To address the aforementioned issues, this application provides methods, apparatus, systems, cloud gateway devices, and computer-readable storage media for providing services to terminals within a local area network. These will be described in detail below. It should be noted that the order of description of the following embodiments is not intended to limit the preferred order of the embodiments.
[0041] Figure 2 This is a flowchart illustrating a method for providing services to terminals within a local area network, as provided in an embodiment of this application. The method is applied to a cloud gateway device, which includes physical network ports, virtual network port devices, and cloud gateway software. The cloud gateway software includes a UPnP protocol module, etc. The method includes the following steps.
[0042] 101. Through the physical network port of the cloud gateway device, receive a request message for a certain service sent by a terminal in the local area network corresponding to the home broadband account. The request message includes an IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for this service.
[0043] The physical network port is the actual network port. It requires a physical network port driver to function, which can be a DPDK driver. The DPDK driver reads request packets from the physical network port. These request packets are requests sent by a terminal within the local area network corresponding to a specific home broadband account to a specific service on the cloud gateway.
[0044] The destination IP address included in the request message is the IP address of the cloud gateway device, which means that the terminal is requesting services from the cloud gateway device, rather than requesting services from the external network that can communicate with the cloud gateway device. That is, the application scenario in this application embodiment involves different home broadband accounts requesting services provided by the cloud gateway device.
[0045] The destination port number included in the request message is a port number pre-assigned by the cloud gateway device to the home broadband account. This means that the destination port number is used to distinguish between different home broadband accounts, or to distinguish the local area network corresponding to different home broadband accounts. Therefore, for the same service, different home broadband accounts will have different destination port numbers, and for different services, different home broadband accounts will also have different assigned port numbers.
[0046] The cloud gateway device needs to pre-assign a corresponding port number to each home broadband account under each service it provides. The following describes how to assign a port number to each home broadband account under each service.
[0047] In one scenario, prior to receiving a request message for a service sent by a terminal within the local area network corresponding to a home broadband account, the method further includes: during the restart process of the cloud gateway device, obtaining all home broadband accounts stored in the cloud gateway device; creating a home broadband account instance for each of the home broadband accounts; for each service that the cloud gateway device can provide, determining the same number of port numbers from the idle port numbers of the cloud gateway device as the number of home broadband account instances under the corresponding service; and assigning corresponding port numbers to each home broadband account instance under the corresponding service according to the determined port numbers, and listening to the corresponding port numbers.
[0048] The cloud gateway device stores all home broadband accounts. During the cloud gateway restart process, it first retrieves all stored home broadband accounts and their classes, then creates a home broadband account instance for each of the home broadband accounts based on its class. Finally, it assigns a port number for each service to each home broadband account instance. This achieves full port number allocation.
[0049] For example, for service A, determine all home broadband account instances under service A, and the number of all home broadband account instances under service A. For instance, if there are 3 home broadband accounts (home broadband account instances) under service A, namely account1, account2, and account3, then... Figure 1 As shown; from the available free port numbers on the cloud gateway device, such as 63535-65535, determine the same number of port numbers as all home broadband account instances under service A. For example, determine 3 port numbers from the available free port numbers, such as port1, port2, and port3. Based on the determined port numbers, assign the corresponding port numbers to each home broadband account instance under service A. For example, assign port1 to account1, port2 to account2, and port3 to account3, and listen on port1, port2, and port3. The same operation is performed for service B, and the details will not be elaborated further.
[0050] Since the port numbers are determined from the available free port numbers on cloud network devices, the number of port numbers determined is the same as the number of home broadband account instances under the corresponding service and is unique. When assigning port numbers to each home broadband account under the corresponding service, each home broadband account is assigned a different port number; that is, each home broadband account under the same service is assigned a different port number, and each home broadband account under different services is assigned a different port number.
[0051] It is important to note that once an idle port number is allocated, the status of the corresponding port number will be changed to "in use". The cloud gateway device listens to each port number in the "in use" state, that is, it listens to the port number allocated to each home broadband account under the corresponding service.
[0052] In one scenario, prior to the step of receiving a request message for a service sent by a terminal within the local area network corresponding to the home broadband account, the method further includes: when the cloud gateway device creates a new home broadband account, creating a home broadband account instance for the new account; for each service that the cloud gateway device can provide, determining the same number of new port numbers from the cloud gateway device's available port numbers as the number of new home broadband account instances under the corresponding service; and assigning corresponding new port numbers to each new home broadband account instance under the corresponding service, and listening to the corresponding new port numbers. For example, if the new home broadband account is account4, then a new port number port4 is determined and assigned to the new home broadband account account4. This achieves incremental port number allocation.
[0053] After assigning a port number to each home broadband account under the corresponding service, the port number is sent to each home broadband account so that when the terminal in the local area network corresponding to each home broadband account requests the service from the cloud gateway device, the terminal includes the port number, i.e., the destination port number, in the service request.
[0054] It is important to note that the purpose of the destination port number in this application differs from that of a general port number. For example, when a user accesses a website using a browser, a website service is set up on a related server (this service allows users to access the website). The user then uses the IP address and the service's port number to connect to the server and perform related access. In this case, the purpose of the port number is either to connect to the service within the server or to distinguish between different services within the server. Therefore, all user terminals using this service need to use their respective IP address and the service's port number; that is, multiple user terminals can use the same port number to access the same service.
[0055] like Figure 1 As shown, assume the request message originates from terminal 1 within LAN1 corresponding to the home broadband account account1, and assume the cloud gateway device's IP address is 192.168.2.1. The port number pre-assigned to account1 is port1. Therefore, the source IP address in the request message is 192.168.2.2, and the source port number can be any available port number within terminal 1 of LAN1; the destination IP address is 192.168.2.1, and the destination port number is port1.
[0056] Terminal 1 generates a request message by encapsulating the source IP address, source port number, destination IP address, destination port number, and request content (such as a request for automatic port mapping service) layer by layer according to the message formats of the network layer and hardware layer. This request message is a hardware layer request message, which is then sent to the cloud gateway device through an intermediate network device. The physical network port of the cloud gateway device receives the request message and reads it through the DPDK driver.
[0057] 102. The request message is decapsulated by the cloud gateway process to obtain the network layer request message.
[0058] Since the request message is a hardware layer message, after obtaining the request message from the physical network interface, it is submitted to the cloud gateway process. The cloud gateway process then calls the corresponding protocol parser to parse the request message. First, the hardware layer protocol parser is called to decapsulate the request message, that is, to remove the hardware layer header of the hardware layer request message to obtain the link layer request message.
[0059] It is important to note that the hardware layer request message header includes VXLAN and VLAN information. Therefore, the VXLAN and VLAN information can be obtained by parsing the request message through the cloud gateway process. In other words, the VXLAN and VLAN information is obtained at the hardware layer. After the hardware layer request message is uploaded to the upper layer, the VXLAN and VLAN information can no longer be obtained.
[0060] Then, the link layer protocol parser is called to decapsulate the link layer request message, that is, to remove the link layer header of the link layer request message to obtain the network layer request message.
[0061] 103. Send the network layer request message to the virtual network port device of the cloud gateway device.
[0062] The network layer request message contains a network layer header. Based on the information in the network layer header, it can be determined that it is a network layer request message for the corresponding service. The network layer request message is then sent to the virtual network port device of the cloud gateway device.
[0063] Specifically, when the service is the automatic port mapping service of the UPnP protocol module, if the destination port in the network layer request message is the pre-allocated destination port number being listened to, and the protocol type is HTTP, then it is determined that the HTTP request message for the automatic port mapping service originates from within the local area network. When it is determined that the network layer request message is an HTTP request message for the automatic port mapping service of the UPnP protocol module, the cloud gateway process submits the network layer request message to the UPnP protocol module, so that the UPnP protocol module can write the network layer request message to the loopback interface of the virtual network interface device.
[0064] 104. The virtual network interface device triggers the listening destination port number to read the network layer request message, and responds to the network layer request message through the service to generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0065] The virtual network interface device contains a protocol stack that operates at the network layer and above. Therefore, when a network layer request message is sent to the virtual network interface device of the cloud gateway device, the protocol stack function of the virtual network interface device can be used to parse the network layer request message and the data of the upper layer message, and save the parsed data to the connection instance that establishes a TCP connection with the terminal.
[0066] Since the corresponding service in the cloud gateway device listens to the allocated port number, after the virtual network interface device receives the network layer request packet, it parses the network layer request packet to obtain the destination port number. It then triggers the listening destination port number to read the network layer request packet. Based on the destination port number, such as port1, it can be determined that the request packet comes from LAN1 corresponding to account1. Based on the source IP address, such as 192.168.2.2, it can be determined that the request packet comes from terminal 1 of LAN1.
[0067] After obtaining the network layer request message, the service responds to the network layer request message using the request information in the message. This request information includes the request parameters for the corresponding service, and a response message is generated. Specifically, the response result can be obtained by using the request information in the network layer request message from the corresponding service, and then written to the virtual network interface device. The source IP address and source port number of the network layer request message are obtained, as well as the IP address of the cloud gateway device and the destination port number listening for the network layer request message. Based on the source IP address, source port number, the IP address and destination port number of the cloud gateway device, and the response result, a response message is generated using the virtual network interface device.
[0068] For example, if the network layer request message requests the automatic port mapping service of the cloud gateway device, the network layer request message is decapsulated and parsed by the protocol stack of the virtual network interface device to obtain the application layer request message. This application layer message includes the request content, which is a request for the automatic port mapping service. The UPnP protocol module reads the network layer request message and its upper-layer message data from the virtual network interface device. Specifically, it reads the network layer request message and its upper-layer message data from the connection instance that has established a TCP connection with the terminal in the virtual network interface device. Therefore, the UPnP protocol module reads the request content from the virtual network interface device, and the automatic port mapping service in the UPnP protocol module responds to the request content, determining a mapping port for the terminal. The corresponding response result is this mapping port. This mapping port is the port (port number) for terminal 1 to access the external network. This mapping port is also the port (port number) for the cloud gateway service, but its function is completely different from that of the destination port number. After receiving the response, the UPnP protocol module writes the response to the virtual network interface device. Specifically, the UPnP protocol module writes the response to the connection instance in the virtual network interface device that has established a TCP connection with the terminal.
[0069] Parsing the network layer request message also reveals the source IP address and source port number. These source IP address and source port number represent the IP address and port number of the terminal sending the request message within the local area network corresponding to the home broadband account, such as the source IP address (192.168.2.2) and source port number of terminal 1. This information can be used to obtain the source IP address and source port number, as well as the IP address of the cloud gateway device and the destination port number listening for network layer request messages.
[0070] After receiving the response, the virtual network interface device encapsulates the response using its protocol stack to obtain an application-layer response message. Then, it encapsulates this application-layer response message using its own protocol stack to obtain a transport-layer response message. Finally, it encapsulates this transport-layer response message using its own protocol stack to obtain a network-layer response message. For example, using the source IP address and source port number as the destination IP address and destination port number, and the cloud gateway device's IP address and destination port number as the source IP address and source port number, along with the transport-layer response message as data, the virtual network interface device's protocol stack generates a response message, which is a network-layer response message.
[0071] It is important to note that request messages are sent from terminals within the local area network to the cloud gateway device, while response messages are sent from the cloud gateway device to terminals within the local area network.
[0072] 105. The response message is sent to the terminal through the virtual network port device to provide services to the terminal.
[0073] The response message can be transmitted to the cloud gateway process through the virtual network port device. The cloud gateway process encapsulates the network layer response message to obtain the hardware layer response message. The hardware layer response message is then sent to the terminal through the physical network port.
[0074] If the service is an automatic port mapping service of the UPnP protocol module, then the UPnP protocol module reads the response packet from the virtual network interface device and submits the network layer response packet to the cloud gateway process. The cloud gateway process calls the corresponding protocol encapsulator to encapsulate the network layer response packet to generate a link layer response packet, and then calls the corresponding protocol encapsulator to encapsulate the link layer response packet to obtain a hardware layer response packet, which is then sent to the terminal through the physical network interface.
[0075] The cloud gateway device can distinguish request messages corresponding to different home broadband accounts by using the port number corresponding to the home broadband account, and respond to the request message to provide services to the terminals in the local area network corresponding to different home accounts. This avoids the situation where terminals in the local area network corresponding to different home accounts have the same private network IP, which would prevent the device from recognizing the messages of terminals in the local area network corresponding to different home accounts, thus preventing the device from responding to the corresponding terminals in the local area network and providing services.
[0076] When the service is the automatic port mapping service in the UPnP protocol module, during execution Figure 2 Before the steps shown, a TCP connection needs to be established with the terminal. This established TCP connection is called a connection instance, as mentioned above. Specifically, the cloud gateway device can receive connection request packets from terminals within the local area network corresponding to the home broadband account, targeting the automatic port mapping service in the UPnP protocol module. Based on these connection request packets, a TCP connection is established between the cloud gateway device and the terminal through the protocol stack of the virtual network port device.
[0077] like Figure 3 As shown, the steps to establish a TCP connection between the cloud gateway device and the terminal include the following steps.
[0078] 201. When the cloud gateway device receives a connection request message for the automatic port mapping service of the UPnP protocol module from a terminal in the local area network corresponding to the home broadband account, it uses the UPnP protocol module to write the connection request message to the loopback interface of the virtual network port device.
[0079] Specifically, when the physical network port of the cloud gateway device receives a hardware layer connection message from a terminal in the local area network corresponding to the home broadband account, the DPDK driver reads the hardware layer connection message from the physical network port and submits it to the cloud gateway process. The cloud gateway process calls the protocol parser to parse the hardware layer connection message, for example, parses the hardware layer message into a link layer message, and then into a network layer connection message. When the destination port of the parsed connection message is the pre-allocated destination port number being listened to, and the protocol involved is the TCP protocol, it is determined to be a connection request message (SYN message) for the automatic port mapping service of the UPnP protocol module.
[0080] The connection request message (SYN message) is submitted to the UPnP protocol module, which then writes the connection request message to the loopback interface of the virtual network port device.
[0081] 202. Utilize the protocol stack of the virtual network interface device to respond to the connection request message in order to generate a connection confirmation message.
[0082] Since the connection request message requests a TCP connection, it corresponds to a TCP message. The virtual network interface device's protocol stack parses the connection request message and responds to the connection request message to generate a connection confirmation message, which is a SYN-ACK message.
[0083] 203. Use the UPnP protocol module to read the connection confirmation message from the loopback interface and send the connection confirmation message to the terminal.
[0084] The UPnP protocol module reads the SYN-ACK packet from the loopback interface. After reading the connection confirmation packet, the UPnP protocol module hands the connection confirmation packet over to the cloud gateway process. The cloud gateway process encapsulates the network layer connection confirmation packet corresponding to the connection confirmation packet into a link layer connection confirmation packet, and then encapsulates the link layer connection confirmation packet to obtain the hardware layer connection confirmation packet. The hardware layer connection confirmation packet is then sent from the physical network port to the terminal.
[0085] 204. When the UPnP protocol module receives the terminal's confirmation message for the connection confirmation message, it writes the confirmation message to the loopback interface of the virtual network port device.
[0086] After receiving the hardware layer connection confirmation message, the terminal encapsulates it layer by layer to obtain a connection confirmation message. It then generates an ACK message in response, which is a hardware layer confirmation message, and encapsulates this ACK message into a hardware layer confirmation message before sending it to the cloud gateway device. The destination port in the confirmation message is the pre-assigned port number being monitored.
[0087] After the physical network port of the cloud gateway device receives the hardware layer acknowledgment message, it hands it over to the cloud gateway process for parsing and processing to obtain the network layer acknowledgment message. The destination port of this acknowledgment message is the pre-allocated destination port number. Therefore, the acknowledgment message is handed over to the UPnP protocol module. After receiving the acknowledgment message, the UPnP protocol module writes the acknowledgment message to the loopback interface of the virtual network port device.
[0088] 205. Use the virtual network port device to respond with an acknowledgment message to establish a connection with the terminal.
[0089] After receiving the acknowledgment message, the virtual network interface device completes the TCP connection process by performing a three-way handshake, establishing a TCP connection with the terminal and using this TCP connection as a connection instance. The automatic port mapping service in the aforementioned UPnP protocol module is implemented based on this connection instance.
[0090] Figure 4This application provides a device for providing services to terminals within a local area network. It is applied in a cloud gateway device. The device includes a receiving module 301, a process unsealing module 302, a writing module 303, a reading module 304, a response module 305, and a sending module 306.
[0091] The receiving module 301 is used to receive a request message for a certain service sent by a terminal in the local area network corresponding to the home broadband account through the physical network port of the cloud gateway device. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for the service.
[0092] The process decapsulation module 302 is used to decapsulate the request message through the cloud gateway process to obtain the network layer request message.
[0093] The writing module 303 is used to send the network layer request message to the virtual network port device of the cloud gateway device, wherein the virtual network port device is a virtual TUN port device.
[0094] The reading module 304 is used to read the network layer request message by triggering the listening destination port number through the virtual network port device.
[0095] The response module 305 is used to respond to the network layer request message through the service and generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0096] In one embodiment, the response module 305 is specifically configured to respond to the request information in the network layer request message through the service to obtain a response result, and send the response result to the virtual network interface device. The request information includes request parameter information for requesting the service; obtain the source IP address and source port number of the network layer request message, and obtain the IP address of the cloud gateway device and the destination port number listening to the network layer request message; generate a response message through the protocol stack of the virtual network interface device based on the source IP address, the source port number, the IP address and destination port number of the cloud gateway device as the source IP address and source port number, and the response result.
[0097] In one embodiment, the response module 305 is further configured to encapsulate the response result through the protocol stack of the virtual network interface device to obtain an application layer response message; encapsulate the application layer response message again through the protocol stack of the virtual network interface device to obtain a transport layer response message; use the source IP address and source port number as the destination IP address and destination port number, use the IP address and destination port number of the cloud gateway device as the source IP address and source port number, use the transport layer response message as data, and generate a response message through the protocol stack of the virtual network interface device.
[0098] The sending module 306 is used to send the response message to the terminal through the virtual network port device, so as to provide the service to the terminal.
[0099] In one embodiment, the sending module 306 is further configured to transmit the response message to the cloud gateway process through the virtual network port device; encapsulate the network layer response message using the cloud gateway process to obtain a hardware layer response message; and send the hardware layer response message to the terminal through the physical network port.
[0100] In one embodiment, such as Figure 4 As shown, the device also includes a port allocation module 307. The port allocation module 307 is used to: obtain all home broadband accounts stored in the cloud gateway device during the cloud gateway device restart process; create a home broadband account instance for each of the home broadband accounts; for each service that the cloud gateway device can provide, determine the same number of port numbers from the cloud gateway device's idle port numbers as the number of home broadband account instances under the corresponding service; allocate corresponding port numbers to each home broadband account instance under the corresponding service according to the port numbers, and listen to the corresponding port numbers.
[0101] In one embodiment, the allocation module 307 is further configured to: create a home broadband account instance for the new home broadband account when the cloud gateway device creates a new home broadband account; for each service that the cloud gateway device can provide, determine the same number of new port numbers from the idle port numbers of the cloud gateway device as the new home broadband account instance under the corresponding service; allocate corresponding new port numbers to the new home broadband account instance under the corresponding service one by one according to the new port numbers, and listen to the corresponding new port numbers.
[0102] In one embodiment, such as Figure 4As shown, the device further includes a connection establishment module 308. The connection establishment module 308 is used to receive a connection request message for the automatic port mapping service sent by a terminal within the local area network corresponding to the home broadband account through the cloud gateway device; and to establish a TCP connection between the cloud gateway device and the terminal based on the connection request message through the protocol stack of the virtual network port device.
[0103] Specifically, for details of each embodiment, please refer to the corresponding description in the method embodiments above, which will not be repeated here.
[0104] This application also provides a cloud gateway device in its embodiments. For example... Figure 5 As shown, Figure 5 This is a schematic diagram of the structure of a cloud gateway device provided in an embodiment of this application. The cloud gateway device 400 includes one or more physical network ports 403, one or more processors 401 with processing cores, one or more memory devices 402 with computer-readable storage media, and computer programs, such as cloud gateway software programs, stored in the memory devices 402 and executable on the processors. The processor 401 is electrically connected to the memory devices 402.
[0105] The processor 401 is the control center of the cloud gateway device 400. It connects various parts of the cloud gateway device 400 through various interfaces and lines. By running or loading software programs (computer programs) and / or modules stored in the memory 402, and calling data stored in the memory 402, it performs various functions of the computer device 400 and processes data, thereby performing overall monitoring of the cloud gateway device 400.
[0106] In this embodiment, the processor 401 in the cloud gateway device 400 loads the instructions corresponding to the processes of one or more application programs / computer programs into the memory 402 according to the following steps, and the processor 401 runs the application programs / computer programs stored in the memory 402 to realize various functions, for example as follows:
[0107] The cloud gateway device receives a request message for a service from a terminal in the local area network corresponding to the home broadband account through the physical network port of the cloud gateway device. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for the service.
[0108] The request message is decapsulated by the cloud gateway process to obtain the network layer request message;
[0109] The network layer request message is sent to the virtual network port device of the cloud gateway device, where the virtual network port device is a virtual TUN port device.
[0110] The virtual network port device triggers the listening of the destination port number to read the network layer request message, and the service responds to the network layer request message to generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0111] The response message is sent to the terminal through the virtual network port device to provide the service to the terminal.
[0112] The processor 401 can execute the steps / operations in any of the above method embodiments. Please refer to the description in the method embodiments above for details, which will not be repeated here. The specific implementation of each of the above operations and the beneficial effects that can be achieved can be referred to the previous embodiments, which will not be repeated here.
[0113] like Figure 5 As shown, the cloud gateway device 400 may also include: a virtual network port device 406. The details of the virtual network port device 406 are described above and will not be repeated here. Optionally, such as... Figure 5 As shown, the cloud gateway device 400 may further include components such as: a radio frequency circuit 404, a wireless Fidelity (WiFi) module 405, and a power supply 407. Those skilled in the art will understand that... Figure 5 The cloud gateway device structure shown does not constitute a limitation on the cloud gateway device and may include more or fewer components than shown, or combine certain parts, or have different component arrangements.
[0114] The RF circuit 404 can be used for signal reception and transmission during information transmission and reception. In particular, after receiving downlink information from the base station, it is handed over to one or more processors 401 for processing; in addition, it transmits data related to the above shape to the base station.
[0115] WiFi is a short-range wireless transmission technology, and the cloud gateway provides users with wireless broadband internet access through the WiFi module 405. Although Figure 5 WiFi module 405 is shown, but it is understood that it is not a necessary component of the cloud gateway device and can be omitted as needed without changing the nature of the application.
[0116] The cloud gateway device also includes a power supply 407 (such as a battery) to power various components. Preferably, the power supply can be logically connected to the processor 401 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0117] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the detailed description above, and they will not be repeated here.
[0118] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by instructions / computer programs, or by instructions / computer programs controlling related hardware. These instructions / computer programs can be stored in a computer-readable storage medium and loaded and executed by a processor.
[0119] Therefore, embodiments of this application provide a computer-readable storage medium storing a plurality of instructions / computer programs that can be loaded by a processor to achieve the following functions:
[0120] The cloud gateway device receives a request message for a service from a terminal in the local area network corresponding to the home broadband account through the physical network port of the cloud gateway device. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. The port number assigned to different home broadband accounts is different for the service.
[0121] The request message is decapsulated by the cloud gateway process to obtain the network layer request message;
[0122] The network layer request message is sent to the virtual network port device of the cloud gateway device, where the virtual network port device is a virtual TUN port device.
[0123] The virtual network port device triggers the listening of the destination port number to read the network layer request message, and the service responds to the network layer request message to generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal.
[0124] The response message is sent to the terminal through the virtual network port device to provide the service to the terminal.
[0125] For details on the implementation of each of the above operations, please refer to the previous examples, which will not be repeated here.
[0126] The storage medium may include: read-only memory (ROM), random access memory (RAM), disk or optical disk, etc.
[0127] Since the instructions / computer programs stored in the storage medium can execute the steps of any of the methods provided in the embodiments of this application, the beneficial effects that any of the methods provided in the embodiments of this application can achieve can be realized, as detailed in the preceding embodiments, and will not be repeated here.
[0128] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions in other embodiments.
[0129] The foregoing has provided a detailed description of a method and apparatus for providing services to terminals within a local area network, a cloud gateway device, and a computer-readable storage medium, as provided in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the technical solutions and core ideas of this application. Those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
Claims
1. A method for providing services to terminals within a local area network, characterized in that, Applied in cloud gateway devices, including: The cloud gateway device receives a request message for a service from a terminal in the local area network corresponding to the home broadband account through the physical network port of the cloud gateway device. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. For the service, different home broadband accounts are assigned different port numbers. The request message is decapsulated by the cloud gateway process to obtain the network layer request message; The network layer request message is sent to the virtual network port device of the cloud gateway device, where the virtual network port device is a virtual TUN port device. The virtual network port device triggers the listening of the destination port number to read the network layer request message, and the service responds to the network layer request message to generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal. The response message is sent to the terminal through the virtual network port device to provide the service to the terminal.
2. The method according to claim 1, characterized in that, Before the step of receiving a request message for a specific service sent by a terminal within the local area network corresponding to the home broadband account, the process also includes: During the restart process of the cloud gateway device, all home broadband accounts stored in the cloud gateway device are retrieved; Create a home broadband account instance for each home broadband account in all home broadband accounts; For each service that the cloud gateway device can provide, determine the same number of port numbers from the idle port numbers of the cloud gateway device as the number of home broadband account instances under the corresponding service; Based on the port number, assign a corresponding port number to each home broadband account instance under the corresponding service, and listen on the corresponding port number.
3. The method according to claim 1, characterized in that, Before the step of receiving a request message for a specific service sent by a terminal with a home broadband account, the following steps are also included: When the cloud gateway device creates a new home broadband account, it creates a home broadband account instance for the new home broadband account; For each service that the cloud gateway device can provide, determine the same number of new port numbers from the idle port numbers of the cloud gateway device as the new home broadband account instance under the corresponding service; Based on the new port number, assign the corresponding new port number to each of the new home broadband account instances under the corresponding service, and listen on the corresponding new port number.
4. The method according to claim 1, characterized in that, The steps of generating a response message by responding to the network layer request message through the service include: The service responds to the request information in the network layer request message to obtain a response result, and sends the response result to the virtual network interface device. The request information includes request parameter information for requesting the service. Obtain the source IP address and source port number of the network layer request message, and obtain the IP address of the cloud gateway device and the destination port number for listening to the network layer request message; Based on the source IP address, the source port number, the IP address and destination port number of the cloud gateway device, and the response result, a response message is generated through the protocol stack of the virtual network port device.
5. The method according to claim 4, characterized in that, The step of generating a response message using the protocol stack of the virtual network interface device based on the source IP address, the source port number, the IP address and destination port number of the cloud gateway device, and the response result includes: The response result is encapsulated using the protocol stack of the virtual network port device to obtain an application layer response message; The application layer response message is encapsulated again through the protocol stack of the virtual network port device to obtain the transport layer response message; The source IP address and source port number are used as the destination IP address and destination port number, the IP address and destination port number of the cloud gateway device are used as the source IP address and source port number, and the transport layer response message is used as data to generate a response message through the protocol stack of the virtual network port device.
6. The method according to claim 1, characterized in that, The step of sending the response message to the terminal through the virtual network port device includes: The response message is transmitted to the cloud gateway process via the virtual network port device. The cloud gateway process is used to encapsulate the response message at the network layer to obtain the response message at the hardware layer. The hardware layer response message is sent to the terminal via the physical network port.
7. The method according to any one of claims 1-6, characterized in that, The service includes the automatic port mapping service in the Universal Plug and Play protocol module. Before the step of receiving a request message for a certain service sent by a terminal in the local area network corresponding to the home broadband account, the method further includes: The cloud gateway device receives connection request messages for the automatic port mapping service sent by terminals within the local area network corresponding to the home broadband account. Based on the connection request message, a TCP connection is established between the cloud gateway device and the terminal through the protocol stack of the virtual network port device.
8. An apparatus for providing services to terminals within a local area network, characterized in that, The device, used in cloud gateway equipment, includes: The receiving module is used to receive, through the physical network port of the cloud gateway device, a request message sent by a terminal in the local area network corresponding to the home broadband account requesting a certain service. The request message includes a destination IP address and a destination port number. The destination IP address is the IP address of the cloud gateway device, and the destination port number is the port number pre-assigned by the cloud gateway device to the home broadband account. For the service, different home broadband accounts are assigned different port numbers. The process decapsulation module is used to decapsulate the request message through the cloud gateway process to obtain the network layer request message; The writing module is used to write the network layer request message to the virtual network port device of the cloud gateway device, wherein the virtual network port device is a virtual TUN port device. The reading module is used to read the network layer request packet by triggering the listening destination port number through the virtual network port device; The response module is used to respond to the network layer request message through the service and generate a response message. The source IP address of the response message is the IP address of the cloud gateway device, the port number is the destination port number, and the destination IP address is the IP address of the terminal. The sending module is used to send the response message to the terminal through the virtual network port device, so as to provide the service to the terminal.
9. A cloud gateway device, characterized in that, The cloud gateway device includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of the method according to any one of claims 1 to 7.
10. 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 method described in any one of claims 1 to 7.