CN111726798A - Method for determining hot IP address of terminal and terminal - Google Patents

Method for determining hot IP address of terminal and terminal Download PDF

Info

Publication number
CN111726798A
CN111726798A CN201910213945.4A CN201910213945A CN111726798A CN 111726798 A CN111726798 A CN 111726798A CN 201910213945 A CN201910213945 A CN 201910213945A CN 111726798 A CN111726798 A CN 111726798A
Authority
CN
China
Prior art keywords
address
terminal
hot spot
numerical value
section
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201910213945.4A
Other languages
Chinese (zh)
Inventor
董亮亮
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hisense Mobile Communications Technology Co Ltd
Original Assignee
Hisense Mobile Communications Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hisense Mobile Communications Technology Co Ltd filed Critical Hisense Mobile Communications Technology Co Ltd
Priority to CN201910213945.4A priority Critical patent/CN111726798A/en
Publication of CN111726798A publication Critical patent/CN111726798A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W8/00Network data management
    • H04W8/26Network addressing or numbering for mobility support

Abstract

The invention relates to the technical field of wireless communication, in particular to a method for determining a hot spot IP address of a terminal and the terminal, which are used for solving the problems that the existing terminal only adopts a default IP address when generating the hot spot IP address, and the method for generating the hot spot IP address is not flexible enough. The terminal selects a first random number from a first preset range; determining the selected first random number as a numerical value of a third section of the hot spot IP address; and generating a hot spot IP address according to the determined numerical value of the third section. In the embodiment of the invention, the randomly selected numerical value is used as the numerical value of the third section of the hot IP address, so that the hot IP address of the terminal is flexibly generated, the default invariable hot IP address of the system is avoided, and the system performance of the terminal is further improved.

Description

