CN118524087A - Positioning method and device based on IP address, computer equipment and storage medium - Google Patents
Positioning method and device based on IP address, computer equipment and storage medium Download PDFInfo
- Publication number
- CN118524087A CN118524087A CN202310163086.9A CN202310163086A CN118524087A CN 118524087 A CN118524087 A CN 118524087A CN 202310163086 A CN202310163086 A CN 202310163086A CN 118524087 A CN118524087 A CN 118524087A
- Authority
- CN
- China
- Prior art keywords
- address
- positioning
- candidate
- target
- determining
- 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
Links
Landscapes
- Mobile Radio Communication Systems (AREA)
Abstract
The application relates to a positioning method, a positioning device, computer equipment and a storage medium based on an IP address. The method can be applied to the fields of map, traffic, network security, management and the like, and comprises the following steps: acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address; determining first distribution information of positioning points corresponding to the IP addresses in a map grid based on the IP addresses and the position information; determining second distribution information of positioning points corresponding to the target address segments in the map grid based on the target address segments of the IP addresses and the first distribution information corresponding to the IP addresses; clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment; and determining the target positions of the clusters as candidate positioning positions. The method can improve the accuracy of positioning based on the IP address.
Description
Technical Field
The present application relates to the field of positioning technologies, and in particular, to a positioning method, apparatus, computer device, and storage medium based on an IP address.
Background
With the rapid development of internet technology, more and more users join the internet, and enterprises and organizations need to know the geographical location of users in order to provide better services, such as advertisement push services, game services, and the like. To this end, the geographic location of the user is currently typically determined by the IP egress location provided by the operator.
However, the update of the IP exit position of the operator is not timely enough, i.e. the geographical position where the network device of the operator is located cannot be updated timely, which results in inaccurate IP positioning results.
Disclosure of Invention
In view of the foregoing, it is desirable to provide an IP address-based positioning method, apparatus, computer device, and storage medium that can improve the accuracy of IP positioning.
In a first aspect, the present application provides a positioning method based on an IP address. The method comprises the following steps:
Acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address;
Determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
Clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
And determining the target position of each cluster as a candidate positioning position.
In a second aspect, the present application further provides a positioning device for an IP address. The device comprises:
The data acquisition module is used for acquiring the IP address of the target object and the position information of the locating point corresponding to the IP address;
the distribution determining module is used for determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
The grid clustering module is used for clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
and the position determining module is used for determining the target position of each cluster as a candidate positioning position.
In one embodiment, the apparatus further comprises:
An address type determining module, configured to determine an address type of the IP address;
and the target address segment determining module is used for determining a target address segment of the IP address based on the address type.
In one embodiment, the destination address segment determining module is further configured to:
When the address type is the first type, taking the network segment of the IP address as a target address segment;
and when the address type is the second type, grading the address segments in the IP address to obtain target address segments of all levels.
In one embodiment, the apparatus further comprises:
the data storage module is used for storing the candidate positioning positions in an IP positioning database;
A request positioning module for:
responding to a positioning request, and acquiring a query key based on an IP address in the positioning request;
inquiring the matched candidate positioning position in the IP positioning database based on the inquiring key;
And taking the searched candidate positioning position as the positioning position requested by the positioning request.
In one embodiment, the data storage module is further configured to:
Constructing a key value pair by taking the IP address as a key, taking a candidate positioning position corresponding to the IP address as a value, taking a target address segment of the IP address as a key, and taking a candidate positioning position corresponding to the target address segment and an IP address interval corresponding to the target address segment as values;
Storing the key value pairs to an IP positioning database;
the request positioning module is further configured to:
and searching matched key value pairs in the IP positioning database based on the query key, and taking the searched values in the key value pairs as matched candidate positioning positions.
In one embodiment, the request positioning module is further configured to:
if the address type of the IP address in the positioning request is a first type, generating a first query key corresponding to the IP address in the positioning request;
And when a first key value pair matched with the first query key is found in the IP positioning database, taking the value in the first key value pair as a matched candidate positioning position.
In one embodiment, the request positioning module is further configured to:
when the first key value pair matched with the first query key is not found in the IP positioning database, generating a second query key corresponding to the IP address in the positioning request;
When a second key value pair matched with the second query key is found in the IP positioning database, determining an IP address interval represented by the value of the second key value pair, and when the IP address in the positioning request belongs to the characterized IP address interval, taking the candidate positioning position characterized by the value of the second key value pair as a matched candidate positioning position.
In one embodiment, the request positioning module is further configured to:
If the address type of the IP address in the positioning request is the second type, generating query keys of various levels corresponding to the IP address in the positioning request;
and when at least one level key value pair matched with the query keys of each level is found in the IP positioning database, acquiring the key value pair meeting the level condition from the at least one level key value pair, and taking the value in the key value pair meeting the level condition as a matched candidate positioning position.
In one embodiment, the IP address includes a first IP address and a second IP address; the distribution determining module is further configured to:
and combining the first distribution information corresponding to the first IP address and the second IP address to obtain the second distribution information of the positioning point corresponding to the target address section in the map grid.
In one embodiment, the mesh clustering module is further configured to: clustering matrix grids in the map grid based on the first distribution information to obtain a first candidate cluster corresponding to the IP address; when the number of the first candidate clusters is at least two, determining the number of first positioning points corresponding to the IP addresses in each first candidate cluster; determining first candidate clusters, of which the number of first positioning points in the at least two first candidate clusters meets a first preset condition, as clusters corresponding to the IP addresses; and when the number of the first candidate cluster clusters is one, determining the first candidate cluster as the cluster corresponding to the IP address.
In one embodiment, the mesh clustering module is further configured to: clustering matrix grids in the map grid based on the first distribution information to obtain a first initial cluster corresponding to the IP address; determining the total number of first positioning points corresponding to the IP address and the corresponding third positioning point number in each first initial cluster based on the first distribution information; determining a first proportion of each of the first initial clusters based on the third number of localization sites and the total number of localization sites; and determining the first initial cluster of which the first proportion reaches a proportion threshold value as a first candidate cluster corresponding to the IP address.
In one embodiment, the mesh clustering module is further configured to: clustering matrix grids in the map grid based on the second distribution information to obtain a second candidate cluster corresponding to the target address segment; when the number of the second candidate clusters is at least two, determining the number of second locating points corresponding to the target address segment in each second candidate cluster; determining second candidate clusters, of which the number of second locating points in the at least two second candidate clusters meets a first preset condition, as clusters corresponding to the target address segment; and when the number of the second candidate cluster clusters is one, determining the second candidate cluster as the cluster corresponding to the target address segment.
In one embodiment, the mesh clustering module is further configured to: clustering matrix grids in the map grid based on the second distribution information to obtain a second initial cluster corresponding to the target address segment; determining the total number of second locating points corresponding to the target address segment and the fourth locating point number in each corresponding second initial cluster based on the second distribution information; determining a second proportion of each of the second initial clusters based on the fourth number of anchor points and the total number of second anchor points; and determining a second initial cluster of which the second proportion reaches a proportion threshold value as a second candidate cluster corresponding to the target address segment.
In one embodiment, the apparatus further comprises a geographic address determination module for:
Respectively acquiring geographic addresses corresponding to the IP address and the target address segment;
Determining a first frequency of occurrence of each geographic address corresponding to the IP address and a second frequency of occurrence of each geographic address corresponding to the target address segment;
And determining the geographic address of which the first frequency meets the second preset condition as a target geographic address corresponding to the IP address, and determining the geographic address of which the second frequency meets the second preset condition as a target geographic address corresponding to the target address segment.
In one embodiment, the apparatus further comprises a data filtering module for:
based on the first distribution information and the second distribution information, determining the total number of positioning points corresponding to the IP address and the target address segment respectively;
When the total number of the positioning points reaches a positioning point number threshold, acquiring the number of the objects of the target object to which the corresponding positioning points belong;
When the number of objects reaches an object number threshold, executing the step of clustering matrix lattices in the map lattice based on the distribution information;
and deleting at least part of IP addresses of the target objects and the position information of the corresponding positioning points when the total number of positioning points does not reach a positioning point number threshold or the number of objects does not reach the object number threshold.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory storing a computer program and a processor which when executing the computer program performs the steps of:
Acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address;
Determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
Clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
And determining the target position of each cluster as a candidate positioning position.
In a fourth aspect, the present application also provides a computer-readable storage medium. The computer readable storage medium having stored thereon a computer program which when executed by a processor performs the steps of:
Acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address;
Determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
Clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
And determining the target position of each cluster as a candidate positioning position.
In a fifth aspect, the present application also provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, implements the steps of:
Acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address;
Determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
Clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
And determining the target position of each cluster as a candidate positioning position.
According to the positioning method, the device, the computer equipment, the storage medium and the computer program product of the IP address, after the IP address of the target object and the position information of the positioning point corresponding to the IP address are acquired, not only the candidate positioning position corresponding to the IP address is determined based on the acquired data, but also the target address segment of the IP address is mined, and the candidate positioning position of the target address segment is determined, so that the corresponding relation between the target address segment and the candidate positioning position can be expanded, and the candidate positioning position of the target address segment corresponding to the IP address can be determined as the positioning position of the IP address when the positioning position corresponding to a certain IP address cannot be acquired later, the positioning accuracy and the positioning reliability are improved; on the other hand, by clustering matrix lattices distributed by a plurality of positioning points of the same IP address or target address segment, interference of unreliable positioning points in the plurality of positioning points on positioning results is eliminated, so that the determined candidate positioning positions of each IP address or target address segment are more accurate, and the positioning accuracy and reliability are improved; in addition, the latest IP address of the target object and the position information of the positioning point corresponding to the IP address are acquired in real time, and the candidate positioning positions of the IP addresses or the target address segments are determined based on the acquired data, so that the respective positioning positions of the IP addresses and the target address segments can be updated in time, and the accuracy of positioning based on the IP addresses is further improved.
Drawings
FIG. 1 is an application environment diagram of an IP address based positioning method in one embodiment;
FIG. 2 is a flow chart of a positioning method based on IP addresses in one embodiment;
FIG. 3 is a schematic diagram of a cluster in one embodiment;
FIG. 4 is a flow chart illustrating a step of determining a target address segment in one embodiment;
FIG. 5 is a flow diagram of a step of determining a location position based on a location request in one embodiment;
FIG. 6 is a schematic diagram of candidate clusters in one embodiment;
FIG. 7 is a flowchart of a positioning method based on IP addresses in another embodiment;
FIG. 8 is a flow chart of a positioning method based on IP address in another embodiment;
FIG. 9 is a schematic diagram of an application scenario for point of interest recommendation in one embodiment;
FIG. 10 is a schematic illustration of an application scenario for building positioning in one embodiment;
FIG. 11 is a schematic illustration of an application scenario for inter-building positioning in a building in one embodiment;
FIG. 12 is a block diagram of an IP address based positioning device in one embodiment;
FIG. 13 is a block diagram of an IP address based positioning device in another embodiment;
FIG. 14 is an internal block diagram of a computer device in one embodiment;
Fig. 15 is an internal structural view of a computer device in one embodiment.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application.
The positioning method based on the IP address provided by the embodiment of the application can be applied to the fields of maps, traffic, network security, management and the like.
The intelligent transportation system (INTELLIGENT TRAFFIC SYSTEM, ITS) is also called an intelligent transportation system (INTELLIGENT TRANSPORTATION SYSTEM), which is a comprehensive transportation system for effectively and comprehensively applying advanced scientific technologies (information technology, computer technology, data communication technology, sensor technology, electronic control technology, automatic control theory, operation research, artificial intelligence and the like) to transportation, service control and vehicle manufacturing, and enhancing the connection among vehicles, roads and users, thereby forming a comprehensive transportation system for guaranteeing safety, improving efficiency, improving environment and saving energy.
The positioning method based on the IP address provided by the embodiment of the application can be applied to an application environment shown in figure 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104 or may be located on the cloud or other servers. The IP address based positioning method may be performed by the terminal 102 or the server 104, or by the terminal 102 and the server 104 in cooperation. In some embodiments, the positioning method based on the IP address is performed by the terminal 102, and the terminal 102 acquires the IP address of the target object and the corresponding positioning point information; determining distribution information of positioning points corresponding to the IP address and the target address segment in the map grid based on the IP address, the target address segment of the IP address and the positioning point information; clustering matrix lattices in the map grids based on the distribution information to obtain clustering clusters corresponding to the IP addresses and the target address segments respectively; determining the target position of each cluster as a candidate positioning position; in response to the location request, a matching location position is found among the candidate location positions based on the IP address in the location request.
The terminal 102 may be, but not limited to, various desktop computers, notebook computers, smart phones, tablet computers, internet of things devices, and portable wearable devices, where the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart vehicle devices, and the like. The portable wearable device may be a smart watch, smart bracelet, headset, or the like. The server 104 may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms, and the like. The terminal 102 and the server 104 may be directly or indirectly connected through wired or wireless communication, and the present application is not limited herein.
In one embodiment, as shown in fig. 2, there is provided an IP address-based positioning method, which is illustrated by taking application of the method to the terminal 102 in fig. 1 as an example, and includes the following steps:
S202, acquiring the IP address of the target object and the position information of the locating point corresponding to the IP address.
The number of the target objects is a plurality of, the IP address can be the IP address of the equipment used by the target objects, and the position information of the positioning points is the position information obtained by positioning the equipment used by the target objects.
The position information can specifically comprise information such as a geographic position, longitude and latitude coordinates, a geographic address and the like of the target object using equipment, wherein the geographic position refers to a spatial position of an object on the earth surface; longitude and latitude coordinates are mathematical representations of the geographic location of a point on the earth's surface, with longitude and latitude identifying a point on the earth; geographic address refers to textual information describing a specific location of a point on the earth's surface, such as: province, city, district, street, house number etc. the three are connected, the geographic position can be represented by longitude and latitude coordinates, and the longitude and latitude coordinates can also be obtained by geographic address conversion.
IP (Internet Protocol) address is an address used to identify a computer and network device on the Internet, which is a number used to identify the location of the computer and network device in the network; IP addresses can be divided into two types according to address types: IPv4 and IPv6, IPv4 addresses consist of a 32-bit binary number, which can be represented in dot decimal form, for example 192.168.1.1; IPv6 addresses are composed of 128-bit binary digits, and typically, IPv6 addresses are divided into a plurality of blocks for easier reading and writing, each block is composed of four hexadecimal digits and separated by a colon ", and IPv6 addresses can be regarded as a string composed of a plurality of hexadecimal digits separated by a colon, and are expressed in the form of a colon separation, for example, 2001:0db8:85a3:0000:0000:8a2e:0370:7334.
Specifically, the terminal acquires user track data of the using device within a preset time period of the target object, extracts an IP address and corresponding original position information from the user track data, and determines position information of a corresponding positioning point based on the original position information.
The preset time period may be a preset historical time period, for example, the preset time period is the last 7 days; the user track data is the moving track of the online or offline using device of the target object, and can be represented by recording online activity of the target object, original position information output by the positioning module and the like.
The original position information refers to the original position information which is not processed in the user track data and can be GPS data, positioning data based on a base station, wi-Fi positioning data or the like; the location information of the positioning point refers to information obtained by further sorting the original location information.
S204, determining first distribution information of positioning points corresponding to the IP addresses in the map grid based on the IP addresses and the position information; and determining second distribution information of positioning points corresponding to the target address segments in the map grid based on the target address segments of the IP addresses and the first distribution information.
Wherein the destination address field of the IP address is a new IP address mined based on the IP address. For example, the IP address is 127.0.0.2, the destination address segment corresponding to the IP address is the first three segments of the IP address, namely "127.0.0", it is understood that the destination address segment "127.0.0" may represent an address interval to which the IPv4 address with "127.0.0" as the first three segments belongs, and the address interval specifically includes 266 IP addresses from "127.0.0.0" to "127.0.0.255". The IP address is 2001:0db8:85a3:0000:ffff:ffff:ffff, the corresponding target address segment is the first four segments of the IP address, i.e. "2001:0db8:85a3:0000", it is understood that the target address segment "2001:0db8:85a3:0000" may represent the address interval to which the IPv6 address of the first four segments belongs, i.e. "2001:0db8:85a 3:0000:0000::: 1" to "2001:0db8:85a3:0000:ffff:ffff: ffff".
In addition, in the embodiment of the present application, for the IPv4 address, after determining the target address field, a target address field of the target address field may be generated, where the target address field is a subfield of a represented address field of the target address field, for example, the target address field is "127.0.0", and the represented address field is "127.0.0.0" to "127.0.0.255", and then "127.0.0.0" to "127.0.0.165" and "127.0.0.166" to "127.0.0.255" are respectively two target address fields of the target address field.
The map grid refers to an electronic map with matrix grids, each matrix grid represents a space area on the map and can be used for representing information such as geographic positions, longitude and latitude coordinates and the like on the map. The map grid system may divide the entire map into a number of matrix lattices of the same size for spatial data analysis and management, for example, a number of 50m by 50m matrix lattices.
The first distribution information refers to the distribution condition of positioning points of the IP address in the map grid, and comprises information such as matrix grids distributed by the positioning points of the IP address, the number of the positioning points in each matrix grid and the like; the second distribution information refers to the distribution condition of the positioning points of the target address segment in the map grid, and comprises information such as matrix grids distributed by the positioning points of the target address segment, the number of the positioning points in each matrix grid and the like.
Specifically, after obtaining the IP address and the target address segment of the IP address, the terminal may further determine a target IP address corresponding to each target address segment, determine location information of a location point of the target IP address as location information of the location point of the target address, and determine, for any one IP address, first distribution information of the location point corresponding to the IP address in the map grid based on the IP address and the location information of the location point corresponding to the IP address; and determining the distribution information of the locating points corresponding to the target address segment in the map grid according to the position information of the target address segment and the locating points corresponding to the target address segment for any target address segment.
The target IP address corresponding to the target address segment is an IP address belonging to the target address segment of the target address segment, the target address segment is a subinterval of the address segment represented by the target address segment, for example, there are four IP addresses 127.0.0.2, 127.0.1.2, 127.0.0.1, 127.0.1.3, if the target address segment of the target address segment 127.0.0 is "127.0.0.0" to "127.0.0.255", the target IP address corresponding to the target address segment 127.0.0 is 127.0.0.2 and 127.0.0.1, the target address segment of the target address segment 127.0.1 is "127.0.1.0" to "127.0.1.255", the target IP address corresponding to the target address segment 127.0.1 is 127.0.1.2 and 127.0.1.3, if there are 10 anchor points corresponding to 127.0.0.2, and 50 anchor points corresponding to 127.0.0.1, the distribution information of the corresponding 10 anchor points in the map grid is determined for 127.0.0.2; for 127.0.0.1, determining distribution information of 50 positioning points corresponding to the distribution information in a map grid; and determining distribution information of 60 positioning points corresponding to the target address field 127.0.0 in the map grid.
For another example, there are 8 IP addresses 127.0.0.2, 127.0.0.39, 127.0.0.85, 127.0.0.100, 127.0.0.128, 127.0.0.195, 127.0.0.202, 127.0.0.248, and destination address intervals 1 of destination address field 127.0.0 are "127.0.0.0" to "127.0.0.165", destination address intervals 2 are "127.0.0.166" to "127.0.0.255", and 127.0.0.2, 127.0.0.39, 127.0.0.85, 127.0.0.100, and 127.0.0.128 are determined as destination IP addresses corresponding to destination address interval 1 of destination address field 127.0.0, and 127.0.0.195, 127.0.0.202, and 127.0.0.248 are determined as destination IP addresses corresponding to destination address interval 2 of destination address field "127.0.0".
In one embodiment, the IP address includes a first IP address and a second IP address, and the process of determining, by the terminal, second distribution information of a locating point corresponding to the target address segment in the map grid based on the target address segment of the IP address and the first distribution information corresponding to the IP address specifically includes the following steps: determining a first IP address and a second IP address which are matched with a target address segment of the IP address in the IP address, combining the first distribution information of the first IP address and the first distribution information of the second IP address to obtain combined distribution information, wherein the combined distribution information is the second distribution information of positioning points corresponding to the target address segment in a map grid.
The first IP address and the second IP address are both target IP addresses corresponding to the target address segment, and the target IP address corresponding to the target address segment refers to an IP address in an IP address interval represented by the target address segment. The first and second are used herein to illustrate that the destination IP addresses are different, and are not used to limit the number of destination IP addresses.
The first distribution information refers to the distribution condition of positioning points corresponding to the IP addresses in the map grid, and comprises information such as matrix grids distributed by the positioning points corresponding to the IP addresses, the number of the positioning points corresponding to the IP addresses in each matrix grid and the like.
The second distribution information refers to the distribution condition of the positioning points corresponding to the target address segments in the map grid, and comprises information such as matrix grids distributed by the positioning points corresponding to the target address segments, the number of the positioning points corresponding to the target address segments in each matrix grid, and the like.
Specifically, after obtaining an IP address and a target address segment of the IP address, the terminal determines, for any one IP address, first distribution information of anchor points corresponding to the IP address in a map grid based on the IP address and anchor point information corresponding to the IP address; and determining a first IP address and a second IP address corresponding to the target address segment aiming at any one target address segment, and combining the first distribution information of the first IP address and the first distribution information of the second IP address to obtain the second distribution information of the positioning point corresponding to the target address segment in the map grid.
For example, if the first IP address corresponding to the destination address field 127.0.0 is 127.0.0.2 and the second IP address is 127.0.0.1, if there are 10 anchor points corresponding to 127.0.0.2 and 50 anchor points corresponding to 127.0.0.1, for 127.0.0.2, determining first distribution information of the 10 anchor points corresponding to 127.0.0.2 on the map grid; for 127.0.0.1, determining first distribution information of 50 positioning points corresponding to the first distribution information in a map grid; for the target address segment 127.0.0, based on first distribution information of 10 positioning points of 127.0.0.2 in the map grid and first distribution information of 50 positioning points of 127.0.0.1 in the map grid, the number of positioning points of 127.0.0.2 and the number of positioning points of 127.0.0.1 in each matrix grid in the map grid can be determined, and the sum of the number of positioning points of 127.0.0.2 and the number of positioning points of 127.0.1 in each matrix grid is calculated respectively to obtain the number of positioning points of each matrix grid 127.0.0, so that second distribution information of 60 positioning points of 127.0.0 in the map grid is obtained.
In one embodiment, the terminal may further perform a combination process on the anchor point information corresponding to each of the first IP address and the second IP address, to obtain second distribution information of anchor points corresponding to the target address segment in the map grid.
Specifically, after determining that the anchor points corresponding to the IP addresses are in the first distribution information of the map grid based on the IP addresses and anchor point information corresponding to the IP addresses, the terminal may further determine a first IP address and a second IP address that are matched with the target address segment in the IP addresses, combine anchor point information corresponding to the first IP address and the second IP address, and determine that the combined anchor point information is anchor point information of the target address segment, and determine that the anchor points corresponding to the target address segment are in the second distribution information of the map grid based on the anchor point information of the target address segment.
S206, clustering matrix grids in the map grid based on the first distribution information to obtain clusters corresponding to the IP addresses; and clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment.
The clustering (Clustering) is a data mining method of unsupervised learning, and aims to classify similar data points into the same Cluster (Cluster) so that the similarity of the data points in the clusters is maximum and the similarity of the data points among the clusters is minimum.
Specifically, after determining distribution information of positioning points corresponding to the IP address and the target address segment in the map grid, the terminal can cluster matrix grids in the map grid by adopting a preset clustering algorithm based on first distribution information of the positioning points of the IP address for any one IP address to obtain a cluster corresponding to the IP address; for any one target address segment, based on the second distribution information of the positioning points of the target address segment, a preset clustering algorithm is adopted to cluster matrix lattices in the map lattice, so that a cluster corresponding to the target address segment is obtained.
The preset clustering algorithm may be clique clustering algorithm, clique clustering algorithm is a grid-based clustering method, which divides the whole embedded space of the data object into units by dividing each dimension into non-overlapping intervals to identify density-based clusters, clique clustering algorithm uses a density threshold to identify dense units, and when the number of objects mapped to the units exceeds the threshold, it is considered dense.
As shown in fig. 3, in one embodiment, the first distribution information of the positioning points based on a certain IP address is a cluster obtained after clustering the map grids, where the points in each matrix grid are the positioning points of the IP address, and the shaded area is the obtained cluster.
S208, determining the target position of each cluster as a candidate positioning position.
The target position may be a central position of the cluster, and the longitude and latitude coordinates of the central position may specifically be an average value of longitude coordinates and an average value of latitude coordinates of each positioning point in the cluster, and the average value of longitude coordinates and the latitude coordinates are used as the longitude and latitude coordinates of the central position of the cluster.
Specifically, for any one IP address, after the terminal clusters the matrix lattice of the map grid based on the distribution information of the locating points of the IP address to obtain a cluster corresponding to the IP address, the target position of the cluster may be determined as the locating position of the IP address, and the locating position may also be referred to as a candidate locating position; for any target address segment, the terminal clusters the matrix lattices of the map grid based on the distribution information of the positioning points of the target address segment, and after obtaining a cluster corresponding to the target address segment, the target position of the cluster can be determined as the positioning position of the target address segment, and the positioning position can also be called as a candidate positioning position.
It can be understood that by performing the above processing on all the IP addresses and the target address segments, the candidate positioning positions of each IP address and the candidate positioning positions of each target address segment can be obtained, each candidate positioning position can be stored, specifically, the IP address and the corresponding positioning position can be stored correspondingly, and the target address segment and the corresponding positioning position can be stored, so that when a positioning request is subsequently received, the corresponding positioning position can be found from the stored relation library containing "IP address-candidate positioning position" and "target address segment-candidate positioning position" based on the IP address in the positioning request.
In one embodiment, the positioning method based on the IP address further includes the following steps: in response to the location request, a matching location position is found among the candidate location positions based on the IP address in the location request.
Specifically, when a terminal receives a positioning request, the terminal responds to the positioning request, analyzes the positioning request to obtain an IP address in the positioning request, searches an IP address or a target address segment matched with the IP address in the positioning request from a stored relation library containing the IP address-candidate positioning position and the target address segment-candidate positioning position, and determines a candidate positioning position corresponding to the matched IP address or target address segment as a positioning position matched with the IP address in the positioning request.
In the above embodiment, after acquiring the IP address of the target object and the location information of the location point corresponding to the IP address, the terminal determines, based on the acquired data, not only the candidate location position corresponding to the IP address, but also the target address segment of the IP address by mining, and determines the candidate location position of the target address segment, so that the correspondence between the target address segment and the candidate location position can be expanded, so that when the location position corresponding to a certain IP address cannot be acquired later, the candidate location position of the target address segment corresponding to the IP address can be determined as the location position of the IP address, thereby improving the locatable rate of location based on the IP address, and further improving the accuracy and reliability of location; on the other hand, by clustering matrix lattices distributed by a plurality of positioning points of the same IP address or target address segment, interference of unreliable positioning points in the plurality of positioning points on positioning results is eliminated, so that the determined candidate positioning positions of each IP address or target address segment are more accurate, and the positioning accuracy and reliability are improved; in addition, the latest IP address of the target object and the position information of the positioning point corresponding to the IP address are acquired in real time, and the candidate positioning positions of the IP addresses or the target address segments are determined based on the acquired data, so that the respective positioning positions of the IP addresses and the target address segments can be updated in time, and the accuracy of positioning based on the IP addresses is further improved.
In one embodiment, before determining that the anchor points corresponding to the IP address and the target address segment are in the distribution information of the map grid based on the IP address, the target address segment of the IP address and the anchor point information, the terminal may further determine the target address segment of the IP address, as shown in fig. 4, and the process specifically includes the following steps:
S402, determining the address type of the IP address.
The address types comprise a first type and a second type, wherein the first type refers to an IPv4 address type, and the second type refers to an IPv6 address type. It will be appreciated that the manner in which the destination address segments are selected for IP addresses of different address types is different.
Specifically, after obtaining the IP address of each target object, the terminal determines, for any one IP address, an address type of the IP address based on a representation form of the IP address, and obtains a selection policy matched with the address type, so as to determine a target address segment corresponding to the IP address based on the determined selection policy.
S404, determining a target address segment of the IP address based on the address type.
Specifically, when acquiring a selection policy matched with an address type, the terminal selects a designated address segment from the IP address based on the determined selection policy, and obtains a target address segment corresponding to the IP address.
In one embodiment, the process of determining the destination address segment of the IP address by the terminal based on the address type specifically includes the following steps: when the address type is the first type, taking the network segment of the IP address as a target address segment; and when the address type is the second type, grading the address segments in the IP address to obtain target address segments of all levels.
Specifically, when the address type is the first type, the terminal acquires a network segment of the IP address later, and takes the network segment of the IP address as a target address segment; when the address type is the second type, the terminal acquires preset address bits of each level matched with the second type; and selecting address segments respectively designated by preset address bits of each level from the IP address to obtain target address segments of each level.
The first type refers to an IPv4 address type, the network segment refers to the first three segments of the IPv4 address, for example, the IPv4 address is composed of a 32-bit binary number, which may be represented in a dot decimal form, for example, the network segment refers to the first three segments of the IPv4 address, and for the IPv4 address "192.168.1.1", the network segment is "192.168.1", that is, the target address segment is "192.168.1". It is understood that the destination address field "192.168.1" may represent an address field to which an IPv4 address having the first three fields of "192.168.1" belongs, and the address field specifically includes 266 IP addresses from "192.168.1.0" to "192.168.1.255".
The second type is an IPv6 address type, and the preset address bits are character bits in a preset IP address, and specifically may include a plurality of levels of preset address bits, such as a first level preset address bit, a second level preset address bit, a third level preset address bit … … twelve levels preset address bits, and so on.
For example, an IPv6 address is composed of 128-bit binary digits, where the IPv6 address may be regarded as a string composed of a plurality of hexadecimal digits separated by a colon, and the first-stage preset address bit is 16 bits, the second-stage preset address bit is 15 bits, the third-stage preset address bit is 14 bits, … …, and the twelve-stage preset address bit is 4 bits, and for the Pv6 address "2001:0db8:85a3:0000:0000:8a2e:0370:7334", the address segments specified by the preset character bits of each level are "2001:0db8:85a3:0000:0000", "2001:0db8:85a3:0000", "2001:2001", "2001:0db0d8:85a8:85a8:0000", "2001:2001:2001:2001:2001:2001:2001:2001:2001:5:being 3:2001:3:being 3:being 3:3:each, i.e, and the target address segments of each level are" 2001:0db8:85a3:0000:0000:0000 ", 2001", 2001:0d0 ". It will be appreciated that the destination address field "2001:0db8:85a3:0000:0000" may characterize the address field to which the first 16 bits of IPv6 address belongs as "2001:0db8:85a3:0000:0000", i.e. "2001:0db8:85a 3:0000:0000:1" to "2001:0db8:85a 3:0000:ffff:ffff:ffff".
In the above embodiment, the terminal determines the address type of the IP address, and determines the target address segment of the IP address based on the address type, so that different address mining modes can be adopted for IP addresses of different address types to obtain corresponding target address segments, and further, the candidate positioning position of the target address segment can be determined, so that the corresponding relationship between the target address segment and the candidate positioning position can be obtained by expansion, and when the positioning position corresponding to a certain IP address cannot be obtained later, the candidate positioning position of the target address segment corresponding to the IP address can be determined as the positioning position of the IP address, thereby improving the positioning rate based on the IP address, and further improving the positioning accuracy and reliability.
In one embodiment, after determining the target position of each cluster as a candidate positioning position, the terminal may further store the candidate positioning position in the IP positioning database; the process of searching for the matched positioning position in the candidate positioning positions based on the IP address in the positioning request by the terminal in response to the positioning request, as shown in fig. 5, specifically comprises the following steps:
S502, responding to the positioning request, and acquiring a query key based on the IP address in the positioning request.
Specifically, the terminal may store "IP address-candidate location" and "target address segment-candidate location" in the form of key value pairs, so that when a location request is received, a query key matching the address type of the IP address is generated based on the IP address in the location request.
S504, based on the query key, the matched candidate positioning position is queried in the IP positioning database.
Specifically, after generating the query key, the terminal queries the matched key value pair in the IP positioning database based on the generated query key, and obtains the candidate positioning position in the queried matched key value pair.
In one embodiment, the process of the terminal querying the IP location database for the matching candidate location based on the query key includes the steps of: searching matched key value pairs based on the query key in the IP positioning database, and taking the values in the searched key value pairs as matched candidate positioning positions.
Specifically, the terminal responds to a positioning request and generates a query key based on an IP address in the positioning request; searching for a matched key value pair in the IP positioning database based on the query key, acquiring a query value from the searched key value pair, and determining a candidate positioning position in the query value as a positioning position matched with the IP address in the positioning request.
S506, taking the inquired candidate positioning position as the positioning position requested by the positioning request.
Specifically, after obtaining the candidate positioning position in the matched key value pair, the terminal takes the candidate positioning position in the key value pair as the positioning position requested by the positioning request.
In the above embodiment, the terminal stores the candidate positioning positions in the IP positioning database, so that the terminal can respond to the positioning request, obtain the query key based on the IP address in the positioning request, query the matched candidate positioning positions in the IP positioning database based on the query key, and take the queried candidate positioning positions as the positioning positions requested by the positioning request, thereby realizing the accurate positioning of the IP address in the positioning request, and improving the accuracy and efficiency of positioning based on the IP address.
In one embodiment, the process of the terminal storing the candidate position fix in the IP position fix database comprises the steps of: constructing key-value pairs by taking the IP address as a key, taking the candidate positioning position corresponding to the IP address as a value, taking the target address segment of the IP address as a key, and taking the candidate positioning position corresponding to the target address segment and the IP address interval corresponding to the target address segment as values; the key value pairs are stored to an IP location database.
The Key-Value Pair is a data structure, and is an ordered Pair, and is composed of keys (keys) and values (values), wherein the keys can be understood as indexes, the indexes are used for identifying data, the values are data corresponding to the keys, and the keys are connected by symbols such as ": or" = ". In addition, it will be appreciated that the data size of the IP address and destination address fields used in the present application is very large, so that distributed storage and retrieval may be implemented using the distributed data structure of the dis, which is a high-performance memory data storage device, which may be used to store and retrieve key-value pairs.
The target address interval corresponding to the target address segment is a sub-interval of the IP address interval represented by the target address segment, for example, the target address segment "192.168.1" may represent an address interval to which an IPv4 address with the first three segments of "192.168.1" belongs, "192.168.1.0" to "192.168.1.255" is an IP address interval of the target address segment "192.168.1," 192.168.1.0 "to" 192.168.1.165, "and" 192.168.1.166 "to" 192.168.1.255 "are two sub-intervals of the IP address interval of the target address segment" 192.168.1, "respectively.
Specifically, after obtaining an IP address and a corresponding candidate positioning position, the terminal takes the IP address as a key, generates a value according to the candidate positioning position, constructs the generated key and value as a key value pair and stores the key value pair into an IP positioning database; after obtaining the target address segment and the corresponding candidate positioning position, the terminal can further obtain the target address segment of the target address segment corresponding to the candidate positioning position, take the target address segment as a key, generate an address identification list according to the target address segment, generate a value according to the address identification list and the corresponding candidate positioning position, construct the generated key and value as a key value pair and store the key and the value into the IP positioning database.
For example, for IP address 127.1.1.24, it may be stored directly as a key:127.1.1.24, value: candidate positioning positions; for the target IP address 127.1.1, it may be stored as a key:127.1.1, value: list, candidate location, where list represents a target address interval, e.g., 1ist is 1-165, which is used to characterize 127.1.1 target address intervals of "127.1.1.1" through "127.1.1.165".
It should be noted that, for the IPv6 type target address segment, the target address segment may be directly used as a key, and the candidate positioning location corresponding to the target address segment may be used as a value to construct a key-value pair; the key value pairs are stored to an IP location database.
In the above embodiment, the terminal constructs the key-value pair by using the IP address as a key, using the candidate location position corresponding to the IP address as a value, using the target address segment of the IP address as a key, and using the candidate location position corresponding to the target address segment and the IP address segment corresponding to the target address segment as a value; storing the key value pairs into an IP positioning database; therefore, the query key can be obtained based on the IP address in the positioning request in response to the positioning request, the matched candidate positioning position is queried in the IP positioning database based on the query key, and the queried candidate positioning position is used as the positioning position requested by the positioning request, so that the accurate positioning of the IP address in the positioning request is realized, and the accuracy and the efficiency of positioning based on the IP address are improved.
In one embodiment, the process of obtaining the query key by the terminal based on the IP address in the location request specifically includes the following steps: if the address type of the IP address in the positioning request is the first type, generating a first query key corresponding to the IP address in the positioning request; the process of searching matched key value pairs in the IP positioning database based on the query key by the terminal and taking the values in the searched key value pairs as matched candidate positioning positions specifically comprises the following steps: and when the first key value pair matched with the first query key is found in the IP positioning database, taking the value in the first key value pair as a matched candidate positioning position.
Wherein the first query key directly uses the IP address in the positioning request as a key.
Specifically, after obtaining an IP address in a positioning request, the terminal determines an address type of the IP address, and when the address type of the IP address is a first type, that is, is an IPv4 address type, directly uses the IP address as a first query key, searches a first key value pair matched with the first query key in an IP positioning database, obtains a value in the first key value pair, and uses a candidate positioning position in the value as a matched candidate positioning position, that is, determines the candidate positioning position in the value as a positioning position of the IP address in the positioning request.
For example, if the IP address in the positioning request is 127.0.1.33 and the address type of the IP address is the first type, 127.0.1.33 is directly used as the first query key, and when the key of 127.0.1.33 is found in the IP positioning database, a value corresponding to 127.0.1.33 is obtained, and the candidate positioning position in the value is determined as the positioning position queried in the positioning request.
In the above embodiment, when the IP address in the positioning request is of the first type, a first query key corresponding to the IP address in the positioning request is generated; therefore, the matched candidate positioning positions can be inquired in the IP positioning database based on the first inquiry key, the inquired candidate positioning positions are used as the positioning positions requested by the positioning request, the accurate positioning of the first type of IP addresses in the positioning request is realized, and the accuracy and the efficiency of positioning based on the IP addresses are improved.
In one embodiment, the positioning method based on the IP address further includes the following steps: when the first key value pair matched with the first query key is not found in the IP positioning database, generating a second query key corresponding to the IP address in the positioning request; when the second key value pair matched with the second query key is found in the IP positioning database, an IP address interval represented by the value of the second key value pair is determined, and when the IP address in the positioning request belongs to the represented IP address interval, the candidate positioning position represented by the value of the second key value pair is used as the matched candidate positioning position.
Wherein the second query key is to use the destination address field of the IP address in the location request as a key.
Specifically, when the first key value pair matched with the first query key is not found in the IP positioning database, the terminal extracts a target address segment from the IP address in the positioning request, takes the extracted target address segment as a second query key, queries the IP positioning database based on the second query key, searches the second key value pair matched with the second query key in the IP positioning database based on the second query key, acquires a value in the second key value pair, acquires an address identification list in the value, and determines whether the IP address in the positioning request is in the address identification list, if so, determines that the IP address in the positioning request belongs to an IP address interval represented by the value in the second key value pair, and takes a candidate positioning position in the value of the second key value pair as a matched candidate positioning position, namely, determines the candidate positioning position in the value of the second key value pair as the positioning position of the IP address in the positioning request.
For example, if the IP address in the positioning request is 127.0.1.33, the address type of the IP address is the first type, 127.0.1.33 is directly used as the first query key, when the key of 127.0.1.33 is not found in the IP positioning database, the target address segment 127.0.1 of 127.0.1.33 is obtained, 127.0.1 is used as the second query key, when the key of 127.0.1 is found in the IP positioning database, the first value corresponding to the key is obtained, the list is obtained from the first value, and when 33 is in the list, the candidate positioning position corresponding to the list in the first value is obtained, and the candidate positioning position is determined as the positioning position of the IP address in the positioning request.
In the above embodiment, when the IP address in the positioning request is of the first type and the matching candidate positioning position is not queried in the IP positioning database based on the first query key, the matching candidate positioning position is not queried in the IP positioning database based on the second query key, so that the positioning rate of positioning based on the IP address of the IPv4 type is improved, and further the positioning accuracy and reliability are improved.
In one embodiment, the process of generating the query key by the terminal based on the IP address in the positioning request in response to the positioning request specifically includes the following steps: if the address type of the IP address in the positioning request is the second type, generating query keys of various levels corresponding to the IP address in the positioning request, searching matched key value pairs in an IP positioning database based on the query keys by the terminal, and taking the searched values in the key value pairs as matched candidate positioning positions, wherein the process specifically comprises the following steps: and when at least one level of key value pairs matched with the query keys of each level are found in the IP positioning database, obtaining key value pairs meeting the level condition from the at least one level of key value pairs, and taking the values in the key value pairs meeting the level condition as matched candidate positioning positions.
Wherein the level condition may be a highest value level.
Specifically, after determining that the address type of the IP address in the positioning request is the second type, the terminal obtains the target address segment of each level of the IP address, determines the target address segment of each level as the query key of the corresponding level, obtains the query key of each level, searches the key value pairs of each level matched with the query key of each level in the IP positioning database in a parallel manner, and when at least one key value pair of the level is found, determines the key value pair of the highest level in the at least one key value pair as the target key value pair, and uses the value in the target key value pair as the matched candidate positioning position.
For example, if the IP address in the positioning request is 2001:298:315f:0000:ffff:ffff:ffff, a primary target address segment 2001:298:315f:0000, a secondary target address segment 2001:298:315f:000, … …, and a twelve-level target address segment 2001 are extracted from the IP address, so that a corresponding-level query key is generated based on each level of target address segment, for example, a primary query key 2001:298:315f:0000, a secondary query key 2001:298:315f:000, … …, and a twelve-level query key 2001 are searched in the IP positioning database in a parallel manner, and when the key value pairs corresponding to five-level to twelve-level query keys are searched, the key value pair corresponding to the highest-level key value pair is determined, and the value of the key value pair corresponding to the five-level query key is determined as the positioning position of the IP address in the positioning request.
In the above embodiment, when the IP address in the positioning request is of the first type, the terminal searches at least one level of key value pair matched with the query key of each level in the IP positioning database by generating the query key of each level corresponding to the IP address in the positioning request, obtains the key value pair meeting the level condition from the at least one level of key value pair, and uses the value in the key value pair meeting the level condition as the candidate positioning position for matching, thereby improving the positionable rate of positioning based on the IP address of the IPv6 type, and further improving the accuracy and reliability of positioning.
In one embodiment, the process of clustering matrix lattices in the map grid by the terminal based on the first distribution information to obtain clusters corresponding to the IP addresses includes the following steps: clustering matrix grids in the map grid based on the first distribution information to obtain a first candidate cluster corresponding to the IP address; when the number of the first candidate clusters is at least two, determining the number of first positioning points corresponding to the IP addresses in each first candidate cluster; determining the first candidate cluster of which the number of first positioning points in at least two first candidate clusters meets a first preset condition as a cluster corresponding to the IP address; when the number of the first candidate clusters is one, determining the first candidate clusters as clusters corresponding to the IP addresses;
the first preset condition may be that the number of positioning points is the largest.
Specifically, for any one IP address, the terminal clusters matrix lattices in the map grid based on first distribution information of locating points of the IP address to obtain first candidate clusters corresponding to the IP address, when the number of the first candidate clusters is 1, the first candidate clusters are directly determined to be the clusters corresponding to the IP address, when the number of the first candidate clusters is at least two, the number of first locating points containing locating points of the IP address in each cluster is respectively determined, and the first candidate cluster with the largest number of first locating points is determined to be the cluster of the IP address.
In one embodiment, the process of clustering matrix lattices in the map grid by the terminal based on the second distribution information to obtain a cluster corresponding to the target address segment includes the following steps: clustering matrix grids in the map grid based on the second distribution information to obtain a second candidate cluster corresponding to the target address segment; when the number of the second candidate clusters is at least two, determining the number of second locating points corresponding to the target address segments in each second candidate cluster; determining second candidate cluster clusters with the number of second locating points meeting the first preset condition in at least two second candidate cluster clusters as cluster clusters corresponding to the target address segment; and when the number of the second candidate clusters is one, determining the second candidate clusters as the cluster corresponding to the target address segment.
For any one target address segment, the terminal clusters matrix lattices in the map grids based on second distribution information of positioning points of the target address segment to obtain second candidate clusters corresponding to the target address segment, when the number of the second candidate clusters is 1, the second candidate clusters are directly determined to be the clusters corresponding to the target address segment, when the number of the second candidate clusters is at least two, the number of second positioning points containing the positioning points of the target address segment in each cluster is respectively determined, and the second candidate clusters with the largest number of second positioning points are determined to be the clusters of the target address segment.
As shown in fig. 6, in an embodiment, the distribution of locating points of a certain IP address is shown, where a hatched area in the figure is two obtained candidate clusters, the number of locating points included in each cluster is counted, and the candidate cluster with the largest number of locating points is determined as the final cluster.
In one embodiment, the process of clustering matrix lattices in the map lattice by the terminal based on the first distribution information to obtain a first candidate cluster corresponding to the IP address includes the following steps: clustering matrix grids in the map grid based on the first distribution information to obtain a first initial cluster corresponding to the IP address; determining the total number of first positioning points corresponding to the IP addresses and the third positioning point number in each corresponding first initial cluster based on the first distribution information; determining a first proportion of each first initial cluster based on the third number of localization sites and the total number of first localization sites; and determining the first initial cluster with the first proportion reaching the proportion threshold value as a first candidate cluster corresponding to the IP address.
Specifically, for any one IP address, the terminal clusters the matrix lattices in the map grid based on the first distribution information of the locating points of the IP address to obtain first initial cluster clusters corresponding to the IP address, when the number of the first initial cluster clusters is at least two, determining the number of third locating points containing the locating point of the IP address in each first initial cluster, determining the total number of the first locating points corresponding to the IP address based on the first distribution information of the locating point of the IP address, for any one first initial cluster, determining the ratio of the number of the third locating points of the locating points in the first initial cluster to the total number of the first locating points corresponding to the IP address as the first proportion of the first initial cluster, thereby obtaining the first proportion of each first initial cluster, comparing each first proportion with a proportion threshold, determining the first initial cluster with the first proportion reaching the proportion threshold as the first candidate cluster corresponding to the IP address, and obtaining the first candidate cluster corresponding to each IP address.
In one embodiment, the process of the terminal clustering the matrix lattices in the map lattice based on the second distribution information to obtain the second candidate cluster corresponding to the target address segment includes the following steps: clustering matrix grids in the map grid based on the second distribution information to obtain a second initial cluster corresponding to the target address segment; determining the total number of second locating points corresponding to the target address segment and the fourth locating point number in each corresponding second initial cluster based on the second distribution information; determining a second proportion of each second initial cluster based on the fourth number of anchor points and the total number of second anchor points; and determining a second initial cluster of which the second proportion reaches a proportion threshold value as a second candidate cluster corresponding to the target address segment.
Specifically, for any one target address segment, the terminal clusters matrix lattices in the map lattice based on the distribution information of the positioning points of the target address segment to obtain second initial clustering clusters corresponding to the target address segment, when the number of the second initial clustering clusters is at least two, determining the number of fourth positioning points containing the positioning points of the target address segment in each second initial clustering cluster, determining the total number of the second positioning points corresponding to the target address segment based on the distribution information of the positioning points of the target address segment, for any one second initial clustering cluster, determining the ratio of the number of the fourth positioning points of the positioning points in the second initial clustering cluster to the total number of the second positioning points corresponding to the target address segment as the second proportion of the second initial clustering cluster, so as to obtain the second proportion of each second initial clustering, comparing each second proportion with a proportion threshold, determining the second initial clustering cluster with the second proportion reaching the proportion threshold as the second candidate clustering corresponding to the target address segment, and obtaining the second candidate clustering corresponding to each target address segment.
In one embodiment, the process of clustering matrix lattices in the map grid by the terminal based on the distribution information to obtain initial clustering clusters corresponding to the IP address and the target address segments specifically includes the following steps: clustering matrix lattices in the map grid based on first distribution information of positioning points of the IP addresses to obtain a first initial cluster of the IP addresses; and clustering matrix lattices in the map grids based on the second distribution information of the positioning points of the target address segments to obtain a first initial cluster of the target address segments.
Specifically, for any one IP address, the process of clustering matrix lattices in the map grid by the terminal based on the first distribution information of the locating points of the IP address to obtain a first initial cluster of the IP address includes the following steps: (1) Determining the number of unit locating points of locating points in each matrix lattice of the map grid based on the first distribution information of the locating points of the IP address; (2) Traversing matrix lattices which are not scanned, and taking the matrix lattices as current lattices when the number of first unit locating points reaches the matrix lattices of a number threshold; (3) If the number of unit locating points of a target adjacent matrix lattice in the adjacent matrix lattice of the current lattice reaches a number threshold, determining that the adjacent matrix lattice and the current lattice belong to the same set; (4) Determining the target adjacent grid matrix grid as a current grid, and re-executing the step (3) until the number of unit locating points of the adjacent matrix grid of the current grid does not reach a number threshold; (5) Determining each matrix lattice belonging to the same set as an initial cluster; (6) And (3) re-executing the steps (2) to (5) until all matrix lattices are scanned, and obtaining all first initial cluster clusters.
Wherein the number of unit locating points is the number of locating points of the IP address in a single matrix lattice; the number threshold may be a predetermined value for identifying dense cells in the matrix grid, for example, the number threshold may be set according to actual requirements. The adjacent matrix lattices of the current lattice refer to the upper, lower, left, and right adjacent matrix lattices of the current lattice.
For any one target address segment, the terminal clusters matrix lattices in the map grid based on the second distribution information of the positioning points of the target address segment, and in the process of obtaining the second initial cluster of the target address segment, after determining the number of unit positioning points of the positioning points in each matrix lattice of the map grid based on the second distribution information of the positioning points of the target address segment, the terminal can execute the same steps as the steps (2) to (6) above, so as to realize the clustering of the matrix lattices in the map grid, and obtain all initial clusters of the target address segment.
In the above embodiment, the terminal clusters the matrix lattices in the positioning grid based on the distribution information to obtain initial clustering clusters corresponding to the IP addresses and the target address segments, and further performs layer-by-layer screening on the initial clustering clusters when the number of the initial clustering clusters is at least two to obtain the most reliable clustering clusters corresponding to the IP addresses or the target address segments, so that the candidate positioning positions of the IP addresses or the target addresses can be determined based on the screened most reliable clustering clusters, interference of unreliable positioning points in a plurality of positioning points on positioning results is eliminated, the determined candidate positioning positions of each IP address or target address segment are more accurate, and positioning accuracy and reliability are improved.
In one embodiment, the positioning method based on the IP address further includes a process of determining a geographic address corresponding to each candidate positioning location, and specifically includes the following steps: respectively acquiring geographic addresses corresponding to the IP address and the target address segment; determining a first frequency of each geographic address corresponding to the IP address and a second frequency of each geographic address corresponding to the target address segment; and determining the geographic address of which the first frequency meets the second preset condition as a target geographic address corresponding to the IP address, and determining the geographic address of which the second frequency meets the second preset condition as a target geographic address corresponding to a target address segment of the geographic address.
Where geographic address refers to textual information describing a specific location of a point on the earth's surface, such as: province, city, district, street, house number, etc. The second preset condition is that the frequency is maximum.
Specifically, for any one IP address, the terminal acquires positioning point information corresponding to the IP address, extracts a geographic address from the positioning point information, determines the first frequency of each geographic address, determines the geographic address with the largest first frequency in each geographic address, and determines the geographic address as a target geographic address corresponding to the IP address; for any one target address segment, the terminal acquires positioning point information corresponding to the target address segment, extracts geographic addresses from the positioning point information, determines the second frequency of each geographic address, determines the geographic address with the largest second frequency in each geographic address, and determines the geographic address as the target geographic address corresponding to the target address segment.
In one embodiment, after obtaining the candidate location of each IP address and the candidate location of each target address segment, the terminal may further analyze each candidate location to determine the target geographic address corresponding to each candidate location.
For example, the candidate positioning location is specifically longitude and latitude coordinates, and then the target geographic address of the candidate positioning location can be obtained through longitude and latitude analysis. The geographic address of the corresponding location is determined by the latitude and longitude coordinates, and a geocoding service, such as Google Maps API, bing Maps API, openStreetMap API, etc., may be used, which provide interfaces through which the developer can query address information, and by invoking these interfaces, the latitude and longitude coordinates can be converted into a specific geographic address.
It can be understood that the target geographic address of each IP address and the target geographic address corresponding to each target address segment can be determined in the above manner, and the target geographic address and the corresponding candidate positioning position are stored in the IP positioning database together, so that when the positioning request is received, the target geographic address matched with the IP address in the positioning request and the positioning position can be returned together, and the user can request the target geographic address of the IP address directly.
In one embodiment, the positioning method based on the IP address further includes a process of screening the data, and specifically includes the following steps: determining the total number of positioning points corresponding to the IP address and the target address segments respectively based on the distribution information; when the total number of positioning points reaches a positioning point number threshold, acquiring the number of objects of the target object to which the corresponding positioning points belong; when the number of objects reaches an object number threshold, executing a step of clustering matrix lattices in the map lattice based on the distribution information; and deleting at least one part of IP addresses and corresponding anchor point information of the target object when the total number of the anchor points does not reach the anchor point number threshold or when the number of the objects does not reach the object number threshold.
It can be understood that if the number of anchor points corresponding to a certain IP address is small, for example, 1, or for example: when a user uses vpn and a person is in Tianjin, but uses Beijing IP, one IP is positioned to the wrong position, the positioning result can be considered to be inaccurate, namely the data source is unreliable and cannot be used for subsequent data processing; if the locating point corresponding to an IP address is contributed by fewer target objects, such as 1 target object, the locating result is considered to be inaccurate, i.e. the data source is unreliable and cannot be used for subsequent data processing.
In one embodiment, as shown in fig. 7, there is further provided an IP address-based positioning method, which is illustrated by using the method applied to the terminal 102 in fig. 1 as an example, and includes the following steps:
S702, the IP address of the target object and the corresponding positioning point information are acquired.
S704, determining first distribution information of locating points corresponding to the IP addresses in the map grid based on the IP addresses and locating point information corresponding to the IP addresses.
S706, determining the target IP address corresponding to the target address segment in the IP addresses.
S708, determining second distribution information of positioning points corresponding to the target address segments in the map grid based on the first distribution information of the positioning points of the target IP addresses in the map grid.
S710, clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address.
S712, clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment.
S714, determining the target position of each cluster as a candidate positioning position.
S716, constructing key-value pairs by taking the IP address as a key, taking the candidate positioning position corresponding to the IP address as a value, taking the target address section of the IP address as a key, and taking the candidate positioning position corresponding to the target address section and the IP address section corresponding to the target address section as values.
S718, storing the key value pairs in an IP positioning database.
S720, searching matched positioning positions in the candidate positioning positions based on the IP address in the positioning request in response to the positioning request.
The application also provides an application scene, which applies the positioning method based on the IP address, as shown in fig. 8, and the positioning method based on the IP address specifically comprises the following steps:
1. Data source preparation
And acquiring a user track of the user for 7 consecutive days, and extracting the IP address and the locating point information from the user track to serve as a data source. The positioning point information can comprise positioning time, GPS information and longitude and latitude coordinates of the positioning point determined based on the GPS information.
2. Setpoint mapping
And mapping each positioning point into a map grid, wherein the size of each matrix grid in the map grid is 50 meters by 50 meters, and the finally obtained positioning accuracy can be controlled within the range of 50 meters.
3. First distribution information determination
And determining the number of locating points and the number of users corresponding to the IP addresses in each matrix lattice according to any one IP address to obtain first distribution information of the IP addresses. And respectively counting all the IP addresses to obtain first distribution information of each IP address.
4. Second distribution information determination
Extracting the first three sections of the IPv4 address aiming at the IPv4 address to obtain a target IP address; aiming at the IPv6 address, the first four sections of the IPv6 address are extracted at the longest, and the first section of the IPv6 address is extracted at the shortest, so that target address sections of all levels are obtained.
And determining the IP address of each IP address containing the target address segment as the corresponding target IP address of the target address segment, and determining the second distribution information of the target address segment based on the first distribution information of the target IP address.
5. Candidate positioning location determination
And clustering matrix lattices in the map lattices based on the first distribution information of the IP addresses to obtain clustering clusters, and determining the central positions of the clustering clusters as candidate positioning positions of the IP addresses.
And clustering matrix lattices in the map grids based on the second distribution information of the target address segments to obtain clustering clusters, and determining the central position of the clustering clusters as the candidate positioning position of the IP address.
6. IP positioning database storage
Constructing key-value pairs by taking the IP address as a key, taking the candidate positioning position corresponding to the IP address as a value, taking the target address segment of the IP address as a key, and taking the candidate positioning position corresponding to the target address segment and the IP address interval corresponding to the target address segment as values; the key value pairs are stored to an IP location database.
7. Geographic address determination
Respectively acquiring geographic addresses corresponding to the IP address and the target address segment; determining a first frequency of each geographic address corresponding to the IP address and a second frequency of each geographic address corresponding to the target address segment; and determining the geographic address of which the first frequency meets the second preset condition as a target geographic address corresponding to the IP address, and determining the geographic address of which the second frequency meets the second preset condition as a target geographic address corresponding to a target address segment of the geographic address.
The destination geographic address of each IP address and the destination geographic address of each destination address segment may also be stored in the IP location database.
8. Positioning and filtering
Determining the total number of positioning points corresponding to the IP address and the target address segments respectively based on the distribution information; when the total number of positioning points reaches a positioning point number threshold, acquiring the number of objects of the target object to which the corresponding positioning points belong; and deleting at least one part of IP addresses and corresponding positioning point information of the target object or deleting corresponding candidate positioning positions when the total number of positioning points does not reach the threshold value of the positioning point number or the number of objects does not reach the threshold value of the object number.
9. IP address lookup
Responding to a positioning request, when the positioning request carries an IPv4 address, generating a first query key corresponding to an IP address in the positioning request, and when a first key value pair matched with the first query key is found in an IP positioning database, taking a value in the first key value pair as a matched candidate positioning position; when the first key value pair matched with the first query key is not found in the IP positioning database, generating a second query key corresponding to the IP address in the positioning request; when the second key value pair matched with the second query key is found in the IP positioning database, an IP address interval represented by the value of the second key value pair is determined, and when the IP address in the positioning request belongs to the represented IP address interval, the candidate positioning position represented by the value of the second key value pair is used as the matched candidate positioning position.
When the positioning request carries the IPv6 address, generating inquiry keys of various levels corresponding to the IP address in the positioning request; and when at least one level of key value pairs matched with the query keys of each level are found in the IP positioning database, obtaining key value pairs meeting the level condition from the at least one level of key value pairs, and taking the values in the key value pairs meeting the level condition as matched candidate positioning positions.
In the scheme, the IP positioning database can be updated by executing the steps 1 to 8 every day, so that the accuracy of positioning data in the IP positioning database is ensured, the influence of a single user on IP positioning is avoided, the storage space is reduced from the aspects of inquiry and storage, and the time for responding to a positioning request for positioning is shortened.
The application also provides an application scene of interest point recommendation, which applies the positioning method based on the IP address, when a user accesses a website, the application scene of interest point recommendation can receive a positioning request of the user, respond to the positioning request, search a matched positioning position in candidate positioning positions of an IP positioning database based on the IP address in the positioning request, thereby determining the position of the user, acquire the preference of the user, recommend interest points to a terminal where the user is based on the preference of the user and the determined position, and display the recommended interest points through the user terminal, as shown in fig. 9, the positioning points on the street in the figure are the determined user positions, "XX" strings, XX "restaurants and the like are the interest points recommended to the user, and the application also provides a method for positioning the interest points based on the IP address.
The application also provides an application scene of building positioning, which applies the positioning method based on the IP address, as shown in fig. 10, network equipment can be installed in each building, the network equipment can collect the position information of the building and other related data and send the information to a background server, the background server uses an IP positioning database after receiving the data sent by the equipment, determines the geographic position of the building according to the IP address of the equipment, and combines the geographic position obtained by IP positioning with the position information sent by the equipment to determine the specific position of the building. In addition, when a user is in a certain building, the user can access the Internet through the network equipment of the building, so that when a positioning request of the user is received, an IP address in the positioning request can be obtained, and a matched positioning position is searched in candidate positioning positions of an IP positioning database based on the IP address, so that the building in which the user is positioned is determined.
The application also provides an application scene of in-building interroom positioning, which applies the positioning method based on the IP address, as shown in a partial waiting hall schematic diagram of a certain station in fig. 11, network equipment can be installed in each waiting hall, the network equipment can collect position information of the waiting hall (room) and other related data and send the information to a background server, the background server uses an IP positioning database to determine the geographic position of the waiting hall (room) according to the IP address of the equipment after receiving the data sent by the equipment, and combines the geographic position obtained by IP positioning with the position information sent by the equipment to determine the specific position of the waiting hall (room). In addition, when the user is in a certain room, the user can access the Internet through the network equipment of the room, so that when the positioning request of the user is received, the IP address in the positioning request can be acquired, and the matched positioning position is searched in the candidate positioning positions of the IP positioning database based on the IP address, so that the room in which the user is determined.
It should be understood that, although the steps in the flowcharts related to the embodiments described above are sequentially shown as indicated by arrows, these steps are not necessarily sequentially performed in the order indicated by the arrows. The steps are not strictly limited to the order of execution unless explicitly recited herein, and the steps may be executed in other orders. Moreover, at least some of the steps in the flowcharts described in the above embodiments may include a plurality of steps or a plurality of stages, which are not necessarily performed at the same time, but may be performed at different times, and the order of the steps or stages is not necessarily performed sequentially, but may be performed alternately or alternately with at least some of the other steps or stages.
Based on the same inventive concept, the embodiment of the application also provides an IP address positioning device for implementing the above-mentioned IP address positioning method. The implementation of the solution provided by the device is similar to the implementation described in the above method, so the specific limitation in the embodiments of the positioning device for one or more IP addresses provided below may refer to the limitation of the positioning method for IP addresses in the above description, and will not be repeated here.
In one embodiment, as shown in fig. 12, there is provided a positioning device for an IP address, including: a data acquisition module 1202, a distribution determination module 1204, a mesh clustering module 1206, a location determination module 1208, and a request positioning module 1210, wherein:
The data acquisition module 1202 is configured to acquire an IP address of a target object and location information of a positioning point corresponding to the IP address.
The distribution determining module 1204 is configured to determine, based on the IP address and the location information, first distribution information of positioning points corresponding to the IP address in the map grid; and determining second distribution information of positioning points corresponding to the target address segments in the map grid based on the target address segments of the IP addresses and the first distribution information.
The grid clustering module 1206 is configured to cluster matrix lattices in the map grid based on the first distribution information, so as to obtain clusters corresponding to the IP addresses; and clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment.
The location determining module 1208 is configured to determine a target location of each cluster as a candidate positioning location.
In the above embodiment, after the IP address of the target object and the location information of the location point corresponding to the IP address are acquired, not only the candidate location position corresponding to the IP address is determined based on the acquired data, but also the target address segment of the IP address is mined, and the candidate location position of the target address segment is determined, so that the correspondence between the target address segment and the candidate location position can be expanded and obtained, and when the location position corresponding to a certain IP address cannot be acquired later, the candidate location position of the target address segment corresponding to the IP address can be determined as the location position of the IP address, so that the locatable rate based on the IP address is improved, and the location accuracy and reliability are further improved; on the other hand, by clustering matrix lattices distributed by a plurality of positioning points of the same IP address or target address segment, interference of unreliable positioning points in the plurality of positioning points on positioning results is eliminated, so that the determined candidate positioning positions of each IP address or target address segment are more accurate, and the positioning accuracy and reliability are improved; in addition, the latest IP address of the target object and the position information of the positioning point corresponding to the IP address are acquired in real time, and the candidate positioning positions of the IP addresses or the target address segments are determined based on the acquired data, so that the respective positioning positions of the IP addresses and the target address segments can be updated in time, and the accuracy of positioning based on the IP addresses is further improved.
In one embodiment, as depicted in fig. 13, the apparatus further comprises:
The request positioning module 1210 is configured to search for a matching positioning location among the candidate positioning locations based on the IP address in the positioning request in response to the positioning request.
In one embodiment, as shown in fig. 13, the apparatus further comprises:
An address type determining module 1212 for determining an address type of the IP address; a destination address segment determination module 1214 for determining a destination address segment of the IP address based on the address type.
In one embodiment, the destination address segment determination module 1214 is further configured to: when the address type is the first type, taking the network segment of the IP address as a target address segment; and when the address type is the second type, grading the address segments in the IP address to obtain target address segments of all levels.
In one embodiment, as depicted in fig. 13, the apparatus further comprises:
a data storage module 1216 for storing candidate position locations in an IP position database;
the request positioning module 1210 is further configured to: responding to the positioning request, and acquiring a query key based on the IP address in the positioning request; inquiring the matched candidate positioning position in the IP positioning database based on the inquiring key; and taking the inquired candidate positioning position as the positioning position requested by the positioning request.
In one embodiment, the data storage module 1216 is further to: constructing key-value pairs by taking the IP address as a key, taking the candidate positioning position corresponding to the IP address as a value, taking the target address segment of the IP address as a key, and taking the candidate positioning position corresponding to the target address segment and the IP address interval corresponding to the target address segment as values; storing the key value pairs into an IP positioning database;
the request positioning module 1210 is further configured to: searching matched key value pairs based on the query key in the IP positioning database, and taking the values in the searched key value pairs as matched candidate positioning positions.
In one embodiment, the request positioning module 1210 is further configured to: if the address type of the IP address in the positioning request is the first type, generating a first query key corresponding to the IP address in the positioning request; and when the first key value pair matched with the first query key is found in the IP positioning database, taking the value in the first key value pair as a matched candidate positioning position.
In one embodiment, the request positioning module 1210 is further configured to: when the first key value pair matched with the first query key is not found in the IP positioning database, generating a second query key corresponding to the IP address in the positioning request; when the second key value pair matched with the second query key is found in the IP positioning database, an IP address interval represented by the value of the second key value pair is determined, and when the IP address in the positioning request belongs to the represented IP address interval, the candidate positioning position represented by the value of the second key value pair is used as the matched candidate positioning position.
In one embodiment, the requested location module 1210 is further configured to: if the address type of the IP address in the positioning request is the second type, generating inquiry keys of various levels corresponding to the IP address in the positioning request; and when at least one level of key value pairs matched with the query keys of each level are found in the IP positioning database, obtaining key value pairs meeting the level condition from the at least one level of key value pairs, and taking the values in the key value pairs meeting the level condition as matched candidate positioning positions.
In one embodiment, the IP address includes a first IP address and a second IP address; the distribution determining module 1204 is further configured to: and combining the first distribution information corresponding to the first IP address and the second IP address to obtain the second distribution information of the positioning point corresponding to the target address section in the map grid.
In one embodiment, the mesh clustering module 1206 is further configured to: clustering matrix grids in the map grid based on the first distribution information to obtain a first candidate cluster corresponding to the IP address; when the number of the first candidate clusters is at least two, determining the number of first positioning points corresponding to the IP addresses in each first candidate cluster; determining the first candidate cluster of which the number of first positioning points in at least two first candidate clusters meets a first preset condition as a cluster corresponding to the IP address; when the number of the first candidate clusters is one, determining the first candidate clusters as clusters corresponding to the IP addresses;
In one embodiment, the mesh clustering module 1206 is further configured to: clustering matrix grids in the map grid based on the second distribution information to obtain a second candidate cluster corresponding to the target address segment; when the number of the second candidate clusters is at least two, determining the number of second locating points corresponding to the target address segments in each second candidate cluster; determining second candidate cluster clusters with the number of second locating points meeting the first preset condition in at least two second candidate cluster clusters as cluster clusters corresponding to the target address segment; and when the number of the second candidate clusters is one, determining the second candidate clusters as the cluster corresponding to the target address segment.
In one embodiment, the mesh clustering module 1206 is further configured to: clustering matrix grids in the map grid based on the first distribution information to obtain a first initial cluster corresponding to the IP address; determining the total number of first positioning points corresponding to the IP addresses and the third positioning point number in each corresponding first initial cluster based on the first distribution information; determining a first proportion of each first initial cluster based on the third number of localization sites and the total number of first localization sites; determining a first initial cluster with the first proportion reaching a proportion threshold value as a first candidate cluster corresponding to the IP address;
in one embodiment, the mesh clustering module 1206 is further configured to: clustering matrix grids in the map grid based on the second distribution information to obtain a second initial cluster corresponding to the target address segment; determining the total number of second locating points corresponding to the target address segment and the fourth locating point number in each corresponding second initial cluster based on the second distribution information; determining a second proportion of each second initial cluster based on the fourth number of anchor points and the total number of second anchor points; and determining a second initial cluster of which the second proportion reaches a proportion threshold value as a second candidate cluster corresponding to the target address segment.
In one embodiment, as shown in fig. 13, the apparatus further comprises a geographic address determination module 1218 for: respectively acquiring geographic addresses corresponding to the IP address and the target address segment; determining a first frequency of each geographic address corresponding to the IP address and a second frequency of each geographic address corresponding to the target address segment; and determining the geographic address of which the first frequency meets the second preset condition as a target geographic address corresponding to the IP address, and determining the geographic address of which the second frequency meets the second preset condition as a target geographic address corresponding to a target address segment of the geographic address.
In one embodiment, as shown in fig. 13, the apparatus further includes a data filtering module 1220 for: determining the total number of positioning points corresponding to the IP address and the target address segments respectively based on the distribution information; when the total number of positioning points reaches a positioning point number threshold, acquiring the number of objects of the target object to which the corresponding positioning points belong; when the number of objects reaches an object number threshold, executing a step of clustering matrix lattices in the map lattice based on the distribution information; and deleting at least one part of IP addresses and corresponding anchor point information of the target object when the total number of the anchor points does not reach the anchor point number threshold or when the number of the objects does not reach the object number threshold.
The various modules in the IP address based locating device described above may be implemented in whole or in part by software, hardware, and combinations thereof. The above modules may be embedded in hardware or may be independent of a processor in the computer device, or may be stored in software in a memory in the computer device, so that the processor may call and execute operations corresponding to the above modules.
In one embodiment, a computer device is provided, which may be a server, and the internal structure of which may be as shown in fig. 14. The computer device includes a processor, a memory, an Input/Output interface (I/O) and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, computer programs, and a database. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The database of the computer device is used to store IP address and anchor point information. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement a positioning method based on an IP address.
In one embodiment, a computer device is provided, which may be a terminal, and an internal structure diagram thereof may be as shown in fig. 15. The computer device includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input means. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage media. The input/output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless mode can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a positioning method based on an IP address. The display unit of the computer equipment is used for forming a visual picture, and can be a display screen, a projection device or a virtual reality imaging device, wherein the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, can also be a key, a track ball or a touch pad arranged on a shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
It will be appreciated by those skilled in the art that the structures shown in fig. 14 or 15 are merely block diagrams of portions of structures associated with aspects of the present application and are not intended to limit the computer apparatus to which aspects of the present application may be applied, and that a particular computer apparatus may include more or less components than those shown, or may combine some of the components, or have a different arrangement of components.
In an embodiment, there is also provided a computer device comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the method embodiments described above when the computer program is executed.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored which, when executed by a processor, carries out the steps of the method embodiments described above.
In an embodiment, a computer program product is provided, comprising a computer program which, when executed by a processor, implements the steps of the method embodiments described above.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and the data (including but not limited to data for analysis, stored data, presented data, etc.) related to the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the related laws and regulations and standards of the related country and region.
Those skilled in the art will appreciate that implementing all or part of the above described methods may be accomplished by way of a computer program stored on a non-transitory computer readable storage medium, which when executed, may comprise the steps of the embodiments of the methods described above. Any reference to memory, database, or other medium used in embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include Read-Only Memory (ROM), magnetic tape, floppy disk, flash Memory, optical Memory, high density embedded nonvolatile Memory, resistive random access Memory (ReRAM), magneto-resistive random access Memory (Magnetoresistive Random Access Memory, MRAM), ferroelectric Memory (Ferroelectric Random Access Memory, FRAM), phase change Memory (PHASE CHANGE Memory, PCM), graphene Memory, and the like. Volatile memory can include random access memory (Random Access Memory, RAM) or external cache memory, and the like. By way of illustration, and not limitation, RAM can be in various forms such as static random access memory (Static Random Access Memory, SRAM) or dynamic random access memory (Dynamic Random Access Memory, DRAM), etc. The databases referred to in the embodiments provided herein may include at least one of a relational database and a non-relational database. The non-relational database may include, but is not limited to, a blockchain-based distributed database, and the like. The processor referred to in the embodiments provided in the present application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic unit, a data processing logic unit based on quantum computing, or the like, but is not limited thereto.
The technical features of the above embodiments may be arbitrarily combined, and all possible combinations of the technical features in the above embodiments are not described for brevity of description, however, as long as there is no contradiction between the combinations of the technical features, they should be considered as the scope of the description.
The foregoing examples illustrate only a few embodiments of the application and are described in detail herein without thereby limiting the scope of the application. It should be noted that it will be apparent to those skilled in the art that several variations and modifications can be made without departing from the spirit of the application, which are all within the scope of the application. Accordingly, the scope of the application should be assessed as that of the appended claims.
Claims (19)
1. A positioning method based on an IP address, the method comprising:
Acquiring an IP address of a target object and position information of a positioning point corresponding to the IP address;
Determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
Clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
And determining the target position of each cluster as a candidate positioning position.
2. The method according to claim 1, wherein the method further comprises:
determining the address type of the IP address;
and determining a target address segment of the IP address based on the address type.
3. The method of claim 2, wherein the determining the destination address segment for the IP address based on the address type comprises:
When the address type is the first type, taking the network segment of the IP address as a target address segment;
and when the address type is the second type, grading the address segments in the IP address to obtain target address segments of all levels.
4. The method according to claim 1, wherein the method further comprises:
storing the candidate positioning positions in an IP positioning database;
responding to a positioning request, and acquiring a query key based on an IP address in the positioning request;
inquiring the matched candidate positioning position in the IP positioning database based on the inquiring key;
And taking the searched candidate positioning position as the positioning position requested by the positioning request.
5. The method of claim 4, wherein the storing the candidate position fix in an IP position fix database comprises:
Constructing a key value pair by taking the IP address as a key, taking a candidate positioning position corresponding to the IP address as a value, taking a target address segment of the IP address as a key, and taking a candidate positioning position corresponding to the target address segment and an IP address interval corresponding to the target address segment as values;
Storing the key value pairs to an IP positioning database;
The searching the matched candidate positioning position in the IP positioning database based on the searching key comprises the following steps:
and searching matched key value pairs in the IP positioning database based on the query key, and taking the searched values in the key value pairs as matched candidate positioning positions.
6. The method of claim 5, wherein the obtaining a query key based on the IP address in the location request comprises:
if the address type of the IP address in the positioning request is a first type, generating a first query key corresponding to the IP address in the positioning request;
the searching for the matched key value pair based on the query key in the IP positioning database, and taking the value in the searched key value pair as the matched candidate positioning position comprises the following steps:
And when a first key value pair matched with the first query key is found in the IP positioning database, taking the value in the first key value pair as a matched candidate positioning position.
7. The method of claim 6, wherein the method further comprises:
when the first key value pair matched with the first query key is not found in the IP positioning database, generating a second query key corresponding to the IP address in the positioning request;
When a second key value pair matched with the second query key is found in the IP positioning database, determining an IP address interval represented by the value of the second key value pair, and when the IP address in the positioning request belongs to the characterized IP address interval, taking the candidate positioning position characterized by the value of the second key value pair as a matched candidate positioning position.
8. The method of claim 5, wherein the obtaining a query key based on the IP address in the location request comprises:
If the address type of the IP address in the positioning request is the second type, generating query keys of various levels corresponding to the IP address in the positioning request;
the searching for the matched key value pair based on the query key in the IP positioning database, and taking the value in the searched key value pair as the matched candidate positioning position comprises the following steps:
and when at least one level key value pair matched with the query keys of each level is found in the IP positioning database, acquiring the key value pair meeting the level condition from the at least one level key value pair, and taking the value in the key value pair meeting the level condition as a matched candidate positioning position.
9. The method of claim 1, wherein the IP address comprises a first IP address and a second IP address; the determining, based on the target address segment of the IP address and the first distribution information, second distribution information of the positioning point corresponding to the target address segment in the map grid includes:
and combining the first distribution information corresponding to the first IP address and the second IP address to obtain the second distribution information of the positioning point corresponding to the target address section in the map grid.
10. The method of claim 1, wherein the clustering the matrix lattices in the map grid based on the first distribution information to obtain clusters corresponding to the IP addresses, includes:
Clustering matrix grids in the map grid based on the first distribution information to obtain a first candidate cluster corresponding to the IP address;
when the number of the first candidate clusters is at least two, determining the number of first positioning points corresponding to the IP addresses in each first candidate cluster; determining first candidate clusters, of which the number of first positioning points in the at least two first candidate clusters meets a first preset condition, as clusters corresponding to the IP addresses;
And when the number of the first candidate cluster clusters is one, determining the first candidate cluster as the cluster corresponding to the IP address.
11. The method of claim 10, wherein clustering the matrix lattices in the map grid based on the first distribution information to obtain first candidate clusters corresponding to the IP addresses, comprises:
clustering matrix grids in the map grid based on the first distribution information to obtain a first initial cluster corresponding to the IP address;
Determining the total number of first positioning points corresponding to the IP address and the corresponding third positioning point number in each first initial cluster based on the first distribution information;
Determining a first proportion of each of the first initial clusters based on the third number of localization sites and the total number of localization sites;
and determining the first initial cluster of which the first proportion reaches a proportion threshold value as a first candidate cluster corresponding to the IP address.
12. The method of claim 1, wherein the clustering the matrix lattices in the map lattice based on the second distribution information to obtain clusters corresponding to the target address segments includes:
Clustering matrix grids in the map grid based on the second distribution information to obtain a second candidate cluster corresponding to the target address segment;
When the number of the second candidate clusters is at least two, determining the number of second locating points corresponding to the target address segment in each second candidate cluster; determining second candidate clusters, of which the number of second locating points in the at least two second candidate clusters meets a first preset condition, as clusters corresponding to the target address segment;
and when the number of the second candidate cluster clusters is one, determining the second candidate cluster as the cluster corresponding to the target address segment.
13. The method of claim 12, wherein clustering the matrix lattices in the map grid based on the second distribution information to obtain second candidate clusters corresponding to the target address segments includes:
Clustering matrix grids in the map grid based on the second distribution information to obtain a second initial cluster corresponding to the target address segment;
Determining the total number of second locating points corresponding to the target address segment and the fourth locating point number in each corresponding second initial cluster based on the second distribution information;
determining a second proportion of each of the second initial clusters based on the fourth number of anchor points and the total number of second anchor points;
and determining a second initial cluster of which the second proportion reaches a proportion threshold value as a second candidate cluster corresponding to the target address segment.
14. The method according to any one of claims 1 to 13, further comprising:
Respectively acquiring geographic addresses corresponding to the IP address and the target address segment;
Determining a first frequency of occurrence of each geographic address corresponding to the IP address and a second frequency of occurrence of each geographic address corresponding to the target address segment;
And determining the geographic address of which the first frequency meets the second preset condition as a target geographic address corresponding to the IP address, and determining the geographic address of which the second frequency meets the second preset condition as a target geographic address corresponding to the target address segment.
15. The method according to any one of claims 1 to 13, further comprising:
based on the first distribution information and the second distribution information, determining the total number of positioning points corresponding to the IP address and the target address segment respectively;
When the total number of the positioning points reaches a positioning point number threshold, acquiring the number of the objects of the target object to which the corresponding positioning points belong;
When the number of objects reaches an object number threshold, executing the step of clustering matrix lattices in the positioning grid based on the distribution information;
and deleting at least part of IP addresses and corresponding anchor point information of the target object when the total number of anchor points does not reach an anchor point number threshold or the number of objects does not reach the object number threshold.
16. An IP address-based positioning apparatus, the apparatus comprising:
The data acquisition module is used for acquiring the IP address of the target object and the position information of the locating point corresponding to the IP address;
the distribution determining module is used for determining first distribution information of positioning points corresponding to the IP address in a map grid based on the IP address and the position information; determining second distribution information of positioning points corresponding to the target address segments in a map grid based on the target address segments of the IP addresses and the first distribution information;
The grid clustering module is used for clustering matrix grids in the map grid based on the first distribution information to obtain a cluster corresponding to the IP address; clustering matrix grids in the map grid based on the second distribution information to obtain a cluster corresponding to the target address segment;
and the position determining module is used for determining the target position of each cluster as a candidate positioning position.
17. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor implements the steps of the method of any one of claims 1 to 15 when the computer program is executed.
18. A computer readable storage medium, on which a computer program is stored, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any of claims 1 to 15.
19. A computer program product comprising a computer program, characterized in that the computer program, when being executed by a processor, implements the steps of the method of any one of claims 1 to 15.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310163086.9A CN118524087A (en) | 2023-02-17 | 2023-02-17 | Positioning method and device based on IP address, computer equipment and storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310163086.9A CN118524087A (en) | 2023-02-17 | 2023-02-17 | Positioning method and device based on IP address, computer equipment and storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN118524087A true CN118524087A (en) | 2024-08-20 |
Family
ID=92276125
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310163086.9A Pending CN118524087A (en) | 2023-02-17 | 2023-02-17 | Positioning method and device based on IP address, computer equipment and storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN118524087A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119342036A (en) * | 2024-10-18 | 2025-01-21 | 山东天合网络空间安全技术研究院有限公司 | A method and system for optimizing node relationships in IP positioning |
-
2023
- 2023-02-17 CN CN202310163086.9A patent/CN118524087A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN119342036A (en) * | 2024-10-18 | 2025-01-21 | 山东天合网络空间安全技术研究院有限公司 | A method and system for optimizing node relationships in IP positioning |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110175216B (en) | Coordinate error correction method and device and computer equipment | |
CN110726418B (en) | Method, Apparatus, Device and Storage Medium for Determining Point of Interest Area | |
US20240077324A1 (en) | Identifying, Processing And Displaying Data Point Clusters | |
CN106709606B (en) | Personalized scene prediction method and device | |
CN103136371B (en) | Subdivision mark generating method and the data retrieval method of multi-source Spatial Data | |
US9730028B2 (en) | Systems and methods to identify home addresses of mobile devices | |
CN113272798B (en) | Map acquisition method, map acquisition device, computer equipment and storage medium | |
CN113342912B (en) | Geographical location area coding method, and method and device for establishing coding model | |
CN107092623B (en) | Method and device for querying a point of interest | |
KR20100068468A (en) | Method, apparatus and computer program product for performing a visual search using grid-based feature organization | |
JP2022504597A (en) | Area division method and equipment, electronic equipment and programs | |
CN113139032B (en) | Method, device, electronic device and storage medium for searching geographic location | |
CN114548811B (en) | Airport reachability detection method and device, electronic equipment and storage medium | |
CN110532437A (en) | Electronic certificate presentation method, device, computer equipment and storage medium | |
CN111782980A (en) | Mining method, device, equipment and storage medium of map interest point | |
US20140370920A1 (en) | Systems and methods for generating and employing an index associating geographic locations with geographic objects | |
CN116108120A (en) | Grid indexing method for track data, track data searching method and track data searching device | |
CN113269379B (en) | Method and device for determining attributes of resource objects, storage medium and computer equipment | |
CN108376157A (en) | Target user's querying method, system and device | |
CN113688299B (en) | Land plot selection method, device, electronic device and storage medium | |
CN113360586B (en) | Address aggregation degree query method, device, equipment and computer readable storage medium | |
CN108345607B (en) | Searching method and device | |
CN104156475B (en) | Geography information read method and device | |
CN118524087A (en) | Positioning method and device based on IP address, computer equipment and storage medium | |
Phan et al. | Collaborative recommendation of photo-taking geolocations |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication |