Qqwry.dat data Structure Text interpretation 1th/2 page _ Other synthesis

Source: Internet
Author: User

Input: IP address ——— > output: This IP address in the country, place names, and sometimes even fine to the floor.

The IP database on the network is the most popular with the pure version, LUMAQQ also uses the pure version IP database as the basis of the IP query function. However, the document on its format is very few, and then finally found several documents on the Internet, only to know its inside, now my understanding of the QQWRY.DAT data structure of the show. Let more people understand the inside of it.

detailed deconstruction:

1. qq.dat Data storage format:

1.1 Three large chunks:
file headers;
Record area;
Index area;
As shown in figure:
1.2 Explain in detail three large chunks:
1.2.1 First Block: file header
The header of the file is 8 byte length, the first four bytes store the absolute address of the second index, and the last four bytes store the absolute address of the final index.
Format as shown:
1.2.2 Second BLOCK: Index area:
The index area format is shown below:
First say the IP address of the start IP and end IP. For example: China, the United States, Britain each country has a different IP segment, IP segment is composed of the start IP and end IP, from the beginning IP to the end of IP in all IP on the composition of what we call the IP segment. Like what:
010.018.132.000 010.018.132.255 [Hebei] [Chengde 169 users]
010.018.160.000 010.018.255.255 [Hebei] [Tangshan]
Again, the storage structure of the index area, which stores a number of indexes, the format of each index is 7 bytes, the first four bytes represents the starting byte of an IP segment, and the last three bytes are the addresses of all IP records that are linked to the IP segment starting with this starting IP, which means that it is an absolute address, Used to link to the record area to query the country, the region's data.
1.2.3 Third block: Record area:
The data format of the record area is indefinite and the data is mainly of the following types:
A: End IP
B: National records (ends at 0x 00)
C: Regional records (end at 0x 00)
D: Identifying characters:
E: Absolute Offset
The above is my reference to the Internet, after the explanation of prawns, according to their own understanding and feelings, the problem again explained in detail, I hope to help.
Attached: This picture is for reference

Current 1/2 page 12 Next read the full text

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.