Method for determining hot IP address of terminal and terminal
Technical Field
The invention belongs to the technical field of wireless communication, and particularly relates to a method for determining a hotspot IP address of a terminal and the terminal.
Background
With the development of society and the progress of science and technology, intelligent terminals have the functions of network sharing and portable hot spots. Specifically, after the portable hotspot function is opened by the intelligent terminal, other terminals having a Wireless Local Area Network (WLAN) function access to the hotspot of the intelligent terminal, and the intelligent terminal shares its own data service to the other terminals that access.
At present, an intelligent terminal generates a hot spot IP address for hot spot service, and the hot spot IP address defaulted by a system is used as the hot spot IP address of the intelligent terminal. For example, the default hot IP address of the Android system is 192.168.43.1, and when the intelligent terminal is a terminal of the Android system, the intelligent terminal sets the hot IP address to be 192.168.43.1, and the hot IP address is fixed and unchangeable; the Dynamic Host Configuration Protocol (DHCP) range is 192.168.43.2-192.168.43.254; when other terminals access the hot spot of the intelligent terminal, the intelligent terminal allocates an IP address to the other terminals from the DHCP range.
In summary, the existing terminal can only adopt the default IP address of the system when generating the hot IP address, and this way of generating the hot IP address is not flexible enough.
Disclosure of Invention
The invention provides a method for determining a hot spot IP address of a terminal and the terminal, which are used for solving the problems that the existing terminal only can adopt a default IP address when generating the hot spot IP address, and the mode for generating the hot spot IP address is not flexible enough.
Based on the foregoing problems, in a first aspect, an embodiment of the present invention provides a method for determining a hotspot IP address of a terminal, including:
the terminal selects a first random number from a first preset range;
the terminal determines that the selected first random number is used as a numerical value of a third section of the hot spot IP address;
and the terminal generates a hot spot IP address according to the determined numerical value of the third section.
In a second aspect, an embodiment of the present invention provides a terminal, including at least one processing unit and at least one storage unit;
wherein the storage unit stores program code that, when executed by the processing unit, causes the processing unit to perform the following:
selecting a first random number from a first preset range;
determining the selected first random number as a numerical value of a third section of the hot spot IP address;
and generating a hot spot IP address according to the determined numerical value of the third section.
In a third aspect, an embodiment of the present invention provides an apparatus for determining a hotspot IP address of a terminal, including:
the selection module is used for selecting a first random number from a first preset range;
the determining module is used for determining the selected first random number as a numerical value of a third section of the hotspot IP address;
and the processing module is used for generating the hot spot IP address according to the determined numerical value of the third section.
In a fourth aspect, an embodiment of the present invention provides a computer-readable medium, on which a computer program is stored, wherein the computer program is configured to, when executed by a processor, implement the steps of the method according to the first aspect.
When determining the hot spot IP address, the terminal randomly selects a first random number from a first preset range, wherein the hot spot IP address comprises four sections, and the selected first random number is used as a numerical value of a third section in the hot spot IP address; and generating the hot spot IP address according to the numerical value of the third section. The embodiment of the invention takes the randomly selected numerical value as the numerical value of the third section in the hot IP address, thereby flexibly generating the hot IP address of the terminal, avoiding using the default invariable hot IP address of the system and further improving the system performance of the terminal.
Drawings
Fig. 1 is a flowchart of a first method for determining a hot spot IP address of a terminal according to an embodiment of the present invention;
fig. 2 is an overall flowchart of determining a hotspot IP address of a terminal according to a first embodiment of the present invention;
fig. 3 is a schematic diagram of a first method for establishing a connection between two terminals according to an embodiment of the present invention;
fig. 4 is a schematic diagram of establishing a connection between two terminals according to a second embodiment of the present invention;
fig. 5 is a flowchart of a second method for determining a hot spot IP address of a terminal according to the embodiment of the present invention;
fig. 6 is an overall flowchart of determining a hotspot IP address of a terminal according to a second embodiment of the present invention;
fig. 7 is a schematic diagram of establishing a connection between two terminals according to a third embodiment of the present invention;
fig. 8 is a schematic diagram illustrating a fourth method for establishing a connection between two terminals according to an embodiment of the present invention;
fig. 9 is a schematic structural diagram of a first terminal according to an embodiment of the present invention;
fig. 10 is a schematic structural diagram of a second terminal according to an embodiment of the present invention;
fig. 11 is a schematic structural diagram of a device for determining a hot spot IP address of a terminal according to an embodiment of the present invention.
Detailed Description
The terminal of the embodiment of the present invention may be a cellular phone, a cordless phone, a Session Initiation Protocol (SIP) phone, a Wireless Local Loop (WLL) station, a Personal Digital Assistant (PDA), or the like. The terminal provided by the embodiment of the invention has the functions of network sharing and portable hot spots.
The embodiment of the invention provides a method for determining a hot IP address of a terminal, wherein the terminal selects a first random number from a first preset range; the terminal determines that the selected first random number is used as a numerical value of a third section of the hot spot IP address; and the terminal generates a hot spot IP address according to the determined numerical value of the third section.
When determining the hot spot IP address, the terminal randomly selects a first random number from a first preset range, wherein the hot spot IP address comprises four sections, and the selected first random number is used as a numerical value of a third section in the hot spot IP address; and generating the hot spot IP address according to the numerical value of the third section. The embodiment of the invention combines the randomly selected numerical value with the preset rule, thereby flexibly generating the hot IP address of the terminal, avoiding using the default invariable hot IP address of the system and further improving the system performance of the terminal.
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
An embodiment of the present invention provides a method for determining a hot spot IP address of a terminal, as shown in fig. 1, where the method includes:
101, a terminal selects a first random number from a first preset range;
step 102, the terminal determines that the selected first random number is used as a numerical value of a third section of the hotspot IP address;
and 103, the terminal generates a hot spot IP address according to the determined numerical value of the third section.
In the embodiment of the present invention, the hot IP address has four segments, for example, the format is x.x.x.x, and the first segment, the second segment, the third segment, and the fourth segment are sequentially arranged from front to back.
It should be noted that, in an alternative provided by the embodiment of the present invention, the terminal selects the first random number from the first preset range, and uses the first random number as a numerical value of the third segment of the hotspot IP address, and the numerical values of other segments may use a numerical value in a default hotspot IP address configured by the system.
In addition, the embodiment of the invention also provides an alternative scheme, wherein the terminal selects a first random number from a first preset range; determining the selected first random number as a numerical value of a third section of the hot spot IP address; the terminal selects a second random number from a second preset range; and determining the selected second random number as the numerical value of the second section of the hot spot IP address.
In a second alternative, the terminal selects a first random number from a first preset range, selects a second random number from a second preset range, uses the first random number as a numerical value of a third section in the hot spot IP address, and uses the second random number as a numerical value of a second section in the hot spot IP address; the values of the other segments may use the values in the default hotspot IP address of the system configuration.
The two schemes are explained separately below.
One, selecting a random number
In this situation, the terminal selects a first random number from a first preset range, and the first random number is used as a numerical value of a third section of the hotspot IP address; and the terminal generates a hot spot IP address according to the determined numerical value of the third section.
Optionally, the preset range of the embodiment of the invention is 55-254;
the terminal selects a first random number from 55-254 and uses the selected first random number as the value of the third segment of the hotspot IP address.
The embodiment of the invention avoids the conflict between the hot IP address of the terminal and the Bluetooth IP address, the USB shared IP address and the like of the terminal, and sets the preset range to be 55-254.
For other segments except the third segment in the hot spot IP address, when the terminal generates the hot spot IP address, determining the numerical values of the other segments according to the following modes:
the terminal determines that a first preset value is used as a numerical value of a first section of the hot spot IP address, a second preset value is used as a numerical value of a second section of the hot spot IP address, and a third preset value is used as a numerical value of a fourth section of the hot spot IP address.
Optionally, the first preset value is 192, the second preset value is 168, and the third preset value is 1.
It should be noted that, the numerical values of the first segment and the second segment in the hot spot IP address adopt the default numerical values of the first segment and the second segment in the hot spot IP address, and only the numerical value of the third segment is randomly generated.
Then, assuming that the first random number selected by the terminal from the preset range is X, the determined hotspot IP address of the terminal is: 192.168. x.1; the DHCP range of the hotspot is: 192.168.X.2 ~ 192.168. X.254.
It should be noted here that since the IP address of 192.168.X.m is a private network address in a class C address, and the private network address is reserved in the IP protocol specification and is dedicated to a private network, using such an address as a hot spot IP address of a terminal can effectively avoid collision with other types of IP addresses.
In addition, an optional implementation manner is that after the hot spot IP address of the terminal is determined in the above manner, the terminal determines whether the hot spot IP address is the same as the WiFi IP address of the terminal, when the hot spot IP address is the same as the WiFi IP address of the terminal, the terminal reselects the first random number from the preset range, uses the selected first random number as the numerical value of the third segment of the hot spot IP address, and generates the hot spot IP address according to the newly determined numerical value of the third segment.
Therefore, the conflict between the WiFi IP address and the hot spot IP address of the terminal is further avoided.
The DHCP service is started at the beginning of the terminal system, namely, the DHCP service also needs to be started when the system of the terminal is started. The opening of the hot spot belongs to manual operation, and the hot spot is opened after receiving an operation instruction of a user.
The timing of determining the hot IP address of the terminal in the embodiment of the present invention may be:
the method comprises the steps that 1, after a terminal is started and before a DHCP service is started, a hot IP address of the terminal is determined;
and at the moment 2, after receiving an operation instruction of starting the hot spot of the user, determining the hot spot IP address of the terminal.
The following description will be made for different timings.
And aiming at the opportunity 1, after the hotspot IP address of the terminal is determined at the opportunity, determining a DHCP range corresponding to the hotspot IP address, setting the determined DHCP range into DHCP service, and starting the DHCP service. And when the hotspot IP address of the terminal is determined at the opportunity 1, the hotspot IP address of the terminal is determined once every time the terminal is started.
A complete flow chart for determining the hot spot IP address of the terminal according to the embodiment of the present invention is described below with reference to fig. 2.
Step 201, starting up a terminal;
step 202, before starting the DHCP service, the terminal selects a first random number X from a preset range;
wherein the preset range can be 55-254;
step 203, the terminal takes the selected first random number X as a numerical value of a third section in the hotspot IP address, and continues to use the numerical values of the first section and the second section in the hotspot IP address which is default by the system;
step 204, the terminal determines that the DHCP range of the hot spot is 192.168. X.2-192.168. X.254;
step 205, the terminal sets the determined DHCP range into DHCP service and starts the DHCP service;
step 206, the terminal determines a starting hotspot according to a user instruction;
and step 207, the terminal group hot spot IP address is 192.168.X.1, and the hot spot IP address of the terminal is set.
And for the opportunity 2, after receiving an operation instruction of starting the hotspot of the user, determining the hotspot IP address of the terminal, and because the DHCP range of the hotspot is set before the DHCP service is started, after determining the IP address of the hotspot, the terminal needs to update the DHCP range of the hotspot, set the DHCP range in the DHCP service, and restart the DHCP service. Therefore, when the terminal opens the hot spot each time, the IP address of the hot spot can be dynamically updated.
Specifically, the terminal 1 opens the hotspot, the terminal 2 accesses the hotspot of the terminal 1, and the terminal 1 shares the mobile data with the terminal 2 in a scene where the two terminals are connected through the hotspot. In this scenario, if the terminal 1 and the terminal 2 both use the existing default hot spot IP address of the system when determining the hot spot IP address, it is assumed that the hot spot IP address of the terminal 1 is 192.168.43.1 of the default system, and the hot spot DHCP range of the terminal 1 is 192.168.43.2-192.168.43.254. The terminal 1 randomly selects an address from the DHCP range 192.168.43.2-192.168.43.254 to allocate to the terminal 2 as a WiFiIP address of the terminal 2, and the terminal 2 establishes connection with a hot spot of the terminal 1 by using the IP address allocated by the terminal 1. For example, terminal 1 chooses 192.168.43.X as the WiFi IP address assigned to terminal 2, with X being any value between 2-254. If the hot spot of the terminal 2 is opened, the terminal 2 uses the hot spot IP address default by the system when setting the hot spot IP address, and the hot spot IP address of the terminal 2 is 192.168.43.1. For the terminal 2, the WiFi IP address and the hotspot IP address of the terminal 2 are both 192.168.43, so that two 192.168.43 network segments exist in the system and are respectively routed to the WiFi interface and the hotspot interface, which results in the collision between the WiFi IP address and the hotspot IP address of the terminal 2. When the terminal 2 accesses the external network, it cannot be determined which route is selected, so that the terminal 2 cannot surf the internet.
Based on the problem, the terminal 1 and the terminal 2 can adopt the mode of determining the hot spot IP address provided by the embodiment of the invention; or any one of the terminal 1 and the terminal 2 adopts the method for determining the hot spot IP address provided by the embodiment of the invention, and the other terminal continues to use the default hot spot IP address of the existing system, so that the problem that the WiFi IP address and the hot spot IP address of the terminal 2 conflict can be solved. The following description will be made by way of examples.
1. Only the terminal 2 uses the method for determining the hot spot IP address provided by the embodiment of the present invention.
As shown in fig. 3, the terminal 1 opens the hot spot sharing mobile data, and the terminal 1 generates a hot spot IP address (i.e., a system default hot spot IP address) of 192.168.43.1 in the existing manner, so that the hot spot DHCP range of the terminal 1 is 192.168.43.2-192.168.43.254.
The terminal 2 accesses a hotspot of the terminal 1 in a WiFi connection mode, and the WiFi IP address allocated to the terminal 2 by the terminal 1 is 192.168.43. X; when the terminal 2 determines the hot spot IP address, selecting a random number Y from a preset range (55-254), and taking the random number Y as the numerical value of the third section in the hot spot IP address, wherein the numerical values of the first section and the second section use the numerical values of the first section and the second section in the default IP address of the system, the hot spot IP address determined by the terminal 2 is 192.168.Y.1, and the hot spot DHCP range of the terminal 2 is 192.168. Y.2-192.168. Y.254.
Since the WiFi IP address of terminal 2 is 192.168.43.X, the hotspot IP address of terminal 2 is 192.168. Y.1; and Y is a numerical value between 55 and 254, so that the WiFi IP address and the hot spot IP address of the terminal 2 are different, and the problem that the WiFi IP address and the hot spot IP address of the terminal 2 conflict is solved.
It should be noted here that, when only the terminal 1 determines the hot spot IP address of the terminal by using the embodiment of the present invention, the problem that the WiFi IP address and the hot spot IP address of the terminal 2 conflict with each other can also be solved, which is the same as the principle of the method that only the terminal 2 determines the hot spot IP address of the terminal by using the embodiment of the present invention.
2. The terminal 1 and the terminal 2 both use the method for determining the hot spot IP address provided by the embodiment of the invention.
As shown in fig. 4, the terminal 1 opens the hot spot sharing mobile data, when determining the hot spot IP address, the terminal 1 selects a random number a from a preset range (55-254), and uses the random number a as the numerical value of the third segment in the hot spot IP address, the numerical values of the first segment and the second segment use the numerical values of the first segment and the second segment in the system default IP address, then the hot spot IP address determined by the terminal 1 is 192.168.a.1, and then the hot spot DHCP range of the terminal 1 is 192.168. a.2-192.168. a.254.
The terminal 2 accesses a hotspot of the terminal 1 in a WiFi connection mode, and the WiFi IP address allocated to the terminal 2 by the terminal 1 is 192.168. A.X; when the terminal 2 determines the hot spot IP address, a random number B is selected from a preset range (55-254), the random number B is used as a numerical value of a third section in the hot spot IP address, the numerical values of the first section and the second section use the numerical values of the first section and the second section in the default IP address of the system, the hot spot IP address determined by the terminal 2 is 192.168.B.1, and the hot spot DHCP range of the terminal 2 is 192.168. B.2-192.168. B.254.
The WiFi IP address of the terminal 2 is 192.168.A.X, and the hot spot IP address of the terminal 2 is 192.168. B.1; since a and B are random numbers arbitrarily selected from 55-254 and the probability that a and B are the same is 1/200, the probability of collision between the WiFi IP address and the hotspot IP address of the terminal 2 can be greatly reduced.
Two, choose two random numbers
In this case, the method for determining the hot spot IP address of the terminal is shown in the flowchart of fig. 5:
501, selecting a first random number from a first preset range and a second random number from a second preset range by a terminal;
step 502, taking the first random number as the numerical value of the third section of the hot spot IP address, and taking the second random number as the numerical value of the second section of the hot spot IP address;
and 503, the terminal generates a hotspot IP address according to the determined numerical value of the third section and the determined numerical value of the second section.
Optionally, the preset range of the embodiment of the present invention is 0 to 254;
the terminal selects the first random number and the second random number from 0 to 254, and takes the selected first random number as the value of the third segment of the hot IP address and the selected second random number as the value of the second segment of the hot IP address.
It should be noted that the first random number and the second random number selected from 0 to 254 by the terminal according to the embodiment of the present invention may be the same or different.
Aiming at other segments except the second segment and the third segment in the hotspot IP address, the terminal determines the numerical values of the other segments according to the following modes:
and the terminal determines to take the fourth preset value as the numerical value of the first section of the hot spot IP address and take the fifth preset value as the numerical value of the fourth section of the hot spot IP address.
Optionally, the fourth preset value is 10, and the fifth preset value is 1.
It should be noted that, since the value of the first segment in the hot spot IP address is 10, the hot spot IP address determined by the terminal is a private network address.
It should be noted that, because the private network address is reserved in the IP protocol specification and is dedicated to the private network, taking such an address as the hot IP address of the terminal can effectively avoid the conflict with other types of IP addresses.
Then, assuming that the terminal selects the first random number X and the second random number Y from the preset range, the determined hotspot IP address of the terminal is: and 10, Y.X.1, determining the hot spot IP address of the terminal as follows: 10, Y.X.2-10. Y.X.254.
In addition, an optional implementation manner is that after the hot spot IP address of the terminal is determined in the above manner, the terminal determines whether the hot spot IP address is the same as the WiFi IP address of the terminal, when the hot spot IP address is the same as the WiFi IP address of the terminal, the terminal reselects the first random number and the second random number from the preset range, uses the selected first random number as the value of the third segment of the hot spot IP address, uses the second random number as the value of the second segment of the hot spot IP address, and generates the hot spot IP address according to the newly determined value of the third segment and the value of the second segment.
Therefore, the conflict between the WiFi IP address and the hot spot IP address of the terminal is further avoided.
The DHCP service is started at the beginning of the terminal system, namely, the DHCP service also needs to be started when the system of the terminal is started. The opening of the hot spot belongs to manual operation, and the hot spot is opened after receiving an operation instruction of a user.
The timing of determining the hot IP address of the terminal in the embodiment of the present invention may be:
the method comprises the steps that 1, after a terminal is started and before a DHCP service is started, a hot IP address of the terminal is determined;
and at the moment 2, after receiving an operation instruction of starting the hot spot of the user, determining the hot spot IP address of the terminal.
It should be noted that, in the scheme of selecting two random numbers, two timings for determining the hot spot IP address of the terminal are the same as the above scheme of selecting one random number, and details are not described here.
A complete flow chart for determining a hot spot IP address of a terminal according to an embodiment of the present invention is described below with reference to fig. 6;
in fig. 6, the description will be given by taking an example in which the terminal determines the IP address of the hotspot after receiving the operation instruction of the user to start the hotspot.
601, the terminal receives an operation instruction of starting a hotspot of a user and starts the hotspot;
step 602, the terminal selects a first random number X and a second random number Y from a preset range;
wherein the predetermined range may be 0-254;
step 603, the terminal takes the selected first random number X as a numerical value of a third section in the hot spot IP address, takes the selected second random number Y as a numerical value of a second section in the hot spot IP address, takes a fourth preset value as a numerical value of the first section, and takes a fifth preset value as a numerical value of the fourth section;
the combined hot spot IP address is assumed to be 10. Y.X.1;
step 604, the terminal judges whether the hotspot IP address is the same as the WiFi IP address of the terminal, if yes, returns to step 602, and if not, executes step 605;
step 605, the terminal determines the DHCP range of the hotspot;
when the combined hot spot IP address is 10.Y.X.1, the DHCP range of the hot spot is 10. Y.X.2-10. Y.X.254;
step 606, the terminal restarts the DHCP service.
Specifically, the terminal 1 opens the hotspot, the terminal 2 accesses the hotspot of the terminal 1, and the terminal 1 shares the mobile data with the terminal 2 in a scene where the two terminals are connected through the hotspot. In this scenario, if the terminal 1 and the terminal 2 both use the existing default hot spot IP address of the system when determining the hot spot IP address, it is assumed that the hot spot IP address of the terminal 1 is 192.168.43.1 of the default system, and the hot spot DHCP range of the terminal 1 is 192.168.43.2-192.168.43.254. The terminal 1 randomly selects an address from the DHCP range 192.168.43.2-192.168.43.254 to allocate to the terminal 2 as a WiFiIP address of the terminal 2, and the terminal 2 establishes connection with a hot spot of the terminal 1 by using the IP address allocated by the terminal 1. For example, terminal 1 chooses 192.168.43.X as the WiFi IP address assigned to terminal 2, with X being any value between 2-254. If the hot spot of the terminal 2 is opened, the terminal 2 uses the hot spot IP address default by the system when setting the hot spot IP address, and the hot spot IP address of the terminal 2 is 192.168.43.1. For the terminal 2, the WiFi IP address and the hotspot IP address of the terminal 2 are both 192.168.43, so that two 192.168.43 network segments exist in the system and are respectively routed to the WiFi interface and the hotspot interface, which results in the collision between the WiFi IP address and the hotspot IP address of the terminal 2. When the terminal 2 accesses the external network, it cannot be determined which route is selected, so that the terminal 2 cannot surf the internet.
Based on the problem, the terminal 1 and the terminal 2 can adopt the mode of determining the hot spot IP address provided by the embodiment of the invention; or any one of the terminal 1 and the terminal 2 adopts the method for determining the hot spot IP address provided by the embodiment of the invention, and the other terminal continues to use the default hot spot IP address of the existing system, so that the problem that the WiFi IP address and the hot spot IP address of the terminal 2 conflict can be solved. The following description will be made by way of examples.
1. Only the terminal 2 uses the method for determining the hot spot IP address provided by the embodiment of the present invention.
As shown in fig. 7, the terminal 1 opens the hot spot sharing mobile data, and the terminal 1 generates a hot spot IP address (i.e., a system default hot spot IP address) of 192.168.43.1 in the existing manner, so that the hot spot DHCP range of the terminal 1 is 192.168.43.2-192.168.43.254.
The terminal 2 accesses a hotspot of the terminal 1 in a WiFi connection mode, and the WiFi IP address allocated to the terminal 2 by the terminal 1 is 192.168.43. X; when the terminal 2 determines the hot spot IP address, two random numbers A, B are selected from a preset range (0-254), the random number A, B is used as the numerical values of the second segment and the third segment in the hot spot IP address, the numerical value of the first segment is set to 10, the hot spot IP address determined by the terminal 2 is 10.a.b.1, and the hot spot DHCP range of the terminal 2 is 10. a.b.2-10. a.b.254.
Since the WiFi IP address of the terminal 2 is 192.168.43.X, the hotspot IP address of the terminal 2 is 10. a.b.1; therefore, the WiFi IP address and the hotspot IP address of the terminal 2 are different, and the problem that the WiFi IP address and the hotspot IP address of the terminal 2 conflict is solved.
It should be noted here that, when only the terminal 1 determines the hot spot IP address of the terminal by using the embodiment of the present invention, the problem that the WiFi IP address and the hot spot IP address of the terminal 2 conflict with each other can also be solved, which is the same as the principle of the method that only the terminal 2 determines the hot spot IP address of the terminal by using the embodiment of the present invention.
2. The terminal 1 and the terminal 2 both use the method for determining the hot spot IP address provided by the embodiment of the invention.
As shown in fig. 8, the terminal 1 opens a hot spot to share mobile data, when determining a hot spot IP address, the terminal 1 selects two random numbers A, B from a preset range (0-254), takes the random number A, B as numerical values of a second segment and a third segment in the hot spot IP address, sets the numerical value of the first segment to 10, and determines that the hot spot IP address determined by the terminal 1 is 10.a.b.1, and determines that a hot spot DHCP range of the terminal 1 is 10. a.b.2-10. a.b.254.
The terminal 2 accesses a hotspot of the terminal 1 in a WiFi connection mode, and a WiFi IP address allocated to the terminal 2 by the terminal 1 is 10. A.B.X; when the terminal 2 determines the hot spot IP address, two random numbers C, D are selected from a preset range (0-254), the random number C, D is used as the numerical values of the second section and the third section in the hot spot IP address, the numerical value of the first section is set to 10, the hot spot IP address determined by the terminal 2 is 10.c.d.1, and the hot spot DHCP range of the terminal 2 is 10. c.d.2-10. c.d 254.
The WiFi IP address of the terminal 2 is 10.A.B.X, and the hot spot IP address of the terminal 2 is 10. C.D.1; a, B, C, D are random numbers randomly selected from 0-254, A is the same as C, and B and D are the same with probability 1/65025, so that the probability of collision between the WiFi IP address and the hotspot IP address of the terminal 2 can be greatly reduced.
Based on the same inventive concept, the embodiment of the present invention further provides a terminal, and since the principle of solving the problem of the terminal is similar to the method for determining the hot IP address of the terminal in the embodiment of the present invention, the implementation of the terminal may refer to the implementation of the method, and repeated details are not repeated.
As shown in fig. 9, a terminal according to an embodiment of the present invention includes at least one processing unit 900 and at least one storage unit 901;
wherein the storage unit 901 stores program code which, when executed by the processing unit 900, causes the processing unit 900 to perform the following:
selecting N random numbers from a preset range; wherein N is more than or equal to 1 and less than or equal to 3, and N is an integer;
selecting a first random number from a first preset range;
determining the selected first random number as a numerical value of a third section of the hot spot IP address;
and generating a hot spot IP address according to the determined numerical value of the third section.
Optionally, when generating the hot spot IP address, the processing unit 900 is further configured to:
and determining that the first preset value is used as the numerical value of the first section of the hot spot IP address, the second preset value is used as the numerical value of the second section of the hot spot IP address, and the third preset value is used as the numerical value of the fourth section of the hot spot IP address.
Optionally, the first preset range is 55 to 254, the first preset value is 192, the second preset value is 168, and the third preset value is 1.
Optionally, the processing unit 900 is further configured to:
selecting a second random number from a second preset range;
and determining the selected second random number as the numerical value of the second section of the hot spot IP address.
Optionally, when generating the hot spot IP address, the processing unit 900 is further configured to:
and determining that the fourth preset value is used as the numerical value of the first section of the hot spot IP address, and the fifth preset value is used as the numerical value of the fourth section of the hot spot IP address.
Optionally, the first preset range is 0 to 254, the second preset range is 0 to 254, the fourth preset value is 10, and the fifth preset value is 1.
Optionally, the processing unit 900 is further configured to:
after a hotspot IP address is generated, judging whether the hotspot IP address is the same as the WiFi IP address of the terminal; and when the hot spot IP address is the same as the WiFi IP address of the terminal, returning to the step of selecting the first random number from the first preset range.
As shown in fig. 10, the terminal 1000 according to the embodiment of the present invention includes: a Radio Frequency (RF) circuit 1010, a power supply 1020, a processor 1030, a memory 1040, an input unit 1050, a display unit 1060, a camera 1070, a communication interface 1080, and a Wireless Fidelity (WiFi) module 1090. Those skilled in the art will appreciate that the configuration of the terminal shown in fig. 10 is not intended to be limiting, and that the terminal provided by the embodiments of the present application may include more or less components than those shown, or some components may be combined, or a different arrangement of components may be provided.
The various components of terminal 1000 are described in detail below with reference to fig. 10:
the RF circuit 1010 may be used for receiving and transmitting data during a communication or conversation. Specifically, the RF circuit 1010 sends downlink data of the base station to the processor 1030 for processing; and in addition, sending the uplink data to be sent to the base station. In general, the RF circuit 1010 includes, but is not limited to, an antenna, at least one Amplifier, a transceiver, a coupler, a Low Noise Amplifier (LNA), a duplexer, and the like.
In addition, the RF circuit 1010 may also communicate with networks and other terminals through wireless communication. The wireless communication may use any communication standard or protocol, including but not limited to Global System for mobile communications (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), and the like.
The WiFi technology belongs to a short-distance wireless transmission technology, and the terminal 1000 realizes Access to a data network through an Access Point (AP) to which the WiFi module 1090 can connect. The WiFi module 1090 may be used for receiving and transmitting data during communication.
The terminal 1000 can be physically connected to other terminals through the communication interface 1080. Optionally, the communication interface 1080 is connected to the communication interfaces of the other terminals through a cable, so as to implement data transmission between the terminal 1000 and the other terminals.
In the embodiment of the present application, the terminal 1000 can implement a communication service and send information to other contacts, so that the terminal 1000 needs to have a data transmission function, that is, the terminal 1000 needs to include a communication module inside. Although fig. 10 illustrates communication modules such as the RF circuit 1010, the WiFi module 1090, and the communication interface 1080, it can be understood that at least one of the above components or other communication modules (such as a bluetooth module) for implementing communication exist in the terminal 1000 for data transmission.
For example, when the terminal 1000 is a mobile phone, the terminal 1000 can include the RF circuit 1010 and can further include the WiFi module 1090; when the terminal 1000 is a computer, the terminal 1000 can include the communication interface 1080 and can further include the WiFi module 1090; when the terminal 1000 is a tablet computer, the terminal 1000 can include the WiFi module.
The memory 1040 may be used to store software programs and modules. The processor 1030 executes various functional applications and data processing of the terminal 1000 by executing the software programs and modules stored in the memory 1040, and after the processor 1030 executes the program codes in the memory 1040, part or all of the processes in fig. 1 according to the embodiment of the present invention can be implemented.
Alternatively, the memory 1040 may mainly include a program storage area and a data storage area. The storage program area can store an operating system, various application programs (such as communication application), a face recognition module and the like; the storage data area may store data (such as various multimedia files like pictures, video files, etc., and face information templates) created according to the use of the terminal, etc.
Further, the memory 1040 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
The input unit 1050 may be used to receive numeric or character information input by a user and generate key signal inputs related to user settings and function control of the terminal 1000.
Alternatively, the input unit 1050 may include a touch panel 1051 and other input terminals 1052.
The touch panel 1051, also called a touch screen, can collect touch operations of a user (for example, operations of a user on or near the touch panel 1051 by using any suitable object or accessory such as a finger or a stylus) and drive the corresponding connection device according to a preset program. Alternatively, the touch panel 1051 may include two portions, i.e., a touch detection device and a touch controller. The touch detection device detects the touch direction of a user, detects a signal brought by touch operation and transmits the signal to the touch controller; the touch controller receives touch information from the touch sensing device, converts the touch information into touch point coordinates, sends the touch point coordinates to the processor 1030, and can receive and execute commands sent by the processor 1030. In addition, the touch panel 1051 may be implemented by various types such as a resistive type, a capacitive type, an infrared ray, and a surface acoustic wave.
Optionally, the other input terminals 1052 may include, but are not limited to, one or more of a physical keyboard, function keys (e.g., volume control keys, switch keys, etc.), a trackball, a mouse, a joystick, and the like.
The display unit 1060 may be used to display information input by a user or information provided to the user and various menus of the terminal 1000. The display unit 1060 is a display system of the terminal 1000, and is used for presenting an interface and realizing human-computer interaction.
The display unit 1060 may include a display panel 1061. Alternatively, the Display panel 1061 may be configured in the form of a Liquid Crystal Display (LCD), an Organic Light-emitting diode (OLED), or the like.
Further, the touch panel 1051 may cover the display panel 1061, and when the touch panel 1051 detects a touch operation on or near the touch panel 1051, the touch panel 1051 transmits the touch operation to the processor 1030 to determine the type of the touch event, and then the processor 1030 provides a corresponding visual output on the display panel 1061 according to the type of the touch event.
Although in FIG. 10, the touch panel 1051 and the display panel 1061 are shown as two separate components to implement the input and output functions of the terminal 1000, in some embodiments, the touch panel 1051 and the display panel 1061 can be integrated to implement the input and output functions of the terminal 1000.
The processor 1030 is a control center of the terminal 1000, connects various components using various interfaces and lines, and performs various functions of the terminal 1000 and processes data by operating or executing software programs and/or modules stored in the memory 1040 and calling data stored in the memory 1040, thereby implementing various services based on the terminal.
Optionally, the processor 1030 may include one or more processing units. Optionally, the processor 1030 may integrate an application processor and a modem processor, wherein the application processor mainly handles operating systems, user interfaces, application programs, and the like, and the modem processor mainly handles wireless communications. It is to be appreciated that the modem processor described above may not be integrated into the processor 1030.
The camera 1070 is configured to implement a shooting function of the terminal 1000, and shoot pictures or videos.
The terminal 1000 can also include a power supply 1020 (e.g., a battery) for powering the various components. Optionally, the power supply 1020 may be logically connected to the processor 1030 through a power management system, so that the power management system implements functions of managing charging, discharging, power consumption, and the like.
Although not shown, the terminal 1000 can further include at least one sensor, audio circuit, etc., which are not described herein.
As shown in fig. 11, an apparatus for determining a hot spot IP address of a terminal according to an embodiment of the present invention includes:
a selecting module 1101, configured to select a first random number from a first preset range;
a determining module 1102, configured to determine that the selected first random number is used as a numerical value of a third segment of the hotspot IP address;
and the processing module 1103 is configured to generate a hot spot IP address according to the determined numerical value of the third segment.
Optionally, the processing module 1103 is further configured to, when generating a hotspot IP address:
and determining that the first preset value is used as the numerical value of the first section of the hot spot IP address, the second preset value is used as the numerical value of the second section of the hot spot IP address, and the third preset value is used as the numerical value of the fourth section of the hot spot IP address.
Optionally, the first preset range is 55 to 254, the first preset value is 192, the second preset value is 168, and the third preset value is 1.
Optionally, the selecting module 1101 is further configured to: selecting a second random number from a second preset range;
the determining module 1102 is further configured to: and determining the selected second random number as the numerical value of the second section of the hot spot IP address.
Optionally, the processing module 1103 is further configured to, when generating a hotspot IP address:
and determining that the fourth preset value is used as the numerical value of the first section of the hot spot IP address, and the fifth preset value is used as the numerical value of the fourth section of the hot spot IP address.
Optionally, the first preset range is 0 to 254, the second preset range is 0 to 254, the fourth preset value is 10, and the fifth preset value is 1.
Optionally, after generating the hotspot IP address, the processing module 1103 is further configured to:
judging whether the hotspot IP address is the same as the WiFi IP address of the terminal;
and when the hotspot IP address is the same as the WiFi IP address of the terminal, controlling to return to the selecting module 1101 for selecting a first random number from a first preset range.
An embodiment of the present invention further provides a computer-readable medium, on which a computer program is stored, where the computer program is executed by a processor to implement the steps of any one of the methods described above.
The present application is described above with reference to block diagrams and/or flowchart illustrations of methods, apparatus (systems) and/or computer program products according to embodiments of the application. It will be understood that one block of the block diagrams and/or flowchart illustrations, and combinations of blocks in the block diagrams and/or flowchart illustrations, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, and/or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer and/or other programmable data processing apparatus, create means for implementing the functions/acts specified in the block diagrams and/or flowchart block or blocks.
Accordingly, the subject application may also be embodied in hardware and/or in software (including firmware, resident software, micro-code, etc.). Furthermore, the present application may take the form of a computer program product on a computer-usable or computer-readable storage medium having computer-usable or computer-readable program code embodied in the medium for use by or in connection with an instruction execution system. In the context of this application, a computer-usable or computer-readable medium may be any medium that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for determining a hotspot IP address of a terminal is characterized by comprising the following steps:
the terminal selects a first random number from a first preset range;
the terminal determines that the selected first random number is used as a numerical value of a third section of the hot spot IP address;
and the terminal generates a hot spot IP address according to the determined numerical value of the third section.
2. The method of claim 1, wherein when the terminal generates the hotspot IP address, the method further comprises:
the terminal determines that the first preset value is used as the numerical value of the first section of the hot spot IP address, the second preset value is used as the numerical value of the second section of the hot spot IP address, and the third preset value is used as the numerical value of the fourth section of the hot spot IP address.
3. The method of claim 2, wherein the first predetermined range is 55-254, the first predetermined value is 192, the second predetermined value is 168, and the third predetermined value is 1.
4. The method of claim 1, further comprising:
the terminal selects a second random number from a second preset range;
and the terminal determines the selected second random number as a numerical value of a second section of the hotspot IP address.
5. The method of claim 4, wherein when the terminal generates the hotspot IP address, the method further comprises:
and the terminal determines that the fourth preset value is used as the numerical value of the first section of the hot spot IP address, and the fifth preset value is used as the numerical value of the fourth section of the hot spot IP address.
6. The method of claim 5, wherein the first predetermined range is 0-254, the second predetermined range is 0-254, the fourth predetermined value is 10, and the fifth predetermined value is 1.
7. The method of claim 1, wherein after the terminal generates the hotspot IP address, the method further comprises:
the terminal judges whether the hotspot IP address is the same as the WiFi IP address of the terminal;
and when the hot spot IP address is the same as the WiFi IP address of the terminal, the terminal returns to the step of selecting the first random number from the first preset range.
8.A terminal, comprising at least one processing unit and at least one memory unit;
wherein the storage unit stores program code that, when executed by the processing unit, causes the processing unit to perform the following:
selecting a first random number from a first preset range;
determining the selected first random number as a numerical value of a third section of the hot spot IP address;
and generating a hot spot IP address according to the determined numerical value of the third section.
9. The terminal of claim 8, wherein the processing unit, in generating the hotspot IP address, is further to:
and determining that the first preset value is used as the numerical value of the first section of the hot spot IP address, the second preset value is used as the numerical value of the second section of the hot spot IP address, and the third preset value is used as the numerical value of the fourth section of the hot spot IP address.
10. The terminal of claim 8, wherein the processing unit is further to:
selecting a second random number from a second preset range;
and determining the selected second random number as the numerical value of the second section of the hot spot IP address.
CN201910213945.4A 2019-03-20 2019-03-20 Method for determining hot IP address of terminal and terminal Pending CN111726798A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910213945.4A CN111726798A (en) 2019-03-20 2019-03-20 Method for determining hot IP address of terminal and terminal

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910213945.4A CN111726798A (en) 2019-03-20 2019-03-20 Method for determining hot IP address of terminal and terminal

