Geolocation query method and apparatus, electronic device, and storage medium

By constructing a mapping table and completing and sorting the IP address ranges, the problems of low efficiency and high cost of existing IPv6 geolocation query methods are solved, and autonomous and rapid IP address geolocation is achieved.

CN118474070BActive Publication Date: 2026-02-03PENG CHENG LAB
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202410389777.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-04-01
Publication Date
2026-02-03
Estimated Expiration
2044-04-01

AI Technical Summary

Technical Problem

Existing IPv6-based geolocation query methods rely on external network services or commercial APIs, resulting in low query efficiency, high costs, and limitations, failing to meet the needs of large-scale users.

Method used

A mapping table is constructed. By completing and sorting the endpoint IP addresses of the IP address range, a first IP address range sequence is formed. The target range is updated using the IP address to be queried until there are no endpoint IP addresses. The associated IP address range is quickly located and the geographical location is output.

Benefits of technology

It enables efficient and convenient large-scale IP data geolocation queries without relying on external services, reducing query costs and improving query efficiency and convenience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118474070B_ABST
    Figure CN118474070B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a geographic position query method and device, electronic equipment and storage medium, and belong to the technical field of communication. The method comprises: obtaining a mapping relationship table; performing IP address completion and sorting on the endpoint IP address of each IP address interval to obtain a first IP address interval sequence; obtaining a to-be-queried IP address; obtaining a middle IP address in a target interval, the middle IP address divides the target interval into a sub-interval, updating the target interval with the sub-interval in which the to-be-queried IP address falls, and returning the step of obtaining the middle IP address in the target interval until the target interval does not contain the endpoint IP address of the IP address interval; in the first IP address interval sequence, determining an associated IP address interval of the target interval, and taking the geographic position corresponding to the associated IP address interval in the mapping relationship table as a queried geographic position. The embodiments of the present application can improve the efficiency and convenience of IP address searching for a corresponding geographic position, and reduce the query cost.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of communication, and in particular to a geographic location query method and device, an electronic device and a storage medium. BACKGROUND

[0002] An IP address is a kind of "identity card" obtained according to each computer network connection point, and querying an IP (Internet Protocol) address can help people know the location of the computer. Among them, an IPv6 address is a kind of IP address. Current geographic location lookup based on IPv6 mainly relies on two forms: one is through online services provided by some websites, and the other is to use commercial charging APIs (Application Programming Interfaces). Although these two ways can meet the basic needs of users to a certain extent, they both have some obvious limitations and problems.

[0003] For the first way, that is, relying on the services provided by the website, users usually need to access these servers through the network to obtain the geographic location information of the IPv6 address. However, this way is highly dependent on the external network environment, and once the network condition is not good or the server fails, the user may not be able to obtain accurate or timely data. In addition, since these services are usually for a large number of users, they often limit the frequency of personal use to prevent server overload. This is undoubtedly a great challenge for users who need to perform large-scale IP data geographic location queries. They may need to process data in batches or wait for a long time to obtain the required results, which greatly reduces the efficiency and practicability of the query.

[0004] On the other hand, although commercial charging APIs can usually provide higher quality data and services, their use cost is usually high. For many small projects or users with limited budgets, these fees can be a heavy burden. In addition, the use of commercial APIs is often subject to some strict terms and conditions. For example, the API may limit the user's query frequency, data volume or data usage mode, etc. These restrictions not only may affect the user's business needs and expansion plans, but also may reduce the flexibility and scalability of the application. SUMMARY

[0005] The main purpose of the embodiments of the present application is to provide a geographic location query method and device, an electronic device and a storage medium, which aims to improve the efficiency and convenience of IP address lookup corresponding to the geographic location and reduce the query cost.

[0006] To achieve the above purpose, a first aspect of the embodiments of the present application provides a geographic location query method, which comprises:

[0007] obtaining a mapping relationship table, wherein each geographical position in the mapping relationship table is mapped to an IP address interval, and the IP address interval includes a plurality of continuous IP addresses;

[0008] completing IP addresses of endpoints of each of the IP address intervals, sorting the completed IP address intervals to obtain a first IP address interval sequence, taking a first IP address of the first IP address interval sequence as a first IP address, taking a tail IP address of the first IP address interval sequence as a second IP address, and taking an IP address interval between the first IP address and the second IP address as a target interval;

[0009] obtaining an IP address to be queried;

[0010] obtaining a middle IP address in the target interval, dividing the target interval into a sub-interval by the middle IP address, updating the first IP address by a first IP address of the sub-interval in which the IP address to be queried falls, updating the second IP address by a tail IP address of the sub-interval in which the IP address to be queried falls, updating the target interval by the sub-interval in which the IP address to be queried falls, and returning the step of obtaining the middle IP address in the target interval until the target interval does not contain the endpoint IP addresses of the IP address intervals;

[0011] determining an associated IP address interval of the target interval in the first IP address interval sequence, and taking a geographical position corresponding to the associated IP address interval in the mapping relationship table as a queried geographical position.

[0012] In some embodiments, the step of determining the associated IP address interval of the target interval in the first IP address interval sequence includes:

[0013] determining a maximum IP address interval in which a first IP address is less than a first IP address of the target interval among the IP address intervals;

[0014] if a tail IP address of the maximum IP address interval is greater than a tail IP address of the target interval, determining the maximum IP address interval as the associated IP address interval.

[0015] In some embodiments, two adjacent IP address intervals in the first IP address interval sequence are discontinuous.

[0016] The step of determining the associated IP address interval of the target interval in the first IP address interval sequence includes:

[0017] determining a maximum first IP address smaller than the target first IP address among the first IP addresses of the IP address intervals, as an anchor first address;

[0018] determining a minimum last IP address greater than the target first IP address among the last IP addresses of the IP address intervals, as an anchor last address;

[0019] determining an IP address interval between the anchor first address and the anchor last address, as a candidate IP address interval;

[0020] determining the associated IP address interval from the candidate IP address intervals.

[0021] In some embodiments, the determining the associated IP address interval from the candidate IP address intervals comprises:

[0022] determining a distance between a center IP address of each candidate IP address interval and the IP address to be queried;

[0023] obtaining a confidence degree of each candidate IP address interval;

[0024] determining the associated IP address interval from the candidate IP address intervals based on the distance and the confidence degree.

[0025] In some embodiments, the obtaining an intermediate IP address in the target interval comprises:

[0026] obtaining a target first IP address and a target last IP address of the target interval;

[0027] taking an average of the first IP address and the target last IP address as the intermediate IP address.

[0028] In some embodiments, the obtaining an intermediate IP address in the target interval comprises:

[0029] obtaining each of the endpoint IP addresses in the target interval;

[0030] taking an average of each of the endpoint IP addresses as the intermediate IP address.

[0031] In some embodiments, the mapping position table comprises the geographic position, a first IP address of an IP address interval to which the geographic position is mapped, and a length of the IP address interval;

[0032] the IP address completion of each of the endpoint IP addresses of the IP address intervals comprises:

[0033] Based on the first IP address of the IP address range and the length of the IP address range, obtain the last IP address of the IP address range;

[0034] Fill the first IP address and the last IP address of the IP address range into the standard IP address segment structure;

[0035] IP address completion is performed on the IP addresses filled into the standard IP address segment structure.

[0036] In some embodiments, the standard IP address segment structure includes multiple address sub-segments, each of which has a predetermined number of sub-segments;

[0037] The step of completing the IP address in the standard IP address segment structure includes:

[0038] If the number of bits in the IP address segment of the entered address segment is less than the number of bits in the predetermined segment of the address segment, the unfilled bits in the address field will be filled with predetermined characters;

[0039] If an address segment is not filled with any IP address fragment, each bit of the address segment is filled with a predetermined character.

[0040] To achieve the above objectives, a second aspect of this application provides a geolocation query device, the device comprising:

[0041] The first acquisition unit is used to acquire a mapping relationship table, wherein each geographical location in the mapping relationship table is mapped to an IP address range, and the IP address range includes multiple consecutive IP addresses;

[0042] The completion unit is used to complete the endpoint IP addresses of each IP address range, sort the completed IP address ranges to obtain a first IP address range sequence, take the first IP address of the first IP address range sequence as the first IP address, take the last IP address of the first IP address range sequence as the second IP address, and take the IP address range between the first IP address and the second IP address as the target range.

[0043] The second acquisition unit is used to acquire the IP address to be queried;

[0044] The query unit is configured to acquire an intermediate IP address in the target interval, the intermediate IP address divides the target interval into a sub-interval, update the first IP address with a first IP address of the sub-interval in which the IP address to be queried falls, update the second IP address with a last IP address of the sub-interval in which the IP address to be queried falls, update the target interval with the sub-interval in which the IP address to be queried falls, and return the step of acquiring the intermediate IP address in the target interval until the target interval does not contain the end point IP address of the IP address interval.

[0045] The output unit is configured to determine an associated IP address interval of the target interval in the first IP address interval sequence, and take the geographic position corresponding to the associated IP address interval in the mapping relationship table as the queried geographic position.

[0046] To achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.

[0047] To achieve the above object, a fourth aspect of the embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.

[0048] The geographic position query method and device, electronic equipment and storage medium provided by the application first construct a mapping relationship table, in which each geographic position is established in correspondence with an IP address interval, which provides basic data for subsequent query operations, and then the end point IP addresses of the IP address intervals in the mapping relationship table are completed and sorted to form a first IP address interval sequence. Completing the IP addresses facilitates subsequent matching operations on the IP address to be queried, and sorting the end point IP addresses can improve the continuity and efficiency of the IP address to be queried in the matching query process. After the preparation of the initialization work in the early stage is completed, the IP address to be queried is obtained, the first IP address and the second IP address are the first IP address and the tail IP address of the first IP address interval sequence, and the initial target interval is formed by the first IP address and the second IP address. The target interval is updated by obtaining the intermediate IP address from the target interval and according to the position relationship between the sub-interval divided by the intermediate IP address and the IP address to be queried until there is no end point IP address in the target interval. The above method can quickly narrow the search range of the IP address to be queried, efficiently query the corresponding target interval, and then determine the corresponding associated IP address interval in the first IP address interval sequence. The geographic position corresponding to the associated IP address interval in the mapping relationship table is taken as the queried geographic position and outputted. The address position query method can not depend on external website services or commercial API after the mapping relationship table is obtained in advance and the first IP address interval sequence is formed. There is no need to continuously pay high service fees thereafter, so that the user can independently query and perform large-scale IP data geographic position query without restrictions. The geographic position of the IP address to be queried can be quickly located without worrying about network conditions or API usage restrictions, improving the query efficiency and convenience and reducing the query cost. BRIEF DESCRIPTION OF DRAWINGS

[0049] Figure 1 is a system architecture diagram of a geographic position query method according to an embodiment of the present disclosure;

[0050] Figure 2 is a general flowchart of a geographic position query method according to an embodiment of the present disclosure;

[0051] Figure 3 is a schematic diagram of a mapping relationship table according to an embodiment of the present disclosure;

[0052] Figure 4 is Figure 3 a specific flowchart of step S220 in

[0053] Figure 5 is Figure 4 a schematic diagram of an embodiment of step execution;

[0054] Figure 6 is Figure 4 a specific flow chart of step S430 in

[0055] Figure 7 is Figure 6 a schematic diagram of an embodiment of the step execution;

[0056] Figure 8 is Figure 3 a schematic diagram of an embodiment of the remaining part of step S220 in

[0057] Figure 9 is Figure 3 a specific flow chart of step S240 in

[0058] Figure 10 is Figure 9 a schematic diagram of an embodiment of the step execution;

[0059] Figure 11 is Figure 3 another specific flow chart of step S240 in

[0060] Figure 12 is Figure 11 a schematic diagram of an embodiment of the step execution;

[0061] Figure 13 is Figure 3 a specific flow chart of step S250 in

[0062] Figure 14 Figure 13 a schematic diagram of an embodiment of the step execution;

[0063] Figure 15 is Figure 3 another specific flow chart of step S250 in

[0064] Figure 16 is Figure 15 a schematic diagram of an embodiment of the step execution;

[0065] Figure 17 is Figure 15 a specific flow chart of step S1540 in

[0066] Figure 18 is a block diagram of a soft keyboard display device according to an embodiment of the present disclosure;

[0067] Figure 19 shows an implementation of a terminal structure for the geographic location query method shown in Figure 3 ​

[0068] Figure 20 a geographic location query method according to one embodiment of the present disclosure is shown Figure 3 a server structure diagram of the geographic location query method shown. DETAILED DESCRIPTION

[0069] For the purpose, technical solutions and advantages of the present application to be more clearly understood, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only intended to explain the present application and not to limit the present application.

[0070] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be performed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification and claims and the above drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.

[0071] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.

[0072] First, the terms involved in the present application are analyzed:

[0073] IP address: IP protocol provides a unified address format, which allocates a logical address for each network and each host on the Internet, so as to shield the difference of physical address. IP protocol is designed for the communication of computer network interconnection. In the Internet, it is a set of rules that can enable all computer networks connected to the Internet to communicate with each other, which specifies the rules that computers should follow when communicating on the Internet. Any computer system produced by a manufacturer can be interconnected with the Internet as long as it follows the IP protocol. Network systems and equipment produced by various manufacturers, such as Ethernet, packet switching network, etc., cannot be interconnected with each other, and the main reason for this is that the basic units (technically referred to as "frames") of the data they transmit are different. IP protocol is actually a set of protocol software composed of software programs, which converts various different "frames" into "IP data report" format. This conversion is one of the most important features of the Internet, which enables all kinds of computers to communicate on the Internet, i.e. has the "openness" feature. It is because of the IP protocol that the Internet has developed rapidly into the world's largest and open computer communication network. Therefore, IP protocol can also be called "Internet protocol".

[0074] IPv6: is the abbreviation of "Internet Protocol Version 6", also known as the next generation Internet protocol. It is designed by the Internet Engineering Task Force (IETF) to replace the existing IPv4 (i.e. the existing IP) protocol. The main advantage of IPv6 is its super large address quantity, which almost solves the problem of network address shortage. Most new network connections now use the IPv6 protocol. When connecting to the network, each user will be assigned a network address to obtain online access. The 128-bit address of IPv6 is usually written as 8 sub-segments, each consisting of four hexadecimal numbers. For example: AD80:0000:0000:0000:ABAA:0000:00C2:0002.

[0075] One-dimensional character array: can be used to store text data, such as a sentence, a word, or a sequence of characters. In most programming languages, a one-dimensional character array is usually a fixed-length array composed of elements of the character type. Elements in the array can be accessed by index, and all elements in the array can be traversed by loop.

[0076] IP address is a "identity card" obtained according to each computer network connection point. Querying IP address can effectively know the location of the computer. Among them, IPv6 address is a kind of IP address. The current IPv6-based geographic location lookup mainly relies on two forms: one is through the online service provided by some websites, and the other is to use commercial charging API (Application Programming Interface). Although these two ways can meet the basic needs of users to some extent, they all have some obvious limitations and problems.

[0077] For the first way, that is, relying on the service provided by the website, users usually need to access these servers through the network to obtain the geographic location information of the IPv6 address. However, this way is highly dependent on the external network environment, once the network condition is not good or the server appears the fault, the user may not be able to obtain accurate or timely data. In addition, since these services are usually for a large number of users, they often limit the frequency of individual use to prevent server overload. This is undoubtedly a great challenge for users who need to query the geographic location of a large amount of IP data. They may need to process data in batches, or wait for a long time to obtain the required results, which greatly reduces the efficiency and practicability of the query.

