MS RPC compression<p align=left><font face=Arial size=2>Hi there,</font></p> <p align=left> </p> <p align=left>The project I am working on involves analyzing MS Exchange traffic. Right now I am working on payload decompression.</p> <p align=left>The MS document, [MS-OXCRPC].pdf, gives a description of a decompressing algorithm but there are some unclear parts in it. So I'd like to know what I should do if the length of the match is greater than the offset. Say the length is 5 and the offset is 2.</p> <p align=left>I hope someone from Microsoft can clarify this for me.</p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left> </p> <p align=left>Igor</p> <p align=left> </p>© 2009 Microsoft Corporation. All rights reserved.Thu, 13 Aug 2009 22:20:09 Zb4e16062-0ecf-40fa-879a-380bfbac0028http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b4e16062-0ecf-40fa-879a-380bfbac0028http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b4e16062-0ecf-40fa-879a-380bfbac0028igor_bhttp://social.msdn.microsoft.com/Profile/en-US/?user=igor_bMS RPC compression<p align=left><font face=Arial size=2>Hi there,</font></p> <p align=left> </p> <p align=left>The project I am working on involves analyzing MS Exchange traffic. Right now I am working on payload decompression.</p> <p align=left>The MS document, [MS-OXCRPC].pdf, gives a description of a decompressing algorithm but there are some unclear parts in it. So I'd like to know what I should do if the length of the match is greater than the offset. Say the length is 5 and the offset is 2.</p> <p align=left>I hope someone from Microsoft can clarify this for me.</p> <p align=left> </p> <p align=left>Thanks,</p> <p align=left> </p> <p align=left>Igor</p> <p align=left> </p>Wed, 04 Jun 2008 17:38:41 Z2008-06-12T23:14:34Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#cfbeb49f-45a4-4d86-8076-a2b80e57bb36http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#cfbeb49f-45a4-4d86-8076-a2b80e57bb36Tom Devey - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20Devey%20-%20MSFTMS RPC compression<p align=left><font face=Arial size=2>This means that the there is a problem with the compressed (LZ77) payload so the server will return the error code ecRpcFormat (0x000004B6).</font></p>Wed, 04 Jun 2008 18:49:16 Z2008-06-09T13:22:12Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#a537fd12-6039-47ee-9b69-90cb174bf475http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#a537fd12-6039-47ee-9b69-90cb174bf475igor_bhttp://social.msdn.microsoft.com/Profile/en-US/?user=igor_bMS RPC compressionThanks Tom for such a quick reply! <p align=left><font face=Arial size=2></font> </p> <p>From what I saw the situation when the length of a match is bigger than an offset is pretty common. It is hard to believe that there were so many faulty packets.</p> <p align=left>The classic LZ77 describes this particular case and I implemented it. So now my algorithm works OK if the length is bigger than the offset AND there is NO additional metadata byte. I am curious if this is just a coincidence.</p> <p align=left> </p> <p align=left>I handle extra length byte this way. If the last 3 bits of a metadata word are set, I read an extra byte. Its high nibble is used to calculate the length, since it is additive. The low order nibble is remembered for future use. The next time the last 3 bits of a metadata word are 1s I do not read an extra byte but use stored low order nibble to calculate the real length. And then if the third time last 3 bits of a metadata are set, I read the extra byte use high order nibble, store low order one and so on... If this additive, high or low order nibble, is all 1s, I read and use another extra byte wich value is additive.</p> <p align=left>There may be 2 additional bytes if previously I got 111 + 1111 + 11111111 but this never happened to me.</p> <p align=left> </p> <p align=left>I hope my understanding of this algorithm is correct. Do you see what I am missing or getting wrong?</p> <p align=left> </p> <p align=left>Sorry for wordiness but it is really frustrating not being able to get it right.</p> <p align=left> </p> <p align=left>Igor</p> <p align=left> </p>Thu, 05 Jun 2008 23:45:54 Z2008-06-05T23:45:54Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b6ef4971-1645-44e3-92fb-f67ff2463622http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b6ef4971-1645-44e3-92fb-f67ff2463622Tom Devey - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20Devey%20-%20MSFTMS RPC compression<p>Igor, </p> <p> </p> <p>Let me dig into this a bit more and look at the actual code to make sure that I'm not missing something.</p> <p> </p> <p>Thanks!</p> <p align=left><font face=Arial size=2></font> </p>Tue, 10 Jun 2008 16:47:22 Z2008-06-10T16:47:22Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#4de6f23b-9fb1-4202-bf13-b8c02b46020ahttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#4de6f23b-9fb1-4202-bf13-b8c02b46020aigor_bhttp://social.msdn.microsoft.com/Profile/en-US/?user=igor_bMS RPC compressionThank you Tom!<br>Looking forward to hearing from you!<br><br>Igor<br><br>Tue, 10 Jun 2008 18:15:31 Z2008-06-10T18:15:31Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b0cabbfc-93e5-4066-b207-79d7396bfabahttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#b0cabbfc-93e5-4066-b207-79d7396bfabaigor_bhttp://social.msdn.microsoft.com/Profile/en-US/?user=igor_bMS RPC compressionTom,<br><br>We finally figured out the problem.<br>The [MS-OXCRPC] document says that if the match length is greater than 9 then we have to read an additional byte and use high-order nibble as an additive length. The low-order nibble should be kept and used when the next time the match length is greater than nine. As it turned out we should do quite opposite: use LOW-order nibble the first time and HIGH-order nibble the next time.<br><br>Igor<br><br>Wed, 11 Jun 2008 17:28:20 Z2008-06-11T17:28:20Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#70fedce8-2fd6-4e6c-afb9-9ad178ed5723http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#70fedce8-2fd6-4e6c-afb9-9ad178ed5723Tom Devey - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20Devey%20-%20MSFTMS RPC compression<font face=Arial size=2> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Whew.<span style="">  </span>I was not t able to repro your scenario and was about to ask for a sample trace for me to debug.<span style="">  </span></span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'"> </span></p> <p><span style="font-size:10pt;font-family:'Arial','sans-serif'">Thanks for the update.</span></p> <p align=left></font> </p>Thu, 12 Jun 2008 23:14:22 Z2008-06-12T23:14:34Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#62711316-0e0f-42c3-942c-1e93742b682chttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#62711316-0e0f-42c3-942c-1e93742b682cPhil_Causshttp://social.msdn.microsoft.com/Profile/en-US/?user=Phil_CaussMS RPC compressionTom,<br><br>I'm not sure if you filed a bug for this but it is still not corrected in the 1.00 documentation.<br><br>Philippe<br>Thu, 03 Jul 2008 21:11:18 Z2008-07-03T21:11:18Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#6d120ced-d16c-48b9-a08a-a79df0b96ffbhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#6d120ced-d16c-48b9-a08a-a79df0b96ffbRobert K Knighthttp://social.msdn.microsoft.com/Profile/en-US/?user=Robert%20K%20KnightMS RPC compression Hi Phillipe.<br><br>I don't know whether or not Tom filed a bug, but I'll follow up with him.<br><br>Thanks,<br><br>Robert.Thu, 03 Jul 2008 21:39:13 Z2008-07-03T21:39:13Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#25144680-503d-4e31-ab41-080313b54dbchttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#25144680-503d-4e31-ab41-080313b54dbcTom Devey - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20Devey%20-%20MSFTMS RPC compression<p>Phillipe, <br><br>To bring closure on your feedback I did file a Technical Document Issue (TDI) some time ago.  The document will be updated to modify the wording &quot;high-order nibbles&quot; to &quot;low-order nibbles&quot; in paragraph 3.1.5.2.2.4. The subsequent table following the paragraph will also be updated to reflect the change. <br><br>The fix will be in a future release of the documentation. <br><br>Thank you for providing this great feedback and please don't hesitate to provide additional feedback.<br></p> <hr align=left size=1 width="25%"> Developer ConsultantThu, 02 Oct 2008 21:07:01 Z2008-10-02T21:32:11Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#8e13bb39-25db-46a7-ac46-21e77beb9b58http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#8e13bb39-25db-46a7-ac46-21e77beb9b58akilgorehttp://social.msdn.microsoft.com/Profile/en-US/?user=akilgoreMS RPC compressionHi Igor,<br/><br/>I am having exactly the same issues trying to decode some MS Exchange traffic. Can you tell me what you mean when you say:<br/><br/>&quot;The classic LZ77 describes this particular case and I implemented it. So now my algorithm works OK if the length is bigger than the offset AND there is NO additional metadata byte. I am curious if this is just a coincidence.&quot;<br/><br/>In particular, what does the LZ77 algorithm say if the Length is greater than the Offset?<br/><br/>In my particular case, if I assume that all the lengths are correct I can calculate the size of the decompressed data. This agrees with the actual size specified in the RPC_HEADER_EXT structure. So, I'm thinking that the lengths are OK but perhaps it's the offsets that are incorrect.<br/><br/>As the calculated length is adjust by adding 3 (because the minimum match is 3 bytes), then it doesn't make sense to allow/have offsets of -1 or -2 which is what I see sometimes. So I'm (desparately) hoping that the caluclate offset should be adjusted accordingly.<br/><br/>Can anyone confirm this?<br/><br/>Thanks,<br/>Andy.<br/>Mon, 29 Jun 2009 16:08:50 Z2009-06-29T16:08:50Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#e12c36be-fb50-4cc9-979a-78ec9b5e598bhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#e12c36be-fb50-4cc9-979a-78ec9b5e598bTom Devey - MSFThttp://social.msdn.microsoft.com/Profile/en-US/?user=Tom%20Devey%20-%20MSFTMS RPC compressionHi Andy,<br/><br/>I will research this and get back to you on your question.  <hr class="sig">Developer ConsultantFri, 10 Jul 2009 23:47:13 Z2009-07-10T23:47:13Zhttp://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#e7ff76f0-e399-4d2d-bf00-6a7abf5ecd93http://social.msdn.microsoft.com/Forums/en-US/os_exchangeprotocols/thread/b4e16062-0ecf-40fa-879a-380bfbac0028#e7ff76f0-e399-4d2d-bf00-6a7abf5ecd93igor_bhttp://social.msdn.microsoft.com/Profile/en-US/?user=igor_bMS RPC compressionHi Andy,<br/> <br/> Just spotted your question.<br/> <br/> Here's what &quot;The classic LZ77&quot; says:<br/> &quot;Many documents which talk about LZ77 algorithms describe a length-distance pair as a command to &quot;copy&quot; data from the sliding window: &quot;Go back <em>distance</em> characters in the buffer and copy <em>length</em> characters, starting from that point.&quot; While those used to<span style="text-decoration:underline"> </span> imperative programming may find this model intuitive, it may also make it hard to understand a feature of LZ77 encoding: namely, that it is not only acceptable but frequently useful to have a length-distance pair where the length actually exceeds the distance. As a copy command, this is puzzling: &quot;Go back <em>one</em> character in the buffer and copy <em>seven</em> characters, starting from that point.&quot; How can seven characters be copied from the buffer when only one of the specified characters is actually <em>in</em> the buffer? Looking at a length-distance pair as a statement of identity, however, clarifies the confusion: each of the next seven characters is identical to the character that comes one before it. This means that each character can be determined by looking back in the buffer – even if the character looked back to was not <em>in</em> the buffer when the decoding of the current pair began. Since by definition a pair like this will be repeating a sequence of <em>distance</em> characters multiple times, it means that LZ77 incorporates a flexible and easy form of run-length encoding.&quot;<br/> <br/> Igor<br/>Mon, 03 Aug 2009 15:09:31 Z2009-08-03T15:09:31Z