Publications (1)

Publication Number Publication Date
CN111726798A true CN111726798A (en) 2020-09-29

Family

ID=72563134

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910213945.4A Pending CN111726798A (en) 2019-03-20 2019-03-20 Method for determining hot IP address of terminal and terminal

Country Status (1)

Country Link
CN (1) CN111726798A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113490257A (en) * 2021-07-01 2021-10-08 读书郎教育科技有限公司 Processing method for multi-device hotspot preemption

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113490257A (en) * 2021-07-01 2021-10-08 读书郎教育科技有限公司 Processing method for multi-device hotspot preemption
CN113490257B (en) * 2021-07-01 2023-11-17 读书郎教育科技有限公司 Multi-equipment hot spot preemption processing method

Similar Documents

Publication Publication Date Title
US11025963B2 (en) Data processing method, apparatus, and system for live streaming page
US10635449B2 (en) Method and apparatus for running game client
CN108173574B (en) Method and terminal for controlling file transmission
CN107770814B (en) Data link equalization method, mobile terminal and computer readable storage medium
JP7200312B2 (en) Method and terminal device for establishing a hotspot connection
US20190159271A1 (en) Bluetooth connection management method, master bluetooth device, and apparatus
EP3565308B1 (en) Method and device for registering to a cell
CN106713799B (en) Projection equipment control method, projection equipment and intelligent terminal
WO2021022720A1 (en) Bluetooth-based data transmission method, storage medium and terminal
CN111356209B (en) Multi-frequency WiFi hotspot opening method and device, storage medium and electronic equipment
JP2022541498A (en) Resource allocation method, device and storage medium
WO2018228313A1 (en) Information transmission method, base station, mobile terminal, and computer-readable storage medium
CN110618806B (en) Application program control method and device, electronic equipment and storage medium
CN106484563B (en) Data migration method and terminal equipment
CN110602707A (en) Method and terminal for connecting wireless network
CN111726798A (en) Method for determining hot IP address of terminal and terminal
JP2019523941A (en) Data access method and associated device
CN112634885A (en) Voice wake-up method and device for cross-local area network
CN111314900B (en) Wireless connection method, wireless connection device and mobile terminal
CN112543493A (en) Wifi connection method, terminal and computer storage medium
CN113613310B (en) WIFI connection method and device, storage medium and mobile terminal
CN110851198B (en) Method and terminal for displaying view of quick application
CN106550461B (en) Resource using method and terminal
WO2018119789A1 (en) Method for connecting to access point, terminal, and management server
WO2017166161A1 (en) Communication method and related device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination