Valhalla Legends Forums Archive | Battle.net Bot Development | Need help: parsing D2GS packets

AuthorMessageTime
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  :)
October 18, 2006, 5:02 AM
l2k-Shadow
[quote author=FooSoft link=topic=15890.msg159962#msg159962 date=1161147740]
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  :)
[/quote]

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.
October 18, 2006, 5:07 AM
FooSoft
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)
October 18, 2006, 5:24 AM
l2k-Shadow
they will always be compressed + D2GS messages have fixed lenghts.
October 18, 2006, 5:31 AM
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!
October 18, 2006, 5:38 AM
FooSoft
One more thing actually...

Anyone know offhand if the packet length list on this page still applicable to 1.11b?
https://davnit.net/bnet/vL/index.php?topic=11756.75

October 18, 2006, 4:00 PM
NetNX
Most of that information is still accurate as far as packet structure although the packetids may be diffrent.
November 1, 2006, 4:38 PM

Search