proto_bin Module

Ionel Cerghit

OpenSIPS Solutions

Table of Contents

1. Admin Guide
1.1. Overview
1.2. Dependencies
1.2.1. OpenSIPS Modules
1.2.2. External Libraries or Applications
1.3. Exported Parameters
1.3.1. bin_port (integer)
1.3.2. bin_port_send_timeout (integer)
1.3.3. bin_max_msg_chunks (integer)
1.3.4. bin_async (integer)
1.3.5. bin_async_max_postponed_chunks (integer)
1.3.6. bin_async_local_connect_timeout (integer)
1.3.7. bin_async_local_write_timeout (integer)

List of Examples

1.1. Set bin_port parameter
1.2. Set bin_send_timeout parameter
1.3. Set bin_max_msg_chunks parameter
1.4. Set bin_async parameter
1.5. Set bin_async_max_postponed_chunks parameter
1.6. Set bin_async_local_connect_timeout parameter
1.7. Set bin_async_local_write_timeout parameter

Chapter 1. Admin Guide

1.1. Overview

The proto_bin module is a transport module which implements Binary Interface TCP-based communication. It does not handle TCP connections management, but only offers higher-level primitives to read and write BIN messages over TCP. It calls registered callback functions for every complete message received.

Once loaded, you will be able to define BIN listeners in your configuration file by adding their IP and, optionally, a listening port, similar to this example:

listen = bin: 		# change the listening IP
listen = bin:	# change the listening IP and port

1.2. Dependencies

1.2.1. OpenSIPS Modules

The following modules must be loaded before this module:

  • None.

1.2.2. External Libraries or Applications

The following libraries or applications must be installed before running OpenSIPS with this module loaded:

  • None.

1.3. Exported Parameters

1.3.1. bin_port (integer)

The default port to be used by all TCP listeners.

Default value is 5555.

Example 1.1. Set bin_port parameter

modparam("proto_bin", "bin_port", 6666)

1.3.2. bin_port_send_timeout (integer)

Time in milliseconds after a TCP connection will be closed if it is not available for blocking writing in this interval (and OpenSIPS wants to send something on it).

Default value is 100 ms.

Example 1.2. Set bin_send_timeout parameter

modparam("proto_bin", "bin_send_timeout", 200)

1.3.3. bin_max_msg_chunks (integer)

The maximum number of chunks in which a BIN message is expected to arrive via TCP. If a received packet is more fragmented than this, the connection is dropped (either the connection is very overloaded and this leads to high fragmentation - or we are the victim of an ongoing attack where the attacker is sending very fragmented traffic in order to decrease server performance).

Default value is 32.

Example 1.3. Set bin_max_msg_chunks parameter

modparam("proto_bin", "bin_max_msg_chunks", 8)

1.3.4. bin_async (integer)

Specifies whether the TCP connect and write operations should be done in an asynchronous mode (non-blocking connect and write) or not. If disabled, OpenSIPS will block and wait for TCP operations like connect and write.

Default value is 1 (enabled).

Example 1.4. Set bin_async parameter

modparam("proto_bin", "bin_async", 0)

1.3.5. bin_async_max_postponed_chunks (integer)

If bin_async is enabled, this specifies the maximum number of BIN messages that can be stashed for later/async writing. If the connection pending writes exceed this number, the connection will be marked as broken and dropped.

Default value is 32.

Example 1.5. Set bin_async_max_postponed_chunks parameter

modparam("proto_bin", "bin_async_max_postponed_chunks", 16)

1.3.6. bin_async_local_connect_timeout (integer)

If bin_async is enabled, this specifies the number of milliseconds that a connect will be tried in blocking mode (optimization). If the connect operation lasts more than this, the connect will go to async mode and will be passed to TCP MAIN for polling.

Default value is 100 ms.

Example 1.6. Set bin_async_local_connect_timeout parameter

modparam("proto_bin", "bin_async_local_connect_timeout", 200)

1.3.7. bin_async_local_write_timeout (integer)

If bin_async is enabled, this specifies the number of milliseconds that a write op will be tried in blocking mode (optimization). If the write operation lasts more than this, the write will go to async mode and will be passed to bin MAIN for polling.

Default value is 10 ms.

Example 1.7. Set bin_async_local_write_timeout parameter

modparam("proto_bin", "tcp_async_local_write_timeout", 100)