Protocol stack applied to 5G gateway and 5G gateway
By introducing the IP:port pool interface and customized transport layer interface into the network layer processing module, the problem that the traditional protocol stack cannot support Internet access for 5G gateways and LAN devices at the same time is solved, unified management of IP:port resources and precise control of traffic are achieved, meeting the communication needs in ubiquitous computing scenarios.
Patent Information
- Application Number
- CN202511033620.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-25
- Publication Date
- 2025-09-26
AI Technical Summary
Traditional protocol stacks are unable to simultaneously meet the Internet access requirements of 5G gateways and LAN devices, especially in ubiquitous computing scenarios where the accuracy requirements for traffic control and data forwarding are not fully considered.
The IP:port pool interface is introduced for unified management in the network layer processing module, providing IP:port resource allocation capabilities dedicated to 5G gateways and LAN devices. Through customized transport layer interfaces and socket interfaces, it supports various application scenarios and realizes traffic conversion and management.
It realizes the functional requirement of simultaneous Internet access for 5G gateways and LAN devices, meets the traffic control and data forwarding requirements in ubiquitous computing scenarios, and improves the flexibility and reliability of the system.
Smart Images

Figure CN120710987A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to a protocol stack applied to a 5G gateway and a 5G gateway. Background Art
[0002] In ubiquitous computing scenarios, fifth-generation (5G) gateways provide interactive services between industrial devices and internet servers. To enhance reliability, these devices connect to 5G gateways via wired local area networks (LANs). These gateways perform key functions such as traffic forwarding, auditing, and protocol conversion. Furthermore, 5G gateways themselves have business needs for interacting with internet servers.
[0003] The normal operation of the 5G gateway is inseparable from the support of the protocol stack, but the traditional protocol stack mainly serves general application scenarios and is difficult to meet the functional requirements of supporting both 5G gateways and LAN devices to access the Internet. Summary of the Invention
[0004] The purpose of the embodiments of the present application is to provide a protocol stack and a 5G gateway applied to a 5G gateway, which can meet the functional requirements of simultaneously supporting the 5G gateway and local area network devices to access the Internet.
[0005] In a first aspect, an embodiment of the present application provides a protocol stack for a 5G gateway, the protocol stack comprising a gateway application interface, a socket interface, a transport layer protocol processing module, and a network layer processing module; the transport layer protocol processing module is connected to the gateway application interface and the socket interface through an internally provided transport layer interface, and the network layer processing module is connected to the transport layer protocol processing module through an internally provided IP:port pool interface and an IP processing interface; wherein: The gateway application interface is used to serve the audit / forwarding application of the 5G gateway; The socket interface is used to serve the client application of the 5G gateway itself; The network layer processing module is used to process the traffic from the transport layer protocol processing module and the traffic from the Ethernet network card driver and 5G module driver of the 5G gateway; The IP:port pool interface is used to uniformly manage IP:port resources for use by the 5G gateway and the LAN end devices connected to the 5G gateway.
[0006] A second aspect of an embodiment of the present application provides a 5G gateway, the 5G gateway comprising: an audit / forwarding application, a client application, an Ethernet network card driver, a 5G module driver, an Ethernet network card, a USB host controller driver, a 5G module, and a protocol stack applied to the 5G gateway as described in the first aspect, the protocol stack being connected to the audit / forwarding application, the client application, the Ethernet network card driver, and the 5G module driver, respectively, wherein: The Ethernet network card driver is used to manage and use the Ethernet network card; The 5G module driver is used to manage and use the 5G module through the USB host controller driver.
[0007] It can be seen from the above technical solution that, considering that in order to simultaneously support 5G gateways and LAN-end devices to access the Internet, the protocol stack needs to be equipped with the ability to allocate IP:port resources to both. This application introduces an IP:port pool interface in the network layer processing module to uniformly manage IP:port resources for use by the 5G gateway and the LAN-end devices connected to the 5G gateway. This can overcome the defect that the working scenarios and business characteristics of the 5G gateway are not fully considered when designing the traditional protocol stack, so that the protocol stack has the ability to allocate IP:port resources to both. In this way, the protocol stack provided by this application can meet the functional requirements of simultaneously supporting 5G gateways and LAN-end devices to access the Internet. BRIEF DESCRIPTION OF THE DRAWINGS
[0008] In order to more clearly illustrate the embodiments of the present application, the following is a brief introduction to the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0009] Figure 1 A schematic diagram of the connection between a local area network device, a 5G gateway, and an Internet server provided in an embodiment of the present application; Figure 2 A schematic diagram of the structure of a protocol stack applied to a 5G gateway provided in an embodiment of the present application; Figure 3 A schematic diagram of a 5G gateway traffic forwarding process provided in an embodiment of the present application; Figure 4 A schematic diagram of a quintuple association provided in an embodiment of the present application; Figure 5 A schematic diagram of an uplink UDP message processing process provided in an embodiment of the present application; Figure 6 A schematic diagram of a local area network IP and traffic configuration table provided in an embodiment of the present application; Figure 7 A schematic diagram of a new connection and data forwarding process provided in an embodiment of the present application; Figure 8 A schematic diagram of the structure of a 5G gateway provided in an embodiment of the present application. DETAILED DESCRIPTION
[0010] First, to facilitate understanding of the technical solutions provided by this application, the main technical concepts involved in the embodiments of this application are briefly described below.
[0011] Flow control: refers to a mechanism used to constrain the sending rate of the sender, whose purpose is to ensure that the sending rate matches the processing capacity of the receiver.
[0012] IP:port pool: refers to a collection of multiple Internet Protocol (IP) addresses and ports (i.e. IP:port resources).
[0013] Maximum Transmission Unit (MTU): The maximum data packet size that can be transmitted on a certain layer of a communication protocol. It depends on the link passed during the transmission process, including the link layer protocol used and the network hardware passed through.
[0014] Transmission Control Protocol / Internet Protocol (TCP / IP): refers to a suite of protocols that enables information transmission across multiple networks. It defines how devices communicate on the Internet and ensures accurate data transmission.
[0015] Transmission Control Protocol (TCP): is a communication protocol that works at the fourth layer (transport layer) of the Open System Interconnect (OSI) model. It is mainly used to provide reliable data transmission services in unreliable network environments.
[0016] Maximum Segment Size (MSS): The maximum amount of data a TCP packet can carry, excluding the length of the TCP and IP headers. The MSS is negotiated between the two communicating parties during TCP connection establishment to ensure that TCP packets do not exceed the MTU and avoid the overhead introduced by fragmentation and reassembly.
[0017] User Datagram Protocol (UDP): is a simple, connectionless, unreliable datagram-oriented transport layer protocol.
[0018] The Synchronize Sequence Numbers (SYN) flag is a flag in the TCP header used to synchronize the initial sequence numbers (ISNs) of both communicating parties during the TCP handshake. This flag is set in both the first TCP handshake (when the client sends a packet with the SYN bit set to the server, called a SYN packet) and the second handshake (when the server replies to the client with both the SYN and ACK bits set, called a SYN / ACK packet). Both communicating parties communicate their respective ISNs through the Sequence Number (Seq) field in the message.
[0019] Acknowledgment (ACK): This is a flag in the TCP header that activates the Acknowledgment Number (Ack) field in the TCP header. Its functions are: (1) Confirming data reception. When ACK is set, the Ack field is valid, indicating that the receiver has successfully received all data segments with a Seq less than the Ack value. (2) Buffer release. After receiving a packet with ACK set, the sender releases the send buffer corresponding to the data segments with a Seq less than the Ack value, as these data segments have been acknowledged by the receiver.
[0020] 5G module connection methods and operating mechanisms: Currently, mainstream 5G modules support connecting to hardware devices (such as ARM development boards) via Universal Serial Bus (USB) 3.0. 5G modules allow users to connect to base stations over the 5G network and, through the base stations, request IP addresses and network resources from the 5G core network. Once the 5G core network allocates IP addresses and resources, users can communicate with internet applications via IP. Currently popular 5G modules widely support the Ethernet Networking Control Model (ECM) and Remote Network Driver Interface Specification (RNDIS) protocols. In this operating mode, the 5G module is virtualized as an Ethernet network card, communicating directly with the TCP / IP protocol stack. 5G gateways deployed at the edge must translate IP addresses when transferring traffic to and from the LAN, which requires maintaining IP and port resources.
[0021] 5G Gateway: A device deployed at the edge of the network that integrates 5G communication components and is responsible for transferring and managing traffic between the local area network and the Internet through 5G technology.
[0022] LAN device: refers to a terminal hardware device (such as a personal computer, embedded device, etc.) that exists in a LAN, participates in data exchange within the LAN, or implements specific functions through the LAN. It requires gateway support to access the external network.
[0023] LAN device protocol stack: This refers to the set of network protocols installed on LAN devices, using a layered structure (such as the TCP / IP protocol stack). Because LAN devices typically only deploy client applications, their protocol stack primarily handles network communications between the LAN device client and server applications.
[0024] Client applications are applications installed on devices that provide specific functionality to users and act as service requesters. These applications rely on the network protocol stack for connectivity. Client applications are defined from the perspective of their communication role, emphasizing their role as service requesters. Therefore, 5G gateways and local area network devices can each run their own client applications.
[0025] Server: A hardware device or virtual device (such as a physical server or cloud server) that exists on a network and provides specific service functions to client applications. It responds to requests from clients by running server applications and communicates with clients based on the server protocol stack.
[0026] A server protocol stack is a layered collection of network protocols installed on a server. A server typically hosts a server application, so its protocol stack primarily handles network communications between the server application and client applications.
[0027] Server applications are applications installed on servers that provide specific service functions to client applications and act as service providers. They rely on network protocol stacks for networking. Server applications are defined from the perspective of their communication role, emphasizing their service provider nature. Therefore, cloud servers, edge computing nodes, and other applications can all run their own server applications.
[0028] The following will be combined with the accompanying drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0029] 5G can break through geographical limitations and provide deterministic latency services, thus gaining widespread application in ubiquitous computing scenarios where humans, machines, and objects are interconnected. In these scenarios, 5G gateways provide interactive services for communication between industrial equipment and internet servers. To enhance reliability, these devices connect to 5G gateways via wired LANs, with 5G gateways playing a key role in traffic forwarding, auditing, and protocol conversion. Furthermore, 5G gateways themselves also have business needs for interacting with internet servers.
[0030] Considering that in the ubiquitous computing scenario, the end devices in each LAN may run different types of services, thus putting forward different requirements for Quality of Service (QoS). In addition, the 5G gateway may also be deployed with services that access the Internet. In order to meet the requirements of forwarding and networking functions, the 5G gateway requires the support of the protocol stack (such as the TCP / IP protocol stack), refer to Figure 1 The diagram shows the connection between the LAN device, 5G gateway, and Internet server, which shows the connection between the LAN device, the 5G gateway deployed with a wired network card (i.e., Ethernet network card), the 5G module and protocol stack, and the Internet server.
[0031] The normal operation of 5G gateways is inseparable from the support of protocol stacks. However, traditional protocol stacks mainly serve general application scenarios and are not optimized for specific 5G gateway-related scenarios that simultaneously support 5G gateways and LAN devices accessing the Internet (as well as those that require precise flow control and low-overhead data forwarding).
[0032] In the ubiquitous computing scenario where 5G gateways operate, the operating system and supporting software such as protocol stacks need to be highly flexible so that developers can comprehensively consider the device's operating scenarios and business needs. Therefore, this application has customized the protocol stack and thereby provided a protocol stack and 5G gateway for application in 5G gateways, thereby achieving optimized support for specific 5G gateway services.
[0033] See also Figure 2 As shown, it is a structural diagram of a protocol stack applied to a 5G gateway provided by an embodiment of the present application. The protocol stack includes a gateway application interface, a socket interface, a transport layer protocol processing module, and a network layer processing module; the transport layer protocol processing module is connected to the gateway application interface and the socket interface through an internally provided transport layer interface, and the network layer processing module is connected to the transport layer protocol processing module through an internally provided IP: port pool interface and an IP processing interface; wherein: The gateway application interface is used to serve the audit / forwarding application of the 5G gateway; The socket interface is used to serve the client application of the 5G gateway itself; The network layer processing module is used to process the traffic from the transport layer protocol processing module and the traffic from the Ethernet network card driver and 5G module driver of the 5G gateway; The IP:port pool interface is used to uniformly manage IP:port resources for use by the 5G gateway and the LAN end devices connected to the 5G gateway.
[0034] Among them, the gateway application interface is mainly used for auditing and forwarding, for example, it is used to count the access of each client application to the Internet server. It can also be further expanded according to actual needs, for example, it can be used to block the blacklist, that is, not allowing communication with the blacklisted domain name or IP; the client application is determined according to actual conditions, and it can include Hypertext Transfer Protocol (HTTP) client application, as well as business-related client applications (such as for regularly backing up data from a designated server).
[0035] In this embodiment, the protocol stack provides a gateway-specific protocol stack interface (i.e., gateway application interface) and a socket interface to accommodate the diverse application scenarios of the 5G gateway. Specifically, a socket interface is provided for 5G gateway client applications (which address the business needs of the 5G gateway itself interacting with internet servers), facilitating the easy porting of widely used applications to the gateway. A dedicated gateway application interface is provided for auditing / forwarding applications. Optionally, the gateway application interface can provide customized functionality for forwarded traffic, such as association connection settings.
[0036] It should be noted that the traditional protocol stack only provides a socket interface (socket) to provide a unified and transparent inter-process communication service between networks. The protocol processing process is transparent to the application. Generally, it only processes the traffic of the two communicating parties and only needs to consider the client application and server application situations. The 5G gateway needs to consider more complicated situations: it works between the LAN device and the server, and needs to consider the network situation from the LAN device client application to the gateway, and from the gateway to the server application. At the same time, in most scenarios, the gateway does not interfere with the communication content. For this reason, this application introduces a protocol stack interface dedicated to the gateway, so that the protocol stack can specifically send, receive and process the data associated with such complex situations, and use the socket interface to enable the protocol stack to normally send, receive and process the data associated with the client application (that is, the gateway itself) and the Internet server on the 5G gateway.
[0037] In the protocol stack provided in this application, the network layer processing module not only provides a traditional IP processing interface, but also provides an IP:port pool interface for unified management of IP:port resources for use by the 5G gateway and the LAN end devices connected to the 5G gateway.
[0038] It should be noted that the 5G gateway can directly use the IP address assigned to it by the 5G module to access the Internet. When the LAN device accesses the Internet through the 5G gateway, the IP address needs to be converted to the address held by the 5G gateway. At the same time, considering that when using the protocol stack for inter-process communication, it is necessary to index according to the five-tuple (i.e., local IP: source port: remote IP: destination port: protocol type, the protocol type is generally TCP or UDP), from the perspective of the 5G gateway, when the LAN device accesses the Internet through the 5G gateway, it will occupy the five-tuple resources of the 5G gateway (i.e., module IP: source port). That is, at this time, the allocation of 5G module IP: port resources needs to consider both the situation from the gateway itself and from the LAN device. Therefore, this application introduces an IP: port pool interface for unified management of IP: port resources, so as to uniformly maintain the occupied port information for the traffic that needs to be sent through the 5G module, i.e., the IP: port pool, so as to realize the function of connecting the LAN device to the 5G gateway through the LAN network and then accessing the Internet, and at the same time support the client application on the 5G gateway to access the Internet.
[0039] It can be seen from the above technical solution that, considering that in order to simultaneously support 5G gateways and LAN-end devices to access the Internet, the protocol stack needs to be equipped with the ability to allocate IP:port resources to both. This application introduces an IP:port pool interface in the network layer processing module to uniformly manage IP:port resources for use by the 5G gateway and the LAN-end devices connected to the 5G gateway. This can overcome the defect that the working scenarios and business characteristics of the 5G gateway are not fully considered when designing the traditional protocol stack, so that the protocol stack has the ability to allocate IP:port resources to both. In this way, the protocol stack provided by this application can meet the functional requirements of simultaneously supporting 5G gateways and LAN-end devices to access the Internet.
[0040] Reference Figure 3 The diagram below shows the 5G gateway forwarding traffic. When forwarding uplink traffic generated by the client application on the LAN device, a conversion process is performed from LAN IP: client port 1 to module IP: client port 1'. Similarly, when forwarding downlink traffic, a reverse conversion process is performed from module IP: client port 1' to LAN IP: client port 1.
[0041] Taking the forwarding of LAN traffic to an internet server as an example, the LAN device submits IP data packets to the network layer processing module through the Ethernet network card driver. After passing through the transport layer protocol processing module, the audit / forwarding application on the 5G gateway reads the data through the gateway application interface, and then sends the data to the associated connection through the gateway application interface. After passing through the transport layer protocol processing module, the data is submitted to the 5G module driver through the IP processing interface. The internet application on the 5G gateway submits data to the transport layer protocol processing module through traditional sockets, and after passing through the IP processing interface, it is submitted to the 5G module driver.
[0042] It's important to note that the 5G module driver virtualizes the 5G module as an Ethernet card object. While the kernel appears to be communicating directly with the Ethernet card, data is ultimately delivered to the 5G module driver, for example, to a 5G module that supports ECM or RNDIS. The Ethernet card object is the data structure used by the driver to describe the Ethernet card. It contains a set of driver-provided interfaces, specifically the set of functions supported by the driver.
[0043] During the aforementioned 5G gateway traffic forwarding services, the protocol stack needs to implement the following functions: 1. Module IP:port resource maintenance: The 5G gateway's audit / forwarding application and client application share module IP:port resources. The IP:port pool interface provides functions for applying for, maintaining, and releasing module IP:port resources.
[0044] 2. Connection / node association: To forward traffic, the protocol stack needs to convert five-tuple information during the forwarding process. For TCP, this is achieved by associating connections; for UDP, this is achieved by associating nodes.
[0045] As a possible implementation, in the implementation of Function 1, the present application modifies the transport layer interface, and in particular customizes the TCP connection mechanism. Specifically, the transport layer interface is configured with a customized connection mechanism for performing at least one of the following operations: When the audit / forwarding application creates a new connection through the s_connect interface, it obtains an unoccupied module IP:port resource through the IP:port pool interface and builds a connection based on the port therein. The s_connect interface is a customized connect interface. Receive the maximum message length MSS value passed by the audit / forwarding application when calling the s_connect interface according to the working environment.
[0046] It should be noted that the traditional connect mechanism does not explicitly configure the MSS value of TCP. It selects the MSS value based on the operating system configuration and link conditions. The entire process is transparent to the application itself. However, the s_connect interface (i.e., the customized connect interface) designed in this application needs to receive the MSS value set by the audit / forwarding application according to the working environment. Therefore, the audit / forwarding application can ensure that the forwarding process will not be fragmented due to the different MSS values between the client application on the LAN device and the 5G gateway, and the 5G gateway and the Internet server, resulting in additional overhead. In addition, during the call of the s_connect interface, the operation of the customized protocol stack will not have any impact on the operation of the server, that is, the processing of the s_connect interface will not change the behavioral logic of the TCP three-way handshake, and it is completely transparent to the server: the Internet server application does not need to modify the code or adjust the configuration, and its protocol stack will not perceive the existence of the customized protocol stack. The two still complete the connection establishment and data interaction according to the standard TCP protocol process, so that the Internet server protocol stack and application do not need any adjustment.
[0047] In this implementation, when a gateway application (i.e., the audit / forwarding application) creates a new connection through the s_connect interface, it retrieves an unused module IP:port resource through the IP:port pool interface and establishes a connection based on the port. Furthermore, the s_connect interface allows applications to customize the MSS value based on their operating environment, enabling flexible configuration of connection parameters.
[0048] As a possible implementation method, in response to the requirement for transparent deployment of gateway applications, and to ensure that the 5G gateway can successfully establish a connection with the client application on the LAN device as a server, this application specially customizes the TCP accept mechanism. Based on the customized accept mechanism, the gateway application can listen to the specified port and respond to connection requests from the LAN device with the server's IP address.
[0049] It's important to note that the traditional protocol stack provides an accept interface, which operates on the listening socket and doesn't participate in the MSS negotiation process. When a client application on a LAN device triggers a new connection request using the connect mechanism, it sends a SYN packet through the LAN device's protocol stack. Upon receiving the SYN packet, the traditional protocol stack selects the negotiated MSS value (MSS = min(MSS_C, MSS_S)) based on the MSS value (MSS_C) in the SYN packet and the MSS value (MSS_S) configured by the internet server protocol stack. The packet is then returned to the LAN device's protocol stack via a SYN / ACK packet. The LAN device's protocol stack automatically responds with an ACK, completing the third handshake and notifying the client application that the connection establishment process is complete. After the three-way handshake is complete, the traditional protocol stack transfers the TCP connection to the listening socket's completed connection queue. The accept interface retrieves the completed connection from the completed connection queue and returns a new socket to the application, which describes and operates the TCP connection between the client application and the internet server.
[0050] The customized accept mechanism provided in this application differs from the traditional accept mechanism described above in that it participates in both the MSS negotiation process and the three-way handshake. Specifically, the customized accept mechanism provides the s_accept interface (i.e., a customized accept interface). Upon receiving a SYN packet, the transport layer protocol processing module configured with this customized accept mechanism does not wait for the three-way handshake to complete. Instead, it immediately calls the s_accept interface to notify the audit / forwarding application to process the packet. This allows the audit / forwarding application to send a connection establishment request to the application on the internet server as a client. After obtaining the TCP configuration item information (such as the MSS value) from the Internet server, the s_accept interface is called again to reply with a SYN / ACK packet to the LAN device protocol stack, and an associated connection is established to implement transparent auditing / forwarding functions. During the call of the s_accept interface, the operation of the customized protocol stack will not have any impact on the operation of the LAN device, that is, the processing of the s_accept interface is completely transparent to the protocol stack and client application on the LAN device: its protocol stack will not perceive the existence of the customized protocol stack, and the client application does not need to modify the code or adjust the configuration. This allows the protocol stack and client application to complete connection establishment and data interaction according to the standard TCP process without any adjustment.
[0051] For example, the formal parameters of the s_accept interface can be used to pass or return a handle describing the TCP connection between the client application and the 5G gateway. Thus, the execution process of the customized accept mechanism is as follows: (1) When the s_accept interface is called for the first time, the interface returns a handle describing the TCP connection between the client application and the 5G gateway. It should be noted that at this time, the connection has not yet been established and is in the waiting for confirmation (SYN_RECV) state. At the same time, the TCP connection maintained by the s_accept interface mark handle has not yet responded to the SYN / ACK packet to the LAN device protocol stack. The audit / forwarding application obtains the MSS value MSS1 negotiated by the LAN device protocol stack through the handle, compares it with the 5G gateway's own MSS value MSS2, takes the min (MSS1, MSS2) value, and participates in the processing of the s_connect interface.
[0052] (2) After the audit / forwarding application completes the connection establishment with the server through the s_connect interface, it generates a handle describing the TCP connection between the 5G gateway and the Internet server. It extracts the MSS value MSS3 obtained after the negotiation between the 5G gateway and the Internet server from the handle. At this time, it calls the s_accept interface again to pass the handle of the TCP connection between the client application and the 5G gateway. The s_accept interface constructs a SYN / ACK packet with MSS3 based on the mark of the handle in the previous step (1) and sends it to the client, declaring the connection establishment complete without waiting for the three-way handshake to complete.
[0053] It should be noted that the s_accept interface declares that the TCP connection is established without waiting for the three-way handshake to be completed, and it will not cause any abnormality in the working scenario of the 5G gateway. Optionally, the customized protocol stack provided in this application enables a timer for the TCP connection after sending the SYN / ACK packet, and will retransmit the SYN / ACK packet when the expected ACK packet is not received. When the expected ACK packet is received, the TCP connection state will be converted to the established connection (ESTABLISHED) state; when the client application sends data to the 5G gateway afterwards, it will pass the IP and port information of the TCP packet to the TCP connection that needs to receive the data, and pass it to the audit / forwarding application through a callback.
[0054] In this implementation, unlike the accept mechanism of the traditional protocol stack, it does not participate in the MSS negotiation process, but only obtains the connection from the completed connection queue and returns it to the application; the customized accept mechanism provided in this application participates in the MSS negotiation process, notifies the application in steps, and adjusts the formal parameters and execution logic of the function, allowing repeated calls to the customized accept interface for a specified TCP connection and triggering different behaviors based on the connection status.
[0055] As a possible implementation, to achieve transparent auditing / forwarding functionality, this application also provides support for connection association. Specifically, the transport layer protocol processing module is used to maintain hash tables for the network card (such as an Ethernet network card) connected to the local area network in the 5G gateway and the 5G module, respectively, to store connection information between the local area network device and the 5G gateway, and between the 5G gateway and the Internet server.
[0056] In this embodiment, reference is made to Figure 4 The schematic diagram of the five-tuple association shown in the figure shows that, unlike the traditional protocol stack, the protocol stack provided by this application maintains hash tables for the network card and 5G module connected to the local area network through the transport layer protocol processing module, respectively, to store the connection information between the local area network device and the 5G gateway, and between the 5G gateway and the Internet server. After the gateway application interface (for example, based on the aforementioned customized accept mechanism and connect function) establishes connections on both sides (i.e., between the local area network device and the 5G gateway, and between the 5G gateway and the Internet server), the association interface can be used to establish an association between the connections on both sides.
[0057] Taking uplink traffic forwarding as an example, a 5G gateway configured with the protocol stack provided in this application first locates the connection between the LAN device and the 5G gateway by searching the LAN hash table (i.e., the hash table associated with the network card connected to the LAN) and extracts the data to be forwarded; then, the 5G gateway will look for the corresponding associated connection to locate the connection between the 5G gateway and the Internet server, thereby realizing the forwarding function; for the forwarding of downlink traffic, the 5G gateway adopts similar steps.
[0058] Optionally, the transport layer protocol processing module is further configured to perform the following steps: When the LAN end device establishes a connection with the 5G gateway through the network card connected to the LAN, returning a first handle from the LAN end device to the audit / forwarding application through the transport layer interface, and using the first handle as a record in a hash table associated with the network card connected to the LAN, where the first handle is used to maintain the connection between the LAN end device and the 5G gateway; When the Internet server establishes a connection with the 5G gateway through the 5G module, the second handle from the Internet server is returned to the audit / forwarding application through the transport layer interface, and the second handle is used as a record in the hash table associated with the 5G module. The second handle is used to maintain the connection between the Internet server and the 5G gateway.
[0059] In this embodiment, taking the uplink traffic forwarding associated with TCP as an example, the LAN device and the 5G gateway, as well as the 5G gateway and the Internet server will each have a TCP connection, and the TCP connection is an associated connection.
[0060] First, when the LAN device establishes a connection with the 5G gateway, a handle (i.e., the first handle) is returned to the gateway application (i.e., the audit / forwarding application) through the transport layer interface, which is used to maintain the connection between the LAN device and the 5G gateway, corresponding to a record in the LAN hash table (i.e., the hash table associated with the network card connected to the LAN).
[0061] When the gateway application calls the transport layer interface to establish a connection to the Internet server through the 5G module, it will also obtain a handle (i.e., the second handle), which corresponds to a record in the module hash table (i.e., the hash table associated with the 5G module).
[0062] When the connection is established, the gateway application will associate the two handles through a customized interface. When receiving data from the LAN, it will locate the handle related to the LAN connection based on the five-tuple information, and inform the relevant application that LAN data has arrived by triggering an event. The gateway application then obtains the arrived data through the handle and locates the connection between the application to output the data and the 5G gateway by searching for the associated handle. The processing method for data received from the Internet is similar.
[0063] It is understandable that the associated connection is located by the related application calling the related interface. In actual application, a pointer named associated connection is usually placed in the handle structure, so that two associated connections can point to each other to achieve connection association.
[0064] As a possible implementation, the ACK packet reply is not automatically triggered by the protocol stack after receiving the data, but the audit / forwarding application replies to the ACK packet when calling the forwarding function and / or replies to the ACK packet when no data traffic from the other end is found within a set time period.
[0065] In this implementation, taking into account the differences in network quality between the LAN and Internet sides, and to reduce data accumulation on the gateway side, this application designs TCP acknowledgments so that they are no longer automatically triggered by the protocol stack upon data reception. Instead, the gateway application responds with an ACK packet when the forwarding function is called. This ensures that the client on the LAN device is allowed to send more data only when the application has sufficient processing power. Furthermore, this application supports piggybacking, which uses a delayed ACK mechanism, whereby an ACK packet is only responded to when no data traffic from the peer is detected for a period of time.
[0066] As a possible implementation manner, the transport layer protocol processing module is configured to perform at least one of the following operations: Item A-1: Use separate IP:port pools for UDP and TCP; Item A-2: When the 5G gateway closes the connection or receives a reset (RST) packet, the IP:port resources occupied by TCP are recovered; Item A-3: When establishing a UDP node, a timestamp is maintained for it. The timestamp is used to record the time when the UDP message was last received. If the UDP message is not received within the set time threshold, a timeout event is triggered and the audit / forwarding application is notified, so that the audit / forwarding application actively reclaims the UDP node and the corresponding IP:port resources.
[0067] In this embodiment, with respect to item A-1, the present application uses IP:port pools for both UDP and TCP to maintain IP:port resources, and uses independent IP:port pools for TCP and UDP respectively.
[0068] It's important to note that, similar to the aforementioned TCP-related management, UDP-related gateway applications also monitor designated ports. Upon receiving a UDP message (i.e., an uplink UDP packet) from a LAN device, the UDP-related gateway application returns the newly created UDP node and the UDP message content to the gateway application layer via a customized interface. Before forwarding the UDP message, the UDP gateway application also registers the corresponding UDP five-tuple information in the module hash table and establishes a new associated node. During this process, the IP:port pool interface is also used to request module IP:port resources.
[0069] For example, referring to Figure 5 The schematic diagram of the uplink UDP message processing process shown is that after the gateway application receives the LAN UDP message, the transport layer protocol processing module checks whether to listen to the destination port in the UDP message. If the destination port is not listened to, the UDP message is discarded and the process ends.
[0070] When monitoring the destination port, the transport layer protocol processing module checks whether the UDP quintuple exists in the LAN hash table. If the UDP quintuple exists in the LAN hash table, it means that the associated node has been established. Therefore, the transport layer protocol processing module directly submits the UDP message to the gateway application for processing through the corresponding UDP node and ends the process.
[0071] If the UDP quintuple does not exist in the LAN hash table, the gateway application inserts the quintuple into the LAN hash table, and the transport layer protocol processing module returns the newly created UDP node and UDP message to the gateway application through the transport layer interface; then, the gateway application first calls the transport layer interface to establish a UDP node, which is maintained by the module hash table. At the same time, the application gateway establishes an association relationship between the two UDP nodes, and then the UDP message can be forwarded through the aforementioned newly created association node, and the process ends.
[0072] Regarding item A-2, the IP:port resource reclaimed by TCP occurs when the gateway closes the connection or receives an RST packet. For example, when the 5G gateway receives a Finish (FIN) packet from a LAN device and completes the connection closure operation with the LAN device, it calls the close operation to send a FIN packet to the Internet server. During this process, the close operation triggers the reclamation of the corresponding IP:port resource. Furthermore, when the 5G gateway receives an RST packet, it also reclaims the IP:port resource while passing the RST packet to the transport layer. That is, the transport layer protocol processing module calls the IP:port pool interface to reclaim the IP:port resource when receiving a FIN or RST packet.
[0073] Regarding item A-3, this application takes into account that the IP:port and node resource recovery mechanism of UDP should be different from the recovery mechanism related to TCP. Specifically, TCP-based applications will explicitly notify the closure of the connection by sending FIN or RST packets, while UDP does not have a similar mechanism.
[0074] Therefore, when establishing a UDP node, the customized protocol stack of this application will maintain a timestamp for it, which is used to record the time when the last UDP message was received; if the UDP message is not received after the specified time threshold, a timeout event will be triggered to notify the gateway application. At this time, the gateway application will actively recycle the UDP node and the corresponding IP: port resources, and will also release the resources associated with the UDP node during the recycling process.
[0075] As a possible implementation method, in order to precisely control the bandwidth resources of each LAN IP, the customized protocol stack of this application also maintains a LAN IP and flow configuration table. Specifically, the network layer processing module is also used to maintain the LAN IP and flow configuration table, which is used to limit the communication rate of the node corresponding to the LAN IP; The LAN IP and flow configuration table includes different LAN IPs and their corresponding flow control configuration information, and the flow control configuration information includes at least the following information: The token bucket growth rate of the LAN IP, that is, the token generation rate of the LAN IP (maintained separately for the sending and receiving directions); Token bucket capacity; Traffic statistics of the LAN IP in the current sampling period (such as the current number of tokens).
[0076] It can be understood that the token generation rate determines the sustainable average traffic rate of the LAN IP, that is, the maximum throughput that the LAN IP can maintain for a long time; the token bucket capacity determines the upper limit of the instantaneous burst traffic it can accommodate.
[0077] In this embodiment, reference is made to Figure 6 The diagram shows a LAN IP and traffic configuration table, which allows the 5G gateway to finely control and configure the bandwidth resources of the IP layer, and the customized protocol stack can provide a management interface to obtain the LAN IP information currently communicating with the 5G gateway from the LAN IP:port pool; by configuring the LAN IP and traffic configuration table, the communication rate (such as the sending rate, etc.) of the node corresponding to the LAN IP can be accurately limited.
[0078] Specifically, the network layer processing module maintains the LAN IP and traffic configuration table. When a new LAN IP is found to be joining the communication, the network layer processing module will add the IP to the LAN IP and traffic configuration table according to the preset configuration (such as the token generation rate and token bucket capacity), and initialize its traffic control parameters. Afterwards, the traffic statistics of the IP (such as the number of bytes sent / received) are recorded in real time through the input / output traffic counter, and associated with the token consumption logic of the token bucket (1 token corresponds to 1 byte of traffic). The number of tokens is updated once every fixed time period (for example, 100 milliseconds) (token number = token generation rate × time interval + token balance after the end of the previous period, and not greater than the token bucket capacity).
[0079] Optionally, the network layer processing module maintains a timer for each record in the LAN IP and traffic configuration table. If no new traffic is found for a relatively long time, the record will be released, wherein the record-related timeout period is not less than the TCP keep-alive timer timeout period.
[0080] Optionally, for the customized protocol stack of this application, the TCP keepalive timer expiration time is a configurable item. When no traffic is detected after the TCP connection times out, the customized protocol stack sends an ACK packet to the peer end, with the following characteristics: (1) The payload is empty (i.e., a data packet with a length of zero); (2) Seq is the normal data sequence number that should be sent next time by this TCP connection minus 1; (3) Ack is the next sequence number expected to be received.
[0081] After receiving this characteristic ACK packet, the peer protocol stack will reply with an ACK packet if the connection status is normal. The characteristics are: (1) The payload is empty (i.e., a data packet with a length of zero); (2) Seq is the next sequence number that the TCP connection expects to receive; (3) Ack is the normal data sequence number to be sent next time.
[0082] It is understandable that, considering that some traffic will be filtered by the transport layer protocol processing module (for example, TCP traffic that cannot match the five-tuple is received), the transport layer protocol processing module will call the interface of the network layer processing module to subtract the traffic discarded by it to ensure the accuracy of the statistical results.
[0083] When the customized protocol stack is started, the maximum allowed input and output throughput will be determined based on the configuration information. When creating a new TCP connection and UDP node, the bandwidth resources of the corresponding LAN IP need to be occupied. The customized protocol stack provided in this application can access the LAN IP and traffic configuration table to determine whether there are sufficient bandwidth resources for creating new TCP connections and UDP nodes; at the same time, apply for corresponding bandwidth resources for TCP connections and UDP nodes. The bandwidth resources occupied by TCP connections and UDP nodes are determined based on pre-configuration and service type (determined by the destination port).
[0084] After the transport layer protocol processing module applies for bandwidth resources, the TCP connection and UDP node will also periodically increase the number of tokens according to the flow control configuration information to control the bandwidth they occupy. Taking uplink traffic as an example, when the data of the client application of the LAN device reaches the 5G gateway, the transport layer protocol processing module will first detect the number of tokens of the TCP connection or UDP node to determine whether the data can be stored in the receiving cache of the TCP connection or UDP node between the LAN application and the 5G gateway. If the data is discarded due to insufficient tokens, the LAN device protocol stack is responsible for retransmission. Before forwarding data, the transport layer protocol processing module will first detect the number of tokens of the TCP connection or UDP node from the 5G gateway to the server application to determine whether the data can be stored in the sending cache of the corresponding TCP connection or UDP node maintained by the 5G gateway, thereby limiting the sending rate of the corresponding TCP connection or UDP node. For downlink traffic, the processing results are similar.
[0085] As a possible implementation method, based on business requirements and working environment, this application further customizes the behavior of TCP to adapt to the special working environment of 5G gateways. Specifically, the transport layer protocol processing module is also used to perform at least one of the following operations for TCP: B-1: Ensure that data fragmentation does not occur on the 5G gateway side during traffic forwarding, and maintain consistency in TCP option configuration on the sending and receiving sides; Item B-2: After receiving a SYN packet from the LAN device protocol stack, construct a SYN packet to be sent to the Internet server based on its (i.e., the LAN device protocol stack) TCP option configuration, adjust the MSS value announced to the Internet server from MSS1 to MSS2, maintain the announcement window Win1 of the LAN device protocol stack unchanged, and self-generate a sequence number Seq, where MSS2 is equal to the smaller value of MSS1 and the MSS value allowed by the 5G module and the USB host controller, that is, MSS2 = min(MSS1, MSS value allowed by the module and the USB host controller); Item B-3: upon receiving a SYN / ACK packet from the Internet server, obtaining the negotiated MSS value MSS3, constructing a SYN / ACK packet returned to the protocol stack of the LAN device using MSS3, maintaining the Internet server's notification window Win2 unchanged, and generating Seq on its own, wherein MSS3 is equal to the smaller value of MSS2 and the MSS value allowed by the Internet server, i.e., MSS3 = min(MSS2, the MSS value allowed by the Internet server); Item B-4: During the process of establishing a connection between the client application on the LAN device and the audit / forwarding application, and between the audit / forwarding application and the server application, record the Seq, Ack, and checksum information of the SYN packets, SYN / ACK packets, and ACK packets generated during the handshake on both sides to obtain upstream and downstream offset information. This information will be used in the subsequent accelerated forwarding process to support the accelerated forwarding function of the transport layer protocol processing module (i.e., the function of forwarding data based on the acceleration mechanism); Item B-5: When the LAN device protocol stack and the protocol stack applied to the 5G gateway (i.e., the 5G gateway customized protocol stack) perform a three-way handshake, and when the 5G gateway customized protocol stack and the Internet server protocol stack perform a three-way handshake, the Seq, Ack, and Checksum information of the SYN packet, SYN / ACK packet, and ACK packet generated during the handshake are recorded to obtain the offset information of the upstream and downstream flows, and the IP address and port number are changed when forwarding data, and the Seq, Ack, and Checksum information are changed according to the offset information; Item B-6: After the connection is established, executing a target cache behavior; wherein the target cache behavior includes at least one of the following: adding data to a receive cache upon receipt; clearing the relevant portion of the data from the receive cache upon reading the data by the relevant application; releasing the acknowledged data from the send cache upon receiving an ACK packet; Item B-7: Maintain a timeout retransmission timer for the TCP connection and activate the timeout retransmission timer when writing data to the sending queue.
[0086] In this embodiment, with respect to items B-4 and B-5, it should be noted that the SYN packet, SYN / ACK packet, and ACK packet are TCP packets generated by the three-way handshake, and all TCP packets contain Seq, Ack, and Checksum information. For example, the ACK packet (which is used to confirm the data that has been sent) itself also contains Seq, Ack, and Checksum information.
[0087] Reference Figure 7 The diagram shows the process of establishing a new connection and forwarding data. Considering that the 5G gateway does not change the data content when acting as a proxy, only the TCP header and IP header need to be changed during the forwarding process. That is, the required changes include: IP address and port number, as well as Seq, Ack and Checksum information; among them, the traffic transferred from the LAN to the Internet will change the source IP and source port, and the traffic transferred from the Internet to the LAN will change the destination IP and destination port.
[0088] Since the information of IP:port resources can be obtained directly from the five-tuple corresponding to the TCP connection, the protocol stack designed in this application will record the Seq, Ack and Checksum information of the SYN packet, SYN / ACK packet and ACK packet generated during the three-way handshake between the LAN device protocol stack and the 5G gateway customized protocol stack, and between the 5G gateway customized protocol stack and the Internet server protocol stack, so as to obtain the offset information of the upstream and downstream flows. Therefore, when forwarding data, the Seq, Ack and Checksum information can be changed according to the relevant offset information, thereby reducing the forwarding overhead.
[0089] For example, Figure 7 As shown, the downstream offset is generated after packet 5 is processed, and is used to quickly generate Seq, Ack, and Checksum when forwarding traffic from the LAN end device to the Internet server; the upstream offset is generated after packet 6 is processed, and is used to quickly generate Seq, Ack, and Checksum when forwarding traffic from the Internet server to the LAN end device, thereby reducing the processing overhead of TCP packets.
[0090] Regarding item B-6, this application designs that the transport layer protocol processing module maintains the send cache and receive cache, and is consistent with related technologies, both are organized in a linked list manner. Regarding the receive cache behavior, this application designs that the transport layer protocol processing module adds data to the receive cache when it receives it; when the application reads data, it clears the read part; and the send cache releases the confirmed data after the transport layer protocol processing module receives the ACK packet. If all data is confirmed, the send cache is cleared.
[0091] Regarding item B-7, this application designs the timeout retransmission of forwarded data packets to be implemented by the transport layer protocol processing module in the protocol stack, so that it can correctly process data outside the receiving window, thereby providing a continuous byte stream reading interface for the application.
[0092] Optionally, the cancellation of the timeout retransmission timer includes: before the timeout occurs, the transport layer protocol processing module receives an ACK packet that can release all the sending queues, so that the sending queue is empty; the triggering condition of the timeout retransmission timer includes: when the timeout occurs, the transport layer protocol processing module fails to receive an ACK packet that can release all the sending queues; The transport layer protocol processing module is further configured to perform the following operations after the timeout retransmission timer is triggered: Submit the data in the sending queue to the Ethernet network card driver or 5G module driver in sequence, then re-drive the timeout retransmission timer and maintain the number of triggers; If the number of consecutive triggers exceeds the preset number, it is determined that the destination address corresponding to the relevant TCP connection is unreachable, the event that the destination address corresponding to the relevant TCP connection is unreachable is reported to the relevant application, and the resources occupied by the relevant TCP connection are reclaimed.
[0093] In this implementation, the transport layer protocol processing module is responsible for sequentially delivering data in the send queue to the driver via the IP layer interface. It then re-activates the timeout retransmission timer and maintains the trigger count. If the number of consecutive triggers exceeds a preset number, the destination corresponding to the TCP connection is deemed unreachable, the event is reported to the relevant application, and the resources occupied by the connection are reclaimed. The relevant application is also responsible for calling the transport layer interface to close the associated connection and reclaim its occupied resources.
[0094] Based on the above embodiments, on the ubiquitous computing platform, based on the highly customizable characteristics of both the operating system and the supporting modules, this application provides a customized TCP / IP protocol stack for the 5G gateway. This protocol stack can enable local area network devices to connect to the 5G gateway through the LAN network and then access the Internet, and at the same time support client applications on the 5G gateway to access the Internet; and it also supports precise flow control, low-overhead data forwarding, and IP: port mapping functions. This customized protocol stack provides a protocol stack interface dedicated to the gateway and a traditional socket interface to adapt to the various application scenarios in which the 5G gateway works; in addition, this customized protocol stack also enables the 5G gateway to implement a fine-grained flow control mechanism based on IP, and can set independent flow control strategies for different connections under the same IP.
[0095] It should be noted that for the method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present application are not limited by the order of the actions described, because according to the embodiments of the present application, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present application.
[0096] The present application also provides a 5G gateway. Figure 8 As shown, the 5G gateway includes: an audit / forwarding application, a client application, an Ethernet network card driver, a 5G module driver, an Ethernet network card, a USB host controller driver, a 5G module, and a protocol stack applied to the 5G gateway as described in the above embodiment. The protocol stack is connected to the audit / forwarding application, the client application, the Ethernet network card driver, and the 5G module driver, respectively, wherein: The Ethernet network card driver is used to manage and use the Ethernet network card; The 5G module driver is used to manage and use the 5G module through the USB host controller driver.
[0097] A hardware device driver is a set of software developed by hardware manufacturers for a specific operating system, enabling the operating system to manage and use the relevant hardware devices. For example, an Ethernet network card driver primarily enables the operating system to manage the Ethernet card and send and receive Ethernet packets through the Ethernet card (i.e., using the Ethernet card through the Ethernet network card driver). The same applies to 5G module drivers, so we won't go into detail here.
[0098] It's important to note that, considering that traditional protocol stacks are primarily designed for client and server models, while the Linux kernel has enhanced protocol stack functionality, such as the Transparent Proxy (TPROXY) feature, which, through the coordination of routing tables and the protocol stack, enables the Linux protocol stack in gateway scenarios to establish a connection with the client as a server, and then with the server, thereby generating two independent, yet business-related TCP connections within the kernel, this traditional approach, however, is relatively costly for the operational scenarios and business requirements of 5G gateways. For example, business-related TCP connections are completely independent within the protocol stack, failing to fully utilize the business-related features.
[0099] To this end, the customized protocol stack of this application has made a number of improvements based on the working scenarios and business requirements of the 5G gateway, mainly including: Low-overhead forwarding; Acknowledge receipt when forwarding to implicitly reduce the sender rate when processing capacity is insufficient; Maintaining TCP send and receive queues to ensure byte stream semantics, thus resolving the problem that TCP splicing cannot ensure byte stream semantics, which makes audit applications difficult. Related mechanisms for implementing refined flow control.
[0100] Therefore, the customized protocol stack of this application and the 5G gateway equipped with the customized protocol stack can better adapt to the working scenarios of the 5G gateway and meet the business needs of the 5G gateway.
[0101] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0102] Those skilled in the art will appreciate that the embodiments of the present application can be provided as methods, devices, or computer program products. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to magnetic disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0103] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, systems, devices, storage media, and program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0104] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.
[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0106] Finally, it should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprises," "includes," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or terminal device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or elements that are inherent to such process, method, article, or terminal device. In the absence of further restrictions, an element defined by the phrase "comprises a ..." does not exclude the presence of additional identical elements in the process, method, article, or terminal device that includes the element.
[0107] The above is a detailed introduction to a protocol stack and a 5G gateway provided by the present application for application to a 5G gateway. This article uses specific examples to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of the present application; at the same time, for those skilled in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. A protocol stack applied to a 5G gateway, characterized in that: The protocol stack includes a gateway application interface, a socket interface, a transport layer protocol processing module and a network layer processing module; the transport layer protocol processing module is connected to the gateway application interface and the socket interface through an internally provided transport layer interface, and the network layer processing module is connected to the transport layer protocol processing module through an internally provided IP:port pool interface and an IP processing interface respectively; wherein: The gateway application interface is used to serve the audit / forwarding application of the 5G gateway; The socket interface is used to serve the client application of the 5G gateway itself; The network layer processing module is used to process the traffic from the transport layer protocol processing module and the traffic from the Ethernet network card driver and 5G module driver of the 5G gateway; The IP:port pool interface is used to uniformly manage IP:port resources for use by the 5G gateway and the LAN end devices connected to the 5G gateway.
2. The protocol stack according to claim 1, wherein: The transport layer protocol processing module is used to maintain hash tables for the network card and 5G module connected to the local area network in the 5G gateway, so as to save the connection information between the local area network device and the 5G gateway and between the 5G gateway and the Internet server.
3. The protocol stack according to claim 2, wherein: The transport layer protocol processing module is further configured to perform the following steps: When the LAN end device establishes a connection with the 5G gateway through the network card connected to the LAN, returning a first handle from the LAN end device to the audit / forwarding application through the transport layer interface, and using the first handle as a record in a hash table associated with the network card connected to the LAN, where the first handle is used to maintain the connection between the LAN end device and the 5G gateway; When the Internet server establishes a connection with the 5G gateway through the 5G module, the second handle from the Internet server is returned to the audit / forwarding application through the transport layer interface, and the second handle is used as a record in the hash table associated with the 5G module. The second handle is used to maintain the connection between the Internet server and the 5G gateway.
4. The protocol stack according to claim 1, wherein: The transport layer protocol processing module is configured to perform at least one of the following operations: Use separate IP:port pools for User Datagram Protocol (UDP) and Transmission Control Protocol (TCP); When the 5G gateway closes the connection or receives a reset RST packet, the IP:port resources occupied by TCP are recovered; When a UDP node is established, a timestamp is maintained for it. The timestamp is used to record the time when the last UDP message was received. If the UDP message is not received within the set time threshold, a timeout event is triggered and the audit / forwarding application is notified, so that the audit / forwarding application actively reclaims the UDP node and the corresponding IP: port resources.
5. The protocol stack according to claim 1, wherein: The network layer processing module is further used to maintain a local area network IP and flow configuration table, wherein the local area network IP and flow configuration table is used to limit the communication rate of the node corresponding to the local area network IP; The LAN IP and flow configuration table includes different LAN IPs and their corresponding flow control configuration information, and the flow control configuration information includes at least the following information: Token bucket growth rate of LAN IP; Token bucket capacity; Traffic statistics of the LAN IP address during the current sampling period.
6. The protocol stack according to claim 1, wherein: The ACK packet reply of the confirmation response flag is not automatically triggered by the protocol stack after receiving the data, but is replied by the audit / forwarding application when calling the forwarding function and / or when no data traffic from the other end is found within the set time.
7. The protocol stack according to claim 1, wherein: The transport layer protocol processing module is configured with a customized accept mechanism for performing the following steps: After receiving the SYN packet, the s_accept interface is immediately called to notify the audit / forwarding application to process, so that the audit / forwarding application sends a connection establishment request to the application in the Internet server as a client. The s_accept interface is a customized accept interface. After obtaining the TCP configuration item information from the Internet server, the s_accept interface is called again to reply a SYN / ACK packet to the LAN device protocol stack and establish an associated connection to implement transparent auditing / forwarding functions; And / or, the transport layer interface is configured with a customized connection mechanism for performing at least one of the following operations: When the audit / forwarding application creates a new connection through the s_connect interface, it obtains an unoccupied module IP:port resource through the IP:port pool interface and builds a connection based on the port therein. The s_connect interface is a customized connect interface. Receive the maximum message length MSS value passed by the audit / forwarding application when calling the s_connect interface according to the working environment.
8. The protocol stack according to any one of claims 1 to 7, characterized in that: The transport layer protocol processing module is further configured to perform at least one of the following operations for TCP: Ensure that data fragmentation does not occur on the 5G gateway side during traffic forwarding, and maintain consistency in TCP option configuration on the sending and receiving sides; After receiving the SYN packet from the LAN device protocol stack, construct a SYN packet to be sent to the Internet server protocol stack according to its TCP option configuration, adjust the MSS value announced to the Internet server from MSS1 to MSS2, keep the announcement window Win1 of the LAN device protocol stack unchanged, and generate a sequence number Seq by itself, where MSS2 is equal to the smaller value of MSS1 and the MSS value allowed by the 5G module and the USB host controller; Upon receiving a SYN / ACK packet from the Internet server protocol stack, obtaining the negotiated MSS value MSS3, constructing a SYN / ACK packet returned to the LAN device protocol stack using MSS3, maintaining the notification window Win2 of the Internet server protocol stack unchanged, and generating Seq on its own, wherein MSS3 is equal to the smaller value of MSS2 and the MSS value allowed by the Internet server protocol stack; During the process of establishing a connection between the LAN client application and the audit / forwarding application, and between the audit / forwarding application and the Internet server, the Seq, acknowledgment number Ack, and checksum information of the SYN packet, SYN / ACK packet, and ACK packet generated during the handshake process on both sides are recorded to obtain upstream and downstream offset information, wherein the offset information is used to support the accelerated forwarding function of the transport layer protocol processing module; When the LAN device protocol stack and the protocol stack applied to the 5G gateway, and the protocol stack applied to the 5G gateway and the Internet server protocol stack perform a three-way handshake, respectively record the Seq, Ack, and checksum of the SYN packet, SYN / ACK packet, and ACK packet generated in the handshake process to obtain the offset information of the upstream and downstream flows, and change the IP address and port number when forwarding data, and change the Seq, Ack, and checksum information according to the offset information; After the connection is established, the target cache behavior is executed; Maintain a timeout retransmission timer for the TCP connection and activate the timeout retransmission timer when writing data to the send queue; The target cache behavior includes at least one of the following: When data is received, it is added to the receive buffer; When the relevant application reads data, the relevant part of the reading is cleared in the receiving buffer; After receiving the ACK packet, the confirmed data in the send buffer is released.
9. The protocol stack according to claim 8, wherein: The cancellation condition of the timeout retransmission timer includes: before the timeout occurs, the transport layer protocol processing module receives an ACK packet that can release all the sending queues; the triggering condition of the timeout retransmission timer includes: when the timeout occurs, the transport layer protocol processing module fails to receive an ACK packet that can release all the sending queues; The transport layer protocol processing module is further configured to perform the following operations after the timeout retransmission timer is triggered: Submit the data in the sending queue to the Ethernet network card driver or 5G module driver in sequence, then re-drive the timeout retransmission timer and maintain the number of triggers; If the number of consecutive triggers exceeds the preset number, it is determined that the destination address corresponding to the relevant TCP connection is unreachable, the event that the destination address corresponding to the relevant TCP connection is unreachable is reported to the relevant application, and the resources occupied by the relevant TCP connection are reclaimed.
10. A 5G gateway, characterized in that: The 5G gateway includes: an audit / forwarding application, a client application, an Ethernet network card driver, a 5G module driver, an Ethernet network card, a USB host controller driver, a 5G module, and a protocol stack applied to the 5G gateway according to any one of claims 1 to 9, wherein the protocol stack is respectively connected to the audit / forwarding application, the client application, the Ethernet network card driver, and the 5G module driver, wherein: The Ethernet network card driver is used to manage and use the Ethernet network card; The 5G module driver is used to manage and use the 5G module through the USB host controller driver.