[0078] On the other hand, commercial charging APIs, although generally able to provide higher quality data and services, tend to have higher usage costs. For many small projects or users with limited budgets, these fees can become a heavy burden. In addition, the use of commercial APIs is often subject to some strict terms and conditions. For example, the API may limit the user's query frequency, data volume, or data usage manner, etc. These restrictions not only may affect the user's business needs and expansion plans, but also may reduce the flexibility and scalability of the application.

[0079] Based on this, the embodiments of the present application provide a geographic location query method and device, electronic equipment and storage medium, aiming to improve the efficiency and convenience of IP address lookup corresponding geographic location, and reduce the query cost.

[0080] Figure 1 is a system architecture diagram to which the geographic location query method according to the embodiments of the present disclosure is applied. It includes terminal 140, Internet 130, gateway 120, server 110, etc.

[0081] The terminal 140 is a device that obtains the mapping relationship table and the IP address to be queried, and the geographic location corresponding to the IP address is also obtained by the device. It includes desktop computers, laptops, PDAs (Personal Digital Assistants), mobile phones, vehicle-mounted terminals, special-purpose terminals, and other forms. In addition, it can be a single device or a combination of multiple devices. For example, multiple desktop computers are connected to each other through a local area network and work together to form a terminal 140, sharing a display and other devices. The terminal 140 can communicate with the Internet 130 in a wired or wireless manner to exchange data, such as obtaining the mapping relationship table and the IP address to be queried through the Internet.

[0082] The server 110 refers to a computer system that can provide certain services to the terminal 140. Compared with the ordinary terminal 140, the server 110 requires higher stability, security, performance, etc. The server 110 can be a high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a high-performance computer (such as a virtual machine), a combination of a portion of multiple high-performance computers (such as a virtual machine), etc.

[0083] The gateway 120 is also known as an internetworking connector or a protocol converter. The gateway implements network interconnection at the transport layer and is a computer system or device that acts as a conversion role. In the case of two systems using different communication protocols, data formats or languages, or even completely different architectures, the gateway is a translator. At the same time, the gateway can also provide filtering and security functions. The messages sent by the terminal 140 to the server 110 are sent to the corresponding server 110 through the gateway 120. The messages sent by the server 110 to the terminal 140 are also sent to the corresponding terminal 140 through the gateway 120.

[0084] The embodiments of the present disclosure can be applied in various scenarios:

[0085] For example, when law enforcement agencies track suspects on the network, police may use IPv6 addresses to track suspects. Simply put, when a suspect uses electronic devices such as mobile phones or computers to connect to the Internet, these devices will be assigned an IPv6 address. Police can obtain this IPv6 address by cooperating with Internet service providers, and then infer the approximate area where the suspect may be located. This process is like using a special "locator" to track the location of the suspect. Police do not need to know the specific IP address resolution process, they only need to know that through the IPv6 address, they can find the approximate location of the suspect.

[0086] For another example, in a smart home environment, various devices such as smart light bulbs, smart sockets, security cameras, smart door locks, etc. are connected to the Internet. These devices may use IPv6 addresses for communication, as they need a globally unique address space to support a large number of device connections. When the smart home system needs to perform some location-based functions, such as automatically adjusting indoor temperature, lighting or security settings according to the user's location, it can use the IPv6 address to query the user's geographic location. This can be achieved through a smart home system central controller or cloud service platform, which can receive the IPv6 address sent by the device and then use the address to locate the location of the device. To be more specific, when the user leaves home, the smart home system can detect that the IPv6 address of the user's smartphone or smartwatch has moved away from the home location. The system can automatically adjust the security settings in the home, such as locking all doors and windows, or adjusting the indoor temperature and lighting to energy-saving mode, according to this information. The system can identify the user's IPv6 address and determine whether the user is at home or away. This can help the system provide more personalized services, such as only pushing indoor temperature and humidity information to users at home, or only allowing users away to adjust the settings of devices in the home through remote control.

[0087] The geographic position query method and device, the electronic device and the storage medium provided by the embodiments of the present application are described in detail as follows. First, the geographic position query method in the embodiments of the present application is described.

[0088] The geographic position query method of the embodiments of the present application can be mainly executed in the terminal 140. After obtaining the basic data from the server 110 in advance, the process of querying can only need to be executed in the terminal 140, thereby realizing the effect of offline query. Of course, the geographic position query of the present application can also be executed in the server 110, or a part of the geographic position query can be executed in the terminal 140 and the other part of the geographic position query can be executed in the server 110.

[0089] It should be noted that in each specific embodiment of the present application, when relevant processing needs to be performed according to user information, user behavior data, user historical data and user position information and other data related to the identity or characteristics of the user, the user's permission or consent will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards of the country and region. In addition, when the embodiments of the present application need to obtain sensitive personal information of the user, the separate permission or separate consent of the user will be obtained through a pop-up window or a jump to a confirmation page, and after obtaining the separate permission or separate consent of the user, the necessary user-related data for enabling the embodiments of the present application to normally operate will be obtained.

[0090] Figure 2 is an optional flowchart of the geographic position query method provided by the embodiments of the present application, Figure 2 The method in the above embodiment can include but is not limited to the following steps:

[0091] Step S210: Obtain a mapping relationship table, wherein each geographic position in the mapping relationship table is mapped to an IP address interval, and the IP address interval includes a plurality of continuous IP addresses.

[0092] Step S220: Perform IP address completion on the end IP addresses of each IP address interval, sort the completed IP address intervals to obtain a first IP address interval sequence, take the first IP address of the first IP address interval sequence as a first IP address, take the tail IP address of the first IP address interval sequence as a second IP address, and the IP address interval between the first IP address and the second IP address is a target interval;

[0093] Step S230: Obtain a to-be-queried IP address.

[0094] Step S240: obtaining an intermediate IP address in the target interval, the intermediate IP address divides the target interval into a sub-interval, updating the first IP address with the head IP address of the sub-interval where the IP address to be queried falls, updating the second IP address with the tail IP address of the sub-interval where the IP address to be queried falls, updating the target interval with the sub-interval where the IP address to be queried falls, and returning to the step of obtaining the intermediate IP address in the target interval until the target interval does not contain the end IP address of the IP address interval;

[0095] Step S250: determining the associated IP address interval of the target interval in the first IP address interval sequence, and taking the geographic location corresponding to the associated IP address interval in the mapping relationship table as the queried geographic location.

[0096] First, the steps S210-S240 are briefly described.

[0097] In step S210, the mapping relationship table includes each geographic location mapping to an IP address interval, the mapping relationship table can be directly obtained through a certain official website, such as a Geo IP database, or an API interface provided by an Internet service provider, etc., the geographic location of the IP address can also be inferred by sending a probe packet to different locations in the network and collecting response data, and some open source projects and communities are committed to collecting and maintaining the mapping relationship between IP addresses and geographic locations, and the specific acquisition method of the mapping relationship table is not limited here.

[0098] The specific content of the geographic location is not limited to country, province, city, latitude and longitude, but can also include time zone, zip code, language use, etc., and the specific address location content can be selected or extracted according to the needs of the user.

[0099] Figure 3For mapping the partial fragment of the relation table in an embodiment, the data text of the fourth row is as follows: "2001:250:400:: / 38, 1792947, 1814991.0,, 0, 0,, 39.1423, 117.1726, 200.0, zh-CN, AS, Asia, CN, China, TJ, Tianjin, 0, 0, 0, 0.0, Asia / shanghai, 0.0". In the above data text, the non-standard IPv6 address "2001:250:400::" can be seen. The characters after the symbol " / " represent the length of the IP address interval, i.e. "38" represents the length of the IP address interval, thus the corresponding IP address interval can be obtained. The specific method for determining the IP address interval is described in detail below, and will not be described here. The characters after "38" are the specific geographic location information, such as "Asia", "China", and "Tianjin", which respectively represent the continent, country, and city where the corresponding IP address interval is located. The English representation "As i a" and the English abbreviation "AS" of Asia are included, and the language "zh-CN" of the region is also included. In addition, the latitude and longitude information can be seen, such as "39.1423" representing the latitude and "117.1726" representing the longitude. The geographic location in the step can be only the country and city, or can include the specific latitude and longitude, language, and the like.

