eDonkey protocol - partly disassembled by hitech (v0.5)

There is a lot of unknown fields, and a lot of it is pure guesswork, but hopefully this document would help get even better servers and client, and for architectures that aren't supported today.
Communication between server/client and client/client is done via TCP/IP. Extended search seem to be done via UDP.

Contact address: n/a.

Thanks to w3seek for supplying additional info

This has been left as an historic archive.

Changelog:
v0.5 : 2002/02/13Cleaned up the document, server is now based on this info
v0.4pre : 2001/12/04Added a lot of misc. stuff, been on vacation so the stuff isn't cleaned up atm.
v0.3 : 2001/11/25Added description for: last connected ip?, changed server info, end of serverinfo -> rooms, servername/servertitle, 0x40 (write donkey version -> client ip).
v0.2 : 2001/11/24Added description for: Return search results, files offered, search file, changed users/files online (hexcode 0x09 -> 0x34).
v0.1 : 2001/11/22First version, far from complete.

File download (client A -> client B):

client A                            client B
Hello (0x1)
                                    file transfer start (dst client) (0x4c)
file transfer (src client) (0x58)
                                    file transfer (dst client) (0x59)

acknowledge file transfer (0x54)
                                    acknowledge file transfer (0x55)
request part(s) (0x47)
                                    return part(s) (0x46)
Example:
IP's and name has been masked out.
hello ->

01                                            hello
10 45 7e 36 d3 da 9e  78 68 4e ea dc a8 8f 69 userhash
db 77                                         ?,?
ec 00 00 00                                   old user id
36 12                                         client port
03 00 00 00                                   ?
02 01 00 01                                   username follows
05 00                                         length of username
78 78 78 78 78                                username (xxxxx)
03 01 00 11                                   client version follows
39 00 00 00                                   client version
03 01 00 0f                                   client port follows
36 12                                         client port
00 00                                         ?
?? ?? ?? ??                                   server ip
35 12                                         server port
00 00 00 00 70 22                             ?

<- file transfer start (dst client)

4c
1c 4a 8f 88 b6 8e cf df  a4 29 0b 42 78 f8 ff 8a userhash
?? ?? ?? ??                                      ip
36 12                                            port
03 00 00 00                                      ?
02 01 00 01                                      username follows
06 00                                            length of username
78 78 78 78 78 78                                username (xxxxxx)
03 01 00 11                                      ?
4e 05 00 00                                      ?
03 01 00 0f                                      ?
36 12                                            port
00 00                                            ?
?? ?? ?? ??                                      server ip
35 12                                            port

file transfer (src client) ->

58
d9 f0 54 10 3c 6c 1e 51  ee 9b 69 b9 0b 06 05 4b file_id

<- file transfer (dst client)

59
d9 f0 54 10 3c 6c 1e 51  ee 9b 69 b9 0b 06 05 4b file_id
48 00                                            length of filename
78 78 78 78 78 78 78 78  78 78 78 78 78 78 78 78 filename (xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.zip)
78 78 78 78 78 78 78 78  78 78 78 78 78 78 78 78
78 78 78 78 78 78 78 78  66 69 78 65 64 20 65 78
66 69 78 65 64 20 65 78  66 69 78 65 64 20 65 78
78 78 78 78 2e 7a 69 70

set file hash ->

4f
d9 f0 54 10 3c 6c 1e 51  ee 9b 69 b9 0b 06 05 4b file_id

<- file transfer go

50
d9 f0 54 10 3c 6c 1e 51  ee 9b 69 b9 0b 06 05 4b file_id
37 00 ff ff ff ff 7f ff  7f                      ?

acknowledge file transfer ->

54                                               T

Packet format:

Header (all packets are wrapped in this header)

0xe3              eDonkey packet marker (byte)
x,x,x,x           Packet length (unsigned long)
SERVER COMMANDS:

serverinfo:

