App Config (TCP/UDP)

Overview

Serveral Application types implement UDP or TCP/SCTP connectivity based on the TcpApp base class. In addition to the common Application configuration parameters and their application-specific attributes, all of these Applications typically require UDP/TCP/SCTP configuration as indicated here.

<?xml version="1.0" encoding="utf-8"?>
<n2svcd>
  ...
  <applications>
    ...
    <application name="(name)" module="(module)">
      <include><lib>/path/to/library</lib></include>
      <parameters>
        <!-- application-specific parameters -->
        ...
        <!-- TCP/UDP application parameters (server example) -->
        <parameter name="listen_queue" value="20"/>
        <parameter name="local_hosts" value="192.168.10.10"/>
        <parameter name="local_port" value="8118"/>
        <parameter name="local_timeout" value="5"/>
        ...
        <!-- TCP/UDP application parameters (client example, identical) -->
        <parameter name="num_client_connections" value="5"/>
        <parameter name="local_hosts" value="192.168.10.10"/>
        <parameter name="remote_hosts" value="192.168.10.44"/>
        <parameter name="remote_port" value="8080"/>
        <parameter name="reconnect_interval" value="60"/>
        <parameter name="backlog_timeout" value="2"/>
        <parameter name="server_timeout" value="5"/>
        ...
        <!-- TCP application parameters (client example, disparate) -->
        <parameter name="local_hosts" value="192.168.10.10"/>
        <parameter name="remote_hosts" value="prod-prim.telco.com"/>
        <parameter name="reconnect_interval" value="60"/>
        <parameter name="backlog_timeout" value="2"/>
        <parameter name="server_timeout" value="5"/>
        ...
        <!-- SSL configuration for a simple SSL-encrypted server -->
        <parameter name="ssl" value="yes"/>
        <parameter name="ssl.SSL_cert_file" value="../etc/ssl/localhost.crt"/>
        <parameter name="ssl.SSL_key_file" value="../etc/ssl/localhost.key"/>
        ...
        <!-- SSL configuration for a simple SSL-encrypted client using self-generated CA -->
        <parameter name="ssl" value="yes"/>
        <parameter name="ssl.SSL_ca_file" value="../etc/ssl/localhost.crt"/>
      </parameters>
      <config>
        <client_connections>
          <client_connection remote_port="8080"/>
          <client_connection remote_port="8081"/>
          <client_connection remote_port="8082"/>
          <client_connection remote_port="8080"
            remote_hosts="prod-sec.telco.com" local_hosts="192.168.11.10" priority="2"/>
        </client_connections>
      </config>     
    </application>
    ...
  </application>
  ...
</n2svcd>

The following applications are UDP-only. They bind to a local UDP port and use that to send and receive messages via UDP datagrams.

The following applications are TCP/SCTP server-mode only. They accept inbound socket requests.

The following applications are TCP/SCTP client-mode only. They perform outbound socket connects.

The following applications are TCP/SCTP and can support either client-mode or server-mode (but not mixed).

Applications which can operate in either mode will use the socket_mode parameter to specify if this configuration is for either the TCP/SCTP server or TCP/SCTP client mode. They may not use both at once.

Note that the terms “client” and “server” in this context apply purely to the TCP/SCTP establishment mode at the socket level, i.e. a “client” will perform a socket “connect” and a “server” will perform a socket “listen”/“accept”.

This does not relate to the mechanism for sending the high-level messaging. For example, a DiameterApp may act as a “client” at the socket level, but then may act as a “server” in the sense that it accepts and processes inbound Diameter Requests and returns Diameter response.

Configuration Details

The application element attributes for all TCP Application instances are as below. For details of the various parameter types used, refer to Common Configuration.