[0100] In step S230, the IP addresses to be queried of other devices can be discovered by using a network scanning tool, the IP addresses to be queried of the related devices can also be viewed through a router management page, the IP addresses of the devices in the same LAN can also be found by using the ARP protocol through some network tools or programming libraries, the IP addresses of the devices can also be accessed from the logs of the DHCP server, and the network monitoring software can monitor the devices on the network and display their IP addresses.

[0101] Overall, the application first constructs a mapping relationship table, in which each geographic location is corresponded to an IP address interval, which provides basic data for subsequent query operations. Then the endpoint IP addresses of the IP address interval in the mapping relationship table are completed and sorted to form a first IP address interval sequence. Completing the IP address facilitates the subsequent matching operation of the IP address to be queried, and sorting the endpoint IP addresses can improve the continuity and efficiency of the IP address to be queried in the matching query process. After the preparation of the initialization work is completed, the IP address to be queried is obtained, the first IP address and the second IP address are the first IP address and the tail IP address of the first IP address interval sequence, and the initial target interval is formed by the first IP address and the second IP address. The target interval is updated by obtaining the intermediate IP address from the target interval and according to the position relationship between the sub-interval divided by the intermediate IP address and the IP address to be queried, until there is no endpoint IP address in the target interval. The above method can quickly narrow the search range of the IP address to be queried, efficiently query the corresponding target interval, and then determine the corresponding associated IP address interval in the first IP address interval sequence. The geographic location corresponding to the associated IP address interval in the mapping relationship table is taken as the queried geographic location and outputted. The address location query method can not depend on external website services or commercial API after the mapping relationship table is obtained in advance and the first IP address interval sequence is formed. Thereafter, there is no need to continuously pay high service fees, so that the user can independently query and perform large-scale IP data geographic location query without restrictions. The user can quickly locate the geographic location of the IP address to be queried without worrying about network conditions or API usage restrictions, improve the query efficiency and convenience, and reduce the query cost.

[0102] Detailed description of step S220

[0103] From the above explanation of the mapping location table of step S210, it can be known that the mapping location table contains a geographic location, a first IP address of the IP address interval mapped by the geographic location, and an IP address interval length, that is, in the set of mapping relationships "2001:250:400:: / 38, 1792947, 1814991.0,,0,0,,39.1423, 117.1726, 200.0, zh-CN, AS, Asia, CN, China, TJ, Tianjin City, 0, 0, 0, 0.0, Asia / shanghai, 0.0", the first IP address is "2001:250:400::", the IP address interval length is "38", and the geographic location is "China Tianjin City".

[0104] Reference Figure 4In the embodiment, the step of performing IP address completion on the end IP address of each IP address interval includes but is not limited to the following steps:

[0105] Step S410: obtaining the tail IP address of the IP address interval based on the head IP address of the IP address interval and the length of the IP address interval;

[0106] Step S420: filling the head IP address and the tail IP address of the IP address interval into the standard IP address segment structure;

[0107] Step S430: performing IP address completion on the IP address filled into the standard IP address segment structure.

[0108] The steps S410-S430 are described below.

[0109] Referring to Figure 5 In step S410, the head IP address and the length of the IP address interval can be obtained from the mapping relationship table. The length of the IP address interval can be expressed in decimal or hexadecimal. The tail IP address can be obtained by directly adding the length to the head IP address or by a predetermined algorithm combined with the head IP address. The specific data structure is determined according to the data structure specified in the data text of different mapping relationship tables. In this embodiment, the head IP address is "2001:250:400::", and the length of the IP address interval is "38". The length of the IP address interval indicates the range of the third address subsegment of the head IP address, so the tail IP address is "2001:250:438::".

[0110] The compressed representation of IPv6 address allows continuous zero bits to be replaced by a double colon (::). This compression makes IPv6 addresses easier to read, but can cause problems when comparing or determining the interval to which the address belongs. Completing the IPv6 address can eliminate this compression, so that each address is presented in its complete, uncompressed form. In this way, when comparing the IP address to be queried with the IP address interval, accurate matching can be ensured, and misjudgment caused by compressed bits can be avoided. Therefore, the IP address needs to be completed.

[0111] A standard IP address segment structure based on a one-dimensional character array is created, for example, for IPv6, which includes 8 strings, each with a length of 4 bits. The first IP address and the last IP address are filled into the corresponding standard IP address segment structure. In addition, all IP addresses in the IP address interval (not limited to the first IP address and the last IP address) can be calculated. According to the number of IP addresses in the IP address interval, the corresponding number of IP address segment structures are created, and the IP addresses are filled into the IP address segment structures. Then, the IP addresses filled into the standard IP address segment structure are completed, i.e., supplemented to the standard format IP address. The IP address to be queried is a standard format IPv6, so the IP addresses filled into the standard IP address segment structure are completed in advance. The to-be-queried IPv6 address can be compared string by string, and the completion operation converts the address to a unified and uncompressed format, simplifying the comparison logic. This means that no additional code needs to be written to handle the compression case, reducing the complexity of programming. At the same time, under the premise of a standard and unified IP address format, the to-be-queried IP address is matched, which is more rapid and efficient in finding the corresponding target interval, improving the query efficiency and accuracy.

[0112] The standard IP address segment structure includes multiple address sub-segments, each having a predetermined sub-segment bit number. For example, in the above embodiment, since IPv6 is composed of 8 groups of 16 hexadecimal numbers, each standard IP address segment structure includes 8 address sub-segments, and the predetermined sub-segment bit number of each address sub-segment is 4. Referring to Figure 6 In step S430, the following steps are included but not limited thereto:

[0113] Step S610: If the IP address segment bit number of the filled address sub-segment is less than the predetermined sub-segment bit number of the address sub-segment, fill the unfilled bits in the address sub-segment with the predetermined character.

[0114] Step S620: If an address sub-segment is not filled with any IP address segment, fill each bit of the address sub-segment with the predetermined character.

[0115] The completion method in step S610 is described as follows:

[0116] For example, the IP address "2001:250:400:: " is taken as an example again. It can be seen from the IP address that the IP address segment bit number of the second and third address sub-segments is 3, which is less than the address sub-segment bit number 4, and therefore the second and third address sub-segments need to be completed. In this embodiment, the predetermined character is 0, that is, 0 is filled in the bits of the second and third address sub-segments, and the IP address segment bit number of the two address sub-segments is completed to 4, that is, after the step S610 is executed, the IP address becomes "2001:0250:0400:: ", and a leading zero is added in front of the second and third address sub-segments, so that the address sub-segments are standardized. It should be noted that it does not mean that only one predetermined character needs to be added to complete the standardization when the IP address segment bit number of the address sub-segment is less than the predetermined sub-segment bit number of the address sub-segment. When the IP address segment bit number of the address sub-segment is equal to the predetermined sub-segment bit number of the address sub-segment, the address sub-segment standardization process is met. For example, in another embodiment, the IP address before completion is "2001:25:4:: ", the IP address segment bit number of the second address sub-segment is 2, and therefore 2 predetermined characters 0 need to be added in front of it. The IP address segment bit number of the third address sub-segment is 1, and therefore 3 predetermined characters 0 need to be added in front of it. Therefore, after the step S610 is executed, the IP address is converted to "2001:0025:0004:: ".

[0117] The completion method in the step S620 is described below.

