1.0.4 • Published 10 months ago

@ipdb/packer v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Binary Structure of ipdb Data Structure

Based on the provided code, we can outline the binary representation of the ipdb data structure as follows:

Binary Structure Overview

The binary representation of the ipdb data structure mainly consists of the following parts:

Header: Contains the JSON string of metadata (meta). The header starts with a 4-byte unsigned integer (uint32) indicating the length of the JSON string, followed by the JSON string itself.

Node Chunk: Contains the node data of the IP address binary tree structure. The length of the node chunk is equal to the number of nodes multiplied by 8 (each node occupies 8 bytes). Each node is represented by two 4-byte unsigned integers (uint32), indicating the offsets of the left and right child nodes.

Loopback Chunk: A special node representing the root of the IP address range. The loopback chunk is 8 bytes long and contains two 4-byte unsigned integers (uint32), both indicating the length of the node chunk.

Data Chunk: Contains data related to IP addresses (such as geolocation information). Each element in the data chunk is a Buffer, containing the length of the data (2-byte unsigned integer, uint16) and the actual data.

Example of Binary Structure

Here is a simplified example of the binary representation of the ipdb data structure:

+-----------------+-----------------+-----------------+-----------------+
| Header Length   | Header          | Node Chunk      | Loopback Chunk  |
| (4 bytes)       | (JSON string)   | (variable size) | (8 bytes)       |
+-----------------+-----------------+-----------------+-----------------+
| Data Chunk      | Data Chunk      | ...             | ...             |
| (variable size) | (variable size) |                 |                 |
+-----------------+-----------------+-----------------+-----------------+

Node Chunk

+-----------------+-----------------+
| Left Child      | Right Child     |
| Offset (4 bytes)| Offset (4 bytes)|
+-----------------+-----------------+
1.0.2

11 months ago

1.0.4

10 months ago

1.0.3

11 months ago

1.0.1

1 year ago

1.0.0

7 years ago