3.1.8.2.2.1 Data Compression Example

The example in this section is merely illustrative of the RDP 6.1 compression techniques presented in section 3.1.8.2.2. The minimum recommended match length is ignored and data expansion does occur when adding the RDP 6.1 Compressed Data (section 2.2.2.4.1) structure.

Consider the following stream data.

 a b c d e f g h i j

With an empty history buffer, this data would translate as being all literals. The history buffer would appear as follows.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
 a b c d e f g h i j

The resultant output data would be as follows.

 a b c d e f g h i j

 Now, assume that the following data is added to the stream to be compressed.

 k l m n o d e f g h i j k l a b c d u

The compressor would again append this to its history buffer (or add to the start of the history buffer if not enough space is available). The history buffer would then appear as follows.

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0
 a b c d e f g h i j k l m n o d e f g h i j k l a b c d u

The output from the compressor would become as follows.

 k l m n o
 [MatchHistoryOffset@3, MatchLength=9, MatchOutputOffset@5]
 [MatchHistoryOffset@0, MatchLength=4, MatchOutputOffset@14] 
 u

The first match includes both literals from the first packet and literals in the beginning of the current packet. The important condition is that any match can contain only literals that have been sent previously in the stream and still exist at the time of compression in its history buffer. Note that the RDP6.1-BC copy-tuple encoding scheme not only specifies where the match begins in the history buffer (MatchHistoryOffset) and its length in bytes (MatchLength) but also its relative position in the decompressed output stream. This extra information enables an on-the-wire format that allows the matches and literals to be grouped independently rather than in line with each other in the compressed stream.

The following is a simplified version of the RDP6.1-BC wire format (described in section 2.2.2.4.1) for the compressor output previously described.

 [2 matches]
 [MatchHistoryOffset@3, MatchLength=9, MatchOutputOffset@5]
 [MatchHistoryOffset@0, MatchLength=4, MatchOutputOffset@14] 
 k l m n o u

Notice that the two matches are grouped together and are not present in line with the literals in the stream.