CN112671948A - Method and device for determining IP address belonging area, electronic equipment and storage medium - Google Patents

Method and device for determining IP address belonging area, electronic equipment and storage medium Download PDF

Info

Publication number
CN112671948A
CN112671948A CN202011581661.XA CN202011581661A CN112671948A CN 112671948 A CN112671948 A CN 112671948A CN 202011581661 A CN202011581661 A CN 202011581661A CN 112671948 A CN112671948 A CN 112671948A
Authority
CN
China
Prior art keywords
address
integer value
determining
target
sequence
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011581661.XA
Other languages
Chinese (zh)
Inventor
谢建乐
万月亮
火一莽
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Ruian Technology Co Ltd
Original Assignee
Beijing Ruian Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Ruian Technology Co Ltd filed Critical Beijing Ruian Technology Co Ltd
Priority to CN202011581661.XA priority Critical patent/CN112671948A/en
Publication of CN112671948A publication Critical patent/CN112671948A/en
Priority to PCT/CN2021/119296 priority patent/WO2022142499A1/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/29Geographical information databases

Landscapes

  • Engineering & Computer Science (AREA)
  • Databases & Information Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Remote Sensing (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

The embodiment of the application discloses a method and a device for determining an IP address belonging area, electronic equipment and a storage medium, wherein the method comprises the following steps: acquiring a target IP address; converting the target IP address into an unsigned integer value by adopting a preset rule; determining the region of the target IP address according to the relationship between the unsigned integer value and the predetermined start address integer value sequence and end address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of an IP address range which are not crossed with each other by adopting a preset rule; by the technical scheme, the IP address belonging area can be simply, conveniently and accurately determined.

Description

Method and device for determining IP address belonging area, electronic equipment and storage medium
Technical Field
The embodiment of the application relates to the technical field of internet, in particular to a method and a device for determining an area to which an IP address belongs, electronic equipment and a storage medium.
Background
Currently, society has entered a period of information volume explosion, however, for the needs of social administration, investigation and statistics, timely and accurate information is urgently needed, wherein for an IP (Internet Protocol) address in the information, the IP address needs to be classified into a region to which the IP address belongs, such as a certain country, a certain province/city/district/county, or even a school or unit.
In the present day with the increasingly developed internet, as the number of addresses is increased explosively and the query frequency of the IP address is higher, the prior art has difficulty in ensuring that the search speed and the search result are optimal when determining the area to which the address belongs according to the IP address. Therefore, there is no method in the prior art to simply, conveniently and accurately determine the belonging area of the IP address.
Disclosure of Invention
The application provides a method and a device for determining an IP address belonging area, electronic equipment and a storage medium, so as to simply, conveniently and accurately determine the IP address belonging area.
In a first aspect, an embodiment of the present application provides a method for determining an area to which an IP address belongs, where the method includes:
acquiring a target IP address;
converting the target IP address into an unsigned integer value by adopting a preset rule;
determining the region of the target IP address according to the relationship between the unsigned integer value and a predetermined initial address integer value sequence and a predetermined final address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
In a second aspect, an embodiment of the present application further provides an apparatus for determining an area to which an IP address belongs, where the apparatus includes:
the target address acquisition module is used for acquiring a target IP address;
the conversion module is used for converting the target IP address into an unsigned integer value by adopting a preset rule;
a target area determining module, configured to determine an area to which the target IP address belongs according to a relationship between the unsigned integer value and a predetermined start address integer value sequence and end address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
In a third aspect, an embodiment of the present application further provides an electronic device, where the device includes:
one or more processors;
a storage device for storing one or more programs,
when the one or more programs are executed by the one or more processors, the one or more processors implement any one of the methods for determining an area to which an IP address belongs as provided in the embodiments of the first aspect.
In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements any one of the methods for determining an area to which an IP address belongs, as provided in the embodiments of the first aspect.
The embodiment of the application converts the target IP address into the unsigned integer value by acquiring the target IP address and adopting the preset rule to facilitate the search of the target IP address, meanwhile, the predetermined start address integer value sequence and the predetermined end address integer value sequence are respectively sequences composed of a plurality of start address integer values and end address integer values, the start address integer value and the end address integer value are obtained by converting the start address and the end address of the IP address range which are not crossed with each other by adopting a preset rule, the consistency of conversion is ensured, and the mutually non-crossed IP address ranges ensure that the areas where the IP address ranges are positioned can not be overlapped, therefore, the region to which the target IP address belongs can be accurately determined according to the relationship between the unsigned integer value and the predetermined integer value sequence of the starting address and the predetermined integer value sequence of the ending address. By adopting the technical scheme, the effect of simply, conveniently and accurately determining the region of the IP address can be achieved.
Drawings
Fig. 1 is a flowchart of a method for determining an area to which an IP address belongs according to an embodiment of the present application;
fig. 2 is a flowchart of a method for determining an area to which an IP address belongs according to a second embodiment of the present application;
fig. 3 is a flowchart of a method for determining an area to which an IP address belongs according to a third embodiment of the present application;
fig. 4 is a schematic diagram of an apparatus for determining an area to which an IP address belongs according to a fourth embodiment of the present application;
fig. 5 is a schematic view of an electronic device provided in this application embodiment five.
Detailed Description
The present application will be described in further detail with reference to the following drawings and examples. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some of the structures related to the present application are shown in the drawings, not all of the structures.
Example one
Fig. 1 is a flowchart of a method for determining an area to which an IP address belongs according to an embodiment of the present application. The method and the device for determining the IP address can be applied to the situation of determining the region to which the IP address belongs. The method can be executed by a device for determining the area to which the IP address belongs, which can be implemented by software and/or hardware, and is specifically configured in an electronic device, which can be a mobile terminal or a fixed terminal.
Referring to fig. 1, a method for determining an area to which an IP address belongs according to an embodiment of the present application includes:
and S110, acquiring a target IP address.
The IP address is an address assigned to each host connected to the internet, and a user can communicate with other hosts in the internet through the host and the IP address.
The target IP address refers to an IP address to be subjected to area determination. The IP address may be an IPv4(Internet Protocol version 4) address, or an IPv6(Internet Protocol version6, Internet Protocol version 6) address, which is not specifically limited in this embodiment of the present application.
Specifically, taking the IPv4 address as an example, the IP address is 32 bits in length and is divided into 4 segments, each segment is 8 bits and is expressed by decimal numbers, the number range of each segment is 0-255, and the segments are separated by dots. For example, the destination IP address is 192.168.1.1.
And S120, converting the target IP address into an unsigned integer value by adopting a preset rule.
The preset rule is predefined and converts the target IP address to obtain an unsigned integer value which is favorable for statistics and analysis. While an unsigned integer value refers to an integer value without sign bits, which may be represented in binary, octal, decimal, or hexadecimal.
The dot data refers to each number field separated by dots in the IP address.
The two-bit hexadecimal numerical value of each point data means that hexadecimal conversion is respectively carried out on digital fields of IP addresses separated by points to obtain the two-bit hexadecimal numerical value of each point data.
The serial connection means that after points in the middle of the IP address are removed, two hexadecimal numerical values of each point data are sequentially connected from left to right to obtain an integral value of the IP address.
It can be understood that, by adopting the preset rule, the target IP address is converted to obtain the target IP address in the form of an unsigned integer value, so that the target IP address can be counted and analyzed by a numerical method.
S130, determining the region of the target IP address according to the relationship between the unsigned integer value and the predetermined initial address integer value sequence and the predetermined final address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting a preset rule.
The starting address and the ending address exist correspondingly, an IP address range is formed by the starting address and the ending address, and the IP address range represents a certain area.
The non-intersection means that for a start address and an end address indicating a certain IP address range, the network addresses (the IP addresses are composed of two parts, namely a network address and a host address) where the start address and the end address are located need to be kept consistent, that is, only if the network addresses where the start address and the end address are located are kept consistent, the start address and the end address are corresponding, and thus the indicated IP address range is correct. The network address refers to a logical address of a node on the internet in the network, the node can be addressed, and the host address refers to a part of the right part of the IP address used for identifying the host. All IP addresses in the same IP address range may be distributed in the same area, for example, belong to the same cell, the same urban area, or the same province.
The starting address integer value sequence is a starting address integer value sequence obtained by sequencing a plurality of starting address integer values; the termination address integer value sequence is a termination address integer value sequence obtained by sorting a plurality of termination address integer values. And the start address integer value in the start address integer value sequence corresponds to the end address integer value in the end address integer value sequence one to one.
Optionally, the start address integer value sequence and the end address integer value sequence may be stored in a memory after being predetermined, and may be called when needed.
In the embodiment of the application, the target IP address is obtained, the target IP address is converted into the unsigned integer value by adopting the preset rule so as to be convenient for searching the target IP address, meanwhile, the predetermined start address integer value sequence and the predetermined end address integer value sequence are respectively sequences composed of a plurality of start address integer values and end address integer values, the start address integer value and the end address integer value are obtained by converting the start address and the end address of the IP address range which are not crossed with each other by adopting a preset rule, the consistency of conversion is ensured, and the mutually non-crossed IP address ranges ensure that the areas where the IP address ranges are positioned can not be overlapped, therefore, the region to which the target IP address belongs can be accurately determined according to the relationship between the unsigned integer value and the predetermined integer value sequence of the starting address and the predetermined integer value sequence of the ending address. By adopting the technical scheme, the effect of simply, conveniently and accurately determining the region of the IP address can be achieved.
Example two
Fig. 2 is a flowchart of a method for determining an area to which an IP address belongs according to a second embodiment of the present application, where the present embodiment is an optimization of the foregoing scheme based on the foregoing embodiment.
Further, before the operation "determining the region to which the target IP address belongs according to the relationship between the unsigned integer value and the predetermined start address integer value sequence and end address integer value sequence", adding an operation "to obtain at least two IP address ranges which are not crossed with each other; wherein, each IP address range corresponds to an area; determining a start address and an end address of each range; converting the starting address and the terminating address by adopting the preset rule to obtain a starting address integer value and a terminating address integer value of each range; sequencing the initial address integer values in each range from small to large to obtain an initial address integer value sequence; and sorting the termination address integer values in each range from small to large to obtain a termination address integer value sequence', so as to perfect the process of determining the starting address integer value sequence and the termination address integer value sequence.
Further, after the operation "obtain the start address integer value sequence and the end address integer value sequence", the operation "is added" to load the start address integer value sequence into a continuous memory, and load the end address integer value sequence into a continuous memory. ", to complete the store operation for the sequence of start address integer values and the sequence of end address integer values.
Wherein explanations of the same or corresponding terms as those of the above-described embodiments are omitted.
Referring to fig. 2, the method for determining an area to which an IP address belongs according to this embodiment includes:
s210, acquiring a target IP address.
S220, converting the target IP address into an unsigned integer value by adopting a preset rule.
S230, acquiring at least two IP address ranges which are not crossed with each other; wherein each IP address range corresponds to a zone.
It can be understood that the at least two IP address ranges that do not intersect each other ensure that the areas where the IP address ranges are located do not overlap.
Optionally, before acquiring at least two IP address ranges that do not intersect with each other, further comprising: detecting whether at least two IP address ranges are crossed; and if the intersection exists, generating prompt information of the existence of the intersection error so as to provide the staff to modify the intersection error.
The prompt message comprises start address information and end address information showing that the intersection exists, so that a worker can modify the intersection error in a targeted mode.
It can be understood that the accuracy of the IP address range is ensured by detecting whether the IP address ranges are crossed, and when the two IP addresses are detected to be crossed, an alarm is given to a worker so as to correct the two IP addresses in time.
And S240, determining the starting address and the ending address of each range.
Specifically, after at least two IP address ranges that do not intersect each other are acquired, since each IP address range has one start address and one end address, a plurality of start addresses and end addresses can be determined based on the plurality of IP address ranges.
And S250, converting the starting address and the ending address by adopting a preset rule to obtain a starting address integer value and an ending address integer value of each range.
Specifically, hexadecimal conversion is performed on the point data of the initial address to obtain two hexadecimal values of the point data; two hexadecimal numerical values of each point data are connected in series to obtain an integer value of an initial address; carrying out hexadecimal conversion on the point data of the termination address to obtain two hexadecimal values of each point data; and connecting the two hexadecimal values of each point data in series to obtain an integer value of the termination address.
It can be understood that the predetermined start address integer value and the predetermined end address integer value are the same as the rule for unsigned integer value conversion of the target IP address, so that the conversion consistency is ensured, and the accurate search of the target IP address is facilitated.
S260, sequencing the initial address integer values in all ranges from small to large to obtain an initial address integer value sequence; and sorting the termination address integer values in each range from small to large to obtain a termination address integer value sequence.
It can be understood that the starting address integer value sequence and the starting address integer value sequence are obtained by arranging the starting address integer value and the ending address integer value in an ascending order, which is beneficial to searching unsigned integer values expressed by target IP addresses in the following.
S270, loading the start address integer value sequence into a continuous memory, and loading the end address integer value sequence into the continuous memory.
The memory refers to a persistent memory for storing a start address integer value sequence and an end address integer value sequence. The memory may be a removable hard disk or an optical disk, and the embodiment of the present application is not limited thereto.
In the embodiment of the present application, the execution sequence of the above S230 to S270 and S210 to S220 is not limited, and S210 to S220 may be executed before S230 to S270, or after S230 to S270 are executed, S210 to S220 may be executed.
In an optional embodiment, assuming that the length of the start address integer value sequence and, correspondingly, the length of the end address integer value sequence are also l, the start address integer value sequence and the end address integer value sequence are respectively stored in an array, and the obtained start address array in ascending order in the unsigned integer form is recorded as asAnd the obtained ascending-order end address array in the form of unnumbered integers is marked as AeArray AsAnd AeThe length of the array is l.
Optionally, the starting address array and the ending address array are stored in the memory of the computer by means of memory mirroring. When the starting address array and the ending address array are to be read, the data can be accessed as if all the data are loaded into the memory of the computer.
In particular, a binary empty file F is createdsAdding n (the length of the array) to the file F byte by byte according to an unsigned integer memory mapping modesRemoving A, thensIt is also added to file F byte by byte in a memory mapped mannersRemoving; creating a binary empty file FeAdding n to file F byte by byte according to unsigned integer memory mapping modeeRemoving A, theneIt is also added to file F byte by byte in a memory mapped mannereAnd (4) removing.
It can be understood that the starting address array and the ending address array are stored in the memory of the computer in a memory mirror image manner, and the effect of simply and quickly accessing the starting address array and the ending address array can be achieved.
S280, determining the region of the target IP address according to the relationship between the unsigned integer value and the predetermined integer value sequence of the starting address and the predetermined integer value sequence of the ending address; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting a preset rule.
In this embodiment, before determining the region to which the target IP address belongs according to the relationship between the unsigned integer value and the predetermined start address integer value sequence and end address integer value sequence, the predetermined start address integer value sequence and end address integer value sequence need to be read from the memory. The manner of reading the predetermined start address integer value sequence and end address integer value sequence from the memory can be referred to as follows.
First, a structure (in C/C + + language) for storing a sequence of integer values is defined, and the code is as follows:
struct kb_addr{
a uint count; // uint denotes an unsigned integer type, count denotes the number of addresses
Agent _ t × saddrs; // saddrs denotes the starting address first address
};
Wherein, uint is a pointer type pointing to an unsigned integer.
When the initial address array needs to be loaded into the memory, a structure variable for representing the initial address array is created: struct kb _ addr mykaddr _ s. To FsRead the n saved in (1) and assign it to mykaddr _ s.count; then allocating a contiguous block of memory BsTo accommodate n number of agent _ t, the first address of the block memory is saved to mykaddr _ s.saddrs; then F is mixedsCopying the content after middle n to B byte by bytesIn (1). Accordingly, a structure variable is created to represent the ending address array: structkb _ addr mykaddr _ e; to FeRead the n saved in (1) and assign it to mykaddr _ e.count; then allocating a contiguous block of memory BeTo accommodate n number of agent _ t, the first address of the block memory is saved to mykaddr _ e.saddrs; then F is mixedeCopying the content after middle n to B byte by byteeIn (1). At this point, the information needed for the query is ready. At this point, the start address integer value sequence and the end address integer value sequence required in the search are read completely.
The method includes the steps that on the basis of the above embodiments, a determination process of a start address integer value sequence and a stop address integer value sequence is described in detail, first, a start address and a stop address of each range are determined according to a plurality of acquired IP address ranges which are not crossed with each other, the start address and the stop address of each range are converted according to a preset rule, a start address integer value and a stop address integer value of each range are obtained, then, the start address integer value and the stop address integer value are arranged in an ascending order to obtain a start address integer value sequence and a start address integer value sequence, and finally, a region to which a target IP address belongs is determined according to a relation between unsigned integer values and the predetermined start address integer value sequence and stop address integer value sequence; the method comprises the steps that a predetermined starting address integer value sequence and a predetermined ending address integer value sequence provide database support for determining the region to which a target IP address belongs; and the predetermined start address integer value sequence and the predetermined end address integer value sequence are loaded in the continuous memory, so that the calling can be conveniently and quickly carried out, and the effect of simply, conveniently and accurately determining the region of the IP address is achieved.
EXAMPLE III
Fig. 3 is a flowchart of a method for determining an area to which an IP address belongs according to a third embodiment of the present application, where the present embodiment is an optimization of the foregoing scheme based on the foregoing embodiments.
Further, the operation of determining the region to which the target IP address belongs according to the relationship between the unsigned integer value and a predetermined start address integer value sequence and end address integer value sequence is refined into the operation of determining a start address integer value to be identified which is smaller than or equal to the unsigned integer value in the start address integer value sequence by adopting a dichotomy; determining an integer value of an ending address to be identified corresponding to the integer value of the starting address to be identified; and if the unsigned integer value is between the start address integer value to be identified and the end address integer value to be identified, determining that the region to which the target IP address belongs is the same as the region of the IP address range of the start address integer value to be identified. ", to complete the determination of the region to which the target IP address belongs.
Wherein explanations of the same or corresponding terms as those of the above-described embodiments are omitted.
Referring to fig. 3, the method for determining an area to which an IP address belongs according to this embodiment includes:
s310, acquiring the target IP address.
S320, converting the target IP address into an unsigned integer value by adopting a preset rule.
S330, determining the start address integer value to be identified which is smaller than or equal to the unsigned integer value in the start address integer value sequence by adopting a dichotomy.
The dichotomy is a binary search method, and can quickly search data to be searched.
Determining a start address integer value to be identified which is smaller than or equal to an unsigned integer value in a start address integer value sequence by adopting a dichotomy method means that a start address integer value closest to the unsigned integer value is found in the start address integer value sequence, and the start address integer value needs to be smaller than the unsigned integer value. That is, it is necessary that the start address integer value to be identified determined in the start address integer value sequence is the largest one of the unsigned integer values or less.
Specifically, in the process of searching the unsigned integer value by adopting the dichotomy, aiming at the initial address integer value sequence arranged in an ascending order, the address integer value recorded in the middle position of the initial address integer value sequence is compared with the searched unsigned integer value, and if the address integer value and the searched unsigned integer value are equal, the searching is successful; if not, continuing to divide and search the initial address integer value sequence; and dividing the initial address integer value sequence into a front sub-initial address integer value sequence and a rear sub-initial address integer value sequence by utilizing the middle position record, if the address integer value recorded in the middle position is smaller than the found unsigned integer value, further searching the front sub-initial address integer value sequence, and otherwise, further searching the rear sub-initial address integer value sequence. And repeating the process until the record meeting the condition is found, so that the search is successful.
S340, determining an integer value of the to-be-identified ending address corresponding to the integer value of the to-be-identified starting address.
And the integer value of the termination address to be identified corresponds to the integer value of the start address to be identified one by one. The position index of the start address integer value to be identified in the start address integer value sequence can be directly used for determining the end address integer value to be identified at the position index with the same end address integer value sequence.
And S350, if the unsigned integer value is between the start address integer value to be identified and the end address integer value to be identified, determining that the region to which the target IP address belongs is the same as the region of the IP address range of the start address integer value to be identified.
It can be understood that the unsigned integer value between the start address integer value to be identified and the end address integer value to be identified has the same network address as the start address integer value to be identified and the end address integer value to be identified, that is, the target IP address represented by the unsigned integer value is the same as the area represented by the start address integer value to be identified, and the host where the target IP address is located is only one host among the hosts in the area.
Optionally, if the unsigned integer value is not between the start address integer value to be identified and the end address integer value to be identified, determining the belonging area of the target IP address fails.
It is understood that the failure of the determination of the home region of the target IP address may be an error in the target IP address itself; alternatively, the predetermined sequence of start address integer values and the predetermined sequence of end address integer values are in error. After determining that the region to which the target IP address belongs is determined to be failed, alarming can be given to a worker, and working log recording can be carried out on the target IP address which is not successfully subjected to region determination.
Optionally, the staff checks the work log at regular time, checks the target IP address, and checks the predetermined start address integer value sequence and end address integer value sequence to determine the cause of the error, and performs corresponding adjustment.
On the basis of the embodiment, the method comprises the steps of converting a target IP address to be determined in a region to which the target IP address belongs to obtain an unsigned integer value, determining a start address integer value to be identified which is smaller than or equal to the unsigned integer value by a binary search method according to the relation between the unsigned integer value and a predetermined start address integer value sequence, determining an end address integer value to be identified according to the corresponding relation between the start address integer value to be identified and the end address integer value sequence, determining whether the unsigned integer value falls in the IP address range according to an IP address range formed by the start address integer value to be identified and the end address integer value to be identified, and if the unsigned integer value falls in the IP address range, determining the region to which the target IP address belongs to be in the IP address range; by the scheme, the effect of simply, conveniently and accurately determining the region of the IP address is achieved.
Example four
Fig. 4 is a schematic structural diagram of an apparatus for determining an area to which an IP address belongs according to a fourth embodiment of the present application. Referring to fig. 4, an apparatus for determining an area to which an IP address belongs according to an embodiment of the present application includes: a target address acquisition module 410, a translation module 420, and a target area determination module 430.
A destination address obtaining module 410, configured to obtain a destination IP address;
a conversion module 420, configured to apply a preset rule to the target IP address and convert the target IP address into an unsigned integer value;
a target area determining module 430, configured to determine an area to which the target IP address belongs according to a relationship between the unsigned integer value and a predetermined start address integer value sequence and end address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
The embodiment of the application obtains the target IP address, converts the target IP address into the unsigned integer value by adopting the preset rule, so as to search the target IP address, simultaneously, the predetermined initial address integer value sequence and the predetermined termination address integer value sequence are respectively sequences consisting of a plurality of initial address integer values and termination address integer values, the initial address integer value and the termination address integer value are obtained by converting the initial address and the termination address of the IP address range which are not crossed by each other by adopting the preset rule, the conversion consistency is ensured, and the IP address range which is not crossed ensures that the areas where the IP address ranges are positioned are not overlapped, so that the area where the target IP address belongs can be accurately determined according to the relation between the unsigned integer value and the predetermined initial address integer value sequence and termination address sequence, the effect of simply, conveniently and accurately determining the region of the IP address is achieved.
Further, the preset rule includes: carrying out hexadecimal conversion on the point data of the IP address to obtain two hexadecimal values of each point data; and connecting the two hexadecimal numerical values of each point data in series to obtain an integral value of the IP address.
Further, the target area determination module includes:
the device comprises an address acquisition unit, a processing unit and a processing unit, wherein the address acquisition unit is used for acquiring at least two IP address ranges which are not crossed with each other; wherein, each IP address range corresponds to an area;
an address determination unit for determining a start address and an end address of each range;
the address conversion unit is used for converting the starting address and the ending address by adopting the preset rule to obtain a starting address integer value and an ending address integer value of each range;
the address sorting unit is used for sorting the initial address integer values in each range from small to large to obtain an initial address integer value sequence; and sorting the termination address integer values in each range from small to large to obtain a termination address integer value sequence.
Further, the target area determination module further includes:
and the loading unit is used for loading the start address integer value sequence into a continuous memory and loading the end address integer value sequence into the continuous memory after obtaining the start address integer value sequence and the end address integer value sequence.
Further, the target area determination module further includes:
the device comprises a detection unit, a processing unit and a processing unit, wherein the detection unit is used for detecting whether at least two IP address ranges are crossed before the at least two IP address ranges which are not crossed with each other are obtained;
and the prompt information generating unit is used for generating prompt information with a cross error if the cross is detected to exist, so that a worker can modify the cross error.
Further, the target area determination module further includes:
the starting address identification unit is used for determining a starting address integer value to be identified which is smaller than or equal to the unsigned integer value in the starting address integer value sequence by adopting a dichotomy;
the termination address identification unit is used for determining a termination address integer value to be identified corresponding to the start address integer value to be identified;
and the target area determining unit is used for determining that the area of the target IP address is the same as the area of the IP address range of the start address integer value to be identified if the unsigned integer value is between the start address integer value to be identified and the end address integer value to be identified.
Further, the target area determining unit is further configured to determine that the area to which the target IP address belongs is determined to be failed if the unsigned integer value is not between the start address integer value to be identified and the end address integer value to be identified.
The device for determining the area to which the IP address belongs, provided by the embodiment of the application, can execute the method for determining the area to which the IP address belongs, provided by any embodiment of the application, and has corresponding functional modules and beneficial effects of the execution method.
EXAMPLE five
Fig. 5 is a schematic structural diagram of an electronic device according to a fifth embodiment of the present disclosure, and as shown in fig. 5, the electronic device includes a processor 510, a memory 520, an input device 530, and an output device 540.
The number of the processors 510 in the device may be one or more, and one processor 510 is taken as an example in fig. 5; the processor 510, the memory 520, the input device 530 and the output device 540 of the apparatus may be connected by a bus or other means, as exemplified by the bus connection in fig. 5.
Wherein the input device 530 is configured to receive the destination IP address.
And an output device 540, configured to output the region to which the target IP address belongs.
Processor 510 may convert the target IP address into an unsigned integer value according to the target IP address input by input device 530 by applying a preset rule to the target IP address; determining the region of the target IP address according to the relationship between the unsigned integer value and a predetermined start address integer value sequence and end address integer value sequence; the area to which the destination IP address belongs may also be transmitted to the output device 540.
The memory 520 is a computer-readable storage medium, and can be used for storing software programs, computer-executable programs, and modules, such as program instructions/modules corresponding to the determination method of the area to which the IP address belongs in the embodiment of the present application (for example, the target address obtaining module 410, the converting module 420, and the target area determining module 430 in the determination device of the area to which the IP address belongs). The processor 510 executes various functional applications of the device and data processing by executing software programs, instructions, and modules stored in the memory 520, that is, implements the above-described method for determining the area to which the IP address belongs.
The memory 520 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application program required for at least one function; the storage data area may store data or the like created according to the use of the terminal (the target IP address, the start address integer value sequence, the end address integer value sequence, and the like in the above-described embodiments). Further, the memory 520 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other non-volatile solid state storage device. In some examples, memory 520 may further include memory located remotely from processor 510, which may be connected to devices through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
The input device 530 may be used to receive input numeric or character information and generate key signal inputs related to user settings and function control of the apparatus. The output device 540 may include a display device such as a display screen.
EXAMPLE six
A storage medium containing computer-executable instructions, which when executed by a computer processor, perform a method for determining an area to which an IP address belongs, the method comprising:
acquiring a target IP address;
converting the target IP address into an unsigned integer value by adopting a preset rule;
determining the region of the target IP address according to the relationship between the unsigned integer value and a predetermined initial address integer value sequence and a predetermined final address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
From the above description of the embodiments, it is obvious for those skilled in the art that the present application can be implemented by software and necessary general hardware, and certainly can be implemented by hardware, but the former is a better embodiment in many cases. Based on such understanding, the technical solutions of the present application may be embodied in the form of a software product, which may be stored in a computer-readable storage medium, such as a floppy disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a FLASH Memory (FLASH), a hard disk or an optical disk of a computer, and includes several instructions for enabling a computer device (which may be a personal computer, a server, or a network device) to execute the methods described in the embodiments of the present application.
It should be noted that, in the embodiment of the apparatus for determining an area to which an IP address belongs, each included unit and module is only divided according to functional logic, but is not limited to the above division, as long as the corresponding function can be implemented; in addition, specific names of the functional units are only used for distinguishing one functional unit from another, and are not used for limiting the protection scope of the application.
It is to be noted that the foregoing is only illustrative of the preferred embodiments of the present application and the technical principles employed. It will be understood by those skilled in the art that the present application is not limited to the particular embodiments described herein, but is capable of various obvious changes, rearrangements and substitutions as will now become apparent to those skilled in the art without departing from the scope of the application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the appended claims.

Claims (10)

1. A method for determining a region to which an IP address belongs, comprising:
acquiring a target IP address;
converting the target IP address into an unsigned integer value by adopting a preset rule;
determining the region of the target IP address according to the relationship between the unsigned integer value and a predetermined initial address integer value sequence and a predetermined final address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
2. The method of claim 1, wherein determining the sequence of start address integer values and the sequence of end address integer values comprises:
acquiring at least two IP address ranges which are not crossed with each other; wherein, each IP address range corresponds to an area;
determining a start address and an end address of each range;
converting the starting address and the terminating address by adopting the preset rule to obtain a starting address integer value and a terminating address integer value of each range;
sequencing the initial address integer values in each range from small to large to obtain an initial address integer value sequence; and sorting the termination address integer values in each range from small to large to obtain a termination address integer value sequence.
3. The method of claim 2, wherein after obtaining the sequence of start address integer values and the sequence of end address integer values, the method further comprises:
and loading the start address integer value sequence into a continuous memory, and loading the end address integer value sequence into a continuous memory.
4. The method of claim 2, wherein prior to obtaining at least two IP address ranges that do not intersect each other, the method further comprises:
detecting whether at least two IP address ranges are crossed;
and if the intersection exists, generating prompt information of the existence of the intersection error so as to allow a worker to modify the intersection error.
5. The method of claim 1, wherein the preset rules comprise:
carrying out hexadecimal conversion on the point data of the IP address to obtain two hexadecimal values of each point data;
and connecting the two hexadecimal numerical values of each point data in series to obtain an integral value of the IP address.
6. The method of claim 1, wherein determining the region to which the target IP address belongs based on a relationship between the unsigned integer value and a predetermined sequence of start address integer values and end address integer values comprises:
determining an initial address integer value to be identified which is smaller than or equal to the unsigned integer value in the initial address integer value sequence by adopting a dichotomy;
determining an integer value of an ending address to be identified corresponding to the integer value of the starting address to be identified;
and if the unsigned integer value is between the start address integer value to be identified and the end address integer value to be identified, determining that the region to which the target IP address belongs is the same as the region of the IP address range of the start address integer value to be identified.
7. The method of claim 6, further comprising:
and if the unsigned integer value is not between the start address integer value to be identified and the end address integer value to be identified, determining that the region to which the target IP address belongs fails to be determined.
8. An apparatus for determining an area to which an IP address belongs, comprising:
the target address acquisition module is used for acquiring a target IP address;
the conversion module is used for converting the target IP address into an unsigned integer value by adopting a preset rule;
a target area determining module, configured to determine an area to which the target IP address belongs according to a relationship between the unsigned integer value and a predetermined start address integer value sequence and end address integer value sequence; the starting address integer value and the ending address integer value are obtained by converting the starting address and the ending address of the IP address range which are not crossed with each other by adopting the preset rule.
9. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement a method of determining a region to which an IP address belongs as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out a method of determining an area to which an IP address belongs according to any one of claims 1 to 7.
CN202011581661.XA 2020-12-28 2020-12-28 Method and device for determining IP address belonging area, electronic equipment and storage medium Pending CN112671948A (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN202011581661.XA CN112671948A (en) 2020-12-28 2020-12-28 Method and device for determining IP address belonging area, electronic equipment and storage medium
PCT/CN2021/119296 WO2022142499A1 (en) 2020-12-28 2021-09-18 Method and apparatus for determining region to which ip address belongs, and electronic device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011581661.XA CN112671948A (en) 2020-12-28 2020-12-28 Method and device for determining IP address belonging area, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN112671948A true CN112671948A (en) 2021-04-16

Family

ID=75411049

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011581661.XA Pending CN112671948A (en) 2020-12-28 2020-12-28 Method and device for determining IP address belonging area, electronic equipment and storage medium

Country Status (2)

Country Link
CN (1) CN112671948A (en)
WO (1) WO2022142499A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114040033A (en) * 2021-10-26 2022-02-11 卓望数码技术(深圳)有限公司 IP address processing method, system and storage medium
CN114201520A (en) * 2021-12-09 2022-03-18 北京航星永志科技有限公司 IP address quick retrieval method and device and electronic equipment
WO2022142499A1 (en) * 2020-12-28 2022-07-07 北京锐安科技有限公司 Method and apparatus for determining region to which ip address belongs, and electronic device and storage medium
CN117278521A (en) * 2023-11-16 2023-12-22 烽台科技(北京)有限公司 Asset identification method and computer device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015070788A1 (en) * 2013-11-15 2015-05-21 北京奇虎科技有限公司 Method and device for identifying regional attribution information of ip address
CN107682466A (en) * 2017-09-26 2018-02-09 小草数语(北京)科技有限公司 The regional information searching method and its device of IP address
CN108875006A (en) * 2018-06-15 2018-11-23 泰康保险集团股份有限公司 Determine method and device regional belonging to IP address
CN110266834A (en) * 2019-07-29 2019-09-20 中国工商银行股份有限公司 The regional lookup method and device of internet protocol-based address

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106789137A (en) * 2015-11-19 2017-05-31 北京国双科技有限公司 The comparative approach and device of IP scopes
US10740265B1 (en) * 2018-09-27 2020-08-11 Amazon Technologies, Inc. PCI-based bus system having peripheral device address translation based on base address register (BAR) index
CN112307138A (en) * 2019-07-30 2021-02-02 华扬联众数字技术股份有限公司 Storage and query method, system and medium of region information
CN112671948A (en) * 2020-12-28 2021-04-16 北京锐安科技有限公司 Method and device for determining IP address belonging area, electronic equipment and storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2015070788A1 (en) * 2013-11-15 2015-05-21 北京奇虎科技有限公司 Method and device for identifying regional attribution information of ip address
CN107682466A (en) * 2017-09-26 2018-02-09 小草数语(北京)科技有限公司 The regional information searching method and its device of IP address
CN108875006A (en) * 2018-06-15 2018-11-23 泰康保险集团股份有限公司 Determine method and device regional belonging to IP address
CN110266834A (en) * 2019-07-29 2019-09-20 中国工商银行股份有限公司 The regional lookup method and device of internet protocol-based address

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2022142499A1 (en) * 2020-12-28 2022-07-07 北京锐安科技有限公司 Method and apparatus for determining region to which ip address belongs, and electronic device and storage medium
CN114040033A (en) * 2021-10-26 2022-02-11 卓望数码技术(深圳)有限公司 IP address processing method, system and storage medium
CN114201520A (en) * 2021-12-09 2022-03-18 北京航星永志科技有限公司 IP address quick retrieval method and device and electronic equipment
CN117278521A (en) * 2023-11-16 2023-12-22 烽台科技(北京)有限公司 Asset identification method and computer device
CN117278521B (en) * 2023-11-16 2024-03-19 烽台科技(北京)有限公司 Asset identification method and computer device

Also Published As

Publication number Publication date
WO2022142499A1 (en) 2022-07-07

Similar Documents

Publication Publication Date Title
CN112671948A (en) Method and device for determining IP address belonging area, electronic equipment and storage medium
EP3767483A1 (en) Method, device, system, and server for image retrieval, and storage medium
CN107807989B (en) Small file processing method and device
CN111354099B (en) Data processing method, data processing device and diagnostic equipment
CN110442642B (en) Data processing method and device for distributed database and storage medium
CN111859033B (en) IP library query method and device and IP library compression method and device
CN111416880A (en) IP address addressing method and device, computer storage medium and electronic equipment
CN111490908A (en) Network speed measurement method, device, equipment, medium and speed measurement system
CN113204345A (en) Page generation method and device, electronic equipment and storage medium
CN111459919A (en) Data query method, loading assembly, search assembly and storage medium
CN111443899B (en) Element processing method and device, electronic equipment and storage medium
CN111666257A (en) File fragment storage method, device, equipment and storage medium
CN116560577A (en) Identification processing method and device, electronic equipment and medium
CN110737678A (en) data searching method, device, equipment and storage medium
CN115225572B (en) Processing method and device of routing information, electronic equipment and storage medium
CN115967604A (en) Message transmission method and device, electronic equipment and computer readable storage medium
CN112291212B (en) Static rule management method and device, electronic equipment and storage medium
CN115630595A (en) Automatic logic circuit generation method and device, electronic device and storage medium
CN115391568A (en) Entity classification method, system, terminal and storage medium based on knowledge graph
CN112527276A (en) Data updating method and device in visual programming tool and terminal equipment
CN113760845A (en) Log processing method, system, device, client and storage medium
CN113419792A (en) Event processing method and device, terminal equipment and storage medium
CN104778197A (en) Data searching method and device
CN114726825A (en) IPv6 address library construction method, system, electronic equipment and storage medium
EP4160396A1 (en) Data processing method and interaction system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210416

RJ01 Rejection of invention patent application after publication