[0118] For example, the IP address "2001:250:400:: " is taken as an example again. It can be seen from the IP address that the IP address segment bit number of the second and third address sub-segments is 3, which is less than the address sub-segment bit number 4, and therefore the second and third address sub-segments need to be completed. In this embodiment, the predetermined character is 0, that is, 0 is filled in the bits of the second and third address sub-segments, and the IP address segment bit number of the two address sub-segments is completed to 4, that is, after the step S610 is executed, the IP address becomes "2001:0250:0400:: ", and a leading zero is added in front of the second and third address sub-segments, so that the address sub-segments are standardized. It should be noted that it does not mean that only one predetermined character needs to be added to complete the standardization when the IP address segment bit number of the address sub-segment is less than the predetermined sub-segment bit number of the address sub-segment. When the IP address segment bit number of the address sub-segment is equal to the predetermined sub-segment bit number of the address sub-segment, the address sub-segment standardization process is met. For example, in another embodiment, the IP address before completion is "2001:25:4:: ", the IP address segment bit number of the second address sub-segment is 2, and therefore 2 predetermined characters 0 need to be added in front of it. The IP address segment bit number of the third address sub-segment is 1, and therefore 3 predetermined characters 0 need to be added in front of it. Therefore, after the step S610 is executed, the IP address is converted to "2001:0025:0004:: ".

[0119] For example, the IP address "2001:250:400:: " is taken as an example again. It can be seen from the IP address that the IP address segment bit number of the second and third address sub-segments is 3, which is less than the address sub-segment bit number 4, and therefore the second and third address sub-segments need to be completed. In this embodiment, the predetermined character is 0, that is, 0 is filled in the bits of the second and third address sub-segments, and the IP address segment bit number of the two address sub-segments is completed to 4, that is, after the step S610 is executed, the IP address becomes "2001:0250:0400:: ", and a leading zero is added in front of the second and third address sub-segments, so that the address sub-segments are standardized. It should be noted that it does not mean that only one predetermined character needs to be added to complete the standardization when the IP address segment bit number of the address sub-segment is less than the predetermined sub-segment bit number of the address sub-segment. When the IP address segment bit number of the address sub-segment is equal to the predetermined sub-segment bit number of the address sub-segment, the address sub-segment standardization process is met. For example, in another embodiment, the IP address before completion is "2001:25:4:: ", the IP address segment bit number of the second address sub-segment is 2, and therefore 2 predetermined characters 0 need to be added in front of it. The IP address segment bit number of the third address sub-segment is 1, and therefore 3 predetermined characters 0 need to be added in front of it. Therefore, after the step S610 is executed, the IP address is converted to "2001:0025:0004:: ". Figure 7For example, it should be noted that the above steps S610 and S620 are not limited in the order of execution. Step S610 can be executed first, and then step S620, i.e., the IP address is first converted from "2001:250:400:: " to "2001:0025:0004:: ", and then converted to "2001:0205:0400:0000:0000:0000:0000:0000". Alternatively, step S620 can be executed first, and then step S610, i.e., the IP address is first converted from "2001:250:400:: " to "2001:205:400:0000:0000:0000:0000:0000", and then converted to "2001:0205:0400:0000:0000:0000:0000:0000".

[0120] After the IP address is standardized by the above steps S410 to S430 and steps S610 to S620, i.e., after the IP address is completed, the completed IP address interval is sorted to obtain a first address sequence. Generally, two adjacent IP address intervals are not overlapped, and it is possible that two adjacent IP address intervals are continuous. The first IP address interval sequence is taken as a first IP address, and the tail IP address of the first IP address interval sequence is taken as a second IP address, thereby forming a target interval with the first IP address as the head end and the second IP address as the tail end. The target interval is the most original target interval, which needs to be iteratively updated in the subsequent step S240. This will be described in detail in the following steps.

[0121] In an embodiment, with reference to Figure 8For the convenience of expression and reading, the IP addresses in the embodiment are better expressed and read, the IP addresses are briefly explained and the decimal IP addresses are taken as examples, there are four IP address intervals in the mapping relationship table, after the above IP address completion, the four IP address intervals are sorted as [201:250:000, 201:250:100], [201:250:110, 201:250:180], [201:250:200, 201:250:270] and [201:250:300, 201:250:500]. The four IP address intervals are combined to form a first IP address interval sequence, then the first IP address of the first IP address interval sequence is taken as a first IP address, that is, the first IP address is "201:250:000", the tail IP address of the first IP address interval sequence is taken as a second IP address, that is, the second IP address is "201:250:500", thus it can be concluded that the most original target interval is [201:250:000, 201:250:500].

[0122] Detailed description of step S240

[0123] In this step, it is mainly required to update the target interval, so that the target interval does not contain the breakpoint IP addresses of all the IP address intervals in the mapping relationship table, that is, it is required that the final target interval does not contain the IP addresses "201:250:000", "201:250:100", "201:250:110", "201:250:180", "201:250:200", "201:250:270", "201:250:300" and "201:250:500".

[0124] In addition, before narrowing the update target interval, it can be determined in priority whether the to-be-queried IP address coincides with an endpoint IP address of an IP address interval, if the to-be-queried IP address coincides with an endpoint IP address, then the IP address interval of the endpoint IP address can be directly determined as the target interval, in an embodiment, for example, the to-be-queried IP address is 201:250:110, the to-be-queried IP address coincides with one of the endpoint IP addresses, thus it can be confirmed that the target interval is [201:250:110, 201:250:180], through the above-mentioned manner, the updating efficiency of the target interval can be improved. On the other hand, if the to-be-queried IP address does not coincide with the breakpoint IP address, the target interval updating step of step S240 is executed, the detailed process of the target interval updating is discussed below.

[0125] Reference Figure 9In an embodiment, the step of obtaining the intermediate IP address in the target interval can include, but is not limited to, the following steps:

[0126] Step S910: obtaining the target head IP address and the target tail IP address of the target interval;

[0127] Step S920: obtaining the average of the head IP address and the target tail IP address as the intermediate IP address.

[0128] Referring to Figure 10 In step S910, the target head IP address of the target interval is obtained as "201:250:000" and the target tail IP address is obtained as "201:250:500", and then in step S920, the average of the head IP address and the target tail IP address is obtained as "201:250:250", so the IP address is taken as the intermediate IP address, i.e. the target interval is divided into two sub-intervals, and the two sub-intervals are [201:250:000, 201:250:249] and [201:250:250, 201:250:500] respectively. Assuming that the IP address to be queried falls in the sub-interval [201:250:000, 201:250:249], the sub-interval [201:250:000, 201:250:249] is taken as the new target interval, but since there are endpoint IP addresses "201:250:100", "201:250:110", "201:250:180" and "201:250:200" in the interval, the target interval needs to be updated.

[0129] At this time, the head IP address of the target interval is "201:250:000" and the target tail IP address is "201:250:249", and the intermediate IP address is obtained again as "201:250:125", so the two sub-intervals obtained are [201:250:000, 201:250:124] and [201:250:125, 201:250:250] respectively. Assuming that the IP address to be queried falls in the sub-interval [201:250:000, 201:250:124], the sub-interval [201:250:000, 201:250:124] is taken as the new target interval, but since there are endpoint IP addresses "201:250:100" and "201:250:110" in the interval, the target interval needs to be updated until there is no endpoint IP address in the target interval obtained. The following updating target interval steps are similar to the above, and will not be introduced in detail here.

[0130] Referring to Figure 11In another embodiment, the step of obtaining the intermediate IP address in the target interval can include, but is not limited to, the following steps:

[0131] Step S1110: obtaining each endpoint IP address in the target interval;

[0132] Step S1120: taking the average of each endpoint IP address as the intermediate IP address.

