I've added an option to compress Level 2 (ax.25) and L4 (NETROM) frames. As large blocks of data compress better than small ones it takes all data queued to be sent on a connection and compresses them using Deflate. The compressed data is then split up into packets to be sent over the link. Once all the compressed packets have been received the data is expanded and passed to the session partner.
There is a trade off between compression efficiency and latency - the receiving end has to receive the whole compressed message before it can be expanded and sent on. So the code limits the number of compressed packets (default is 3) that can be sent. If the compressed data exceeds this limit the input data is split into chunks. The number of compressed frames is configurable. With L2 the maximum frame size is taken from the PORT PACLEN parameter. With L4 the size is configurable and defaults to 236.
Compression is only used if both ends of the connection have compression enabled.
L2 and L4 compression can be enabled separately but the L2 compress code will not compress NETROM frames, so it is generally better to enable both.
L2 compression is negotiated using XID frames so will only be used on ax.25 V2.2 sessions (those started with NC rather than C commands).
L4 compression uses aspare bit in the NETROM Opcode to indicate compressed frames and a spare bit in the BPQ NETROM Connect Request extensions to request and confirm compression.
Both are backwards compatible with earlier versions of BPQ. There is a possibility that these could be handled differently in other node software so please check for problems if communicating with other software.
Configuration.
L2Compress=1 turns on L2 compression. default is off.
L2CompMaxframe=n limits number of frames of compressed data to send. Default 3.
L4Compress=1 turns on L4 compression. default is off.
L4CompMaxframe=n limits number of frames of compressed data to send. Default 3.
L4CompPaclen=n sets packet size of compressed frames. Default it 236.
Monitoring.
In BPQ monitor output L2 compress negotiation and info frames are displayed as below
GM8BPQ-2>BPQ Port=3 <XID C P> 2=21 3=22a486 RX Paclen=256 RX Window=7 Can Compress
BPQ>GM8BPQ-2 Port=3 <XID R F> 2=21 3=22a480 RX Paclen=256 RX Window=7 Compress ok
BPQ>GM8BPQ-2 Port=3 <I C S1 R1> <236 Bytes of Compressed L2 Data>
with NETROM frames have a C on end of monitor header, eg MB7NPW to G8BPQ-9 ttl 21 cct=09F2
At the end of each session a line is written to syslog (Linux) or DebugView log (Windows) giving compression stats.
L4 Compression Stats G8BPQ-9 MB7NPW TX 171 133 22% RX 1157 1311 13%.
Numbers are input then output so for receive the bytes output is greater than the bytes input.