crelay - Relay for compressing interactive traffic

Special feature: will flush buffers when no pending data is present. This enables compressing telnet, x-windows, nntp, and other types of "interactive" traffic.

Usage

crelay [O|T]  
O               Act as originating relay (compresses)
T               Act as terminating relay (decompresses)
remote-ip       Dotted-quad of remote machine
remote-port     Port to connect to on remote machine

The program is designed to run under inetd

Prerequisites

compiler, zlib

Compilation

g++ -O2 -Wall crelay.cc -o crelay -lz

Example

Let's compress the famous bandwidth-hog: telnet :-)

The originating machine needs to have crelay installed under inetd (otherwise the telnet application would have to be modified) On the originating machine:

  1. Add this to /etc/services:
    ctelnet 23023/tcp
  2. Add this to /etc/inetd.conf (or equivalent):
    ctelnet stream tcp nowait your_username_here /home/your_sername_here/bin/crelay o 10.0.0.2 23024

This means that when you telnet to 127.0.0.1:23023 crelay will connect to 10.0.0.2:23024 and compress outgoing traffic and decompress ingoing traffic.

The terminating machine also has to have crelay running under inetd.

  1. Add this to /etc/services:
    dtelnet 23024/tcp
  2. Add this to /etc/inetd.conf (or equivalent):
    dtelnet stream tcp nowait your_username_here /home/your_sername_here/bin/crelay t 127.0.0.1 23

This means that crelay will connect to to 127.0.0.1:23 (local telnet) and decompress ingoing traffic and compress outgoing.

Now test it with:

  telnet 127.0.0.1 23023

Performance

zlib is quite good and you will rarely see in in "top".

The compression ratio varies with the protocol. Normal telnet traffic will not compress much, and besides normal modems are really good at compressing that part already.

For NNTP traffic can usually be compressed 30-60%

X/Windows traffic can on the average be compressed to 13% which is quite good. In one pathetic application I have seen the traffic be compressed to a 80th of the original.

Download

here: crelay.cc (5KB)