Parameter Name Type XML Type Description
parameters Array Element [Required] As per Common Configuration Application parameters.
"socket_mode" String Attribute This must be either listen (TCP/SCTP Server) or connect (TCP/SCTP Client).
This applies only for applications which support TCP/SCTP. It does not apply for UDP-only applications.
(Default = connect if supported, or listen)
"stream_proto" TCP / SCTP Attribute Specify which stream protocol will be used for all connections in this application. It is not possible to mix TCP and SCTP connections within a configuration application.
This applies only for applications which support TCP/SCTP. It does not apply for UDP-only applications.
(Default = TCP)
"listen_queue" Integer Attribute TCP Server only.
Backlog of pending accepts on the listen socket when socket_mode is listen.
This value may need to be increased when operating under heavy load.
(Default = 10)
"local_hosts" /
"local_host"
String Attribute TCP/SCTP Server or TCP/SCTP Client.
Local Host Names or A.B.C.D IPv4 Addresses for the TCP/SCTP server listen or TCP/SCTP client connection.
For TCP only one entry is permitted. For SCTP, multiple local bind hosts may be specified.
(Default = 0.0.0.0, all addresses)
"local_port" Positive Integer Attribute TCP/SCTP Server or TCP/SCTP Client.
Local IPv4 Port Number.
Using this option in TCP/SCTP Client mode will cause a port confict if num_client_connections is > 1.
(Default = application-specific or determined by OS TCP layer, generally a system-allocated ephemeral port)
"remote_hosts" /
"remote_host"
String Attribute TCP/SCTP Client only.
Remote Host Names or A.B.C.D IPv4 Addresses to connect to.
For TCP only one entry is permitted. For SCTP, multiple remote connect hosts may be specified.
[Required] for TCP/SCTP Client unless using the client_connections configuration.
"remote_port" Positive Integer Attribute TCP/SCTP Client only.
IPv4 Port Number to connect to.
[Required] for TCP Client unless using the client_connections configuration.
"default_udp_so_rcvbuf" / "default_so_rcvbuf" Positive Integer Attribute The default value to apply for Socket Option so_rcvbuf for new UDP sockets.
(Default = The default operating-system-configured settings apply)
"default_udp_so_sndbuf" / "default_so_sndbuf" Positive Integer Attribute The default value to apply for Socket Option so_sndbuf for new UDP sockets.
(Default = The default operating-system-configured settings apply)
"default_tcp_so_rcvbuf" / "default_so_rcvbuf" Positive Integer Attribute The default value to apply for Socket Option so_rcvbuf for new TCP connections.
This value will be applied to both client and server TCP socket connections.
(Default = The default operating-system-configured settings apply)
"default_tcp_so_sndbuf" / "default_so_sndbuf" Positive Integer Attribute The default value to apply for Socket Option so_sndbuf for new TCP connections.
This value will be applied to both client and server TCP socket connections.
(Default = The default operating-system-configured settings apply)
"default_tcp_nodelay" Boolean Attribute Set to a "true" value to enable TCP No-Delay by default on TCP our TCP endpoint sockets.
This value will be applied to both client and server TCP socket connections.
(Default = The default operating-system-configured settings apply)
"default_sctp_sndrcv_buffer" Positive Integer Attribute The default value to apply for SCTP Socket Option sndrcv_buffer for new connections.
This value will be applied to both client and server SCTP socket connections.
(Default = The default operating-system-configured settings apply)
"ssl" Boolean Attribute TCP/SCTP Client or TCP/SCTP Server.
Set to a "true" value for the Application to apply SSL/TLS all client and server connections.
SSL is not supported for UDP sockets.
(Default = false)
"ssl.SSL_verify_mode" 0 / 1 Attribute TCP/SCTP Client or TCP/SCTP Server.
Whether the Application should verify the Peer's certificate.
1 (Verify Server's Certificate) or 0 (Do not verify Server's Certificate).
Not supported for UDP.
(Server Default = 0, Client Default = 1)
"ssl.SSL_ca_file" String Attribute TCP/SCTP Client or TCP/SCTP Server.
Use the Certificate Authority certificates contained in the indicated file.
Not supported for UDP.
(Default = Use system default Certificate Authorities)
"ssl.SSL_ca_path" String Attribute TCP/SCTP Client or TCP/SCTP Server.
Use all Certificate Authority files contained in the indicated directory.
Multiple directories may be delimited by the : character.
Not supported for UDP.
(Default = Use system default Certificate Authorities)
"ssl.SSL_cert_file" String Attribute TCP/SCTP Client or TCP/SCTP Server.
Use the certificate contained in this file.
Not supported for UDP.
(Server Default = Use system default certificate, Client Default = Do not present a certificate)
"ssl.SSL_key_file" String Attribute TCP/SCTP Client or TCP/SCTP Server.
Use the key contained in this file.
Not supported for UDP.
(Server Default = Use system default key, Client Default = Do not use a key file)
"ssl.SSL_server_name" String Attribute TCP Client.
Include a Server Name Indication (SNI) extension with this value in the SSL/TLS ClientHello message.
Not supported for UDP.
(Default = Do not include an SNI extension in the SSL/TLS ClientHello message.)
"num_client_connections" Positive Integer Attribute TCP Client only.
Number of simultaneous TCP client connections opened when socket_mode = connect.
(Default = 1)
"connection_backlog" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Number of in-progress requests to allow on a connection when sending.
(Default = 10)
"backlog_timeout" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Number of seconds to wait for a free connection before abandoning the request.
(Default = 10)
"server_timeout" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Number of seconds to wait on a submitted request before abandoning the request.
Note that timeout checking is only performed every half-second.
(Default = 20)
"local_timeout" Positive Integer Attribute TCP Server only.
Number of seconds to wait for internal processing to complete before abandoning the request and returning an error to the client.
Note that timeout checking is only performed every half-second.
(Default = 5)
"reconnect_interval" Positive Integer Attribute TCP Client only.
Time in seconds between attempts to re-connect a failed connection.
(Default = 5)
"ping_interval" Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Time in seconds between sending the Application's protocol-specific ping message to check each connection.
Note that not all applications support sending pings; this value will be ignored if so. A ping_interval of zero will disable ping connection checks.
(Default = 0)
"ping_always" Boolean Attribute TCP/SCTP Client or TCP/SCTP Server.
Whether the Application's protocol-specific ping message should always be sent, even when the connection is active with user messages.
(Default = false, send ping only when inactive)
"max_send_attempts" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Maximum number of attempts for sending each request. This includes the original attempt, plus none or more retries.
A value of 1 means do not retry messages on failed connections.
(Default = 2)
"warning_queue_above" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Generate a warning if the number of backlog unqueued requests rises to this value.
(Default = 20)
"notice_queue_below" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
Generate a notice if the number of backlog unqueued requests falls below this value.
(Default = 15)
"report_queue_warning_period" Positive Integer Attribute TCP/SCTP Client or TCP/SCTP Server.
The number of seconds between reporting on the queue warning state.
(Default = 30)
config Object Element TCP/SCTP Client or TCP/SCTP Server.
This is a container for extended configuration for the LogicApp.
.client_connections Array of client_connection Objects Element TCP/SCTP Client or TCP/SCTP Server.
Defines the configured static Client Connections for this App.
This mechanism is used when the client connections are NOT identical within an application, for example when a single TCP Client application is connecting to more than one different remote port and/or remote host.
.client_connection Object Element Defines a single TCP Client connection.

TCP Client Connection

In the simplest case, a TCP Client application will create a single client connection, or will create multiple identical client connections. In that case the parameters mechanism will suffice.

However, there are cases where an TCP Client application wishes to connect to disparate remote hosts and/or ports. In this case the config.client_connections element must be configured to define two or more client_connection elements.

A client_connection entry within the config.client_connections element of a TCP Client application has the following attributes:

Parameter Name Type XML Type Description
.local_hosts / .local_host String Attribute TCP/SCTP Server or TCP/SCTP Client.
Local Host Names or A.B.C.D IPv4 Addresses for the explicit TCP/SCTP client connection.
For TCP only one entry is permitted. For SCTP, multiple local bind hosts may be specified.
(Default = the parameters application default)
.local_port Positive Integer Attribute TCP Server or TCP Client.
Local IPv4 Port Number.
Using this option in TCP Client mode will cause a port confict if num_client_connections is > 1.
(Default = the parameters application default)
.remote_hosts / .remote_host String Attribute TCP/SCTP Client only.
Remote Host Names or A.B.C.D IPv4 Addresses to connect to.
For TCP only one entry is permitted. For SCTP, multiple remote connect hosts may be specified.
(Default = the parameters application default)
.remote_port Positive Integer Attribute TCP Client only.
IPv4 Port Number to connect to.
(Default = the parameters application default)
.priority Integer 1 - 99 Attribute The priority of this connection compared to the other connections within this application.
This is an integer value from 1 (top priority) to 99 (lowest priority).
The use of this "priority" for connection selection will vary from application to application. Some applications (particularly those which use transient TCP connections) may ignore this priority value.
(Default = 1 best priority)

Note that the num_client_connections parameter is incompatible with config.client_connections.

Some applications (e.g. FoxApp) may also have the option to load TCP client connection information from other sources, e.g. from a database.