0x32              serverinfo? (byte)
donkey servers    donkey servers ip (byte)
donkey servers * {
x,x,x,x           server ip
x,x               server port (unsigned short)
}
return search results:
0x33              return search results
x,x,x,x           results (unsigned long)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
x,x,x,x           client ip (4 bytes) 
x,x               client port (unsigned short)
7,0,0,0           ?? (unsigned long)
2,1,0,1           tagtype = 2, len = 1, type = 1 (name)
x,x               length of filename
x.....x           filename
3,1,0,2           tagtype = 3, len = 1, type = 2 (size)
00,78,07,21       length of file (unsigned long) ?
2,1,0,3           tagtype = 2, len = 1, type = 3 (type)
x,x               length of file type
x.....x           filetype
2,1,0,4           tagtype = 2, len = 1, type = 4 (format)
3
x,x               length of file extension
x.....x           fileextension
}
[..avi..]
Video {
2
x,x               length of codec
x.....x           codec
x,x               length of codectype
x.....x           codectype
}
2
x,x               length of length
x.....x           length
x,x               length of runtime
x.....x           runtime
3,1,0,15
5,0,0,0           unsigned int

Audio {
3
x,x               length of bitrate
x.....x           length
x,x,x,x           bitrate (unsigned long)
}

[..mp3..]
2
x,x               length of artist
x.....x           artist
x,x               length of artistname
x.....x           artistname
2
x,x               length of album
x.....x           album
x,x               length of albumname
x.....x           albumname
2
x,x               length of title
x.....x           title
x,x               length of titlename
x.....x           titlename
2
x,x               length of length
x.....x           length
x,x               length of runtime
x.....x           runtime
3
x,x               length of bitrate
x.....x           bitrate
x,x,x,x           actual bitrate (unsigned long)



users/files online:
0x34              users/files online (byte)
x,x,x,x           users online (unsigned long)
x,x,x,x           files online (unsigned long)
write string:
0x38              write string (byte)
x,x               Length of string (unsigned short)
x.....x           string
rooms:
0x39              rooms (byte)
donkey rooms      donkey rooms (byte)
donkey rooms * {
x,x               lengt of roomname
x.....x           roomname
0,0               users in room? (unsigned short)
2,0               room number? (+1 for each room)
}
client ip:
0x40              client ip
x,x,x,x           client ip (unsigned int)
servername/servertitle:
0x41              servername/servertitle? (byte)
0,0,0,0,0,0,0,0   bytes (byte)
0,0,0,0,0,0,0,0   bytes (byte)
x,x,x,x           server IP (bytes)
x,x               server port (unsigned short)
2,0,0,0           bytes (byte)
2,1,0,1           tagtype = 2, len = 1, type = 1 (name)
x,x               length of servername (unsigned short)
x.....x           servername
2,1,0,0xb         tagtype = 2, len = 1, type = 11 (title)
x,x               length of servertitle (unsigned short)
x.....x           servertitle
Return download sources
0x42
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
1									no of clients
CLIENTS x {
x,x,x,x           ip ?
x,x               port (unsigned short)
}
CLIENT COMMANDS:

hello packet:

