IP positioning prediction method used in strong dynamic scene
Through the method of screening and data enhancement through Geohash, combined with the two -layer map attention mechanism and time and space attention mechanism, a prediction model for IP positioning is constructed, which solves the accuracy and reliability of existing technology in strong dynamic IP space. The problem has achieved more efficient IP positioning predictions.
Patent Information
- Application Number
- CN202411256857.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-09-09
AI Technical Summary
The existing static prediction strategies fail to effectively cope with the strong dynamics of the IP space, which damages the accuracy and reliability of positioning.
Based on Geohash screening target IP, data enhancement is performed, IP space diagrams are established, and two layers of attention mechanisms and time and space attention mechanisms are used to build prediction models to perform IP positioning prediction.
Improving the prediction ability of IP positioning technology in a strong scene, improving the accuracy and availability of positioning, and ensuring the reliability of positioning in dynamic changes in the network and geographical environment.
Smart Images

Figure CN119383222A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of IP location prediction, and specifically belongs to an IP location prediction method for highly dynamic scenes. Background Art
[0002] With the development of Internet technology, location-based services (LBSs) have been widely used around the world. They not only enhance the functionality of mobile and spatial computing, but also improve the convenience of using services such as map navigation and advertising recommendations. However, this brings the risk of location privacy leakage, leading to various network attacks such as location tracking and identity theft. Under the circumstances of legal restrictions and increased user privacy awareness, traditional client-dependent positioning technologies (such as GPS and Wi-Fi) face challenges. In contrast, client-independent IP positioning technology can effectively provide positioning services without activating these sensors, and reduces the collection and transmission of personal location information, effectively protecting user privacy, which makes this technology widely used in areas such as advertising recommendation, geographic content restriction and fraud detection.
[0003] However, with the exhaustion of IPv4 addresses, operators adopt a variety of dynamic and reuse strategies. For example, through network address translation technology (NAT), an external IP address can be mapped to multiple internal devices, so that one IP address may correspond to the location of multiple users in a short time. At the same time, the widespread popularity of mobile networks has led to the physical location of a large number of mobile IP addresses changing more frequently as users move, which significantly increases the dynamic nature of IP allocation. However, the existing static prediction strategy fails to effectively cope with the strong dynamics of IP space, which impairs the accuracy and reliability of positioning because it is based on the assumption of IP space stability (i.e., IP geographical location and range are generally considered to remain unchanged or change slowly). Based on this, the goal of the present invention is to enhance the prediction ability of IP positioning technology in strong dynamic scenarios and improve its accuracy and availability. Summary of the invention
[0004] The purpose of the present invention is to provide a street-level IP positioning technology for use in a highly dynamic scenario of IP allocation space.
[0005] An IP location prediction method for a highly dynamic scene, comprising:
[0006] Filter out target IPs with set mobility and scalability based on geohash, and obtain spatial data of target IPs;
[0007] Performing data enhancement on the spatial data to obtain enhanced spatial data of the target IP; the data enhancement is used to expand the trainable spatial data; the enhanced spatial data includes the spatial data and the new trainable spatial data;
[0008] Performing location aggregation on the enhanced spatial data based on geohash to obtain an IP geographic map;
[0009] An IP space graph is established through the IP geographic graph; the feature vectors of graph nodes in the IP space graph are composed of statistical features of the IP geographic graph;
[0010] The IP space graph is input into a prediction model to obtain an IP location prediction result, and the prediction model is established by the following method:
[0011] Based on each graph node in the IP space graph, a spatial node embedding is established through a two-layer graph attention mechanism;
[0012] Assigning weights according to the importance of each of the spatial nodes embedded in the graph to obtain a global spatial graph embedding;
[0013] The global spatial graph is embedded with superimposed position codes and associated to obtain IP spatiotemporal graph embedding;
[0014] The IP spatiotemporal graph embedding is integrated to obtain a global IP spatiotemporal context graph embedding;
[0015] The IP spatiotemporal context graph embedding representation is decoded layer by layer to obtain a position center prediction result at the next moment.
[0016] Preferably, the spatial data of the target IP includes: a spatiotemporal cluster, a location set and a spatiotemporal center location set; the location set is a member set of the spatiotemporal cluster; and each element in the location set is a latitude and longitude point.
[0017] Preferably, the data enhancement comprises: performing N random offsets with a distance not exceeding ε on each longitude and latitude point of the location set, where 5≤N≤10, 100≤ε≤300.
[0018] Preferably, the establishment of spatial node embedding through a two-layer graph attention mechanism includes: calculating the local spatial attention coefficient between each graph node and any node in its neighbor node set; each graph node aggregating all features of its neighbor node set in a cumulative weighted sum manner to obtain the spatial node embedding.
[0019] Preferably, the allocating weights according to the importance of each of the spatial nodes embedded in the graph includes: calculating the global spatial attention coefficient of the spatial node embedding as the importance of the spatial node embedding, and using global weighted sum pooling to allocate the weights.
[0020] Preferably, the global spatial graph is embedded in the superimposed position code and associated, wherein the associating method is: after the global spatial graph is embedded in the superimposed position, the association is performed through a self-attention mechanism and a multi-head attention mechanism.
[0021] Preferably, the fusion of the IP spatiotemporal graph embedding includes: calculating the spatiotemporal attention weight coefficients of the IP spatiotemporal graph embedding at each moment, and aggregating the IP spatiotemporal graph embedding at each moment in a weighted summation manner.
[0022] Preferably, the prediction model uses mean square error as the loss function.
[0023] The beneficial effects of the present invention are as follows:
[0024] The present invention screens out the target IP based on geohash, which realizes the fine division of geographical location and provides fine-grained geographical information, so the spatial data of the target IP is accurate. Moreover, the spatial data obtained based on geohash can be flexibly enhanced to generate a richer trainable data space, thereby improving the robustness and generalization ability of the prediction model. Data enhancement technology can generate data samples similar to but different from the original spatial data, thereby improving the diversity of the training data space, avoiding overfitting of the prediction model, and reducing the dependence on training data. When establishing the IP space map, statistical features are fully considered. The geographical location information of the target IP can be described more comprehensively in combination with statistical features, and the characteristics of the target IP are fully expressed, thereby providing rich input for the prediction model and improving the positioning accuracy of the model. At the same time, the distribution of the target IP in space can be reflected in combination with statistical features, helping the prediction model to better understand the gathering and dispersion trend and dispersion degree of the target IP. In the prediction model of the present invention, a global spatiotemporal context graph embedding is constructed to capture the spatial pattern and change trend of the target IP, so that the geographic positioning system can better understand and adapt to the dynamic changes of the network and geographical environment, thereby ensuring the accuracy and availability of the present invention in strong dynamic spatial scenes. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 is a simplified flow chart of an embodiment of the present invention.
[0026] Figure 2 is a flow chart of an embodiment of the present invention.
[0027] Figure 3 It is a schematic diagram of data enhancement of the present invention. DETAILED DESCRIPTION
[0028] The following is combined with Figure 1 This method is further described.
[0029] A street-level IP positioning method and system for highly dynamic scenes, comprising the following steps:
[0030] S1: IP space data enhancement;
[0031] S2: IP space encoder;
[0032] S3: IP space-time encoder;
[0033] S4: IP space-time decoder.
[0034] Combined with Figure 2 , each step is explained in detail:
[0035] S1-1: IP spatial data preprocessing, based on geohash, filter out target IPs with set mobility and scalability, and obtain the spatial data of the target IPs. Filter out target IPs with strong spatial dynamics, obtain the spatiotemporal cluster L of the target IP within T moments, and calculate the spatiotemporal center location set C.
[0036] S1-2: IP spatial data diversification, data enhancement is performed on the spatial data to obtain enhanced spatial data of the target IP, the data enhancement is used to expand the trainable spatial data; the enhanced spatial data includes the spatial data and the new trainable spatial data. Through an optimized restricted Gaussian noise algorithm, the location set L at each moment is enriched and diversified i , generate a new set of locations
[0037] S1-3: Structuring IP spatial data, performing location aggregation on the enhanced spatial data based on geohash to obtain an IP geographic map. Construct an IP geographic map based on a geohash coding grid. This step adopts a static processing strategy, that is, by fixing the IP geographic map structure and monitoring the changes in location statistical characteristics within a limited geohash grid, to capture the spatial changes of the target IP geographic location over time.
[0038] S1-4: IP space data association, establishing an IP space graph through the IP geographic graph; the feature vector of the graph node in the IP space graph is composed of the statistical characteristics of the IP geographic graph. The location statistical characteristics in the geohash grid are used as nodes, and the average distance between the locations of the geohash grids is used as the relationship metric to construct the graph structure data in the target IP space graph.
[0039] S2-1: Spatial graph encoding. Based on each graph node in the IP spatial graph, a spatial node embedding is established through a two-layer graph attention mechanism. The graph node represents the IP spatial distribution at a single moment, and the characteristics of the node and its neighbors are captured through a message passing mechanism to establish an IP spatial node embedding with local characteristics.
[0040] S2-2: Spatial attention mechanism. Weights are assigned according to the importance of each spatial node embedded in the graph to obtain a global spatial graph embedding. Weights are assigned according to the relative importance of IP space nodes, and these local embedding representations are fused to reveal the structure and pattern of the IP space.
[0041] S3-1: The global spatial graph embedding is superimposed with the position coding and associated to obtain the IP spatiotemporal graph embedding. The global spatial graph embedding at each moment is associated to capture the temporal change trend and association pattern of the target IP.
[0042] S3-2: The IP spatiotemporal graph embedding is integrated to obtain a global IP spatiotemporal context graph embedding to enhance the model's ability to extract key information of spatiotemporal data and understand spatiotemporal phenomena.
[0043] S4-1: Decode the IP spatiotemporal context graph embedding representation layer by layer to obtain the location center prediction result at the next moment. Use two fully connected layers to decode the IP spatiotemporal context graph embedding representation layer by layer to predict the location center at the T+1th moment. It includes two variables: latitude and longitude. The mean square error is used as an indicator to measure the accuracy of model prediction.
[0044] As described in step 1-1, IP space data is preprocessed. First, screen IPs whose daily average number of reported geographic locations exceeds 10 and whose number of geohash8 blocks is between 5 and 200. The IPs are client source IPs that access LBS type services. They need to report longitude and latitude information to use the service. The longitude and latitude information is uploaded to the server through geohash8 encoding. One IP will correspond to multiple reported locations, so filter out IPs with 5-200 geohash8 blocks reported by a single IP. Calculate IPs with different reporting times and block numbers based on the average daily reporting times and block numbers of all IPs, construct a cumulative distribution, and screen the reporting times and block numbers when the cumulative distribution is 60% and round them up. Calculate the spatial coverage of IPs at T moments. Since this embodiment focuses on street-level IP positioning, IPs with an average spatial distribution range of less than 5 kilometers are screened out, where T is set to one month. The daily moving distance and range expansion ratio of these IPs are calculated at T moments, and they are screened based on strong mobility (average daily moving distance of more than 3 kilometers, for more than 10 days) and strong scalability (scalability between 0.6 and 0.3, for more than 10 days) to obtain n target IPs with strong mobility and scalability. Then, the spatial data of the target IPs at T historical moments are obtained. The spatiotemporal cluster of the target IPs is L = {L1, L2, L3…L T}, the position set L at time i i It consists of n longitude and latitude points, denoted as L i = {l i1 (lat,lng),l i2 (lat,lng),l i3 (lat,lng)…l in (lat,lng)}, i∈[1,T], the position center C at time i i The calculation method is L i The average value of all latitudes and longitudes in It constitutes the space-time center location set C = {C1, C2, C3…C T}.
[0045] As described in step 1-2, an optimized restricted Gaussian noise algorithm is used to enhance the position set L at each moment i , generate a new set of locations Define an enhanced operation as "to L i Each position within ij A random offset is implemented, and the offset direction is one of N, NE, E, SE, S, SW, W, NW, and the offset distance does not exceed ε", to enhance the diversity of the data. Furthermore, to enhance the richness of the data, for each l ijPerform random N enhancements, where N is between α and β. α and β are the lower and upper bounds of the number N, which are determined according to data quality. In this embodiment, it is set to 5-10, and ε is set to 100 meters to 300 meters in the embodiment. Finally, to ensure that the newly generated space set With the original set L i Keeping some consistency, we set the optimization goal: minimize With L i Haversine distance, ensuring that this distance is less than ε, this process is shown in the formula.
[0046]
[0047] Follow steps 1-3 and combine with Figure 3 First, the enhanced IP location set at each moment Convert to geohash6 encoding set geohash i , X represents the encoding length, and Neighbor is the geohash i Each code in the set finds the neighbor geohash in the surrounding 8 directions and adds it to the geohash i Finally, merge and remove the geohash of T moments i Set together to complete the construction of the IP geographic map, denoted as B. This process is shown in the formula.
[0048]
[0049] As described in steps 1-4, for any given time i, the graph node set V i Defined by all geohash units in the geographic graph B, to ensure that the number n and position of graph nodes are fixed at each time, where n is equal to the total number of geohash units contained in the geographic graph B. Single graph node V ij The feature vector of The statistical characteristics of There are N+1 elements in . As shown in Table 1, is the position set at the i-th moment A subset of , corresponding to the geohash unit geohash in geographic map B j Furthermore, to capture the proximity of geographic space, the graph node set V is calculated. i The position subset of two graph nodes i and k in and The Haversine distance between the center points is denoted as D jk , if D jkIf it is less than the set threshold δ, it is considered that there is an edge E between the two nodes. jk , and the distance D jk Let it be the attribute A of the edge jk , all edges form a set E i , the edge attributes constitute a set A i , whose number is m. Finally, the IP space graph at the i-th moment is recorded as G i (V,E,A).
[0050]
[0051]
[0052] Table 1
[0053] As described in step 2-1, IP space encoding uses a two-layer graph attention mechanism. This mechanism introduces a dynamic attention mechanism so that each node can dynamically adjust the attention weight according to the feature differences between itself and its neighbors, thereby accurately capturing the structural features and patterns of graph nodes. Specifically, given an IP space graph G i (V, E, A), where V is the node set, E is the edge set, and A is the edge attribute set. For any node V in the node set V p , node V p Update to new node V p The steps of ′ are as follows. First, we calculate V p Its neighbor node set N(V p ) any node V q The local spatial attention coefficient between pq , as shown in the following formula
[0054]
[0055] Among them A p,q Yes V p With neighboring node V q The edge attributes between p 、V q , A p,q Through the activation function σ and the learnable weight matrix θ s ,θ t ,θ r Perform nonlinear transformation, and a is a learnable weight vector. They are normalized by a softmax to obtain the local spatial dynamic attention coefficient ∝ pq , thereby determining the importance of neighbor node V in the feature aggregation process. Finally, using the above attention coefficient, V p Aggregate the neighbor node set N(V p) all features, update to get V p ′, the formula is as follows
[0056] V p ′=∝ pp θ s V p +∑ q∈N(p) ∝ pq θ t V q
[0057] According to step 2-2, IP spatial attention mechanism, first any node V p ′’s global spatial attention coefficient ∝ p As shown in the formula,
[0058]
[0059] V′ is the set of all spatial embeddings, V′ k represents the need to obtain all V′ spatial node embeddings, ∝ p To calculate the attention coefficient of node p, it is used to express V′ p The importance of V′ in the global graph. p Through a trainable vector a T Perform a linear transformation and then use softmax normalization to get the global spatial attention coefficient ∝ p , thus determining V′ p The importance of the graph is finally obtained by using the global weighted sum pooling of the graph to obtain the spatial node embedding SGE, which enables us to capture the global patterns and relationships in the IP space. The formula is shown below.
[0060]
[0061] As described in step 3-1, IP spatiotemporal encoding associates the spatial node embeddings of each moment to capture the temporal change trend and correlation pattern of IP space. Subsequently, Temporal Spatial Attention evaluates the relative importance of each moment and fuses the spatiotemporal embeddings of multiple moments into a more expressive spatiotemporal context embedding to enhance the model's ability to extract key information of spatiotemporal data and understand spatiotemporal phenomena.
[0062] Temporal Spatial Encoder uses a two-layer Transformer to process the temporal relationship of spatial node embeddings, effectively captures the dynamic relationship of spatial embeddings at multiple moments through position encoding and self-attention mechanism, and explores multiple types of associations through multi-head attention mechanism. Specifically, for any spatial node embedding SGE at any moment i iPositional encoding is introduced to give it time characteristics, as shown in the following formula:
[0063]
[0064] SGE i ′=SGE i +PositionalEncoding(i)i <T
[0065] The calculation of PositionalEncoding(i) takes into account the parity of the feature dimension index k, and assigns different temporal codes to each dimension through sine or cosine functions to form a spatial node embedding SGE with temporal features. i ′. Then, in order to fully integrate the spatial information, we use the concat operation to combine the SGE i ′ is merged into a connected space graph embedding CSGE. Then CSGE is processed by self-attention, through three trainable weight matrices W Q , W K , W V A linear transformation is performed to generate queries (Q), keys (K), and values (V). Then, Q and K are multiplied to associate spatial embeddings at different times, and then divided by √d for scaling to stabilize the calculated gradient. Then, the self-attention weight matrix distribution is obtained by softmax normalization, and then multiplied by V to complete the self-attention calculation to efficiently capture the temporal changes and association patterns of the IP space.
[0066] Q=W Q (CSGE), K = W K (CSGE), V = W V (CSGE)
[0067]
[0068] To further enhance the expressiveness of the model, we introduce a multi-head attention mechanism to merge the h self-attention calculation results (heads) and pass them through the weight matrix W o Perform a linear transformation and get our IP spatiotemporal graph embedded in TSGE, as shown in the following formula.
[0069] head j =Self_Attention(Q j ,K j ,V j )
[0070] TSGE=Concat(head1,head2…head h )W o
[0071] As described in step 3-2, the spatiotemporal attention mechanism aims to dynamically assign weights to the IP spatiotemporal graph embedding TSGE at different moments, so as to focus on the IP spatiotemporal features at significant moments, and use this information to construct a global IP spatiotemporal context embedding that fully reflects the evolution and interaction of the IP space over time. Specifically, the spatiotemporal embedding at each moment represents the TSGE i Through a trainable vector a T After linear transformation and softmax normalization, the spatiotemporal attention weight coefficient ∝ i , and its calculation method is shown in the following formula.
[0072]
[0073] Finally, we aggregate the TSGE of T moments by weighted summation i , the global IP spatiotemporal context graph is embedded into STCGE, as shown in the following formula.
[0074]
[0075] As described in step 4-1, the spatiotemporal decoder uses two fully connected layers to decode the IP spatiotemporal context graph embedding STCGE layer by layer to predict the location center at time T+1 The loss function is designed to measure the prediction accuracy of the model. Specifically, the loss function calculates the actual C T+1 (Lat, Lng) and the position center at the T+1th moment predicted by the model This design encourages the model to continuously optimize its prediction results during the training process to achieve smaller errors and higher prediction accuracy. The formula is shown below.
[0076]
[0077] Four IP geolocation performance evaluation indicators are used in this embodiment. First, the median (MEDIAN) measures the central tendency of a set of values, that is, the number in the middle after the values are arranged in order, which has good resistance to outliers. Secondly, the mean absolute error (MAE) calculates the average value of the absolute difference between all predicted values and actual values, providing an average level of prediction error. Third, the root mean square error (RMSE) takes the square root of the average value of the square of the difference between the observed value and the true value. Compared with MAE, RMSE emphasizes the weight of larger errors and is therefore more sensitive to outliers. Fourth, the coverage rate (Cover_Rate(5km)) under 5km, that is, the proportion of IPs in the positioning result within 5km, measures the availability of the model at street-level accuracy. The evaluation indicators of this embodiment are as follows: RMSE, MAE, Median and Cover_Rate(5km) reach 6.165008km, 3.389291km, 2.253356km, and 0.89 respectively.
Claims
1. A method for predicting IP location in a highly dynamic scenario, comprising: Filter out target IPs with set mobility and scalability based on geohash, and obtain spatial data of target IPs; Performing data enhancement on the spatial data to obtain enhanced spatial data of the target IP; the data enhancement is used to expand the trainable spatial data; The enhanced spatial data includes the spatial data and the new trainable spatial data; Performing location aggregation on the enhanced spatial data based on geohash to obtain an IP geographic map; An IP space graph is established through the IP geographic graph; the feature vectors of graph nodes in the IP space graph are composed of statistical features of the IP geographic graph; The IP space graph is input into a prediction model to obtain an IP location prediction result, and the prediction model is established by the following method: Based on each graph node in the IP space graph, a spatial node embedding is established through a two-layer graph attention mechanism; Assigning weights according to the importance of each of the spatial nodes embedded in the graph to obtain a global spatial graph embedding; The global spatial graph is embedded with superimposed position codes and associated to obtain IP spatiotemporal graph embedding; The IP spatiotemporal graph embedding is integrated to obtain a global IP spatiotemporal context graph embedding; The IP spatiotemporal context graph embedding representation is decoded layer by layer to obtain a position center prediction result at the next moment.
2. The method according to claim 1, characterized in that The spatial data of the target IP includes: A space-time set family, a position set and a space-time center position set; the position set is a member set of the space-time set family; each element in the position set is a longitude and latitude point.
3. The method according to claim 2, characterized in that The data enhancement includes: For each longitude and latitude point of the position set, N random shifts with a distance not exceeding ε are performed, wherein 5≤N≤10, 100≤ε≤300.
4. The method according to claim 1, characterized in that: The establishment of spatial node embedding through a two-layer graph attention mechanism includes: Calculate the local spatial attention coefficient between each graph node and any node in the set of neighboring nodes; Each graph node aggregates all features of its neighbor node set in a cumulative weighted sum manner to obtain a spatial node embedding.
5. The method according to claim 2, characterized in that: The assigning of weights according to the importance of each spatial node embedded in the graph comprises: The global spatial attention coefficient of the spatial node embedding is calculated as the importance of the spatial node embedding, and the global weighted sum pooling is used to allocate the weight.
6. The method according to claim 1, characterized in that The global spatial map is embedded with the superimposed position code and associated, wherein the method of the association is: After the global spatial graph is embedded in the superimposed position, the association is performed through a self-attention mechanism and a multi-head attention mechanism.
7. The method according to claim 1, characterized in that The fusing of the IP spatiotemporal graph embedding comprises: The spatiotemporal attention weight coefficient of the IP spatiotemporal graph embedding at each moment is calculated, and the IP spatiotemporal graph embedding at each moment is aggregated in a weighted summation manner.
8. The method according to claim 1, characterized in that The prediction model uses mean square error as the loss function.
9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, the computer program is configured to be executed by the processor, and the computer program comprises instructions for executing the method according to any one of claims 1 to 8.
10. A storage medium storing a computer program, wherein when the computer program is executed by a computer, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Patent Citations
IP address positioning method and apparatus, electronic device, and storage medium
CN108011987A
Spatial data indexing method integrating GeoHash and Quadtree
CN111723096A
Street-level IP address positioning method based on graph neural network
CN115242868A
Method of acquiring route hotspot of traffic road and device
WO2017107800A1