Network sharing method, device and storage medium
By acquiring and configuring the inlet and exit network types, the problem that the terminal device only supports the current network type is solved, achieving reasonable allocation of network resources and improving user experience.
Patent Information
- Application Number
- CN202211438593.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-16
- Publication Date
- 2025-08-26
- Estimated Expiration
- 2042-11-16
AI Technical Summary
In the prior art, terminal devices only support sharing the currently used network type, resulting in wasted network resources and reducing user experience.
By acquiring the inlet network type and the exit network type, the inlet network between the first device and the second device, and the exit network between the first device and the public network, and performing network address conversion, the reasonable allocation of network resources is realized.
Optimize network resource configuration, improve user experience, and realize the rational allocation and effective utilization of network resources.
Smart Images

Figure CN115941374B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information interaction, and in particular to a network sharing method, device and storage medium. Background Art
[0002] Tethering uses computers and other terminal devices as a carrier, providing the ability to share Ethernet, Wi-Fi, and cellular data with third-party devices. These third-party devices can access the internet through tethering. While terminal devices can share a variety of network types, current mainstream devices only support sharing the network currently in use, resulting in wasted network resources and a reduced user experience. Summary of the Invention
[0003] The main purpose of this application is to provide a network sharing method, device and storage medium, which aims to perform network sharing based on the inlet network type and the outlet network type, realize the reasonable allocation of network resources, optimize the network resource configuration, and improve the user experience.
[0004] In a first aspect, the present application provides a network sharing method, the network sharing method comprising the following steps:
[0005] Get the ingress network type and egress network type;
[0006] configuring an ingress network between the first device and the second device according to the ingress network type, the ingress network being used for data transmission between the first device and the second device;
[0007] configuring an egress network between the first device and a public network according to the egress network type, the egress network being used for data transmission between the first device and the public network;
[0008] Network address translation is configured based on the ingress network and the egress network.
[0009] In a second aspect, the present application further provides a computer device, comprising a memory and a processor;
[0010] The memory is used to store computer programs;
[0011] The processor is used to execute the computer program and implement any one of the network sharing methods provided in the embodiments of the present application when executing the computer program.
[0012] In a third aspect, the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the processor enables the processor to implement any one of the network sharing methods provided in the embodiments of the present application.
[0013] This application provides a network sharing method, device, and computer-readable storage medium. The method obtains an ingress network type and an egress network type; configures an ingress network between a first device and a second device based on the ingress network type, where the ingress network is used for data transmission between the first and second devices; configures an egress network between the first device and a public network based on the egress network type, where the egress network is used for data transmission between the first device and the public network; and configures network address translation based on the ingress network and the egress network. Sharing the network based on the ingress network type and the egress network type achieves reasonable allocation of network resources, optimizes network resource configuration, and improves user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0015] Figure 1 This is a flow chart of a network sharing method provided in an embodiment of the present application;
[0016] Figure 2 This is a flow chart of a network sharing method provided in an embodiment of the present application;
[0017] Figure 3 This is a flow chart of a network sharing method provided in an embodiment of the present application;
[0018] Figure 4 This is a flow chart of a network sharing method provided in an embodiment of the present application;
[0019] Figure 5 This is a schematic block diagram of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0021] The flowcharts shown in the accompanying drawings are for illustrative purposes only and do not necessarily include all contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may be decomposed, combined, or partially merged, so the actual execution order may vary depending on the actual situation.
[0022] The term "and / or" as used in this specification and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0023] The following describes some embodiments of the present application in detail with reference to the accompanying drawings. In the absence of conflict, the following embodiments and features therein may be combined with each other.
[0024] See also Figure 1 , Figure 1 This is a schematic flow chart of a network sharing method provided by an embodiment of the present application. The network sharing method can obtain an ingress network type and an egress network type; configure an ingress network between a first device and a second device according to the ingress network type, where the ingress network is used for data transmission between the first device and the second device; configure an egress network between the first device and a public network according to the egress network type, where the egress network is used for data transmission between the first device and the public network; and configure network address translation based on the ingress network and the egress network. This achieves reasonable allocation of network resources, optimizes network resource configuration, and improves user experience.
[0025] like Figure 1 As shown, the network sharing method includes steps S101 to S104.
[0026] S101. Obtain an ingress network type and an egress network type.
[0027] Among them, Figure 2 As shown, the ingress network type is the communication technology type that realizes data transmission between devices, and the egress network type is the communication technology type that realizes data transmission between the device and the public network.
[0028] It should be noted that when the ingress network type or egress network type is Ethernet, the corresponding network port name also needs to be obtained.
[0029] Specifically, in order to achieve reasonable allocation of network resources, the ingress network type and the egress network type are obtained.
[0030] In some embodiments, to further improve user experience, obtaining the ingress network type and the egress network type includes: obtaining a selection operation instruction, the selection operation instruction being used to select the ingress network type and the egress network type; checking the validity of the selection operation instruction; and if the selection operation instruction is valid, obtaining the ingress network type and the egress network type according to the selection operation instruction.
[0031] Specifically, the selection operation instruction made by the user is obtained, and the instruction data of the entry network type and the instruction data of the exit network type are obtained based on the selection operation instruction; it is checked whether the instruction data of the entry network type and the instruction data of the exit network type meet the requirements for implementing the network sharing function; if the requirements for implementing the network sharing function are met, the selection operation instruction is valid, and the entry network type and the exit network type are obtained according to the selection operation instruction; if the requirements for implementing the network sharing function are not met, the selection operation instruction is invalid.
[0032] It should be noted that command data refers to the data included in the user's command. Different network types require different command data. For example, when a user selects a cellular network as the egress network, the command data only needs to include the network type data. For another example, when a user selects Ethernet as the egress network, the command data must include not only the network type data but also the network port name data, because network sharing via Ethernet requires specifying the network port name. In other words, when a user selects Ethernet as the ingress network type, the network type command data must include the network port data specifying the network port name. If the network port name is not specified or does not exist, the network sharing function cannot be implemented, and the selected operation command is invalid.
[0033] It should be understood that only when the instruction data of the inlet network type and the instruction data of the outlet network type meet the requirements for realizing the network sharing function, is it considered a valid input instruction; otherwise, the selected operation instruction is invalid.
[0034] For example, based on the selection operation instruction, the inlet network type is obtained as Ethernet, and the network port name data is specified in the instruction data, the instruction data of the inlet network type meets the requirements for implementing the network sharing function; continue to detect whether the technical information of the outlet network type meets the requirements for implementing the network sharing function. If it meets the requirements, the selection operation instruction is valid, and the inlet network type and outlet network type are obtained according to the selection operation instruction; if it does not meet the requirements, the selection operation instruction is invalid.
[0035] In some embodiments, the checking of the validity of the selection operation instruction includes: if the ingress network type selected by the selection operation instruction is not within the preset ingress network type range, the selection operation instruction is invalid; if the egress network type selected by the selection operation instruction is not within the preset egress network type range, the selection operation instruction is invalid; if the ingress network type and the egress network type selected by the selection operation instruction are both Ethernet, and the network port name specified by the ingress network type is the same as the network port name specified by the egress network type, the selection operation instruction is invalid.
[0036] The preset entry network type range can be pre-set based on device capabilities. Different devices support different communication technologies, and the preset entry network type range can be determined based on the types of communication technologies available between the devices. Common entry network types include Ethernet and WiFi AP mode. Hereinafter, WiFi AP mode will be referred to as WiFi (AP).
[0037] It should be noted that since Ethernet requires the specification of a network port name to realize the network sharing function, when the inlet network type is Ethernet, the corresponding preset inlet network type range also includes a valid and usable network port name range. If the network port name in the inlet network type instruction data does not belong to the valid and usable network port name range, the selected operation instruction is invalid.
[0038] The preset egress network type range can be pre-set based on the device's capabilities. The preset egress network type range can be determined based on how different devices communicate with the public network. Common egress network types include Ethernet, cellular data, and WiFi STA mode. Hereinafter, WiFi STA mode will be referred to as WiFi (STA).
[0039] It should be noted that since Ethernet requires the specification of a network port name to realize the network sharing function, when the export network type is Ethernet, the corresponding preset export network type range also includes a valid and usable network port name range. If the network port name in the export network type instruction data does not belong to the valid and usable network port name range, the selected operation instruction is invalid.
[0040] For example, if the inbound network type selected by the selection instruction is cellular data, which is not within the range of inbound network types, the selection instruction is invalid. For another example, if both the inbound and outbound network types selected by the selection instruction are Ethernet, and the network port name specified by the inbound network type is the same as the network port name specified by the outbound network type, the selection instruction is invalid. For another example, if both the inbound and outbound network types selected by the selection instruction are Ethernet, and the network port name specified by the inbound network type is not within the range of valid and usable network port names, the selection instruction is invalid.
[0041] It should be understood that the validity check of the selected operation instruction is for the realization of the network sharing function. If the inlet network type is not within the preset inlet network type range, or the outlet network type is not within the preset outlet network type range, or the Ethernet port of the outlet network and the inlet network is the same, network sharing cannot be realized.
[0042] S102: Configure an ingress network between the first device and the second device according to the ingress network type, where the ingress network is used for data transmission between the first device and the second device.
[0043] The first device is a device that provides network sharing, and the second device is a device that needs to receive network sharing. Figure 2 As shown, the second device can access the public network based on the first device. It should be understood that the first device and the second device are in the same local area network.
[0044] Specifically, in order to perform network sharing according to the ingress network type, a corresponding ingress network is configured between the first device and the second device according to the ingress network type.
[0045] In some embodiments, as Figure 2 As shown, configuring the ingress network between the first device and the second device according to the ingress network type includes steps S1021 to S1023.
[0046] S1021. Generate a corresponding adaptation solution based on the ingress network type.
[0047] The adaptation scheme is a scheme for adjusting the operating parameters of the device to adjust the network communication function of the device to a state capable of executing the network sharing function. For example, when the entry network type is WiFi (AP), the first device is controlled to enable the hotspot function in the WiFi. The specific scheme is not limited here.
[0048] S1022: Request service from the ingress network according to the adaptation solution.
[0049] Specifically, based on the ingress network type, a corresponding adaptation processing solution is generated; and according to the adaptation processing solution, the operating parameters of the device are adjusted so that the device starts the network communication function corresponding to the ingress network.
[0050] S1023. Configure an IP address for the portal network on the first device side and the second device side respectively.
[0051] The first device end is a port where the ingress network is connected to the first device, and the second device end is a port where the ingress network is connected to the second device.
[0052] Specifically, IP addresses are configured for the ingress network on the first device side and the second device side respectively to enable data transmission between the first device and the second device.
[0053] In some embodiments, configuring IP addresses for the entry network on the first device side and the second device side respectively includes: selecting a currently unused network segment as a shared network segment; randomly selecting an IP address within the shared network segment and configuring it to the first device side of the entry network; and using a DHC server to select another IP address within the shared network segment and configuring it to the second device side of the entry network.
[0054] The "network segment" is the IP segment of the internal network, which is a range of IP addresses. A Dynamic Host Configuration Protocol (DHCP) server provides an automated method for allocating and updating IP addresses and other configuration information on a network. It should be understood that to ensure network communication between devices, you can manually configure the IP addresses of devices, or you can install a DHCP server to assign IP addresses to each client computer or device on the network.
[0055] Specifically, an unused network segment is selected as a shared network segment; an IP is selected within the shared network segment as the IP address of the first device, the selected IP address is configured to the first device end of the portal network, the DHCP server is started, an IP address is allocated to the second device within the range of the shared network segment, and the IP address is configured to the second device end of the portal network.
[0056] S103: Configure an egress network between the first device and a public network according to the egress network type, where the egress network is used for data transmission between the first device and the public network.
[0057] Specifically, in order to perform network sharing according to the egress network type, a corresponding egress network is configured between the first device and the public network according to the egress network type.
[0058] In some embodiments, configuring the ingress network between the first device and the second device according to the ingress network type includes steps S1021 to S1023.
[0059] In some embodiments, as Figure 3 As shown, configuring the egress network between the first device and the public network according to the egress network type includes steps S1031 to S1033.
[0060] S1031. Obtain a network type currently used by the first device.
[0061] The currently used network type is the network type currently being used by the first device.
[0062] It should be understood that, in order to rationalize network resource configuration, when the first device has multiple communication technologies capable of performing data transmission on a public network, the egress network type may be different from the network type currently used by the first device.
[0063] For example, the network type currently used by the first device is a cellular network. In order to ensure the communication speed of the mobile cellular network, the export network type can be set to WIFI (STA), so that the second device uses WIFI (STA) without occupying the mobile cellular network, and can use network resources more fully and reasonably.
[0064] S1032: Determine whether the currently used network type is consistent with the egress network type.
[0065] It should be understood that when the currently used network type and the egress network type are both Ethernet, the method further includes determining whether the currently used Ethernet port is consistent with the port specified for the egress network type. If the currently used network type is consistent with the egress network type, the currently used network is directly used as the egress network.
[0066] S1033: If they are inconsistent, request to start the network corresponding to the egress network type.
[0067] Specifically, if they are inconsistent, a request is made to start the egress network corresponding to the egress network type to implement network sharing from the egress network type.
[0068] In some embodiments, after the request to start the network corresponding to the egress network type, it also includes: obtaining the source address of the second device; formulating a routing strategy based on the egress network and the source address of the second device, the routing strategy being used to set the data forwarding path of the second device to the egress network.
[0069] It should be understood that after formulating the routing strategy based on the source address of the second device, when the source address of the second device is identified, the export network will be used to forward the data packet, without interfering with the current network operation of the first device, and network sharing will be provided to the second device from the export network type.
[0070] For example, the network currently used by the first device is cellular data, and the export network type is WiFi (STA). At this time, a routing strategy is formulated for the source address of the second device, and all data packets with the source address of the second device are transmitted through WiFi (STA). The data transmission of the first device is not affected and still uses cellular data for transmission. In this way, the reasonable allocation of network resources is achieved, the network resource configuration is optimized, and the user experience is improved.
[0071] S104: Configure network address translation based on the ingress network and the egress network.
[0072] Specifically, according to the information of the ingress network and the egress network, the network address translation is configured to convert the private IP address of the internal network into a public IP address, so that the data packet of the second device is transmitted to the public network through the first device.
[0073] In some embodiments, configuring network address translation based on the ingress network and the egress network includes: obtaining ingress network information based on the ingress network, the ingress network information including network port information and network segment information; obtaining egress network information based on the egress network, the egress network information including network port information and network segment information; and configuring network address translation according to the ingress network information and the egress network information.
[0074] Specifically, NAT forwarding is configured according to the network port name information and network segment information of the ingress network and the network port name information and network segment information of the egress network, so that all data packets incoming from the ingress network are forwarded through the egress network, so that the second device can access the public network.
[0075] In some embodiments, after configuring network address translation based on the ingress network and the egress network, the method further includes monitoring the ingress network status and disabling network sharing when the egress network is disconnected. For example, when the ingress network type is Ethernet, disabling network sharing when a network cable is unplugged is detected.
[0076] In some embodiments, the egress network status is monitored. When the egress network information changes, the changed egress network information is obtained, the previously configured NAT forwarding is deleted, and NAT forwarding is reconfigured based on the changed egress network information and the ingress network information. This allows all incoming packets from the ingress network to be forwarded through the changed egress network, allowing the second device to access the public network. For example, if a user needs to switch the egress network type, they only need to select the new network type and configure NAT forwarding to switch the egress network type, thereby improving the user experience.
[0077] For example, the above method can be implemented in the form of a computer program. Figure 5 Runs on the computer equipment shown.
[0078] See also Figure 5 , Figure 5 1 is a schematic diagram of a computer device provided in an embodiment of the present application. The computer device may be a terminal device, such as a mobile phone, a tablet computer, or a wearable device.
[0079] like Figure 5As shown, the computer device includes a processor, a memory, and a network interface connected via a system bus, wherein the memory may include a volatile storage medium, a non-volatile storage medium, and an internal memory.
[0080] The non-volatile storage medium can store an operating system and a computer program. The computer program includes program instructions, and when the program instructions are executed, the processor can execute any network sharing method.
[0081] The processor is used to provide computing and control capabilities and support the operation of the entire computer equipment.
[0082] The internal memory provides an environment for the operation of the computer program in the non-volatile storage medium. When the computer program is executed by the processor, the processor can execute any network sharing method.
[0083] The network interface is used for network communication, such as sending assigned tasks. Those skilled in the art will understand that the structure of the computer device is merely a block diagram of a portion of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0084] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.
[0085] In some embodiments, the processor is configured to execute a computer program stored in the memory to implement the following steps:
[0086] Get the ingress network type and egress network type;
[0087] configuring an ingress network between the first device and the second device according to the ingress network type, the ingress network being used for data transmission between the first device and the second device;
[0088] configuring an egress network between the first device and a public network according to the egress network type, the egress network being used for data transmission between the first device and the public network;
[0089] Network address translation is configured based on the ingress network and the egress network.
[0090] In some embodiments, the processor is further used to: obtain a selection operation instruction, the selection operation instruction being used to select an ingress network type and an egress network type; check the validity of the selection operation instruction; and if the selection operation instruction is valid, obtain the ingress network type and the egress network type according to the selection operation instruction.
[0091] In some embodiments, the processor is further used to: if the ingress network type selected by the selection operation instruction is not within the preset ingress network type range, the selection operation instruction is invalid; if the egress network type selected by the selection operation instruction is not within the preset egress network type range, the selection operation instruction is invalid; if the ingress network type and the egress network type selected by the selection operation instruction are both Ethernet, and the network port name specified by the ingress network type is the same as the network port name specified by the egress network type, the selection operation instruction is invalid.
[0092] In some embodiments, the processor is further configured to: generate a corresponding adaptation processing solution based on the ingress network type; request services from the ingress network according to the adaptation processing solution; and configure IP addresses for the ingress network on the first device side and the second device side, respectively.
[0093] In some embodiments, the processor is also used to: select a currently unused network segment as a shared network segment; select any IP address within the shared network segment and configure it to the first device end of the portal network; use the DHC server to select another IP address within the shared network segment and configure it to the second device end of the portal network.
[0094] In some embodiments, the processor is further used to: obtain the network type currently used by the first device; determine whether the currently used network type is consistent with the egress network type; if not, request to start the network corresponding to the egress network type.
[0095] In some embodiments, the processor is further used to: obtain the source address of the second device; formulate a routing strategy based on the egress network and the source address of the second device, the routing strategy being used to set the data forwarding path of the second device to the egress network.
[0096] In some embodiments, the processor is further used to: obtain ingress network information based on the ingress network, the ingress network information including network port information and network segment information; obtain egress network information based on the egress network, the egress network information including network port information and network segment information; and configure network address translation according to the ingress network information and the egress network information.
[0097] An embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. The computer program includes program instructions, and when the program instructions are executed, any one of the network sharing methods provided in the embodiments of the present application is implemented.
[0098] The computer-readable storage medium may be an internal storage unit of the computer device described in the aforementioned embodiment, such as a hard disk or memory of the computer device. The computer-readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a SmartMedia Card (SMC), a Secure Digital (SD) card, a flash memory card, etc., equipped on the computer device.
[0099] Furthermore, the computer-readable storage medium may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function, etc.; the data storage area may store data created according to the use of the blockchain node, etc.
[0100] This invention refers to a novel application model for computer technologies, including storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms, in the blockchain language model. Blockchain, in essence, is a decentralized database consisting of a series of data blocks linked together using cryptographic methods. Each block contains information about a batch of online transactions, used to verify the validity of this information (to prevent counterfeiting) and generate the next block. Blockchain can include an underlying blockchain platform, a platform product and service layer, and an application service layer.
[0101] The above description is merely a specific embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in the present application, and such modifications or substitutions should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.
Claims
1. A network sharing method, characterized in that: The method comprises: Acquire a selection operation instruction, and acquire instruction data of an ingress network type and instruction data of an egress network type based on the selection operation instruction; If the entry network type selected by the selection operation instruction is not within the preset entry network type range, the selection operation instruction is invalid; If the egress network type selected by the selection operation instruction is not within the preset egress network type range, the selection operation instruction is invalid; If the ingress network type and the egress network type selected by the selection operation instruction are both Ethernet, and the network port name specified by the ingress network type is the same as the network port name specified by the egress network type, the selection operation instruction is invalid; If the selection operation instruction is valid, obtaining the ingress network type and the egress network type; configuring an ingress network between the first device and the second device according to the ingress network type, the ingress network being used for data transmission between the first device and the second device; configuring an egress network between the first device and a public network according to the egress network type, the egress network being used for data transmission between the first device and the public network; Network address translation is configured based on the ingress network and the egress network.
2. The method according to claim 1, characterized in that Configuring the ingress network between the first device and the second device according to the ingress network type includes: Generate corresponding adaptation solutions based on the ingress network type; requesting a service from the portal network according to the adaptation processing solution; An IP address is configured for the ingress network on the first device side and the second device side respectively.
3. The method according to claim 2, characterized in that Configuring an IP address for the ingress network on the first device and the second device respectively includes: Select a network segment that is not currently in use as a shared network segment; Select an IP address in the shared network segment and assign it to the first device on the entry network; Another IP address is selected in the shared network segment by using the DHC server and configured to the second device end of the portal network.
4. The method according to claim 1, wherein Configuring the egress network between the first device and the public network according to the egress network type includes: Obtaining a network type currently used by the first device; Determine whether the currently used network type is consistent with the egress network type; If they are inconsistent, a request is made to start the network corresponding to the egress network type.
5. The method according to claim 4, characterized in that After the request to start the network corresponding to the egress network type, the method further includes: Obtaining a source address of the second device; A routing strategy is formulated based on the egress network and a source address of the second device, where the routing strategy is used to set a data forwarding path of the second device to the egress network.
6. The method according to claim 1, characterized in that The configuring network address translation based on the ingress network and the egress network includes: acquiring ingress network information based on the ingress network, the ingress network information including network port information and network segment information; Acquire egress network information based on the egress network, the egress network information including network port information and network segment information; Network address translation is configured according to the ingress network information and the egress network information.
7. A computer device, characterized in that: The computer device includes a memory and a processor; The memory is used to store computer programs; The processor is configured to execute the computer program and implement the network sharing method according to any one of claims 1 to 6 when executing the computer program.
8. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, which, when executed by a processor, enables the processor to implement the network sharing method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Network sharing method and device
CN110752975A
Electronic device for providing tethering service and method thereof
WO2022191348A1