Documente Academic
Documente Profesional
Documente Cultură
-----------------
----------------------
1. General Information
----------------------
The communication between client and server uses UDP transport protocol, and h
as the mechanism of timeout-resend, packet-duplicated detection, etc. After rece
iving a packet, the receiver should send an ACK packet to the sender. If after a
few seconds the sender does not receive the ack, it will resend the correspondi
ng packet. If after trying a few times it still fails, the sender will drop this
packet.
Almost all packets from client to server is encrypted using DES algorithm with
the user's password as the key.
If two clients can communicate directly, they will establish a tcp connection
with each other. Otherwise, If this is a message session, the message will be se
nt through the server. If it is a file session(or chat session, etc), unfortunat
ely, communication is impossible.
--------------
2. Convention
--------------
BYTE 8-bit data
WORD 16-bit data
DWORD 32-bit data
STRING length + string
Any data in a packet is in net-order binary format, for example, if 5 is sent:
00 00 00 05, instead of 05 00 00 00, or the ascii of '5'
STRING is encoded as the length(including '\0') followed by the real NULL-term
inated string.
for example, if 'freeman' is sent:
00 08 'f' 'r' 'e' 'e' 'm' 'a' 'n' 00
--------
3. UDP
--------
Every udp packet has a header. The format of a packet from client is as follows:
field size discription
-------------------------------------------
version WORD Protocol version, 1 for now
reserved DWORD Reserved, for forward compatiblity, always 0 for now
uin DWORD Unique myICQ Number
sid DWORD Every session is identified by a session ID to prevent from being spoo
fing
it is randomly generated when the client logins.
cmd WORD Command
seq WORD The sequence number of this packet, the first sequence number in a sess
ion
is randomly selected by client
cc WORD Check Code. See below.
The sender should calculate check code before encrypting this packet, and the re
ceiver will check this field after decrypting it.
Following are the steps to generate a checkcode:
1) Randomly select a position(i) in the real data(after header)
2) Get the byte value(v) at i.
3) Compose the 16-bit checkcode with i as the higher byte and v as the lower byt
e
The format of a packet from server is as follows:
version WORD
reserved DWORD
uin DWORD
sid DWORD
cmd WORD
seq WORD
ackseq WORD The sequence number to be acked
-----------
4. TCP
-----------
Just like UDP packet above, every tcp packet also has a header:
version WORD p2p version, 1 for now
reserved DWORD
cmd WORD tcp command
uin DWORD
face BYTE our face number
When you want to establish a tcp session with a contact, first a MSG_TCP_REQUEST
message is sent. If the remote accepted your request, he will send a MSG_TCP_AC
CEPTED message. After that, you can connect to the port which MSG_TOP_ACCEPTED r
efers.
When a new TCP connection is established, the one who makes the active call will
send a hello packet. After that, it is the plugin's responsibility to send real
data.