0x01              hello (byte)
10 45 7e 36 d3 da 9e 78  68 4e ea dc a8 8f 69 db user hash (byte)
x,x,x,x,          old user id (unsigned long)
36 12             client port (unsigned short)
03 00 00 00       bytes (byte)
02 01 00 01       username follows
x,x               length of username (unsigned short)
x.....x           username
03 01 00 11 
39 00 00 00       client version (unsigned long)
03 01 00 0f       bytes (byte)
36 12             client port (unsigned short)
00 00             bytes (byte)
03 01 00 0f
36 12             client port (unsigned short) ?
00 00 
00 00 00 00 00 00       bytes (byte)
0x14 ?
0x14              ??? (byte)
files offered:
0x15              files offered
x,x,x,x           files offered (unsigned long)
files offered * {
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
0,0,0,0
0,0
?,0,0,0           (2 == Document? 4 == No additional info? 5 == Image? 6 == AVI ? 8 == MP3, 9 == MP3?)
2,1,0,1           tagtype = 2, len = 1, type = 1 (name)
x,x               length of filename
x.....x           filename
3,1,0,2           tagtype = 3, len = 1, type = 2 (size)
x,x,x,x           length of file (unsigned long)
! Document {
2,1,0,3           tagtype = 2, len = 1, type = 3 (type)
x,x               length of file type
x.....x           filetype
2,1,0,4           tagtype = 2, len = 1, type = 4 (format)
3
x,x               length of file extension
x.....x           fileextension
}
[..avi..]
Video {
2
x,x               length of codec
x.....x           codec
x,x               length of codectype
x.....x           codectype
}
2
x,x               length of length
x.....x           length
x,x               length of runtime
x.....x           runtime
Audio {
3
x,x               length of bitrate
x.....x           length
x,x,x,x           bitrate (unsigned long)
}

[..mp3..]
2
x,x               length of artist
x.....x           artist
x,x               length of artistname
x.....x           artistname
2
x,x               length of album
x.....x           album
x,x               length of albumname
x.....x           albumname
2
x,x               length of title
x.....x           title
x,x               length of titlename
x.....x           titlename
2
x,x               length of length
x.....x           length
x,x               length of runtime
x.....x           runtime
3
x,x               length of bitrate
x.....x           bitrate
x,x,x,x           actual bitrate (unsigned long)

[..doc..]
}
search file
0x16              search file
! ALL {
0, 0
}
1                 byte
x,x								length of searchstring
x.....x           searchstring
! ALL, Format and size {
2                 byte
x,x								length of searchtype
x.....x           searchtype (Audio, Video, Pro, Doc, Col)
1,0,3             bytes ?
}
Format and size {
0,0,0,0
1
x,x								length of searchstring
x.....x           searchstring
2                 byte
x,x								length of searchtype
x.....x           searchtype (Audio, Video, Pro, Doc, Col)
1,0,4,3
x,x,x,x           filesize greater than (unsigned long)
1
1,0,2,3
x,x,x,x           filesize less than (unsigned long)
2,1,0,2
}
download file
0x19
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
search user
0x1a              search user (byte)
1
x,x								length of user
x.....x           user
0x1d ?
0x1d              ??? (byte)
request parts
0x46              send block (blocksize seems to be around 10Kb)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file hash?
x,x,x,x           start offset (unsigned long)
x,x,x,x           end offset (unsigned long)
data              bytes (byte)
return parts?
0x47              got file segment? (byte)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file hash
block size / 8 * {
x,x,x,x           start offset (unsigned long)
x,x,x,x           end offset (unsigned long)
}
file transfer start (dst client)?
0x4c              ??? (byte)
16 byte hash      user hash ? (byte) ?
x,x,x,x           ip
x,x               port (unsigned short)
3,0,0,0
2,1,0,1           tagtype = 2, len = 1, type = 1 (name)
x,x               length of username
x....x            username
3,1,0,11          tagtype = 3, len = 1, type = 17 (client)
39,0,0,0
3,1,0,f           tagtype = 3, len = 1, type = 15 (port)
x,x               port (unsigned short)
0,0
d9,0,48,22        server ip
x,x               port (unsigned short)
0,0,0,0,0,0
0x4d ?
0x4d              ??? (byte)
x,x,x,x           file start (unsigned long) ??
x,x,x,x           file end (unsigned long) ??
set file hash ?
0x4f              set file hash ? (byte)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id ??(16 bytes)
file transfer go ?
0x50              file transfer go? (byte)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
0,0,1
acknowledge file transfer
0x54              acknowledge file transfer (byte) ??

0x55
0x55              acknowledge file transfer (byte) ??
file transfer (src client)?
0x58              file transfer (src client) (byte)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)

file transfer (dst client)?
0x59              file transfer (dst client)? (byte)
x,x,x,x,x,x,x,x,x,x,x,x,x,x,x,x file_id (16 bytes)
x,x               length of filename
x.....x           filename