[0133] Referring to Figure 12 In step S1110, each endpoint IP address in the target interval is "201:250:000", "201:250:100", "201:250:110", "201:250:180", "201:250:200", "201:250:270", "201:250:300", and "201:250:500", respectively. Thus, by averaging the above eight endpoint IP addresses in step S1120, the intermediate IP address "201:250:208" is obtained. The target interval is divided into two sub-intervals, [201:250:000, 201:250:207] and [201:250:208, 201:250:500], respectively. Assuming that the IP address to be queried falls within the sub-interval [201:250:000, 201:250:207], the sub-interval [201:250:000, 201:250:207] is taken as the new target interval. However, since the endpoint IP addresses "201:250:100", "201:250:110", "201:250:180", and "201:250:200" still exist in this interval, the target interval needs to be updated.

[0134] The method of updating the target interval is basically similar to the above, and the main difference from the previous embodiment is the method of selecting the intermediate IP address. In steps S910 to S920, this method is simple and fast to calculate, because only two IP addresses need to be considered, and the intermediate IP address can be obtained more quickly. In steps S1110 to S1120, multiple endpoint IP addresses are calculated, and the intermediate IP address obtained is more accurate. The target interval can be updated to the final target interval with fewer iterations, i.e., the target interval without endpoint IP addresses. Users can select different target interval iterative updating processes according to specific application scenarios.

[0135] In addition, there can be more than one intermediate IP address. For example, if there are two intermediate IP addresses, the two intermediate IP addresses are "201:250:167" and "201:250:333" obtained from steps S910 to S920. Thus, the target interval can be divided into three sub-intervals by the two intermediate IP addresses, and the three sub-intervals are [201:250:000, 201:250:166], [201:250:167, 201:250:332] and [201:250:333, 201:250:500]. Then, it is determined in which sub-interval the IP address to be queried falls. In addition, the two intermediate IP addresses can be obtained from steps S1110 to S1120, so that the target interval is divided into three sub-intervals. In addition, there can be three, four or more intermediate IP addresses, until the last updated target interval does not contain the end IP address of the IP address interval.

[0136] Detailed description of step S250

[0137] In the above step, the final target interval obtained by updating is combined with the first IP address interval sequence to determine the associated IP address interval corresponding to the target interval. The associated IP address interval is essentially one of the IP address intervals in the mapping relationship table. The corresponding geographic position is obtained by substituting the associated IP address interval into the mapping relationship table. In this step, how to determine the associated IP address interval according to the target interval in the first IP address interval sequence is a key step.

[0138] Reference Figure 13 In the first IP address interval sequence, the step of determining the associated IP address interval of the target interval can include but is not limited to the following steps:

[0139] Step S1310: determining the largest IP address interval in which the first IP address is less than the first IP address of the target interval.

[0140] Step S1320: if the last IP address of the largest IP address interval is greater than the last IP address of the target interval, the largest IP address interval is determined as the associated IP address interval.

[0141] The steps S1310 to S1320 are described in detail as follows.

[0142] After the target interval is updated, since the target interval does not contain the end IP address of the IP address interval, the target interval can be located in an IP address interval, and the IP address interval is needed to be found out and taken as the associated IP address interval. In steps S1310 and S1320, the maximum IP address interval whose first IP address is less than the first IP address of the target interval is determined from the IP address intervals, and then it is determined whether the IP address of the maximum IP address interval is greater than the end IP address of the target interval, that is, whether the maximum IP address interval contains the target interval. When it is determined that the target interval is entirely located in the maximum IP address interval.

[0143] With reference to Figure 14 In an embodiment, it is assumed that the final target interval obtained after step S240 is [201:250:130, 201:250:165], and the first IP address of each IP address interval is "201:250:000", "201:250:110", "201:250:200" and "201:250:300". Figure 10 Or Figure 12 It can be known that the first IP address of each IP address interval is "201:250:000", "201:250:110", "201:250:200" and "201:250:300", and the first IP address of the IP address interval less than the first IP address of the target interval is "201:250:000" and "201:250:110", and the corresponding maximum IP address interval is the interval [201:250:110, 201:250:180] corresponding to the first IP address "201:250:110". At this time, the end IP address of the maximum IP address interval is "201:250:180", which is greater than the end IP address "201:250:165" of the target interval, so it can be determined that the maximum IP address interval [201:250:110, 201:250:180] is the associated IP address interval.

[0144] In addition, in an ideal case, all IP address intervals of the first IP address interval sequence are continuous and non-overlapping, but in practice, there can be undefined or specified IP addresses between adjacent IP address intervals due to loss of basic data. Based on this, with reference to Figure 15 In the first IP address interval sequence, the step of determining the associated IP address interval of the target interval can include but is not limited to the following steps:

[0145] Step S1510: determining the maximum first IP address less than the first IP address of the target interval as the anchor first address from the first IP address of each IP address interval;

[0146] Step S1520: determining the minimum end IP address greater than the first IP address of the target interval as the anchor end address from the end IP address of each IP address interval;

[0147] Step S1530: determining the IP address interval between the anchor head address and the anchor tail address as the candidate IP address interval;

[0148] Step S1540: determining the associated IP address interval from the plurality of candidate IP address intervals.

[0149] In step S1510, the largest head IP address smaller than the head IP address of the target interval is determined as the anchor head address from the plurality of IP address intervals, and in step S1520, the smallest tail IP address larger than the tail IP address of the target interval is determined as the anchor tail address from the plurality of IP address intervals by a similar method. All the IP addresses between the anchor head address and the anchor tail address are determined as the candidate IP address, and one of the candidate IP addresses is selected as the associated IP interval address according to a certain selection rule.

[0150] Specifically, referring to Figure 16 , it is assumed that the final target interval obtained after step S240 is [201:250:273, 201:250:295], and in combination with Figure 10 or Figure 12It can be seen that the first IP address of each IP address interval is "201:250:000", "201:250:110", "201:250:200" and "201:250:300", so the first IP address of the IP address interval is "201:250:000", "201:250:110", "201:250:200", and the maximum first IP address is taken as the anchor first address, that is, the anchor first address is "201:250:200", but the IP address interval [201:250:200, 201:250:270] corresponding to the anchor first address does not contain the target interval [201:250:273, 201:250:295], so it can be judged that the target interval may be between the adjacent two IP address intervals of the first IP address interval sequence. Therefore, the anchor tail address needs to be obtained, so as to obtain the adjacent interval of the above IP address interval containing the anchor first address. Similarly, the tail IP address of each IP address interval is "201:250:100", "201:250:180", "201:250:270" and "201:250:500", and the tail IP address of the IP address interval is greater than the tail IP address of the target interval "201:250:500", so the IP address is directly taken as the anchor tail address. The IP address interval between the anchor first address and the anchor tail address is determined, and the determined IP address interval is taken as the candidate IP address interval, that is, the IP address intervals [201:250:200, 201:250:270] and [201:250:300, 201:250:500] are taken as the candidate IP address interval. According to the preset selection method, one of the two candidate IP intervals is selected as the associated IP address interval. The method of how to determine the associated IP address interval from multiple candidate IP address intervals will be described in detail below.

[0151] Referring to Figure 17 In step S1540, the following steps can be included but are not limited to:

[0152] Step S1710: determining the center IP address of each candidate IP address interval and the distance between the center IP address and the IP address to be queried;

[0153] Step S1720: obtaining the confidence degree of each candidate IP address interval;

[0154] Step S1730: determining the associated IP address interval in the multiple candidate IP address intervals based on the distance and the confidence degree.

[0155] The steps S1710 to S1730 will be described in detail below.

[0156] In step S1710, the correlation between the IP address to be queried and each candidate IP address range can be determined by measuring the distance between them. In step S1720, the confidence level of the corresponding candidate IP address range can be obtained from the mapping table. For example, if the mapping between some IP address ranges and geographical locations has been verified by multiple users, its confidence level will be relatively high. Conversely, if the mapping between some IP address ranges and geographical locations has not been verified by users, its confidence level will be relatively low. Furthermore, if the mapping between some IP address ranges and geographical locations is provided by the official website, its confidence level will be relatively high; however, if the mapping between some IP address ranges and geographical locations is provided by netizens, its confidence level will be relatively low.

