Iris2.de

Iris2-Forum
It is currently Thu Mar 28, 2024 10:05 am

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Gzip packets
PostPosted: Tue Jan 29, 2008 4:13 am 
Offline

Joined: Tue Jan 29, 2008 2:55 am
Posts: 5
This is not related to Iris itself but hoping someone is willing to help.

How exactly are UO gzip packets handled? I'm looking at the source but still can't quite make out. I know it uses a hufman tree and saw the algorthm, but don't quite understand whats happening, and can't seem to see in that code where it actually uses the gzip library.

Also, how is the size of a gzip packet determined before it is sent to the decompresser?

I'm writing my own client for educational purposes and as well for penetration testing my own server at the packet level. (in no way competing with iris - mine has no graphics and is not really "usable" for playing)


From what I seen so far in Iris, good job, its looking good. Still a buggy and very choppy and lot of stuff wont render, but I'm assuming this is normal as its still in development.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 29, 2008 12:37 pm 
Offline
iris2-developer
User avatar

Joined: Tue Aug 22, 2006 1:21 pm
Posts: 173
Location: Munich, Germany
For general infos about huffman coding see http://en.wikipedia.org/wiki/Huffman_coding

fifo is a first-in-first-out buffer.

http://www.zwischenwelt.org/trac/iris/b ... ib.net.lua
in function NetTrafficStep ()
gMainConnection:Pop(gCompressedRecvFifo)
HuffmanDecompress(gCompressedRecvFifo,gRecvFifo)

http://www.zwischenwelt.org/trac/iris/b ... uffman.cpp
in void HuffmanDecompress (cFIFO *pInFifo, cFIFO *pOutFifo) {

contains the huffman decoding.

there is no gzip usage because we implemented the huffman our self. im not sure but i think its based on the old iris code which is based on runuo or something.
the decompressor dont know the size of the packet. it just gets a stream of compressed data and tries to decompress element by element.

while (HuffmanDecompressOne(pInFifo,pOutFifo)) ;

this way every complete huffman code gets decompressed and moved into a new fifo. if there is half a code the decompressor stops and leaves the fifo untouched.
every frame we insert the new recieved compressed data into the fifo and try again to decode. do we get a decompressed
fifo of recieved network packets that we can parse.

_________________
O-->---


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 2:29 am 
Offline

Joined: Tue Jan 29, 2008 2:55 am
Posts: 5
So basically all data is sent to the decompresser before its even handled, then added to a packet queue to the handler? If yes, I'm on the right track.

Only thing I'm still not sure about is how do I determine when I've gotten enough data to try sending to huffman. Since if I wait on too much data and never get it, then it will just block. Or maybe all the data is not compressed and should be sent to normal packet handler. Is there like a specific packet number to indicate that there is compressed data coming?

And thanks for the help, well appreciated.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 30, 2008 8:15 am 
Offline
iris2-developer
User avatar

Joined: Tue Aug 22, 2006 1:21 pm
Posts: 173
Location: Munich, Germany
yes, recieved data is send to the decompressor and decompressed data to the packet parser

after login the login server sends a server redirect packet (0x8c). after this packet everything the servers send is compressed.

_________________
O-->---


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 31, 2008 1:20 am 
Offline
iris2-developer
User avatar

Joined: Tue Apr 18, 2006 10:28 pm
Posts: 823
Location: Munich, Bavaria, Germany
you'll have too "peek"(look at data without removing) before you "pop"(remove data) from the incoming data stream for compressed packets.

the huffman decompressor tries to read "chunks", which can be of varying length (varying number of BITS), but it ONLY removes them IF THEY ARE COMPLETE.

the code for that is in iris/src/huffman.cpp

HuffmanDecompressOne reads ONE such "chunk".

about the compression-system (not decompression) :
the huffman tree compresses often used patterns(in the uncompressed data) as shorter chunks than seldomly used ones. but in some cases the chunk encoding a pattern can even be longer than original pattern, but the tree is designed so that this seldomly happens.

the tree used here is specific for the uo network protocol : it tries compresses patterns that occur often strongly.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group