• Welcome to Valhalla Legends Archive.
 

Need help: parsing D2GS packets

Started by FooSoft, October 18, 2006, 12:02 AM

Previous topic - Next topic

FooSoft

I'm working on a project that requires me to work with decompressed S > C packets. This means that if a packet is sent from the server decompressed it should be left alone, but if it is sent compressed in compressed format then then it should be decompressed. I have all of the decompression/compression stuff working fine, but I'm not sure how to tell if a packet in a "lump" recv'd from the D2GS is in compressed format or not.

For compressed packets we have
Size: 1-2 bytes (bytes[0] < 0xf0 ? 1 : 2)
PacketId: 1 byte
Data: ? bytes

For decompressed packets it's simply
PacketId: 1 byte
Data ? bytes

So when I receive a packet, is there any way to determine if the first byte is a:
1) First byte of a compressed packet's size
2) PacketId byte of a decompressed packet

I really appreciate any help with this matter   :)

l2k-Shadow

Quote from: FooSoft on October 18, 2006, 12:02 AM
I'm working on a project that requires me to work with decompressed S > C packets. This means that if a packet is sent from the server decompressed it should be left alone, but if it is sent compressed in compressed format then then it should be decompressed. I have all of the decompression/compression stuff working fine, but I'm not sure how to tell if a packet in a "lump" recv'd from the D2GS is in compressed format or not.

For compressed packets we have
Size: 1-2 bytes (bytes[0] < 0xf0 ? 1 : 2)
PacketId: 1 byte
Data: ? bytes

For decompressed packets it's simply
PacketId: 1 byte
Data ? bytes

So when I receive a packet, is there any way to determine if the first byte is a:
1) First byte of a compressed packet's size
2) PacketId byte of a decompressed packet

I really appreciate any help with this matter   :)

length of the packet... in any case the logic to that is obvious. since TCP data can be split among several packets, the packet must include a length for you to be able to receive all the data and then decompress.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

FooSoft

#2
Thanks for the reply, but I'm not sure I follow. Are you saying that a server "message" will always be enclosed in at least one whole packet regardless of whether or not it is compressed or decompressed? I found this not to be the case.

The whole problem is that I don't know how to distinguish between compressed and decompressed messages if multiple messages arrive in one packet. There just appears to be a total lack of context of how to interpret this data.

(messages being logical data D2GS sends out and packets are the TCP segmentation of it)

l2k-Shadow

they will always be compressed + D2GS messages have fixed lenghts.
Quote from: replaced on November 04, 2006, 11:54 AM
I dunno wat it means, someone tell me whats ix86 and pmac?
Can someone send me a working bot source (with bnls support) to my email?  Then help me copy and paste it to my bot? ;D
Já jsem byl určenej abych tady žil,
Dával si ovar, křen a k tomu pivo pil.
Tam by ses povídaj jak prase v žitě měl,
Já nechci před nikym sednout si na prdel.

Já nejsem z USA, já nejsem z USA, já vážně nejsem z USA... a snad se proto na mě nezloběj.

FooSoft

Ah! All D2GS S > C messages are compressed? Awesome! I was under the impression that some were and some were not. That makes things a lot easier, thanks!

FooSoft

#5
One more thing actually...

Anyone know offhand if the packet length list on this page still applicable to 1.11b?
http://forum.valhallalegends.com/index.php?topic=11756.75


NetNX

Most of that information is still accurate as far as packet structure although the packetids may be diffrent.