[0157] Subsequently, in step S1730, based on the distance, the corresponding weight, the confidence level, and the corresponding weight, it can be calculated which candidate IP address range is more suitable as the associated IP address range. A score calculation function y = c1d / c2b can be established, where d represents the distance between the IP address to be queried and the center IP address of the candidate IP address range, c1 represents the weight of the distance, b represents the confidence level of the corresponding candidate IP address range, and c2 represents the weight of the confidence level. The candidate IP address range with the higher comprehensive score is selected as the associated IP address range.

[0158] For example, refer to Figure 16 As shown in the figure, it can be seen that the IP address to be queried is closer to the candidate IP address range [201:250:200, 201:250:270]. Assuming that the confidence level of the candidate IP address range [201:250:200, 201:250:270] is greater than that of the candidate IP address range [201:250:300, 201:250:500], the candidate IP address range [201:250:200, 201:250:270] is used as the associated IP address range.

[0159] Additionally, if the target range is located between two adjacent IP address ranges in the first IP address range sequence, you can directly output commands such as "Query error" or "Query invalid" to avoid address query errors.

[0160] It can be understood that, although each step in each of the above flowcharts is shown in sequence according to the representation of the arrow, these steps are not necessarily executed in the order represented by the arrow. Unless otherwise specified in the embodiments, the execution of these steps is not strictly limited in sequence, and these steps can be executed in other orders. Moreover, at least part of the steps in the above flowcharts can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily sequential, but can be alternately executed with at least part of other steps or steps or stages in other steps.

[0161] It should be noted that, in each specific embodiment of the present application, when it is necessary to perform relevant processing according to the data related to the characteristics of the target object, such as target object attribute information or attribute information set, the permission or consent of the target object will be obtained first, and the collection, use and processing of these data will comply with relevant laws, regulations and standards of the country and region. In addition, when the present application needs to obtain target object attribute information, it will obtain the separate permission or separate consent of the target object through a pop-up window or by jumping to a confirmation page, and after obtaining the separate permission or separate consent of the target object, the necessary target object related data for the normal operation of the present application will be obtained.

[0162] Please refer to Figure 18 The present application also provides a geographic position query device, which can implement the above geographic position query method. The device comprises:

[0163] A first obtaining unit is configured to obtain a mapping relationship table, wherein each geographic position in the mapping relationship table is mapped to an IP address interval, and the IP address interval comprises a plurality of continuous IP addresses.

[0164] A completion unit is configured to complete the end IP address of each IP address interval, sort the completed IP address interval to obtain a first IP address interval sequence, take the first IP address of the first IP address interval sequence as a first IP address, take the tail IP address of the first IP address interval sequence as a second IP address, and take the IP address interval between the first IP address and the second IP address as a target interval.

[0165] A second obtaining unit is configured to obtain a to-be-queried IP address.

[0166] The query unit is configured to obtain an intermediate IP address in the target interval, divide the target interval into a sub-interval by the intermediate IP address, update the first IP address by a first IP address of the sub-interval in which the IP address to be queried falls, update the second IP address by a last IP address of the sub-interval in which the IP address to be queried falls, update the target interval by the sub-interval in which the IP address to be queried falls, and return the step of obtaining the intermediate IP address in the target interval until the target interval does not contain an end point IP address of an IP address interval.

[0167] The output unit is configured to determine an associated IP address interval of the target interval in the first IP address interval sequence, and take a geographic location corresponding to the associated IP address interval in the mapping relationship table as the queried geographic location.

[0168] The specific implementation of the geographic location query device is basically the same as the specific embodiments of the geographic location query method described above, and will not be repeated here.

[0169] Optionally, the completion unit is further configured to:

[0170] obtain a last IP address of the IP address interval based on the first IP address of the IP address interval and the length of the IP address interval;

[0171] fill the first IP address and the last IP address of the IP address interval into the standard IP address segment structure;

[0172] perform IP address completion on the IP address filled into the standard IP address segment structure;

[0173] if the number of IP address segments of a filled address sub-segment is less than the predetermined sub-segment number of the address sub-segment, fill the unfilled bits in the address field with predetermined characters;

[0174] if an address sub-segment is not filled with any IP address segment, fill each bit of the address sub-segment with predetermined characters.

[0175] Optionally, the query unit is further configured to:

[0176] obtain a target first IP address and a target last IP address of the target interval;

[0177] take an average of the target first IP address and the target last IP address as the intermediate IP address.

[0178] or,

[0179] obtain each end point IP address in the target interval;

[0180] take an average of each end point IP address as the intermediate IP address.

[0181] Optionally, the output unit is further configured to:

[0182] determining the maximum IP address interval in each IP address interval, whose head IP address is less than the head IP address of the target interval;

[0183] If the tail IP address of the maximum IP address interval is greater than the tail IP address of the target interval, the maximum IP address interval is determined as the associated IP address interval;

[0184] determining the maximum head IP address in the head IP address of each IP address interval, which is less than the head IP address of the target interval, as the anchor head address;

[0185] determining the minimum tail IP address in the tail IP address of each IP address interval, which is greater than the head IP address of the target interval, as the anchor tail address;

[0186] determining the IP address interval between the anchor head address and the anchor tail address as the candidate IP address interval;

[0187] determining the associated IP address interval in the multiple candidate IP address intervals;

[0188] determining the distance between the center IP address of each candidate IP address interval and the IP address to be queried;

[0189] obtaining the confidence of each candidate IP address interval;

[0190] determining the associated IP address interval in the multiple candidate IP address intervals based on the distance and the confidence.

[0191] Reference Figure 19 , Figure 19 A structure block diagram of part of a terminal 140 for implementing the geographic location query method of the embodiments of the present disclosure is shown in FIG. 13. The terminal includes a radio frequency (RF) circuit 1910, a memory 1915, an input unit 1930, a display unit 1940, a sensor 1950, an audio circuit 1960, a wireless fidelity (WiFi) module 1970, a processor 1980, and a power supply 1990, and the like. Those skilled in the art can understand that the terminal structure shown in FIG. 13 does not constitute a limitation on a mobile phone or a computer, and can include more or fewer components than shown in the figure, or combine certain components, or different component arrangements. Figure 19 The terminal structure shown in FIG. 13 does not constitute a limitation on a mobile phone or a computer, and can include more or fewer components than shown in the figure, or combine certain components, or different component arrangements.

[0192] The RF circuit 1910 can be used for receiving and sending signals in the process of information or call, especially, receiving the downlink information of the base station and processing by the processor 1980; in addition, sending the uplink data to the base station.

[0193] The memory 1915 can be used to store software programs and modules, and the processor 1980 executes various function applications and data processing of the terminal by running the software programs and modules stored in the memory 1915.

[0194] The input unit 1930 can be used to receive inputted digital or character information, and to generate key signal input related to the setting and function control of the terminal. Specifically, the input unit 1930 can include a touch panel 1931 and other input devices 1932.

[0195] The display unit 1940 can be used to display inputted information or provided information and various menus of the terminal. The display unit 1940 can include a display panel 1941.

[0196] The audio circuit 1960, the speaker 1961, and the microphone 1962 can provide an audio interface.

[0197] In the embodiment, the processor 1980 included in the terminal can execute the data integration method of the foregoing embodiment.

[0198] The terminal of the embodiments of the present disclosure includes but is not limited to a mobile phone, a computer, a smart voice interactive device, a smart home appliance, a vehicle-mounted terminal, an aircraft, etc. The embodiments of the present disclosure can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, intelligent transportation, and assisted driving, etc.

