Network access method, computing device and computing device cluster
By modifying the type parameters and IP addresses of socket creation requests and connection requests in the computing device, and using the address mapping relationship, mutual access between IPv4 and IPv6 is realized, solving the problem of high complexity in the dual-stack support in the existing technology. Simplifies network access logic and promotes IPv6 promotion.
Patent Information
- Application Number
- CN202310954685.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-05-05
- Filing Date
- 2023-07-31
- Publication Date
- 2024-11-05
AI Technical Summary
When the existing network access method supports IPv4 and IPv6 dual stacks, it is necessary to make code logic judgment and modification based on the address scenario, which increases the code complexity, resulting in difficulty in promoting IPv6 and making it difficult to achieve mutual access between IPv4 and IPv6.
By receiving socket creation requests and connection requests in the computing device, the type parameters and IP addresses are modified, and the preset address mapping relationship is converted to ensure the protocol stack matching and network mutual access between IPv4 and IPv6 is realized.
It simplifies the code logic, reduces complexity, realizes mutual access between IPv4 and IPv6, supports network access between devices with different protocol stacks, and promotes IPv6 promotion.
Smart Images

Figure CN118900289A_ABST
Abstract
Description
[0001] CROSS-REFERENCE TO RELATED APPLICATIONS
[0002] This application claims priority to the Chinese patent application filed with the Intellectual Property Office of the People's Republic of China on May 5, 2023, with application number 202310497837.0 and invention name "A Network Access Method", the entire contents of which are incorporated by reference in this application. Technical Field
[0003] The present application relates to the field of computer technology, and in particular to a network access method, a computing device, and a computing device cluster. Background Art
[0004] With the development of Internet Protocol (IP), the addresses of Internet Protocol version 4 (IPv4) have been exhausted, and Internet Protocol version 6 (IPv6) has become the mainstream network protocol.
[0005] However, since the IPv4 network has been developed for decades, most services only support IPv4 and have not considered supporting IPv6. If the services that currently support IPv4 are to support IPv6, it is necessary to modify the current massive services, which is difficult to achieve. At the same time, with the expansion of cloud services, the number of containers far exceeds the number of virtual machines. In order to meet their address requirements, IPv6 addresses need to be allocated to containers. However, most of the existing services use IPv4 addresses, which requires a technology that supports mutual access between IPv4 and IPv6 so as not to affect the normal operation of current services.
[0006] In the current network access method, if you want to support IPv4 and IPv6 dual stacks, you need to make judgments based on the address scenario in the code logic and modify the existing code according to different protocol stack scenarios. This will increase the complexity of the code and make it difficult to promote IPv6. Summary of the invention
[0007] The present application provides a network access method, a computing device, and a computing device cluster for implementing network mutual access between devices supporting different protocol stacks.
[0008] In the first aspect, the present application provides a network access method, which can be executed by a first computing device or a kernel state in the first computing device. In the method, the first computing device receives a first socket creation request initiated by a target application, the first socket creation request is used to request the creation of a socket for accessing a target application in a second computing device; the first computing device modifies the type parameter of the first socket creation request, and creates a socket based on the modified type parameter; the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the second computing device; the first computing device receives a connection request initiated by the target application, the connection request is used to request to establish a connection with the second computing device, and the connection request includes a first Internet Protocol IP address; the first IP address in the connection request is modified to a second IP address according to a preset address mapping relationship; the first IP address belongs to the first protocol stack, and the second IP address is the IP address of the second computing device under the second protocol stack supported by the second computing device; the first computing device establishes a connection with the second computing device based on the socket and the connection request.
[0009] In the above method, the first computing device can modify the type parameter of the socket when receiving the socket creation request of the target application, thereby generating a socket that matches the protocol stack supported by the second computing device, and the first computing device modifies the peer IP address in the connection request initiated by the target application to the IP address under the actual protocol stack of the second computing device, ensuring that the first computing device can establish a connection with the second computing device based on the accurate IP address, thereby realizing the network access of the first computing device to the second computing device.
[0010] In a possible design, after creating a socket based on the modified type parameter and before receiving a connection request initiated by the target application, the method further includes: receiving an address binding request initiated by the target application, the address binding request including a third IP address; modifying the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship; binding the fourth IP address and the socket according to the address binding request; wherein the third IP address belongs to the first protocol stack, and the fourth IP address is the IP address of the first computing device under the second protocol stack;
[0011] The establishing a connection with the second computing device based on the socket and the connection request includes: establishing a connection with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
[0012] Through this design, after receiving the address binding request, the first computing device can modify the local IP address in the address binding request to a local IP address belonging to the protocol stack supported by the second computing device, so that the first computing device can establish a connection with the second computing device based on the modified local IP address, and then successfully access the second computing device.
[0013] In one possible design, after receiving the address binding request initiated by the target application, before modifying the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship, the method also includes: determining that the preset address mapping relationship includes a mapping relationship between the third IP address and the fourth IP address.
[0014] Through this design, when the first computing device determines that the preset address mapping relationship includes the mapping relationship between the third IP address and the fourth IP address, it can modify the third IP address in the address binding request according to the mapping relationship between the third IP address and the fourth IP address, thereby ensuring the accuracy of the network address conversion.
[0015] In one possible design, establishing a connection with the second computing device based on the socket and the connection request includes: selecting a fourth IP address from multiple IP addresses of the first computing device, the fourth IP address and the second IP address belonging to the same protocol stack; establishing a connection with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
[0016] Through this design, if the first computing device does not receive the address binding request sent by the target application, the first computing device can select the fourth IP address when establishing a connection with the second computing device, and establish a connection with the second computing device based on the fourth IP address. The fourth IP address and the second IP address belong to the same protocol stack, so that the network connection can be correctly established, ensuring the accuracy of network access.
[0017] In one possible design, after receiving a first socket creation request initiated by a target application and before modifying a type parameter of the first socket creation request, the method further includes: determining that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0018] Through this design, a list of applications that require network address translation can be stored in advance in the first computing device, so that the first computing device can monitor the applications in the application list and perform socket type conversion and network address translation in a timely manner.
[0019] In a possible design, the preset application list is system preconfigured or user-defined; the preset address mapping relationship is system preconfigured or user-defined.
[0020] Through this design, the system can pre-configure applications that need network address translation, or users can select applications that need network address translation. The preset address mapping relationship can also be pre-configured by the system or customized by the user, which improves the flexibility of network access methods.
[0021] In one possible design, after receiving a connection request initiated by the target application, before modifying the first IP address in the connection request to the second IP address according to a preset address mapping relationship, the method also includes: determining that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0022] Through this design, when the first computing device determines that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address, it can modify the first IP address in the connection request according to the mapping relationship between the first IP address and the second IP address, thereby ensuring the accuracy of the network address conversion.
[0023] In one possible design, after establishing a connection with the second computing device based on the socket and the connection request, the method further includes: performing system call processing according to the second IP address; the system call processing includes reading a message from the second computing device, and / or sending a message to the second computing device.
[0024] Through this design, the network access method provided in this application can correctly establish a network connection between the first computing device and the second computing device, thereby realizing message transmission between the first computing device and the second computing device.
[0025] In one possible design, the first protocol stack is an IPv4 protocol stack and the second protocol stack is an IPv6 protocol stack; or the first protocol stack is an IPv6 protocol stack and the second protocol stack is an IPv4 protocol stack.
[0026] Through this design, network mutual access between the first computing device and the second computing device under different protocol stacks can be achieved, which is beneficial to the promotion and application of the IPv4 protocol.
[0027] In the second aspect, the present application provides a network access method, which can be executed by a second computing device or a kernel state in the second computing device. In the method, the second computing device receives a second socket creation request initiated by a target application, the second socket creation request is used to request the creation of a socket for monitoring messages sent by a target application in other devices; the type parameter of the second socket creation request is modified, and a socket is created based on the modified type parameter; the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the first computing device corresponding to the target application; the second computing device receives an address binding request initiated by the target application in the second computing device, the address binding request includes a first server Internet Protocol IP address; the second computing device modifies the first IP address in the address binding request to a second IP address according to a preset address mapping relationship; the first IP address belongs to the first protocol stack, and the second IP address is the IP address of the second computing device under the second protocol stack; the second protocol stack is the protocol stack supported by the first computing device corresponding to the target application; the second computing device binds the socket and the second IP address according to the address binding request.
[0028] In the above method, the second computing device can modify the type parameter of the socket when receiving the socket creation request of the target application, thereby generating a socket that matches the protocol stack of the first computing device, and the second computing device modifies the local IP address in the address binding request initiated by the target application to an IP address under the protocol stack supported by the first computing device, thereby ensuring that the second computing device can accept network access from the first computing device based on the accurate IP address.
[0029] In one possible design, after receiving a second socket creation request initiated by a target application and before modifying a type parameter of the second socket creation request, the method further includes: determining that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0030] In a possible design, the preset application list is system preconfigured or user-defined; the preset address mapping relationship is system preconfigured or user-defined.
[0031] In one possible design, after receiving an address binding request initiated by a target application in the second computing device, and before modifying the first IP address in the address binding request to a second IP address according to a preset address mapping relationship, the method further includes: determining that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0032] In one possible design, after binding the socket and the second IP address according to the address binding request, the method further includes: performing system call processing according to the second IP address; the system call processing includes reading a message from the first computing device of the target application, and / or sending a message to the first computing device of the target application.
[0033] In one possible design, the first protocol stack is an IPv4 protocol stack and the second protocol stack is an IPv6 protocol stack; or the first protocol stack is an IPv6 protocol stack and the second protocol stack is an IPv4 protocol stack.
[0034] In a third aspect, the present application provides a network access method, which can be executed by a first computing device or in the kernel state of the first computing device, such as the method can be executed by the first computing device. In this method, the first computing device receives a first socket creation request initiated by a target application, the first socket creation request is used to request the creation of a socket for accessing a target application in a second computing device; the first computing device creates a first socket according to the first socket creation request; the first computing device receives a connection request initiated by the target application in the first computing device, the connection request is used to request to establish a connection with the second computing device, the connection request includes a first server Internet Protocol IP address; the first IP address belongs to a first protocol stack; the first computing device determines that a preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address; the second IP address is the IP address of the second computing device under the second protocol stack supported by the second computing device; the first computing device The computing device closes the first socket and generates a third socket creation request, the index of the third socket creation request is the same as the index of the first socket creation request, and the type parameter of the third socket creation request is different from the type parameter of the first socket creation request, and the protocol stack corresponding to the type parameter of the third socket creation request is the same as the protocol stack supported by the second computing device; the first computing device creates a second socket according to the third socket creation request; the first computing device modifies the first IP address in the connection request to the second IP address according to the preset address mapping relationship; the protocol stack to which the second IP address belongs is the same as the protocol stack supported by the second computing device; the first computing device establishes a connection with the second computing device based on the second socket and the connection request.
[0035] In the above method, when the first computing device supports dual stack, when the first computing device determines that the preset address mapping relationship includes the target IP address requested by the connection request, it generates a new socket creation request and converts the IP address of the second computing device, thereby ensuring that the first computing device can accurately identify the business that requires network address translation and establish a connection with the second computing device based on the accurate IP address.
[0036] In a possible design, before generating the third socket creation request, the method further includes: determining that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0037] In a possible design, the preset application list is system preconfigured or user-defined; the preset address mapping relationship is system preconfigured or user-defined.
[0038] In one possible design, after establishing a connection with the second computing device based on the second socket and the connection request, the method further includes: performing system call processing based on the second IP address; the system call processing includes reading a message from the second computing device, and / or sending a message to the second computing device.
[0039] In one possible design, generating the third socket creation request includes: generating socket creation requests in sequence according to the index arrangement order until the third socket creation request is generated.
[0040] Through this design, since the kernel always assigns the process with the smallest index in the current process, the first computing device can generate a socket creation request once until a third socket creation request with the same index as the first socket creation request is generated, thereby not affecting the normal business of the target application and ensuring the normal operation of the network access business.
[0041] In a fourth aspect, the present application provides a computing device, comprising a kernel network module, for receiving a first socket creation request initiated by a target application, the first socket creation request being used to request the creation of a socket for accessing a target application in a second computing device; a conversion module, for modifying a type parameter of the first socket creation request, the protocol stack corresponding to the modified type parameter being the same as the protocol stack supported by the second computing device; the kernel network module is also used to create a socket based on the modified type parameter; receiving a connection request initiated by the target application, the connection request being used to request a connection with the second computing device, the connection request including a first Internet Protocol IP address, the first IP address belonging to a first protocol stack; the conversion module is also used to modify the first Internet Protocol IP address in the connection request to a second IP address according to a preset address mapping relationship; the second IP address is the IP address of the second computing device under a second protocol stack supported by the second computing device; the kernel network module is also used to establish a connection with the second computing device based on the socket and the connection request.
[0042] In one possible design, the kernel network module is also used to: after creating a socket based on the modified type parameters and before receiving a connection request initiated by the target application, receive an address binding request initiated by the target application, the address binding request including a third IP address, and the third IP address belongs to the first protocol stack; the conversion module is also used to: modify the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship; the fourth IP address is the IP address of the first computing device under the second protocol stack; the kernel network module is also used to: bind the fourth IP address and the socket according to the address binding request; when the kernel network module establishes a connection with the second computing device based on the socket and the connection request, it is specifically used to: establish a connection with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
[0043] In one possible design, the conversion module is also used to: after receiving the address binding request initiated by the target application, before modifying the third IP address in the address binding request to the fourth IP address according to the preset address mapping relationship, determine that the preset address mapping relationship includes a mapping relationship between the third IP address and the fourth IP address.
[0044] In one possible design, the kernel network module is specifically used to: select a fourth IP address from multiple IP addresses of the first computing device, and the fourth IP address and the second IP address belong to the same protocol stack; establish a connection with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
[0045] In one possible design, the conversion module is also used to: after receiving a first socket creation request initiated by a target application, before modifying a type parameter of the first socket creation request, determine that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0046] In one possible design, the conversion module is also used to: before modifying the first server Internet Protocol IP address in the connection request to the second IP address according to a preset address mapping relationship, determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0047] In one possible design, the kernel network module is also used to: after establishing a connection with the second computing device based on the socket and the connection request, perform system call processing according to the second IP address; the system call processing includes reading messages from the second computing device, and / or sending messages to the second computing device.
[0048] In one possible design, the first IP address and the third IP address belong to the IPv4 protocol stack, and the second IP address and the fourth IP address belong to the IPv6 protocol stack; or the first IP address and the third IP address belong to the IPv6 protocol stack, and the second IP address and the fourth IP address belong to the IPv4 protocol stack.
[0049] In a fifth aspect, the present application provides a computing device, which includes: a kernel network module, used to receive a second socket creation request initiated by a target application, the second socket creation request is used to request the creation of a socket for listening to messages sent by the target application in other devices; a conversion module, used to modify the type parameter of the second socket creation request, the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the first computing device corresponding to the target application; the kernel network module is also used to create a socket based on the modified type parameter; receive an address binding request initiated by the target application, the address binding request includes a first server Internet Protocol IP address; the conversion module is also used to modify the first IP address in the address binding request to a second IP address according to a preset address mapping relationship; the first IP address belongs to the first protocol stack, and the second IP address is the IP address of the second computing device under the second protocol stack; the second protocol stack is a protocol stack supported by the first computing device corresponding to the target application; the kernel network module is also used to bind the socket and the second IP address according to the address binding request.
[0050] In one possible design, the conversion module is also used to: after receiving a second socket creation request initiated by the target application and before modifying the type parameter of the second socket creation request, determine that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0051] In one possible design, the conversion module is also used to: after receiving the address binding request initiated by the target application, before modifying the first IP address in the address binding request to the second IP address according to a preset address mapping relationship, determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0052] In one possible design, the kernel network module is also used to: after binding the socket and the second IP address according to the address binding request, perform system call processing according to the second IP address; the system call processing includes reading a message from the first computing device of the target application, and / or sending a message to the first computing device of the target application.
[0053] In one possible design, the first IP address belongs to the IPv4 protocol stack and the second IP address belongs to the IPv6 protocol stack; or the first IP address belongs to the IPv6 protocol stack and the second IP address belongs to the IPv4 protocol stack.
[0054] In a sixth aspect, the present application provides a computing device, the computing device comprising: a kernel network module, for receiving a first socket creation request initiated by a target application, the first socket creation request being used to request the creation of a socket for accessing a target application in a second computing device; creating a first socket according to the first socket creation request; receiving a connection request initiated by the target application, the connection request being used to request the establishment of a connection with the second computing device, the connection request comprising a first server Internet Protocol IP address, the first IP address belonging to a first protocol stack; determining that a preset address mapping relationship includes a mapping relationship between the first IP address and a second IP address, the second IP address being the IP address of the second computing device under a second protocol stack supported by the second computing device; closing the The first socket is used to generate a third socket creation request, the index of the third socket creation request is the same as the index of the first socket creation request, and the type parameter of the third socket creation request is different from the type parameter of the first socket creation request, and the protocol stack corresponding to the type parameter of the third socket creation request is the same as the protocol stack supported by the second computing device; create a second socket according to the third socket creation request; a conversion module is used to modify the first IP address in the connection request to a second IP address according to the preset address mapping relationship; the protocol stack to which the second IP address belongs is the same as the protocol stack supported by the second computing device; the kernel network module is also used to: establish a connection with the second computing device based on the second socket and the connection request.
[0055] In a possible design, the conversion module is further used to: before generating the third socket creation request, determine that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
[0056] In one possible design, the kernel network module is also used to: after establishing a connection with the second computing device based on the second socket and the connection request, perform system call processing based on the second IP address; the system call processing includes reading messages from the second computing device, and / or sending messages to the second computing device.
[0057] In one possible design, the kernel network module is specifically used to generate socket creation requests in sequence according to the index arrangement order until the third socket creation request is generated.
[0058] In a seventh aspect, the present application provides a computing device, comprising a processor and a memory; the processor is used to execute instructions stored in the memory, so that the computing device executes the method described in the first aspect and any possible design of the first aspect, or executes the method described in the second aspect and any possible design of the second aspect, or executes the method described in the third aspect and any possible design of the third aspect.
[0059] In an eighth aspect, the present application provides a computing device cluster, the computing device cluster comprising at least one computing device, each computing device comprising a processor and a memory; the processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method described in the first aspect and any possible design of the first aspect, or executes the method described in the second aspect and any possible design of the second aspect, or executes the method described in the third aspect and any possible design of the third aspect.
[0060] In a ninth aspect, the present application provides a computer program product comprising instructions, which, when executed by a computing device, causes the computing device to execute the method described in the first aspect and any possible design of the first aspect, or execute the method described in the second aspect and any possible design of the second aspect, or execute the method described in the third aspect and any possible design of the third aspect.
[0061] In the tenth aspect, the present application provides a computer-readable storage medium comprising computer program instructions. When the computer program instructions are executed by a computing device, the computing device executes the method described in the first aspect and any possible design of the first aspect, or executes the method described in the second aspect and any possible design of the second aspect, or executes the method described in the third aspect and any possible design of the third aspect.
[0062] The embodiments of the present application can be further combined to provide more implementations based on the implementations provided in the above aspects. For the beneficial effects of the fourth to tenth aspects, please refer to the description of the beneficial effects of the first to third aspects, which will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 This is a schematic diagram of the architecture of NAT64 technology;
[0064] Figure 2 A schematic diagram of the architecture of a communication system capable of implementing network address translation;
[0065] Figure 3 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0066] Figure 4 A flowchart of a network access method provided in an embodiment of the present application;
[0067] Figure 5 A flowchart of a network access method provided in an embodiment of the present application;
[0068] Figure 6 A flowchart of a network access method provided in an embodiment of the present application;
[0069] Figure 7 A flowchart of a network access method provided in an embodiment of the present application;
[0070] Figure 8 A flowchart of a network access method provided in an embodiment of the present application;
[0071] Fig. 9 A flowchart of a network access method provided in an embodiment of the present application;
[0072] Fig.10 A schematic diagram of the structure of a computing device provided in an embodiment of the present application;
[0073] Fig.11 A schematic diagram of a computing device cluster provided in an embodiment of the present application;
[0074] Fig.12 A schematic diagram of a computing device cluster connection method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0075] In order to make the purpose, technical scheme and advantages of the embodiments of the present application clearer, the embodiments of the present application will be further described in detail below in conjunction with the accompanying drawings. Among them, in the description of the embodiments of the present application, the terms "first" and "second" are used only for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features.
[0076] It should be understood that in the embodiments of the present application, "at least one" refers to one or more, and "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can represent: a, b, c, a and b, a and c, b and c, or a, b and c, where a, b, c can be single or multiple.
[0077] Transmission Control Protocol / Internet Protocol (TCP / IP) is the most basic communication protocol used in the Internet. The TCP / IP transmission protocol specifies the standards and methods for communication between various parts of the Internet.
[0078] Internet Protocol Address (IP) is a unified address format provided by the IP protocol. Based on the IP protocol, an IP address can be assigned to each network and each host on the Internet, so that all hosts connected to the network can communicate with each other based on their own IP addresses and the IP address of the receiving host.
[0079] Internet protocol version 4 (IPv4) uses a 32-bit address length, providing approximately 4.3 billion addresses, but with the development of the Internet protocol (IP), IPv4 addresses have been exhausted, and Internet protocol version 6 (IPv6) has become the mainstream network protocol. IPv6 uses a 128-bit address length, which can provide addresses almost without restrictions.
[0080] However, since the IPv4 network has been developed for decades, most services only support IPv4 and have not considered supporting IPv6. If the services that currently support IPv4 are to support IPv6, it is necessary to modify the current massive services, which is difficult to achieve. At the same time, with the expansion of cloud services, the number of containers far exceeds the number of virtual machines. In order to meet their address requirements, IPv6 addresses need to be allocated to containers. However, most of the existing services use IPv4 addresses, which requires a technology that supports mutual access between IPv4 and IPv6 so as not to affect the normal operation of current services.
[0081] In the current network access method, if you want to support IPv4 and IPv6 dual stacks, you need to make judgments based on the address scenario in the code logic and modify the existing code according to different protocol stack scenarios. This will increase the complexity of the code and make it difficult to promote IPv6.
[0082] Figure 1 A schematic diagram of a communication system. Figure 1 The communication system may include multiple computing devices and gateways. The embodiment of the present application does not limit the number of computing devices in the communication system. Figure 1 The first computing device, the gateway, and the second computing device are only examples and not limitations.
[0083] In the embodiments of the present application, computing devices refer to various electronic devices that need to access the Internet (referring to connecting to the IPv4 public network or the IPv6 public network), such as computers, laptops, smart phones, tablet computers, smart wearable devices, etc., or servers, or other household devices, or virtual machines, containers and other computing instances. Figure 1 In the example, the first computing device is a terminal and the second computing device is a server. The embodiment of the present application does not limit the type of computing device. In the embodiment of the present application, the computing device can install applications, and the application in the computing device can be a client or a server. The client can request to access the server, and the client can also request to access other clients. The server can monitor the access request initiated by the client. In the following introduction, the application in the first computing device accesses the application in the second computing device as an example.
[0084] An application can be installed in the first computing device. When the user uses the network service provided by the application, the first computing device can interact with the second computing device based on the IP address of the first computing device and the IP address of the second computing device, thereby completing the service. For example, taking IPv4 as an example, the IP address based on IPv4 is 32 bits in total. IPv4 divides the 32-bit address into two parts, the front part represents the network address, and the back part represents the address of the host in the local area network. If the two IP addresses are in the same subnet, the network addresses must be the same. In order to determine the network address in the IP address, the IP protocol also introduces a subnet mask. The IP address and the subnet mask can be used to obtain the network address through bitwise AND operation. When the first computing device sends a data packet to the second computing device, it can first use the IPv4 protocol to determine whether the first computing device and the second computing device are in the same subnet. If they are in the same subnet, the first computing device can query the media access control (MAC) address through the address resolution protocol (ARP), so that the first computing device can send a data packet to the second computing device in the subnet in the form of a broadcast. If the first computing device and the second computing device are not in the same subnet, Ethernet will forward the data packet to the gateway of the subnet for routing. The gateway can forward the data packet multiple times and finally forward the data packet to the subnet where the second computing device is located, and then obtain the MAC address of the second computing device through ARP, and finally send the data packet to the second computing device through broadcast.
[0085] Under the IPv4 protocol, when a first computing device needs to send a data packet to a second computing device, the first computing device performs the following steps:
[0086] Step a: Create a socket with type parameter as IPv4;
[0087] Step b: Bind the local IPv4 address;
[0088] Step c: Connect to the IPv4 address of the second computing device.
[0089] Similarly, under the IPv6 protocol, when the first computing device needs to send a data packet to the second computing device, the first computing device performs the following steps:
[0090] Step a: Create a socket with type parameter as IPv6;
[0091] Step b: Bind the local IPv6 address;
[0092] Step c: Connect to the IPv6 address of the second computing device.
[0093] The socket in the above process can be regarded as the endpoint of the communication connection between two applications on different hosts. This is a logical concept. The socket is equivalent to the application programming interface (API) for inter-process communication in the network environment. It is a communication endpoint that can be named and addressed. Each socket has its type and a process connected to it. The socket is a mechanism based on IP addresses and ports for transmitting data packets to application layer processes.
[0094] Under different versions of the IP protocol, the data packets transmitted between the first computing device and the second computing device need to be routed by different gateways. For example, under IPv4, an IPv4 gateway is required to route the data packets, and under IPv6, an IPv6 gateway is required to route the data packets. How to achieve network access between devices under different protocol stacks has become an extremely important topic at present.
[0095] In an optional implementation, a network address translation (NAT) device may be deployed at an intermediate node between an IPv6 network and an IPv4 network, such as a NAT64 device (also known as a NAT46 device) that supports network address translation between IPv6 and IPv4.
[0096] For example, Figure 2 The invention is a schematic diagram of the architecture of a communication system capable of implementing network address translation. Figure 2 Taking the interaction between a first computing device supporting IPv6 and a second electronic device supporting IPv4 as an example, Figure 2 , the communication system includes an IPv6 device, an IPv6 gateway, a NAT64 device, an IPv4 gateway, and an IPv4 device. Assume that the IP address of the IPv6 device is: fe80::fbaf:32c5:ac97:0102, and the IP address of the IPv4 device is 192.168.1.1. The NAT64 device has the dual stack capability of supporting IPv6 and IPv4, and the NAT64 device has the addresses of two networks. In order to achieve the conversion of IPv6 and IPv4 addresses, the following correspondence needs to be configured in the NAT64 device: the IPv6 address fe80::fbaf:32c5:ac97:0102 of the IPv6 device corresponds to the IPv4 address 192.168.2.2; the IPv6 address corresponding to the IPv4 address 192.168.1.1 of the IPv4 device is fe80::fbaf:32c5:ac98:0304.
[0097] When the IPv6 device needs to send a data packet to the server, the source address and destination address of the data packet are both IP addresses under IPv6. The source address of the data packet is fe80::fbaf:32c5:ac97:0102, and the destination address is fe80::fbaf:32c5:ac98:0304. After being forwarded by the IPv6 gateway, the NAT64 device receives the data packet. The NAT64 device queries the pre-configured network address correspondence and determines that the source address and destination address of the data packet both have corresponding IPv4 addresses. Then NAT64 modifies the source address of the data packet to 192.168.2.2 and the destination address to 192.168.1.1. The data packet with the modified network address can be forwarded through the IPv4 gateway and reach the IPv4 device.
[0098] Similarly, when an IPv4 device sends a data packet to an IPv6 device, the NAT64 device can modify the source address and destination address of the data packet to the IPv6 address corresponding to the IPv4 address, thereby achieving the transmission of the data packet from the IPv4 device to the IPv6 device.
[0099] However, although the above solution can realize the mutual access between IPv4 network and IPv6 network, it needs to introduce new equipment in the communication system, which increases the complexity of service deployment. At the same time, the data packet forwarding through NAT64 equipment will also increase the delay, and the performance of NAT64 equipment will also affect the service performance.
[0100] Based on the above problems, the present application provides a network access method, which can be performed by a first computing device and a second computing device. In the network access method provided in an embodiment of the present application, the first computing device receives a first socket creation request initiated by a target application, and the first socket creation request is used to request the creation of a socket for accessing the target application in the second computing device. The first computing device can modify the type parameter of the first socket creation request, and create a socket based on the modified type parameter, and the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the second computing device. The first computing device receives a connection request initiated by the target application, and the connection request is used to request to establish a connection with the second computing device, and the connection request includes a first IP address, and the first IP address belongs to the first protocol stack. The first computing device can modify the first IP address in the connection request to a second IP address according to a preset address mapping relationship, and the second IP address is the IP address of the second computing device under the second protocol stack supported by the second computing device. The first computing device can establish a connection with the second computing device based on the created socket and the connection request. Through this solution, the first computing device can modify the type parameters of the socket when receiving the socket creation request from the target application, thereby generating a socket that matches the protocol stack of the second computing device, and the first computing device modifies the peer IP address in the connection request initiated by the target application to the IP address under the actual protocol stack of the second computing device, thereby ensuring that the first computing device can establish a connection with the second computing device based on the accurate IP address.
[0101] In another network access method provided in an embodiment of the present application, the first computing device can support the IPv4 protocol and the IPv6 protocol. In this method, the first computing device receives a first socket creation request initiated by a target application in the first computing device, and creates a first socket according to the first socket creation request. The first computing device receives a connection request sent by the target application, and the first computing device determines that the preset address mapping relationship includes a mapping relationship between the first IP address in the connection request and the second IP address, the first IP address belongs to the first protocol stack, and the second IP address is the IP address of the second computing device under the second protocol stack supported by the second computing device, then the first computing device can determine that the connection request needs to be converted to a network address. The first computing device can close the first socket and generate a third socket creation request, the third socket creation request has the same index as the first socket creation request, and the type parameter of the third socket matches the protocol stack of the second computing device. The first computing device creates a second socket according to the third socket creation request, and modifies the first IP address in the connection request to the second IP address according to the preset mapping relationship, and the protocol stack to which the second IP address belongs is the same as the protocol stack supported by the second computing device. The first computing device can establish a connection with the second computing device based on the second socket and the connection request. Through this solution, when the first computing device supports dual stacks, when the first computing device determines that the preset address mapping relationship includes the target IP address requested by the connection request, it will generate a new socket creation request and convert the IP address of the second computing device, ensuring that the first computing device can accurately identify the business that needs network address translation and establish a connection with the second computing device based on the accurate IP address.
[0102] The structure of a computing device provided in an embodiment of the present application is introduced below. The computing device may be a first computing device or a second computing device. Figure 3 A schematic diagram of the structure of a computing device provided in an embodiment of the present application. Figure 3 , the computing device may be installed with at least one application, such as Figure 3 In the example, the user state includes three applications (APP1, APP2, and APP3). In the kernel state, the kernel network module is used to execute system calls and actual execution functions of system calls, so that it can be used to respond to system call requests initiated by applications, establish a connection with a second computing device, and send data packets to the second computing device or receive data packets sent by the second computing device.
[0103] The network access method provided in the embodiment of the present application can be executed by a conversion module in a computing device. Figure 3As shown, the conversion management module can be used to send the application list and conversion type to be monitored, as well as the address mapping relationship, to the conversion module. Optionally, the user can set the application list to be monitored, and the user can configure the address conversion relationship; or the application list to be monitored and the address conversion relationship can be pre-configured by the system. The conversion module can store the application list and conversion type to be monitored, and store the preset address mapping relationship.
[0104] Assuming that the list of applications to be monitored includes APP1, when the kernel network module of the computing device receives the system call request initiated by APP1, it can send the context related to the system call request to the conversion module. The conversion module can modify the type parameter of the socket creation request and modify the target address in the connection request. The conversion module can return the processed socket creation request and connection request to the kernel network module. The kernel network module then creates a socket according to the processed socket creation request and establishes a connection with the remote end according to the modified connection request, thereby realizing network mutual access of devices under different protocol stacks without affecting the original data processing process and data transmission and reception process.
[0105] In some embodiments, the network access method provided in the embodiments of the present application can also be used to enable a computing device to support other IP protocols. For example, assuming that the first computing device supports IPv4, the user can enable the "Support IPv6" function in the control interface of the first computing device, and the first computing device loads Figure 3 The conversion module and conversion management module shown in , when loading the conversion module, the first computing device can register the detection information of the socket interface with the kernel. The IPv6 address is allocated to the first computing device through the conversion management module, and the preset application list, conversion type and preset address mapping relationship are sent to the conversion module, so that the first computing device can access the IPv6 second computing device based on the network access method provided in the embodiment of the present application, and realize the function of the first computing device supporting different protocol stacks.
[0106] The network mutual access method provided in the embodiment of the present application can be applied to the first computing device or the second computing device supporting a single stack, and can also be applied to the first computing device supporting a dual stack. The network mutual access method in different protocol stack scenarios is further introduced below.
[0107] 1. Single stack scenario
[0108] The single stack scenario in the embodiments of the present application means that in the initial state, the first computing device supports the IPv4 protocol and the second computing device supports the IPv6 protocol, or in the initial state, the first computing device supports the IPv6 protocol and the second computing device supports the IPv4 protocol.
[0109] Figure 4A flowchart of a network access method provided in an embodiment of the present application. The method can be executed by a first computing device or a kernel state in the first computing device. In this embodiment, the first computing device receives a request initiated by a target application and accesses the target application in the second computing device. Figure 4 , the method comprises the following steps:
[0110] S401: Receive a first socket creation request initiated by a target application.
[0111] The first socket creation request is used to request the creation of a client socket for network communication.
[0112] The target application is an application in a preconfigured application list stored in a first computing device. The application in the preconfigured application list and the second computing device to which the application requests to connect are in different protocol stacks. The first computing device needs to monitor the system call request initiated by the target application to perform socket type conversion processing and network address conversion processing.
[0113] S402: Modify the type parameter of the first socket creation request, and create a socket based on the modified type parameter.
[0114] In an optional implementation, after receiving the first socket creation request, the first computing device may query whether the target application is included in a preset application list, where the applications in the preset application list are applications that require network address translation. After determining that the target application belongs to the preset application list, the first computing device modifies the type parameter of the first socket creation request and creates a socket based on the modified type parameter.
[0115] The first socket creation request initiated by the target application includes a type parameter of the first socket creation request. The first computing device can modify the type parameter of the first socket creation request, and the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the second computing device. For example, assuming that the target application is an IPv4 application, the type parameter of the first socket creation request is AF_INET, and the second computing device supports IPv6, the first computing device can modify the type parameter of the first socket creation request to AF_INET6. For another example, assuming that the target application is an IPv6 application, the type parameter of the first socket creation request is AF_INET6, and the second computing device supports IPv4, the first computing device can modify the type parameter of the first socket creation request to AF_INET.
[0116] The first computing device can create a socket based on the modified type parameter. For example, when the modified type parameter is AF_INET6, the first computing device can create a socket under IPv6; when the modified type parameter is AF_INET, the first computing device can create a socket under IPv4. Through this design, the first computing device can generate a socket that matches the protocol stack supported by the second computing device, ensuring that the first computing device can subsequently correctly access the second computing device based on the socket.
[0117] S403: Receive an address binding request sent by the target application.
[0118] Optionally, the address binding request sent by the target application is used to request binding of the local IP address of the first computing device. In an embodiment of the present application, the address binding request sent by the target application includes a third IP address, and the third IP address belongs to the first protocol stack. The target application can obtain the third IP address from the configuration file and generate an address binding request based on the obtained third IP address. Optionally, the third IP address can be the address of the first computing device under the first protocol stack; or the third IP address can be any IP address under the first protocol stack, that is, the third IP address in the address binding request may not be the real address of the first computing device.
[0119] In an optional implementation, after receiving the address binding request of the target application, the first computing device can determine whether the preset address mapping relationship includes the mapping relationship between the third IP address and the fourth IP address, and then execute S404 after determining that the preset address mapping relationship includes the mapping relationship between the third IP address and the fourth IP address.
[0120] S404: modify the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship, and bind the fourth IP address and the socket according to the address binding request.
[0121] In an optional implementation, the first computing device may store a preset address mapping relationship. Taking the first protocol stack and the second protocol stack as IPv4 and IPv6 as an example, the address mapping relationship may include the IPv4 address and IPv6 address corresponding to the first computing device, and may also include the IPv4 address and IPv6 address corresponding to the second computing device. In an embodiment of the present application, an IP address under other protocol stacks may be allocated to the first computing device. For example, assuming that the first computing device supports IPv4 in its initial state, an IP address under IPv6 may be allocated to the first computing device, and the mapping relationship between the IPv4 address and the IPv6 address of the first computing device may be stored.
[0122] In some embodiments, when the target application in the first computing device initiates an address binding request, the third IP address of the first computing device can be obtained from the configuration file. If the third IP address in the configuration file is a preconfigured fake address under the first protocol stack, the address mapping relationship can store the mapping relationship between the fake address and the real address of the first computing device under the second protocol stack. If the third IP address in the configuration file is the real address of the first computing device under the first protocol stack, the address mapping relationship can store the mapping relationship between the real address of the first computing device under the first protocol stack and the real address of the first computing device under the second protocol stack.
[0123] The first computing device may modify the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship, wherein the fourth IP address is the IP address of the first computing device under the second protocol stack, and the protocol stack to which the fourth IP address belongs is the same as the protocol stack supported by the second computing device. For example, assuming that the target application is an IPv4 application, the third IP address is an IPv4 address, and the second computing device supports IPv6, then the fourth IP address modified by the first computing device is the IPv6 address of the first computing device. For another example, assuming that the target application is an IPv6 application, the third IP address is an IPv6 address, and the second computing device supports IPv4, then the fourth IP address modified by the first computing device is the IPv4 address of the first computing device.
[0124] The first computing device may bind the fourth IP address and the socket according to the address binding request after the address is modified.
[0125] Through this design, after receiving the address binding request, the first computing device can modify the local IP address in the address binding request to the local IP address under the protocol stack supported by the second computing device, so that the first computing device can bind the modified local IP address to the socket, and then successfully access the second computing device based on the socket.
[0126] It should be noted that, in a specific implementation, S403-S404 are optional steps, and the target application may not initiate an address binding request. Then, when the first computing device establishes a connection with the second computing device, it may select a fourth IP address from the multiple IP addresses of the first computing device, and the protocol to which the fourth IP address belongs is the same as the protocol supported by the second computing device.
[0127] S405: Receive a connection request initiated by the target application.
[0128] The connection request initiated by the target application is used to request the first computing device to establish a connection with the second computing device, and the connection request includes a first IP address, and the first IP address belongs to the first protocol stack. The target application can obtain the first IP address from the configuration file and generate a connection request based on the obtained first IP address. Optionally, the first IP address can be any IP address under the first protocol stack, that is, the first IP address in the connection request may not be the real address of the second computing device.
[0129] In an optional implementation, after receiving the connection request of the target application, the first computing device may determine whether the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address, wherein the second IP address is an IP address of the second computing device under the second protocol stack supported by the second computing device. After determining that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address, S406 is executed.
[0130] S406: Modify the first IP address in the connection request to the second IP address according to the preset address mapping relationship.
[0131] Based on the above description, it can be known that when the protocol stack supported by the first computing device is different from the protocol stack supported by the second computing device, the IP address of the second computing device in the connection request is not the actual IP address of the second computing device, and the first computing device needs to modify the IP address of the second computing device in the connection request. In an embodiment of the present application, the first computing device can modify the first IP address in the connection request to the second IP address according to a preset address mapping relationship. Among them, the protocol to which the first IP address belongs is the same as the protocol supported by the first computing device, and the protocol stack to which the first IP address belongs is the first protocol stack; the protocol to which the second IP address belongs is the same as the protocol supported by the second computing device, and the second IP address is the IP address of the second computing device under the second protocol stack.
[0132] For example, assuming that the target application is an IPv4 application, the first IP address in the connection request is an IPv4 address, and the second computing device supports IPv6, then the second IP address modified by the first computing device is an IPv6 address. For another example, assuming that the target application is an IPv6 application, the first IP address in the connection request is an IPv6 address, and the second computing device supports IPv4, then the second IP address modified by the first computing device is an IPv4 address.
[0133] Through this design, the first computing device can modify the peer IP address in the connection request initiated by the target application to the IP address under the actual protocol stack of the second computing device, ensuring that the first computing device can establish a connection with the second computing device based on the accurate IP address, thereby realizing the network access of the first computing device to the second computing device.
[0134] S407: Establish a connection with the second computing device based on the socket and the connection request.
[0135] In an optional implementation, the first computing device may establish a connection with the second computing device based on the socket created by the modified type parameter according to the fourth IP address and the second IP address in the connection request.
[0136] S408: Perform system call processing according to the second IP address.
[0137] Optionally, the system call processing includes reading a message from the second computing device, and / or sending a message to the second computing device.
[0138] Through the network access method provided in the embodiment of the present application, the first computing device can modify the type parameters of the socket when receiving the socket creation request of the target application, thereby generating a socket that matches the protocol stack of the second computing device, and the first computing device modifies the target IP address in the connection request initiated by the target application to the IP address under the actual protocol stack of the second computing device, thereby ensuring that the first computing device can establish a connection with the second computing device based on the accurate IP address.
[0139] based on Figure 3 The structure of the computing device shown in the figure, the network access method provided in the embodiment of the present application is further introduced from the interaction of each module in the first computing device. Figure 5 A flowchart of a network access method provided by an embodiment of the present application, which can be executed by a target application, a kernel network module, and a conversion module in a first computing device. Figure 5 , the method comprises the following steps:
[0140] S501: The target application sends a first socket creation request to the kernel network module.
[0141] The first socket creation request is used to request the creation of a socket for accessing a target application in the second computing device. For example, the target application is an IPv6 application, and the type parameter of the first socket creation request is AF_INET6.
[0142] S502: The kernel network module sends a first socket creation request to the conversion module.
[0143] Optionally, after receiving the first socket creation request, the conversion module may determine whether the target application belongs to a preset application list before modifying the type parameter of the first socket creation request. After determining that the preset application list includes the target application, S503 is executed.
[0144] S503: The conversion module modifies the type parameter of the first socket creation request.
[0145] For example, if the target application is an IPv6 application and the second computing device supports IPv4, the conversion module may modify the type parameter of the first socket creation request from AF_INET6 to AF_INET.
[0146] S504: The conversion module sends the modified first socket creation request to the kernel network module.
[0147] S505: The kernel network module creates a socket according to the modified type parameter.
[0148] S506: The kernel network module returns the execution result to the target application.
[0149] S507: The target application sends an address binding request to the kernel network module.
[0150] Optionally, the address binding request sent by the target application is used to request binding of the IP address of the first computing device. For example, the third IP address included in the address binding request is FE80::1234::2.
[0151] S508: The kernel network module sends the address binding request to the conversion module.
[0152] Optionally, after receiving the address binding request, the conversion module may determine whether the preset address mapping relationship includes the mapping relationship between the third IP address and the fourth IP address. After determining that the preset address mapping relationship includes the mapping relationship between the third IP address and the fourth IP address, S509 is executed.
[0153] S509: The conversion module modifies the third IP address in the address binding request into a fourth IP address according to a preset address mapping relationship.
[0154] For example, the conversion module modifies the third IP address FE80::1234::2 in the binding request to the fourth IP address 192.168.1.2.
[0155] S510: The conversion module sends the address binding request after the address is modified to the kernel network module.
[0156] S511: The kernel network module binds the fourth IP address and the socket according to the address binding request.
[0157] S512: The kernel network module returns the execution result to the target application.
[0158] S513: The target application sends a connection request to the kernel network module.
[0159] Optionally, the connection request sent by the target application is used to request the first computing device to establish a connection with the second computing device. For example, the first IP address included in the connection request is FE80::1234::1:80.
[0160] S514: The kernel network module sends the connection request to the conversion module.
[0161] Optionally, after receiving the connection request, the conversion module may determine whether the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address. After determining that the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address, S515 is executed.
[0162] S515: The conversion module modifies the first IP address in the connection request into a second IP address according to a preset address mapping relationship.
[0163] For example, the conversion module modifies the first IP address FE80::1234::1:80 in the binding request to the second IP address 192.168.1.1.
[0164] S516: The conversion module sends the connection request with the modified address to the kernel network module.
[0165] S517: The kernel network module establishes a connection with the second computing device based on the socket and the connection request.
[0166] S518: The kernel network module returns the execution result to the target application.
[0167] S519: The target application sends a write request to the kernel network module.
[0168] S520: The kernel network module sends a data packet to the second computing device according to the received write request.
[0169] S521: The target application sends a read request to the kernel network module.
[0170] S522: The kernel network module receives the data packet sent by the second computing device according to the received read request.
[0171] Figure 6 A flowchart of a network access method provided by an embodiment of the present application. The method can be executed by a second computing device or a kernel state in the second computing device. In this embodiment, the second computing device can monitor messages sent by target applications in other devices. Figure 6 , the method comprises the following steps:
[0172] S601: Receive a second socket creation request initiated by a target application.
[0173] Optionally, the second socket creation request is used to request the creation of a socket for monitoring messages sent by a target application in other devices.
[0174] S602: Modify the type parameter of the second socket creation request, and create a socket based on the modified type parameter.
[0175] The second socket creation request includes a type parameter of the second socket creation request, and the second computing device can modify the type parameter of the second socket creation request. For example, if the type parameter of the second socket creation request is AF_INET, and the target application is an IPv6 application, the second computing device can modify the type parameter of the second socket creation request to AF_INET6. For another example, if the type parameter of the second socket creation request is AF_INET6, and the target application is an IPv4 application, the second computing device can modify the type parameter of the second socket creation request to AF_INET.
[0176] The second computing device can create a socket based on the modified type parameter. For example, when the modified type parameter is AF_INET6, the second computing device can create a socket under IPv6; when the modified type parameter is AF_INET, the second computing device can create a socket under IPv4.
[0177] S603: Receive an address binding request initiated by the target application.
[0178] Among them, the address binding request is used to request to bind the IP address of the second computing device. In an embodiment of the present application, the address binding request includes a first IP address, and the first IP address belongs to the first protocol stack. The target application can obtain the first IP address from the configuration file and generate an address binding request based on the obtained first IP address. Optionally, the first IP address can be the address of the second computing device under the first protocol stack; or the first IP address can be any IP address under the first protocol stack, that is, the first IP address in the address binding request may not be the real address of the second computing device.
[0179] In an optional implementation, after receiving the address binding request of the target application, the second computing device can determine whether the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address, and then execute S604 after determining that the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address.
[0180] S604: modify the first IP address in the address binding request to the second IP address according to the preset address mapping relationship, and bind the socket and the second IP address based on the address binding request.
[0181] In an optional implementation, the second computing device may store a preset address mapping relationship. Taking the first protocol stack and the second protocol stack as IPv4 and IPv6 as an example, the address mapping relationship may include the IPv4 address and the IPv6 address of the second computing device. In an embodiment of the present application, an IP address under other protocol stacks may be allocated to the second computing device. For example, assuming that the second computing device supports IPv4 in the initial state, an IP address under IPv6 may be allocated to the second computing device, and the mapping relationship between the IPv4 address and the IPv6 address of the second computing device may be stored.
[0182] In some embodiments, when initiating an address binding request, the target application in the second computing device may obtain the first IP address of the second computing device from the configuration file. If the first IP address in the configuration file is a preconfigured fake address under the first protocol stack, the address mapping relationship may store the mapping relationship between the fake address and the real address of the second computing device under the second protocol stack. If the first IP address in the configuration file is the real address of the second computing device under the first protocol stack, the address mapping relationship may store the mapping relationship between the real address of the second computing device under the first protocol stack and the real address of the second computing device under the second protocol stack.
[0183] The second computing device can modify the first IP address in the address binding request to a second IP address according to a preset address mapping relationship, and the second IP address is the IP address of the second computing device under the second protocol stack. For example, assuming that the first IP address in the address binding request is an IPv4 address, and the target application is an IPv6 application, the second IP address modified by the second computing device is the IPv6 address of the second computing device. For another example, assuming that the first IP address in the address binding request is an IPv6 address, and the target application is an IPv4 application, the second IP address modified by the second computing device is the IPv4 address of the second computing device.
[0184] The second computing device can bind the socket to the second IP address according to the modified address binding request, so that the second computing device can monitor messages whose target address is the second IP address, ensuring that the second computing device can successfully accept the network access initiated by the first computing device.
[0185] S605: Perform system call processing according to the second IP address.
[0186] Optionally, the system call processing includes reading a message from the first computing device of the target application, and / or sending a message to the first computing device of the target application.
[0187] Through the network access method provided in the embodiment of the present application, the second computing device can modify the type parameter of the socket when receiving the socket creation request of the target application, thereby generating a socket that matches the protocol stack of the first computing device, and the second computing device modifies the server IP address in the binding request initiated by the target application to an IP address under the protocol stack of the first computing device, thereby ensuring that the second computing device can interact with the first computing device of the target application.
[0188] based on Figure 3 The structure of the computing device shown in the figure, the network access method provided in the embodiment of the present application is further introduced from the interaction of each module in the second computing device. Figure 7 A flowchart of a network access method provided by an embodiment of the present application, which can be executed by a target application, a kernel network module, and a conversion module in a second computing device. Figure 7 , the method comprises the following steps:
[0189] S701: The target application sends a second socket creation request to the kernel network module.
[0190] The second socket creation request is used to request the creation of a socket for monitoring messages sent by a target application in another device. For example, the second computing device supports IPv4, and the type parameter of the second socket creation request is AF_INET.
[0191] S702: The kernel network module sends a second socket creation request to the conversion module.
[0192] Optionally, after receiving the second socket creation request, the conversion module may determine whether the target application belongs to a preset application list before modifying the type parameter of the second socket creation request. After determining that the preset application list includes the target application, S703 is executed.
[0193] S703: The conversion module modifies the type parameter of the second socket creation request.
[0194] For example, the second computing device supports IPv4, and the target application is an IPv6 application. The conversion module may modify the type parameter of the second socket creation request from AF_INET to AF_INET6.
[0195] S704: The conversion module sends the modified second socket creation request to the kernel network module.
[0196] S705: The kernel network module creates a socket according to the modified type parameter.
[0197] S706: The kernel network module returns the execution result to the target application.
[0198] S707: The target application sends an address binding request to the kernel network module.
[0199] Optionally, the address binding request sent by the target application is used to request binding of an IP address of the second computing device. For example, the first IP address included in the address binding request is 192.168.1.1.
[0200] S708: The kernel network module sends the address binding request to the conversion module.
[0201] Optionally, after receiving the address binding request, the conversion module may determine whether the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address. After determining that the preset address mapping relationship includes the mapping relationship between the first IP address and the second IP address, S709 is executed.
[0202] S709: The conversion module modifies the first IP address in the address binding request into a second IP address according to a preset address mapping relationship.
[0203] For example, the conversion module modifies the first IP address 192.168.1.1 in the binding request into the fourth IP address FE80::1234::1.
[0204] S710: The conversion module sends the address binding request after the address is modified to the kernel network module.
[0205] S711: The kernel network module binds the socket and the second IP address based on the address binding request.
[0206] S712: The kernel network module returns the execution result to the target application.
[0207] S713: The target application sends a read request to the kernel network module.
[0208] S714: The kernel network module receives the data packet sent by the first computing device according to the received read request.
[0209] S715: The target application sends a write request to the kernel network module.
[0210] S716: The kernel network module sends a data packet to the first computing device according to the received write request.
[0211] 2. Dual-stack scenario
[0212] The dual stack scenario in the embodiment of the present application means that the first computing device supports both the IPv4 protocol and the IPv6 protocol in an initial state.
[0213] Figure 8A flowchart of a network access method provided in an embodiment of the present application. The method can be executed by a first computing device or a kernel state in the first computing device. In this embodiment, the first computing device receives a request initiated by a target application and accesses the target application in the second computing device. Figure 8 , the method comprises the following steps:
[0214] S801: Receive a first socket creation request initiated by a target application, and create a first socket according to the first socket creation request.
[0215] The first socket creation request is used to request the creation of a socket for accessing a target application in the second computing device.
[0216] The target application is an application in a preconfigured application list stored by the first computing device. The application in the preconfigured application list may be in a different protocol stack from the second computing device that the application requests to connect to. The first computing device needs to monitor the system call request initiated by the target application. Since the first computing device in this embodiment supports both IPv4 and IPv6 dual stacks, when the first computing device receives the first socket creation request initiated by the target application, it cannot determine the IP address of the second computing device that the target application requests to connect to, and therefore cannot determine whether socket type conversion processing and network address conversion processing are required. The first computing device needs to wait until it receives the connection request initiated by the target application, and then determine whether socket type conversion processing and network address conversion processing are required based on the IP address of the second computing device in the connection request.
[0217] S802: Receive a connection request initiated by the target application.
[0218] The connection request is used to request to establish a connection with the second computing device, and the connection request includes a first IP address. The first IP address belongs to the first protocol stack. The target application can obtain the first IP address from the configuration file and generate a connection request based on the obtained first IP address. Optionally, the first IP address can be any IP address under the first protocol stack, that is, the first IP address in the connection request may not be the real address of the second computing device.
[0219] S803: Determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0220] In an optional implementation, a preset address mapping relationship is stored in the first computing device. When the first computing device receives a connection request, it can obtain the first IP address in the connection request and find out whether the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address, wherein the second IP address is the IP address of the second computing device under the second protocol stack supported by the second computing device. If the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address, it means that the first computing device needs to convert the address in the connection request.
[0221] S804: Close the first socket and generate a third socket creation request.
[0222] Optionally, the first computing device may close the first socket created in S801 and generate a third socket creation request, the index of the third socket creation request is the same as the index of the first socket creation request, and the type parameter of the third socket creation request is different from the type parameter of the first socket creation request.
[0223] In an optional implementation, when a new socket creation request is created, since the kernel always allocates the process with the smallest index in the current process, the first computing device needs to generate socket creation requests in order of index arrangement until a third socket creation request with the same index as the first socket creation request is generated. After generating the third socket creation request, the first computing device can close other useless socket creation requests. In addition, the type parameter of the third socket creation request generated by the first computing device is different from the type parameter of the first socket creation request, and the protocol stack corresponding to the type parameter of the third socket creation request is the same as the protocol stack supported by the second computing device. For example, when the type parameter of the first socket creation request is AF_INET, the type parameter of the third socket creation request is AF_INET6; when the type parameter of the first socket creation request is AF_INET6, the type parameter of the third socket creation request is AF_INET.
[0224] Optionally, in the embodiment of the present application, the index of the socket creation request may be a file descriptor.
[0225] S805: Create a second socket according to the third socket creation request.
[0226] In an embodiment of the present application, the type parameter of the third socket creation request generated by the first computing device is different from the type parameter of the first socket creation request, and the protocol stack corresponding to the third socket creation request is the same as the protocol stack supported by the second computing device. The first computing device can create a second socket according to the third socket creation request, thereby ensuring that the protocol stack corresponding to the type parameter of the second socket is a protocol stack supported by the second computing device, so that the first computing device can perform network access to the second computing device based on the second socket.
[0227] S806: Modify the first IP address in the connection request to the second IP address according to the preset address mapping relationship.
[0228] In an embodiment of the present application, the first computing device may modify the first IP address in the connection request to a second IP address according to a preset address mapping relationship, wherein the second IP address is the IP address of the second computing device under the second protocol stack.
[0229] For example, assuming that the target application is an IPv4 application, the first IP address in the connection request is an IPv4 address, and the second computing device supports IPv6, then the second IP address modified by the first computing device is an IPv6 address. For another example, assuming that the target application is an IPv6 application, the first IP address in the connection request is an IPv6 address, and the second computing device supports IPv4, then the second IP address modified by the first computing device is an IPv4 address.
[0230] Through the network access method provided by the embodiment of the present application, since the index of the third socket creation request is the same as the index of the first socket creation request, after the first computing device generates the second socket and modifies the address in the connection request, it can continue the process of the original connection request based on the second socket and the second IP address in the modified connection request, and then establish a connection with the second computing device to achieve network access to the second computing device.
[0231] S807: Establish a connection with the second computing device based on the second socket and the connection request.
[0232] In an optional implementation, the first computing device may select a fourth IP address from a plurality of IP addresses of the first computing device, and the protocol to which the fourth IP address belongs is the same as the protocol supported by the second computing device of the target application. The first computing device may establish a connection with the second computing device based on the second socket according to the fourth IP address and the second IP address in the connection request.
[0233] S808: Perform system call processing according to the second IP address.
[0234] Optionally, the system call processing includes reading a message from the second computing device, and / or sending a message to the second computing device.
[0235] Through the network access method provided by the embodiment of the present application, when the first computing device supports dual stack, the first computing device, when determining that the preset address mapping relationship includes the target IP address requested by the connection request, generates a new socket creation request and converts the IP address of the second computing device, thereby ensuring that the first computing device can accurately identify the business that requires network address conversion and establish a connection with the second computing device based on the accurate IP address.
[0236] based on Figure 3 The structure of the computing device shown in the figure, the network access method provided in the embodiment of the present application is further introduced from the interaction of each module in the first computing device. Fig. 9 A flowchart of a network access method provided by an embodiment of the present application, which can be executed by a target application, a kernel network module, and a conversion module in a first computing device. Fig. 9 , the method comprises the following steps:
[0237] S901: The target application sends a first socket creation request to the kernel network module.
[0238] The first socket creation request is used to request the creation of a socket for accessing a target application in the second computing device. For example, the target application is an IPv6 application, and the type parameter of the first socket creation request is AF_INET6.
[0239] S902: The kernel network module creates a first socket according to the first socket creation request.
[0240] S903: The target application sends a connection request to the kernel network module.
[0241] Optionally, the connection request sent by the target application is used to request the first computing device to establish a connection with the second computing device. For example, the first IP address included in the connection request is 192.168.1.1.
[0242] S904: The kernel network module sends the connection request to the conversion module.
[0243] S905: The conversion module determines that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
[0244] S906: The conversion module sends a confirmation message to the kernel network module.
[0245] S907: The kernel network module closes the first socket and generates a third socket creation request.
[0246] The index of the third socket creation request is the same as the index of the first socket creation request, and the type parameter of the third socket creation request is different from the type parameter of the first socket creation request.
[0247] S908: The kernel network module generates a second socket according to the third socket creation request.
[0248] S909: The conversion module modifies the first IP address in the connection request into a second IP address according to a preset address mapping relationship.
[0249] For example, the conversion module modifies the first IP address 192.168.1.1 in the binding request into the second IP address FE80::1234::1:80.
[0250] S910: The conversion module sends the connection request with the modified address to the kernel network module.
[0251] S911: The kernel network module establishes a connection with the second computing device based on the second socket and the connection request.
[0252] S912: The kernel network module returns the execution result to the target application.
[0253] S913: The target application sends a write request to the kernel network module.
[0254] S914: The kernel network module sends a data packet to the second computing device according to the received write request.
[0255] S915: The target application sends a read request to the kernel network module.
[0256] S916: The kernel network module receives the data packet sent by the second computing device according to the received read request.
[0257] In addition, in some embodiments, the network access method provided in the embodiments of the present application can also be applied to network access between devices with multiple IP addresses under the same IP protocol stack. For example, the embodiments of the present application can also be used to implement network address conversion between IPv4 addresses and IPv4 addresses, or between IPv6 addresses and IPv6 addresses. In this implementation, the conversion module also needs to pre-store the address mapping relationship and perform network address conversion based on the address mapping relationship. The specific implementation can refer to the above embodiments and will not be repeated here.
[0258] Based on the above embodiments, the present application also provides a computing device 1000. Fig.10As shown, computing device 1000 includes: bus 1002, processor 1004, memory 1006 and communication interface 1008. Processor 1004, memory 1006 and communication interface 1008 communicate through bus 1002. Computing device 1000 can be a second computing device or a first computing device, and can be used to execute the functions performed by the second computing device or the first computing device in the network access method provided in the embodiment of the present application. It should be understood that the present application does not limit the number of processors and memories in computing device 1000.
[0259] The bus 1002 may be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Fig.10 The bus 1002 may include a path for transmitting information between various components of the computing device 1000 (eg, the memory 1006, the processor 1004, and the communication interface 1008).
[0260] The processor 1004 may include any one or more of a central processing unit (CPU), a graphics processing unit (GPU), a microprocessor (MP), or a digital signal processor (DSP).
[0261] The memory 1006 may include a volatile memory, such as a random access memory (RAM). The processor 1004 may also include a non-volatile memory, such as a read-only memory (ROM), a flash memory, a hard disk drive (HDD), or a solid state drive (SSD). It should be noted that the memory of the methods described herein is intended to include, but is not limited to, these and any other suitable types of memory.
[0262] The memory 1006 stores executable program codes, and the processor 1004 executes the executable program codes to respectively implement the functions performed by the aforementioned first computing device or the second computing device, thereby implementing the network access method provided in the embodiment of the present application. That is, the memory 106 stores instructions for executing the network access method. For example, the memory 1006 in the computing device 1000 stores instructions for executing the functions of the kernel network module and the conversion module.
[0263] The communication interface 1008 uses a transceiver module such as, but not limited to, a network interface card or a transceiver to implement communication between the computing device 1000 and other devices or a communication network.
[0264] The embodiment of the present application also provides a computing device cluster. The computing device cluster includes at least one computing device. The computing device can be a server, such as a central server, an edge server, or a local server in a local data center. In some embodiments, the computing device can also be a terminal device such as a desktop computer, a laptop computer, or a smart phone.
[0265] like Fig.11 As shown, the computing device cluster includes at least one computing device 1000. The memory 1006 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the method of the embodiment of the present application.
[0266] In some possible implementations, the memory 1006 of one or more computing devices 1000 in the computing device cluster may also store partial instructions for executing the method of the embodiment of the present application. In other words, the combination of one or more computing devices 1000 can jointly execute the instructions for executing the method of the embodiment of the present application.
[0267] It should be noted that the memory 1006 in different computing devices 1000 in the computing device cluster may store different instructions, which are respectively used to execute part of the functions performed by the first computing device or the second computing device in the above method embodiment. That is, the instructions stored in the memory 1006 in different computing devices 1000 can implement the functions of one or more modules in the above-mentioned first computing device, or implement the functions of one or more modules in the above-mentioned second computing device.
[0268] In some possible implementations, one or more computing devices in the computing device cluster may be connected via a network, which may be a wide area network or a local area network. Fig.12 A possible implementation is shown. Fig.12As shown, two computing devices 1000A and 1000B are connected via a network. Specifically, the network is connected via a communication interface in each computing device. In this type of possible implementation, the memory 1006 in the computing device 1000A stores instructions for executing the functions of the kernel network module. At the same time, the memory 1006 in the computing device 1000B stores instructions for executing the functions of the conversion module.
[0269] The present application embodiment also provides another computing device cluster. The connection relationship between the computing devices in the computing device cluster can be similar to that of Fig.11 and Fig.12 The connection mode of the computing device cluster is different in that the memory 1006 in one or more computing devices 1000 in the computing device cluster may store the same instructions for executing the network access method.
[0270] In some possible implementations, the memory 1006 of one or more computing devices 1000 in the computing device cluster may also store partial instructions for executing the network access method. In other words, the combination of one or more computing devices 1000 may jointly execute instructions for executing the network access method.
[0271] Based on the above embodiments, the present application further provides a computer program. When the computer program is run on a computer, the computer is enabled to execute the methods described in the embodiments of the present application.
[0272] Based on the above embodiments, the present application further provides a computer-readable storage medium, in which a computer program is stored. When the computer program is executed by a computer, the computer executes the methods described in the embodiments of the present application.
[0273] Based on the above embodiments, the present application further provides a chip, which is used to read a computer program stored in a memory to implement the methods described in the embodiments of the present application.
[0274] Based on the above embodiments, the present application provides a chip system, which includes a processor for supporting a computer device to implement the methods described in the embodiments of the present application. In one possible design, the chip system also includes a memory, which is used to store the necessary programs and data for the computer device. The chip system can be composed of a chip, or it can include a chip and other discrete devices.
[0275] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0276] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to 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 device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0277] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0278] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0279] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of protection of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A network access method, characterized in that: The method comprises: Receiving a first socket creation request initiated by a target application in a first computing device, wherein the first socket creation request is used to request creation of a socket for accessing a target application in a second computing device; Modifying a type parameter of the first socket creation request, and creating a socket based on the modified type parameter; the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the second computing device; receiving a connection request initiated by a target application in the first computing device, the connection request being used to request to establish a connection with the second computing device, the connection request including a first Internet Protocol IP address; Modify the first IP address in the connection request to a second IP address according to a preset address mapping relationship; the first IP address belongs to a first protocol stack, and the second IP address is an IP address of the second computing device under a second protocol stack supported by the second computing device; A connection is established with the second computing device based on the socket and the connection request.
2. The method according to claim 1, characterized in that After creating the socket based on the modified type parameter and before receiving a connection request initiated by the target application in the first computing device, the method further includes: Receiving an address binding request initiated by a target application in the first computing device, the address binding request including a third IP address; modifying the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship; binding the fourth IP address and the socket according to the address binding request; wherein the third IP address belongs to the first protocol stack, and the fourth IP address is the IP address of the first computing device under the second protocol stack; The establishing a connection with the second computing device based on the socket and the connection request comprises: A connection is established with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
3. The method according to claim 2, characterized in that After receiving the address binding request initiated by the target application, and before modifying the first IP address in the address binding request to the second IP address according to a preset address mapping relationship, the method further includes: Determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
4. The method according to claim 1, characterized in that The establishing a connection with the second computing device based on the socket and the connection request comprises: Selecting a fourth IP address from the plurality of IP addresses of the first computing device, the fourth IP address belonging to the same protocol stack as the second IP address; A connection is established with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
5. The method according to any one of claims 1 to 4, characterized in that: After receiving the first socket creation request initiated by the target application and before modifying the type parameter of the first socket creation request, the method further includes: It is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
6. The method according to claim 5, characterized in that The preset application list is system preconfigured or user-defined; The preset address mapping relationship is system preconfigured or user-defined.
7. The method according to any one of claims 1 to 6, characterized in that: After receiving a connection request initiated by a target application in the first computing device, and before modifying the first IP address in the connection request to a second IP address according to a preset address mapping relationship, the method further includes: Determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
8. The method according to any one of claims 1 to 7, characterized in that: After establishing a connection with the second computing device based on the socket and the connection request, the method further includes: Performing system call processing according to the second IP address; The system call processing includes reading a message from the second computing device and / or sending a message to the second computing device.
9. The method according to any one of claims 1 to 8, characterized in that The first protocol stack is an IPv4 protocol stack, and the second protocol stack is an IPv6 protocol stack; or The first protocol stack is an IPv6 protocol stack, and the second protocol stack is an IPv4 protocol stack.
10. A network access method, characterized in that: The method comprises: receiving a second socket creation request initiated by a target application in a second computing device, wherein the second socket creation request is used to request creation of a socket for monitoring messages sent by a target application in another device; Modifying a type parameter of the second socket creation request, and creating a socket based on the modified type parameter; the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the first computing device corresponding to the target application; receiving an address binding request initiated by a target application in the second computing device, wherein the address binding request includes a first Internet Protocol IP address; The first IP address in the address binding request is modified to a second IP address according to a preset address mapping relationship; the first IP address belongs to a first protocol stack, and the second IP address is an IP address of the second computing device under the second protocol stack; the second protocol stack is a protocol stack supported by the first computing device corresponding to the target application; The socket and the second IP address are bound according to the address binding request.
11. The method according to claim 10, characterized in that After receiving a second socket creation request initiated by a target application in a second computing device and before modifying a type parameter of the second socket creation request, the method further includes: It is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
12. The method according to claim 11, characterized in that The preset application list is system preconfigured or user-defined; The preset address mapping relationship is system preconfigured or user-defined.
13. The method according to any one of claims 10 to 12, characterized in that: After receiving the address binding request initiated by the target application in the second computing device, and before modifying the first IP address in the address binding request to the second IP address according to a preset address mapping relationship, the method further includes: Determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
14. The method according to any one of claims 10 to 13, characterized in that: After binding the socket and the second IP address according to the address binding request, the method further includes: Performing system call processing according to the second IP address; The system call processing includes reading a message from the first computing device and / or sending a message to the first computing device.
15. The method according to any one of claims 9 to 12, characterized in that: The first protocol stack is an IPv4 protocol stack, and the second protocol stack is an IPv6 protocol stack; or The first protocol stack is an IPv6 protocol stack, and the second protocol stack is an IPv4 protocol stack.
16. A network access method, characterized in that: The method comprises: Receiving a first socket creation request initiated by a target application in a first computing device, wherein the first socket creation request is used to request creation of a socket for accessing a target application in a second computing device; Creating a first socket according to the first socket creation request; receiving a connection request initiated by a target application in the first computing device, the connection request being used to request to establish a connection with the second computing device, the connection request including a first Internet Protocol IP address; the first IP address belongs to a first protocol stack; Determine that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address; the second IP address is an IP address of the second computing device under a second protocol stack supported by the second computing device; Closing the first socket, generating a third socket creation request, wherein the index of the third socket creation request is the same as the index of the first socket creation request, and the type parameter of the third socket creation request is different from the type parameter of the first socket creation request, and the protocol stack corresponding to the type parameter of the third socket creation request is the same as the protocol stack supported by the second computing device; Creating a second socket according to the third socket creation request; Modifying the first IP address in the connection request to a second IP address according to the preset address mapping relationship; the protocol stack to which the second IP address belongs is the same as the protocol stack supported by the second computing device; A connection is established with the second computing device based on the second socket and the connection request.
17. The method according to claim 16, characterized in that Before generating the third socket creation request, the method further includes: It is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
18. The method according to claim 17, characterized in that The preset application list is system preconfigured or user-defined; The preset address mapping relationship is system preconfigured or user-defined.
19. The method according to any one of claims 16 to 18, characterized in that: After establishing a connection with the second computing device based on the second socket and the connection request, the method further includes: Performing system call processing based on the second IP address; The system call processing includes reading a message from the second computing device and / or sending a message to the second computing device.
20. The method according to any one of claims 16 to 19, characterized in that: The generating of the third socket creation request comprises: The socket creation requests are generated in sequence according to the index arrangement order until the third socket creation request is generated.
21. A computing device, characterized in that The computing device comprises: A kernel network module, configured to receive a first socket creation request initiated by a target application, wherein the first socket creation request is used to request creation of a socket for accessing the target application in a second computing device; a conversion module, configured to modify a type parameter of the first socket creation request, wherein the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the second computing device; The kernel network module is further used to create a socket based on the modified type parameter; receive a connection request initiated by the target application, the connection request is used to request to establish a connection with the second computing device, the connection request includes a first Internet Protocol IP address, and the first IP address belongs to the first protocol stack; The conversion module is also used to modify the first IP address in the connection request to a second IP address according to a preset address mapping relationship; the second IP address is an IP address of the second computing device under a second protocol stack supported by the second computing device; The kernel network module is further configured to establish a connection with the second computing device based on the socket and the connection request.
22. The device according to claim 21, characterized in that The kernel network module is further used to: after creating a socket based on the modified type parameter and before receiving a connection request initiated by the target application, receive an address binding request initiated by the target application, the address binding request including a third IP address, and the third IP address belongs to the first protocol stack; The conversion module is further used to: modify the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship; the fourth IP address is the IP address of the first computing device under the second protocol stack; The kernel network module is further used for: binding the fourth IP address and the socket according to the address binding request; When the kernel network module establishes a connection with the second computing device based on the socket and the connection request, it is specifically used to: A connection is established with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
23. The device according to claim 22, characterized in that The conversion module is also used for: After receiving the address binding request initiated by the target application, before modifying the third IP address in the address binding request to a fourth IP address according to a preset address mapping relationship, determine that the preset address mapping relationship includes a mapping relationship between the third IP address and the fourth IP address.
24. The device according to claim 21, characterized in that The kernel network module is specifically used for: Selecting a fourth IP address from the plurality of IP addresses of the computing device, the fourth IP address belonging to the same protocol stack as the second IP address; A connection is established with the second computing device based on the socket according to the fourth IP address and the second IP address in the connection request.
25. The device according to any one of claims 22 to 24, characterized in that The conversion module is also used for: After receiving a first socket creation request initiated by a target application, before modifying a type parameter of the first socket creation request, it is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
26. The device according to any one of claims 21 to 25, characterized in that The conversion module is also used for: After receiving the connection request initiated by the target application, before modifying the first IP address in the connection request to the second IP address according to the preset address mapping relationship, it is determined that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
27. The device according to any one of claims 21 to 26, characterized in that The kernel network module is also used to: After establishing a connection with the second computing device based on the socket and the connection request, performing system call processing according to the second IP address; The system call processing includes reading a message from the second computing device and / or sending a message to the second computing device.
28. A computing device, characterized in that The computing device comprises: A kernel network module, configured to receive a second socket creation request initiated by a target application, wherein the second socket creation request is used to request the creation of a socket for monitoring messages sent by the target application in other devices; a conversion module, configured to modify a type parameter of the second socket creation request, wherein the protocol stack corresponding to the modified type parameter is the same as the protocol stack supported by the first computing device; The kernel network module is also used to create a socket based on the modified type parameter; receive an address binding request initiated by the target application, the address binding request including a first server Internet Protocol IP address; The conversion module is further used to modify the first IP address in the address binding request to a second IP address according to a preset address mapping relationship; the first IP address belongs to a first protocol stack, and the second IP address is an IP address of the second computing device under the second protocol stack; the second protocol stack is a protocol stack supported by the first computing device corresponding to the target application; The kernel network module is also used to bind the socket and the second IP address according to the address binding request.
29. The device according to claim 28, characterized in that The kernel network module is also used to: After receiving a second socket creation request initiated by a target application and before modifying a type parameter of the second socket creation request, it is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
30. The device according to claim 28 or 29, characterized in that The conversion module is also used for: After receiving the address binding request initiated by the target application, before modifying the first IP address in the address binding request to the second IP address according to the preset address mapping relationship, it is determined that the preset address mapping relationship includes a mapping relationship between the first IP address and the second IP address.
31. The device according to any one of claims 28 to 30, characterized in that The kernel network module is also used to: After binding the socket and the second IP address according to the address binding request, performing system call processing according to the second IP address; The system call processing includes reading a message from the first computing device and / or sending a message to the first computing device.
32. A computing device, characterized in that The computing device comprises: A kernel network module, for receiving a first socket creation request initiated by a target application, the first socket creation request being used to request the creation of a socket for accessing a target application in a second computing device; creating a first socket according to the first socket creation request; receiving a connection request initiated by the target application, the connection request being used to request the establishment of a connection with the second computing device, the connection request comprising a first server Internet Protocol IP address, the first IP address belonging to a first protocol stack; determining that a preset address mapping relationship includes a mapping relationship between the first IP address and a second IP address, the second IP address being the IP address of the second computing device under a second protocol stack supported by the second computing device; closing the first socket, generating a third socket creation request, the index of the third socket creation request being the same as the index of the first socket creation request, and the type parameter of the third socket creation request being different from the type parameter of the first socket creation request, the protocol stack corresponding to the type parameter of the third socket creation request being the same as the protocol stack supported by the second computing device; creating a second socket according to the third socket creation request; A conversion module, configured to modify the first IP address in the connection request into a second IP address according to the preset address mapping relationship; the protocol stack to which the second IP address belongs is the same as the protocol stack supported by the second computing device; The kernel network module is further configured to establish a connection with the second computing device based on the second socket and the connection request.
33. The device according to claim 32, characterized in that The conversion module is also used for: Before generating the third socket creation request, it is determined that the target application belongs to a preset application list, and the applications in the preset application list are applications that require network address translation.
34. The device according to claim 32 or 33, characterized in that The kernel network module is also used to: After establishing a connection with the second computing device based on the second socket and the connection request, performing system call processing based on the second IP address; The system call processing includes reading a message from the second computing device and / or sending a message to the second computing device.
35. The device according to any one of claims 32 to 34, characterized in that The kernel network module is specifically used for: The socket creation requests are generated in sequence according to the index arrangement order until the third socket creation request is generated.
36. A computing device, characterized in that The computing device includes a processor and a memory; The processor is configured to execute instructions stored in the memory, so that the computing device executes the method according to any one of claims 1 to 9, or executes the method according to any one of claims 10 to 15, or executes the method according to any one of claims 16 to 20.
37. A computing device cluster, characterized in that: comprising at least one computing device, each computing device comprising a processor and a memory; The processor of the at least one computing device is used to execute instructions stored in the memory of the at least one computing device, so that the computing device cluster executes the method according to any one of claims 1-9, or executes the method according to any one of claims 10-15, or executes the method according to any one of claims 16-20.
38. A computer program product comprising instructions, characterized in that When the instructions are executed by a computing device, the computing device executes the method according to any one of claims 1 to 9, or executes the method according to any one of claims 10 to 15, or executes the method according to any one of claims 16 to 20.
39. A computer-readable storage medium, characterized in that: The method comprises computer program instructions. When the computer program instructions are executed by a computing device, the computing device executes the method according to any one of claims 1 to 9, or executes the method according to any one of claims 10 to 15, or executes the method according to any one of claims 16 to 20.
Citation Information
Cited By
Protocol stack attribute modification method and device
CN119676326A
A method and apparatus for modifying protocol stack attributes
CN119676326B
