IP positioning prediction method for strong dynamic scene
By constructing an IP geomap through geohash filtering and data augmentation, and combining graph attention mechanism and IP spatiotemporal context graph embedding, the problem of IP positioning accuracy and reliability in highly dynamic scenarios is solved, and high-precision IP location prediction is achieved.
Patent Information
- Application Number
- CN202411256857.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2025-11-18
- Estimated Expiration
- 2044-09-09
AI Technical Summary
Existing IP positioning technologies cannot effectively cope with frequent changes in IP addresses in highly dynamic scenarios, resulting in decreased positioning accuracy and reliability, and failing to meet user privacy protection and service needs.
We employ a geohash-based IP filtering and data augmentation method to construct an IP geographic map. We then use a two-layer graph attention mechanism and global spatial graph embedding to perform location prediction, combined with IP spatiotemporal graph embedding. Finally, we utilize IP spatiotemporal context graph embedding for layer-by-layer decoding to improve prediction accuracy.
It improves the accuracy and usability of IP positioning in highly dynamic scenarios, enhances the fine description of geographical location and adaptability to dynamic changes, reduces dependence on training data, and improves the robustness and generalization ability of the model.
Smart Images

Figure CN119383222B_ABST
Abstract
Description
Technical Field
[0001] This method relates to the field of IP location, specifically a method for predicting IP location in highly dynamic scenarios. Background Technology
[0002] With the development of internet technology, location-based services (LBSs) have been widely used globally. They not only enhance the functionality of mobile and spatial computing but also improve the ease of use of services such as map navigation and advertising recommendations. However, this brings the risk of location privacy breaches, leading to various cyberattacks such as location tracking and identity theft. Under legal restrictions and increased user privacy awareness, traditional client-side location technologies (such as GPS and Wi-Fi) face challenges. In contrast, client-side IP-based location technologies can effectively provide location services without activating these sensors, reducing the collection and transmission of personal location information and effectively protecting user privacy. This has led to the widespread application of this technology in areas such as advertising recommendations, geographic content restrictions, and fraud detection.
[0003] However, with the depletion of IPv4 addresses, operators have adopted various dynamic and reuse strategies. For example, through Network Address Translation (NAT), an external IP address can be mapped to multiple internal devices, meaning that one IP address may correspond to the locations of multiple users in a short period of time. Simultaneously, the widespread adoption of mobile networks means that the physical locations of a large number of mobile IP addresses change more frequently with user movement, significantly increasing the dynamism of IP allocation. However, existing static prediction strategies have failed to effectively address the strong dynamism of the IP space, compromising the accuracy and reliability of location services because they are based on the assumption of IP space stability (i.e., IP geographic locations and ranges are generally considered to remain constant or change slowly). Therefore, the goal of this invention is to enhance the predictive capabilities of IP location technology in highly dynamic scenarios, improving its accuracy and availability. Summary of the Invention
[0004] The purpose of this invention is to provide a street-level IP positioning technology for highly dynamic scenarios in IP allocation space.
[0005] A method for IP location prediction in highly dynamic scenarios, comprising:
[0006] Based on geohash, target IPs with set mobility and scalability strengths are filtered out to obtain the spatial data of the target IPs;
[0007] The spatial data is augmented to obtain augmented spatial data for the target IP; the data augmentation is used to expand the trainable spatial data; the augmented spatial data includes the spatial data and the new trainable spatial data.
[0008] Based on geohash, the enhanced spatial data is aggregated to obtain an IP geographic map;
[0009] An IP spatial map is established using the IP geographic map; the feature vectors of the nodes in the IP spatial map are composed of the statistical features of the IP geographic map.
[0010] The IP spatial map is input into the prediction model to obtain the IP location prediction result. The prediction model is established by the following method:
[0011] Based on each graph node in the IP space graph, a space node embedding is established through a two-layer graph attention mechanism;
[0012] The global spatial graph embedding is obtained by assigning weights based on the importance of each spatial node embedded in the graph.
[0013] The global spatial graph is embedded, overlaid with positional encoding, and associated to obtain the IP spatiotemporal graph embedding.
[0014] By fusing the IP spatiotemporal graph embedding, a global IP spatiotemporal context graph embedding is obtained;
[0015] The IP spatiotemporal context graph embedding representation is decoded layer by layer to obtain the location center prediction result for the next time step.
[0016] Preferably, the spatial data of the target IP includes: a spatiotemporal family, a location set, and a spatiotemporal center location set; the location set is a member set of the spatiotemporal family; each element in the location set is a latitude and longitude point.
[0017] Preferably, the data augmentation includes: performing N random offsets on each latitude and longitude point of the location set, with a distance not exceeding ε, where 5≤N≤10 and 100≤ε≤300.
[0018] Preferably, the spatial node embedding established 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; and aggregating all features of each graph node's neighbor node set in a cumulative weighted sum manner to obtain the spatial node embedding.
[0019] Preferably, the weight allocation based on the importance of each spatial node 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 pooling to allocate the weight.
[0020] Preferably, the global spatial graph embedding overlay position encoding and association are performed, wherein the association method is: after the global spatial graph embedding overlay 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 time moment, and aggregating the IP spatiotemporal graph embedding at each time moment in a weighted summation manner.
[0022] Preferably, the prediction model uses mean squared error as the loss function.
[0023] The beneficial effects of this invention are as follows:
[0024] This invention uses geohash to filter target IPs. Geohash enables fine-grained geographic segmentation, providing detailed geographic information, thus ensuring accurate spatial data for target IPs. Furthermore, the spatial data obtained from geohash can be flexibly augmented to generate a richer trainable data space, thereby improving the robustness and generalization ability of the prediction model. Data augmentation techniques can generate data samples similar to but different from the original spatial data, increasing the diversity of the training data space, avoiding overfitting of the prediction model, and reducing dependence on the training data. Statistical features are fully considered when constructing the IP spatial map. Combining statistical features provides a more comprehensive description of the geographic location information of the target IPs, fully expressing their characteristics, thus providing rich input for the prediction model and improving its positioning accuracy. Simultaneously, statistical features reflect the spatial distribution of target IPs, helping the prediction model better understand their clustering and dispersion trends. The prediction model of this invention constructs a global spatiotemporal context graph embedding, capturing the spatial patterns and changing trends of target IPs, enabling the geolocation system to better understand and adapt to the dynamic changes in the network and geographic environment, thereby ensuring the accuracy and usability of this invention in highly dynamic spatial scenarios. Attached Figure Description
[0025] Figure 1 This is a simplified flowchart of an embodiment of the present invention.
[0026] Figure 2 This is a flowchart of an embodiment of the present invention.
[0027] Figure 3 This is a schematic diagram of the data enhancement method of the present invention. Detailed Implementation
[0028] The following is in conjunction with the appendix Figure 1 This method will be further described.
[0029] A street-level IP positioning method and system for highly dynamic scenarios includes the following steps:
[0030] S1: IP space data enhancement;
[0031] S2: IP Space Encoder;
[0032] S3: IP spatiotemporal encoder;
[0033] S4: IP Spatiotemporal Decoder.
[0034] Combined with appendix Figure 2 Each step will be explained in detail:
[0035] S1-1: IP spatial data preprocessing. Based on geohash, target IPs with defined mobility and scalability are selected to obtain their spatial data. Target IPs with strong spatial dynamics are filtered out, and the spatiotemporal family L of the target IPs at T time points is obtained, along with the set C of their spatiotemporal center locations.
[0036] S1-2: IP spatial data diversification involves data augmentation to obtain enhanced spatial data for the target IP. This data augmentation expands the trainable spatial data. The enhanced spatial data includes the existing spatial data and the new trainable spatial data. An optimized restricted Gaussian noise algorithm is used to enrich and diversify the location set L at each time step. i Generate a new set of locations
[0037] S1-3: IP spatial data structuring. Based on geohash, the enhanced spatial data is aggregated to obtain an IP geographic map. An IP geographic map based on a geohash-coded grid is constructed. This step employs a static processing strategy, i.e., by fixing the IP geographic map structure and monitoring changes in location statistical characteristics within a finite geohash grid, to capture the spatial changes of the target IP's geographic location over time.
[0038] S1-4: IP spatial data association, establishing an IP spatial map through the IP geographic map; the feature vectors of the graph nodes in the IP spatial map are composed of the statistical features of the IP geographic map. Using the location statistical features within the geohash grid as nodes, and the average distance between locations in the geohash grid as the relation metric, the graph structure data in the target IP spatial map is constructed.
[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. Graph nodes represent the IP spatial distribution at a single moment. The characteristics of nodes and their neighbors are captured through a message passing mechanism to establish IP spatial node embeddings with local characteristics.
[0040] S2-2: Spatial Attention Mechanism. Weights are assigned based on the importance of each spatial node embedded in the graph, resulting in a global spatial graph embedding. Weights are also assigned based on the relative importance of IP spatial nodes, and these local embedding representations are fused to reveal the structure and patterns of the IP space.
[0041] S3-1: The global spatial graph embedding is overlaid with position encoding and correlated to obtain the IP spatiotemporal graph embedding. The global spatial graph embeddings at various times are correlated to capture the temporal change trend and correlation pattern of the target IP.
[0042] S3-2: Integrate the IP spatiotemporal graph embedding to obtain a global IP spatiotemporal context graph embedding, thereby enhancing the model's ability to extract key information from 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 for the next time step. Two fully connected layers are used to decode the IP spatiotemporal context graph embedding representation layer by layer to predict the location center at time step T+1. This includes two variables: latitude and longitude. Mean squared error was used as a metric to measure the accuracy of the model's predictions.
[0044] As described in step 1-1, IP spatial data preprocessing is performed. First, IPs with an average daily reported geographic location frequency exceeding 10 and a geohash8 block count between 5 and 200 are filtered. These IPs are the source IPs of clients accessing LBS-type services, requiring latitude and longitude information to use the service. This latitude and longitude information is uploaded to the server after geohash8 encoding. Since one IP may correspond to multiple reported locations, IPs with 5-200 reported geohash8 blocks are filtered out. Based on the calculated average daily reported frequency and block count for all IPs, different intervals of reported frequency and block count are calculated, and a cumulative distribution is constructed. IPs with a cumulative distribution of 60% are selected, rounded down to the nearest integer. The spatial coverage of IPs at time T is calculated. Since this embodiment focuses on street-level IP positioning, IPs with an average spatial distribution range of less than 5 kilometers are selected, where T is set to one month. For these IPs, calculate the daily movement distance and range scaling ratio at T time points. Based on the criteria of strong mobility (average daily movement distance exceeding 3 km for more than 10 days) and strong scaling (scaling ratio between 0.6 and 0.3 for more than 10 days), filter to obtain n target IPs possessing both strong mobility and strong scaling. Next, obtain the spatial data of the target IPs at T historical time points. The spatiotemporal family of the target IPs is L = {L1, L2, L3…L…} T}, the set of positions L at time i i It consists of n latitude and longitude 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 of time i is... i The calculation method is L i The average of all latitudes and longitudes in the middle, i.e. This constitutes the set of spacetime center locations C = {C1, C2, C3…C…} T}
[0045] As described in steps 1-2, an optimized restricted Gaussian noise algorithm is used to enhance the position set L at each time step. i Generate a new set of locations Define an enhancement operation as "on L" i Each position l ij A random offset is implemented, with the offset direction being one of N, NE, E, SE, S, SW, W, NW, and the offset distance not exceeding ε”, to enhance data diversity. Furthermore, to enhance data richness, for each l… ijA random N-fold enhancement is performed, where N is between α and β, where α and β are the lower and upper bounds of the number of enhancements N, determined based on data quality. In this embodiment, N is set to 5-10. ε is set to 100 meters to 300 meters in this embodiment. Finally, to ensure the newly generated spatial set... With the original set L i To maintain a certain level of consistency, we set the optimization objective as: minimizing With L i The Haversine distance is such that this distance is less than ε, as shown in the formula.
[0046]
[0047] As described in steps 1-3, in conjunction with the appendix Figure 3 First, the enhanced set of IP locations at each time point will be... Convert to geohash6 encoding set geohash i X represents the encoding length, and Neighbor is geohash. i Each code in the set finds its neighboring geohash in eight directions and adds it to the geohash. i In the set. Finally, merge and deduplicate the geohash at time T. i The set, denoted as B, completes the construction of the IP geographic map, and 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 cells in geographic map B, ensuring that the number and location of graph nodes are fixed at each time step, where n equals the total number of geohash cells in geographic map B. A single graph node V ij The feature vector is composed of a set of geographic locations The statistical characteristics constitute, among which There are N+1 elements. As shown in Table 1. The set of positions at time i A subset, corresponding to the geohash unit geohash in geographic map B. j The set of locations within the graph. Further, to capture geographic proximity, the set of graph nodes V is calculated. i The subset of positions of two graph nodes i and k and The Haversine distance between the center points is denoted as D. jk If D jkIf the value is less than the set threshold δ, then an edge E is considered to exist between these two nodes. jk and distance D jk Let the property A of the edge be denoted as jk All edges form a set E i The edge attributes constitute set A i Their quantities are all m, and finally, the IP space graph at time i is denoted as G. i (V,E,A).
[0050]
[0051]
[0052] Table 1
[0053] As described in step 2-1, IP space coding employs a two-layer graph attention mechanism. This mechanism introduces a dynamic attention mechanism, allowing each node to dynamically adjust its attention weights based on the differences in features between itself and its neighbors, thereby accurately capturing the structural features and patterns of graph nodes. Specifically, given an IP space graph G... i In the set (V, E, A), V is the set of nodes, E is the set of edges, and A is the set of edge attributes. For any node V in the set V... p Node V p Update to new node V p The steps are as follows: First, we calculate V. p Its neighbor set N(V) p Any node V in ) q Local spatial attention coefficients between ∝ pq As shown in the following formula
[0054]
[0055] Where A p,q It is V p With neighbor node V q The edge properties between them, V p V q A p,q Through the σ activation function and the learnable weight matrix θ s θ t θ r A nonlinear transformation is performed, and 'a' is a learnable weight vector. These are normalized using a softmax method to obtain the local spatial dynamic attention coefficients ∝. pq This determines the importance of neighboring node V in the feature aggregation process. Finally, using the aforementioned attention coefficients, V... p Aggregate the neighbor node set N(V) by cumulative weighted sum. pAll features are updated to obtain V. p The formula is shown below.
[0056] V p ′=∝ pp θ s V p +∑ q∈N(p) ∝ pq θ t V q
[0057] As described in step 2-2, the IP space attention mechanism first involves any node V... p The global spatial attention coefficient of ′ is ∝ p As shown in the formula,
[0058]
[0059] V′ is the set of all spatial embeddings, V′ k This means that all spatial nodes of V′ need to be embedded, ∝ p To calculate the attention coefficient of node p, used to express V′ p Importance in the global graph. Where V′ p Using a trainable vector a T Perform a linear transformation, then use softmax normalization to obtain the global spatial attention coefficients ∝. p Thus, V′ is determined. p Given the importance of the graph, we finally use global weighted sum pooling of the graph to obtain the spatial node embedding (SGE), which allows us to capture global patterns and relationships in the IP space. The formula is shown below.
[0060]
[0061] As described in step 3-1, IP spatiotemporal encoding is performed, and spatial node embeddings at various time points are associated to capture the temporal trends and association patterns of IP space. Subsequently, Temporal Spatial Attention evaluates the relative importance of each time point and merges the spatiotemporal embeddings of multiple time points into a more expressive spatiotemporal context embedding to enhance the model's ability to extract key information from spatiotemporal data and understand spatiotemporal phenomena.
[0062] The Temporal Spatial Encoder employs a two-layer Transformer to handle the temporal relationships of spatial node embeddings. It effectively captures the dynamic relationships of spatial embeddings across multiple time steps through positional encoding and self-attention mechanisms, and explores various association types using a multi-head attention mechanism. Specifically, for any spatial node embedding SGE at time i... iPositional encoding is introduced to impart temporal characteristics, as shown in the following formula.
[0063]
[0064] SGE i ′=SGE i +PositionalEncoding(i) i <T
[0065] The computation 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, forming a spatial node embedding (SGE) with temporal features. i Subsequently, in order to fully integrate spatial information, we used a concat operation to combine the SGE data from T time points. i The CSGEs are then merged into a single connected space graph embedding. Self-attention processing is then applied to the CSGEs using three trainable weight matrices W. Q W K W V A linear transformation is performed to generate a query (Q), a key (K), and a value (V). Then, the spatial embeddings at different times are associated by multiplying Q and K, and finally divided by... Scaling is performed to stabilize the gradient calculation, followed by softmax normalization to obtain the self-attention weight matrix distribution, and then multiplication by V to complete the self-attention calculation, so as to efficiently capture the temporal changes and association patterns in the IP space.
[0066] Q = W Q (CSGE), K = W K (CSGE), V = W V (CSGE)
[0067]
[0068] To further enhance the model's expressive power, we introduce a multi-head attention mechanism, merging the results (heads) of h self-attention calculations and applying them through a weight matrix W. o A linear transformation is performed to obtain our IP spatiotemporal graph embedding 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 Wo
[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 times, thereby focusing on the spatiotemporal features of IP at salient moments and using this information to construct a comprehensive 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 Using a trainable vector a T After performing linear transformation and softmax normalization, the spatiotemporal attention weight coefficients are obtained. i The calculation method is shown in the following formula.
[0072]
[0073] Finally, we aggregate the TSGE values at T time points using a weighted summation method. i The global IP spatiotemporal context graph embedding STCGE is obtained, 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. This includes two variables: latitude and longitude. In the design of the loss function, the mean squared error (MSE) is used as a metric to measure the model's predictive accuracy. Specifically, the loss function calculates the true CT+1. T+1 (Lat,Lng) and the center of the position predicted by the model at time T+1. The mean squared error between the two values. This design encourages the model to continuously optimize its predictions during training to achieve smaller errors and higher prediction accuracy. The formula is shown below.
[0076]
[0077] This embodiment employs four IP geolocation performance evaluation metrics. First, the median measures the central tendency of a set of values, specifically the number in the middle when the values are arranged in ascending order; it exhibits good resistance to outliers. Second, the mean absolute error (MAE) calculates the average of the absolute differences between all predicted and actual values, providing an average level of prediction error. Third, the root mean square error (RMSE) calculates the square root of the average of the squared differences between observed and true values; compared to MAE, RMSE places greater emphasis on larger errors and is therefore more sensitive to outliers. Fourth, the coverage rate (Cover_Rate(5km)) is the percentage of IPs with a location result within a 5km radius, measuring the model's usability at street-level accuracy. The evaluation metrics in 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 IP location prediction in highly dynamic scenarios, comprising: Based on geohash, target IPs with set mobility and scalability strengths are filtered out to obtain the spatial data of the target IPs; The spatial data is augmented to obtain enhanced spatial data for the target IP; the data augmentation is used to expand the trainable spatial data. The enhanced spatial data includes the spatial data and the expanded trainable spatial data; Based on geohash, the enhanced spatial data is aggregated to obtain an IP geographic map; An IP spatial map is established using the IP geographic map; the feature vectors of the nodes in the IP spatial map are composed of the statistical features of the IP geographic map. The IP spatial map is input into the prediction model to obtain the IP location prediction result. The prediction model is established by the following method: Based on each graph node in the IP space graph, a space node embedding is established through a two-layer graph attention mechanism; The global spatial graph embedding is obtained by assigning weights based on the importance of each spatial node embedded in the graph. The global spatial graph is embedded, overlaid with positional encoding, and associated to obtain the IP spatiotemporal graph embedding. By fusing the IP spatiotemporal graph embedding, a global IP spatiotemporal context graph embedding is obtained; The IP spatiotemporal context graph embedding representation is decoded layer by layer to obtain the location center prediction result for the next time step.
2. The method according to claim 1, characterized in that, The spatial data of the target IP includes: The spacetime family, the location set, and the spacetime center location set; the location set is the member set of the spacetime family; each element in the location set is a latitude and longitude point.
3. The method according to claim 2, characterized in that, The data enhancements include: For each latitude and longitude point in the location set, N random offsets with a distance not exceeding ε are performed, where 5≤N≤10 and 100≤ε≤300.
4. The method according to claim 1, characterized in that, The method of establishing 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 its set of neighboring nodes; Each graph node is obtained by aggregating all features of its neighboring node sets in a cumulative weighted sum manner to obtain a spatial node embedding.
5. The method according to claim 2, characterized in that, The weighting based on the importance of each spatial node embedded in the graph includes: The global spatial attention coefficient of the spatial node embedding is calculated as the importance of the spatial node embedding, and the weights are allocated using global weighted sum pooling.
6. The method according to claim 1, characterized in that, The global spatial map is embedded with overlay position codes and associated, wherein the association method is as follows: After the global spatial graph is embedded and overlaid, 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 fusion of the IP spatiotemporal graph embedding includes: The spatiotemporal attention weight coefficients of the IP spatiotemporal graph embedding at each time step are calculated, and the IP spatiotemporal graph embeddings at each time step are aggregated by weighted summation.
8. The method according to claim 1, characterized in that, The prediction model uses mean squared error as the loss function.
9. An electronic device comprising a memory and a processor, the memory storing a computer program configured to be executed by the processor, the computer program including instructions for performing the method of any one of claims 1 to 8.
10. A storage medium storing a computer program, which, when executed by a computer, implements the method of any one of claims 1 to 8.
Citation Information
Patent Citations
Spatial data indexing method integrating GeoHash and Quadtree
CN111723096A
Street-level IP address positioning method based on graph neural network
CN115242868A