Difference between revisions of "Nodes.dat file"
GonoszTopi (Talk | contribs) m (file name) |
Vollstrecker (Talk | contribs) m (Adjusted Links, Added Version-Tag) |
||
Line 4: | Line 4: | ||
== File == | == File == | ||
− | |||
'''Name:''' ''nodes.dat'' | '''Name:''' ''nodes.dat'' | ||
Line 10: | Line 9: | ||
== Description == | == Description == | ||
− | |||
This file stores details about other known [[Kademlia]] [[client]]s (also known as [[node]]s). | This file stores details about other known [[Kademlia]] [[client]]s (also known as [[node]]s). | ||
Line 16: | Line 14: | ||
== Format == | == Format == | ||
− | |||
As you can see, all the fields are stored without any separator character. This is done like this because all the fields have a specific size: | As you can see, all the fields are stored without any separator character. This is done like this because all the fields have a specific size: | ||
*''Number of contacts'': Number of contacts that will be listed (4 bytes) | *''Number of contacts'': Number of contacts that will be listed (4 bytes) | ||
Line 22: | Line 19: | ||
After specifying the number of contacts that will be listed, the file lists them. Each contact takes 25 bytes, splitted into the following fields: | After specifying the number of contacts that will be listed, the file lists them. Each contact takes 25 bytes, splitted into the following fields: | ||
*''ClientID'': The contact's [[ID|ClientID]] (16 bytes) | *''ClientID'': The contact's [[ID|ClientID]] (16 bytes) | ||
− | *''IP'': The contact's [[IP]] (4 bytes) | + | *''IP'': The contact's [[IP address|IP]] (4 bytes) |
*''UDP Port'': The [http://www.ietf.org/rfc/rfc768.txt UDP] [[port]] to [[connect]] to when trying to reach the contact (2 bytes) | *''UDP Port'': The [http://www.ietf.org/rfc/rfc768.txt UDP] [[port]] to [[connect]] to when trying to reach the contact (2 bytes) | ||
*''TCP Port'': The [http://www.ietf.org/rfc/rfc793.txt TCP] [[port]] to [[connect]] to when trying to reach the contact (2 bytes) | *''TCP Port'': The [http://www.ietf.org/rfc/rfc793.txt TCP] [[port]] to [[connect]] to when trying to reach the contact (2 bytes) | ||
Line 30: | Line 27: | ||
== Example == | == Example == | ||
− | |||
The following is a hex dump of an hypothetic ''nodes.dat'' file: | The following is a hex dump of an hypothetic ''nodes.dat'' file: | ||
Line 52: | Line 48: | ||
== Extra == | == Extra == | ||
− | |||
Since the ''number of contacts'' field is 4 bytes long, the maximum number of [[node]]s you could store in this file is 4294967296 (~4300M), which should be far enough. Anyway, since this number is so big, [[aMule]], [[eMule]] and all clients have hard limitted the amount of contacts that can be stored ([[aMule]]'s hard limit is ''5000''). | Since the ''number of contacts'' field is 4 bytes long, the maximum number of [[node]]s you could store in this file is 4294967296 (~4300M), which should be far enough. Anyway, since this number is so big, [[aMule]], [[eMule]] and all clients have hard limitted the amount of contacts that can be stored ([[aMule]]'s hard limit is ''5000''). | ||
Line 58: | Line 53: | ||
== Script for dumping nodes.dat == | == Script for dumping nodes.dat == | ||
− | |||
Here's a little script I wrote for dumping contents of the nodes.dat file: | Here's a little script I wrote for dumping contents of the nodes.dat file: | ||
− | + | #!/usr/bin/env python | |
− | #!/usr/bin/env python | + | # this code belongs to public domain |
− | # this code belongs to public domain | + | |
− | + | import struct | |
− | import struct | + | nodefile = open('nodes.dat', 'r') |
− | nodefile = open('nodes.dat', 'r') | + | (count,) = struct.unpack("<I", nodefile.read(4)) |
− | (count,) = struct.unpack("<I", nodefile.read(4)) | + | |
+ | print ' idx type ip address udp tcp' | ||
+ | for i in xrange(count): | ||
+ | (clientid, ip1, ip2, ip3, ip4, udpport, tcpport, type) = \ | ||
+ | struct.unpack("<16s4BHHB", nodefile.read(25)) | ||
+ | ipaddr = '%d.%d.%d.%d' % (ip1, ip2, ip3, ip4) | ||
+ | print '%4d %4d %-15s %5d %5d' % (i, type, ipaddr, udpport, tcpport) | ||
+ | nodefile.close() | ||
− | + | == Version == | |
− | + | Created by "Unknown User" on 28.08.05 at 06:43<br> | |
− | + | Updated by Vollstrecker on 23.01.08 at 14:49 | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + |
Revision as of 14:49, 23 January 2008
English | Deutsch
File
Name: nodes.dat
Location: ~/.aMule/
Description
This file stores details about other known Kademlia clients (also known as nodes).
It is usually used to achieve a successfull bootstrap faster.
Format
As you can see, all the fields are stored without any separator character. This is done like this because all the fields have a specific size:
- Number of contacts: Number of contacts that will be listed (4 bytes)
After specifying the number of contacts that will be listed, the file lists them. Each contact takes 25 bytes, splitted into the following fields:
- ClientID: The contact's ClientID (16 bytes)
- IP: The contact's IP (4 bytes)
- UDP Port: The UDP port to connect to when trying to reach the contact (2 bytes)
- TCP Port: The TCP port to connect to when trying to reach the contact (2 bytes)
- Type: This indicates the type of the contact, which is how much you can be confident on that contact (a scale from 0 to 4, being 0 the best and 4 the worst). (1 byte)
Once this data is put together, it is stored in little-endian.
Example
The following is a hex dump of an hypothetic nodes.dat file:
0200000012257425DBA4EDDBD097150757404486E55E04DE40123612021F64632587A31EC2FC8566C4A9BAB184E6E9B7D44012361202
In the above example, the following data can be seen:
- Number of contacts: 2 (In hex: 02000000, remember it's in little endian)
- Contact #1:
- ClientID: 12257425DBA4EDDBD097150757404486
- IP: 222.4.94.229 (In hex: E55E04DE, remember it's in little endian)
- UDP Port: 1240 (In hex: 4012, remember it's in little endian)
- TCP Port: 1236 (In hex: 3612, remember it's in little endian)
- Type: 2 (In hex: 02)
- Contact #2:
- ClientID: 1F64632587A31EC2FC8566C4A9BAB184
- IP: 212.183.233.230 (In hex: E6E9B7D4, remember it's in little endian)
- UDP Port: 1240 (In hex: 4012, remember it's in little endian)
- TCP Port: 1236 (In hex: 3612, remember it's in little endian)
- Type: 2 (In hex: 02)
Extra
Since the number of contacts field is 4 bytes long, the maximum number of nodes you could store in this file is 4294967296 (~4300M), which should be far enough. Anyway, since this number is so big, aMule, eMule and all clients have hard limitted the amount of contacts that can be stored (aMule's hard limit is 5000).
Since Type 4 contacts are those which are marked for deletion, there should never be any Type 4 contact in the nodes.dat file. If there was, it would just be ignored when reading the file.
Script for dumping nodes.dat
Here's a little script I wrote for dumping contents of the nodes.dat file:
#!/usr/bin/env python # this code belongs to public domain import struct nodefile = open('nodes.dat', 'r') (count,) = struct.unpack("<I", nodefile.read(4)) print ' idx type ip address udp tcp' for i in xrange(count): (clientid, ip1, ip2, ip3, ip4, udpport, tcpport, type) = \ struct.unpack("<16s4BHHB", nodefile.read(25)) ipaddr = '%d.%d.%d.%d' % (ip1, ip2, ip3, ip4) print '%4d %4d %-15s %5d %5d' % (i, type, ipaddr, udpport, tcpport) nodefile.close()
Version
Created by "Unknown User" on 28.08.05 at 06:43
Updated by Vollstrecker on 23.01.08 at 14:49