[0199] Reference Figure 20 , Figure 20 The structure block diagram of the part of the server for implementing the geographic location query method of the embodiments of the present disclosure, the server 110 can be different due to configuration or performance, and can include one or more central processing units (CPU) 2019 (for example, one or more processors) and a memory 2032, one or more storage media 2030 (for example, one or more mass storage devices) storing application programs 2042 or data 2044. Among them, the memory 2032 and the storage medium 2030 can be temporary storage or persistent storage. The programs stored in the storage medium 2030 can include one or more modules (not shown in the figure), each of which can include a series of instruction operations in the server 2000. Further, the central processing unit 2019 can be configured to communicate with the storage medium 2030 and execute the series of instruction operations in the storage medium 2030 on the server 2000.

[0200] The server 2000 can also include one or more power supplies 2026, one or more wired or wireless network interfaces 2050, one or more input / output interfaces 2058, and / or one or more operating systems 2041, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, and the like.

[0201] The processor in the server 2000 can be configured to execute the geographic location query method according to the embodiments of the present disclosure.

[0202] The embodiments of the present disclosure also provide an electronic device, which includes a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the geographic location query method. The electronic device can be any smart terminal, such as a tablet computer or a vehicle-mounted computer.

[0203] The embodiments of the present disclosure also provide a computer readable storage medium, which stores a computer program. The computer program is executed by a processor to implement the geographic location query method.

[0204] The memory, as a non-transitory computer readable storage medium, can be configured to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory can include a high-speed random access memory, and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0205] The embodiments described in the embodiments of the present disclosure are used to more clearly illustrate the technical solutions of the embodiments of the present disclosure, and do not constitute a limitation on the technical solutions provided by the embodiments of the present disclosure. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present disclosure are also applicable to similar technical problems.

[0206] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present disclosure, and can include more or fewer steps than those shown in the figures, or combine certain steps or different steps.

[0207] The apparatus embodiments described above are merely exemplary, and units described as separate components may or may not be physically separate, i.e., may be located in one place, or may be distributed over multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment.

[0208] Those skilled in the art can understand that all or some of the steps in the method disclosed above, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and appropriate combinations thereof.

[0209] The terms "first", "second", "third", "fourth" and the like in the description of the application and in the claims of the foregoing drawings, if any, are used for distinguishing between similar objects and not necessarily for describing a particular sequential or chronological order. It is to be understood that the use of the terms so

[0210] It should be understood that in the present application, "at least one" means one or more, and "multiple" means two or more. "And / or" is used to describe the relationship between the associated objects, which means that there can be three relationships, for example, "A and / or B" can mean that there are three cases: only A, only B, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally represents that the associated objects before and after are in an "or" relationship. "At least one of the following" or the like means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can mean a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0211] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the above units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.

[0212] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they can be located in one place or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0213] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0214] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, including a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.

[0215] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, but this does not limit the scope of the embodiments of the present application. Any modification, equivalent replacement and improvement made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.

Claims

1. A method for querying geographic locations, characterized in that, include: Obtain a mapping table, wherein each geographical location in the mapping table is mapped to an IP address range, and the IP address range includes multiple consecutive IP addresses; The endpoint IP addresses of each IP address range are padded with IP addresses. The padded IP address ranges are sorted to obtain a first IP address range sequence. The first IP address of the first IP address range sequence is taken as the first IP address, the last IP address of the first IP address range sequence is taken as the second IP address, and the IP address range between the first IP address and the second IP address is the target range. Get the IP address to be queried; Obtain an intermediate IP address in the target range, the intermediate IP address divides the target range into sub-ranges, update the first IP address with the first IP address of the sub-range in which the IP address to be queried falls, update the second IP address with the last IP address of the sub-range in which the IP address to be queried falls, update the target range with the sub-range in which the IP address to be queried falls, and return to the step of obtaining the intermediate IP address in the target range, until the target range does not contain the endpoint IP address of the IP address range; In the first IP address range sequence, the associated IP address range of the target range is determined, and the geographical location corresponding to the associated IP address range in the mapping table is used as the queried geographical location; Wherein, two adjacent IP address ranges in the first IP address range sequence are not consecutive; Determining the associated IP address range of the target range within the first IP address range sequence includes: The largest starting IP address among the starting IP addresses of each IP address range that is smaller than the starting IP address of the target range is determined and used as the anchor starting address; The smallest tail IP address among the tail IP addresses of each of the IP address ranges that is greater than the first IP address of the target range is determined as the anchor tail address; Determine the IP address range between the anchor head address and the anchor tail address as a candidate IP address range; Among the multiple candidate IP address ranges, the associated IP address range is determined.

2. The geographic location query method according to claim 1, characterized in that, Obtaining the intermediate IP address within the target range includes: Obtain the first and last IP addresses of the target range; The average value of the first IP address and the target last IP address is used as the intermediate IP address.

3. The geographic location query method according to claim 1, characterized in that, Obtaining the intermediate IP address within the target range includes: Obtain the IP addresses of each endpoint in the target range; The average value of all the endpoint IP addresses is used as the intermediate IP address.

4. The geographic location query method according to claim 1, characterized in that, The mapping table includes the geographical location, the first IP address of the IP address range mapped to the geographical location, and the length of the IP address range; The step of padding the endpoint IP addresses of each IP address range includes: Based on the first IP address of the IP address range and the length of the IP address range, obtain the last IP address of the IP address range; Fill the first IP address and the last IP address of the IP address range into the standard IP address segment structure; IP address completion is performed on the IP addresses filled into the standard IP address segment structure.

5. The geographic location query method according to claim 4, characterized in that, The standard IP address segment structure includes multiple address sub-segments, each of which has a predetermined number of sub-segments; The step of completing the IP address in the standard IP address segment structure includes: If the number of bits in the IP address segment of the entered address segment is less than the number of bits in the predetermined segment of the address segment, the unfilled bits in the address segment will be filled with predetermined characters; If an address segment is not filled with any IP address fragment, each bit of the address segment is filled with a predetermined character.

6. A geographic location query device, characterized in that, include: The first acquisition unit is used to acquire a mapping relationship table, wherein each geographical location in the mapping relationship table is mapped to an IP address range, and the IP address range includes multiple consecutive IP addresses; The completion unit is used to complete the endpoint IP addresses of each IP address range, sort the completed IP address ranges to obtain a first IP address range sequence, take the first IP address of the first IP address range sequence as the first IP address, take the last IP address of the first IP address range sequence as the second IP address, and take the IP address range between the first IP address and the second IP address as the target range. The second acquisition unit is used to acquire the IP address to be queried; A query unit is configured to obtain an intermediate IP address in the target interval, wherein the intermediate IP address divides the target interval into sub-intervals, update the first IP address with the first IP address of the sub-interval in which the IP address to be queried falls, update the second IP address with the last IP address of the sub-interval in which the IP address to be queried falls, update the target interval with the sub-interval in which the IP address to be queried falls, and return to the step of obtaining an intermediate IP address in the target interval until the target interval does not contain the endpoint IP address of the IP address interval; The output unit is configured to determine the associated IP address range of the target range in the first IP address range sequence, and use the geographical location corresponding to the associated IP address range in the mapping table as the queried geographical location; Wherein, two adjacent IP address ranges in the first IP address range sequence are not consecutive; Determining the associated IP address range of the target range within the first IP address range sequence includes: The largest starting IP address among the starting IP addresses of each IP address range that is smaller than the starting IP address of the target range is determined and used as the anchor starting address; The smallest tail IP address among the tail IP addresses of each of the IP address ranges that is greater than the first IP address of the target range is determined as the anchor tail address; Determine the IP address range between the anchor head address and the anchor tail address as a candidate IP address range; Among the multiple candidate IP address ranges, the associated IP address range is determined.

7. An electronic device, characterized in that, include: At least one memory; At least one processor; At least one program; The program is stored in the memory, and the processor executes at least one of the programs to implement the geographic location query method as described in any one of claims 1 to 5.

8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable signals for performing the geographic location query method as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Geographic position information query method and device, storage medium and equipment

    CN112541133A