Message Compression


SmartSockets allows messages to be compressed before they are sent. There are three ways to compress a message:

Compression and decompression of messages is CPU time intensive, and should only be used when:

The compression library provided by SmartSockets is ZLIB (version 1.1.4). ZLIB is a general-purpose data compression library that provides in-memory compression and decompression, including integrity checks of the decompressed data. For more information on ZLIB, see the official ZLIB website, at http://www.gzip.org/zlib/.

To read a compressed message, the receiver must use the same compression library as was used to compress the message. If a message consumer receives a compressed message that it cannot decompress, usually through a TipcMsgNext* function call, the function fails with error:

Compressing by Message Type

Message type compression allows you to specify that any message of a particular type, such as all STRING_DATA messages, be compressed before it is sent to RTserver. Only the SmartSockets message payload, or user-data, is compressed.

The message is not decompressed until the first attempt is made to access the payload. In other words, the message remains compressed until the message receiver attempts to read the message. RTserver does not decompress the message; compression and decompression only takes place end-to-end, not at every hop.

If compression is enabled for a message but SmartSockets cannot load the compression library, it prints a warning and sends the message uncompressed.

Compression does not always result in a smaller payload. When compression yields a larger payload, SmartSockets prints a warning and sends the message uncompressed.

Enable or disable message type compression with the function TipcMtSetCompression. When compression is set, you can change the compression level with the Compression_Args option. For more information on TipcMtSetCompression, see the TIBCO SmartSockets Application Programming Interface.

Compressing a Single Message

You can always override the default message type compression setting for a given message with the function TipcMsgSetCompression. If compression for a message type is enabled but you wish to send a message uncompressed, use TipcMsgSetCompression to change the compression setting for that message only.

For more information on TipcMsgSetCompression, see the TIBCO SmartSockets Application Programming Interface.

Compressing at the Connection Level

Connection level compression causes all data sent across a connection (peer-to-peer, RTclient-RTserver, or RTserver-RTserver) to be compressed at the sender and decompressed at the receiver. Connection level compression is only available on point-to-point connections such as TCP, and is not available for PGM.

Connection level compression, as implemented by ZLIB, builds a rich dictionary and, over time, achieves higher compression ratios. The more messages you send over a connection, the better compression becomes. With connection level compression, the message header and payload are both compressed, and messages are decompressed at every hop.

Connection level compression is enabled with the SmartSockets Compression option. You can configure the compression setting by using an extended logical connection name (LCN), and with the options Compression_Args, Compression_Name, and Compression_Stats. Both sides of the connection must have the same Compression and Compression_Name option values in order for a connection to be made.

Using the Logical Connection Name

Connection level compression can be fully enabled and configured with SmartSockets options. However, you can also change compression settings with an extended logical connection name (LCN). Compression settings given in the LCN override options settings. For example, you can use the Compression option to enable compression across all connections by default, then use an extended LCN to disable compression for a specific connection.

LCNs are described in more detail in Logical Connection Names and also in Logical Connection Names for RT Processes.

This section describes only the extended portion that is used to configure connection level compression.

The extended logical connection name has the form:

protocol:node:address[?name=value[&name=value]] 

where:

protocol
is the IPC protocol type
node
is a computer node name
address
is a protocol-specific IPC location, such as a TCP port number
name
represents the connection property to be set. Properties that configure connection level compression are:
  • compression — enables or disables compression for the connection. If this property is omitted, the compression setting defined by the SmartSockets Compression option is used.
  • compression_name — specifies the compression library to use. If this property is omitted then the compression name defined by the SmartSockets Compression_Name option is used.
  • compression_args — lists the arguments to pass to the compression library. If this property is omitted then the compression arguments defined by the SmartSockets Compression_Args option is used.
value
is the value assigned to the connection property. Supported values for connection level compression properties are:
  • if name is compression, use TRUE to enable compression; FALSE otherwise.
  • if name is compression_name, use ZLIB. The compression library provided by SmartSockets is ZLIB.
  • if name is compression_args, the value is determined by the compression library. For the ZLIB compression library, this is an integer value from 1 to 9.

If no compression settings are specified in the LCN, SmartSockets compression is determined by the Compression option. By default, compression is disabled. Including the compression=true property in the LCN enables compression for the connection. This is an example of enabling compression for one of two connections in the RTserver:

setopt Conn_Names tcp:_node:5998, tcp:_node:5999?compression=true 

You can also disable compression for a connection:

setopt Compression true 
setopt Conn_Names tcp:_node:5998?compression=false, tcp:_node:5999 

Both sides of the connection must have the same compression and compression_name property values in order for a connection to be made.


TIBCO SmartSockets™ User’s Guide
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com