Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

Sending Messages


The process by which an underlying transport is chosen for sending of a message is broken up into different steps depending on the type of message.

SIP Request

1. URI Parsing

 The PJSIP stack fundamentally acts on URIs. When sending to a URI it is parsed into the various parts (user, host, port, user parameters). For the purposes of transport selection the transport parameter is examined. This specifies the type of transport. If this parameter is not present it is assumed to be UDP. This is important because it is used in DNS resolution.

 

2. DNS SRV Resolution (If host portion is not an IP address)

The transport type from above is used to determine which SRV record to look up. This means that the original URI *must* include the transport type for TCP and TLS types.

3a. Transport Selection (No explicit transport provided)

Now that the underlying type of transport is known and the resolved target exists the transport selection process can begin.

 Connection-less protocols (such as UDP)

 The first configured transport matching the transport type and address family is selected.

 Connection-oriented protocols (such as TCP or TLS)

 An already open connection to the resolved IP address and port is searched for. If the connection exists it is reused for the request.
If no connection exists the first configured transport matching the transport type and address family is selected. It is instructed to establish a new connection to the resolved IP address and port.
 


3b. Transport Selection (Explicit transport provided)

Connection-less protocols (such as UDP)

The provided transport is used.

 
Connection-oriented protocols (such as TCP or TLS) 

The provided transport is instructed to establish a new connection to the resolved IP address and port.


Icon

This does NOT currently attempt to reuse any existing connections. A new one will always be created. This is an issue being tracked under issue ASTERISK-22658.


4. Multihomed Transport Selection (Connection-less protocols)

Before the message is sent out the transport the routing table is queried to determine what interface it will be going out on.
Source matches source in message
The message is left untouched and passed to the transport.
 
Source differs from message
The message contents are updated with the different source address information.

 

If a transport is bound to the new source address the outgoing transport for the message is changed to it.

5. Message is sent


The message is provided to the transport and it is instructed to send it.

SIP Response


1. Transport Selection

Connection-oriented protocols (such as TCP or TLS)
If the connection the request was received on is still open it is used to send the response.

If no connection exists or the connection is no longer open the first configured transport matching the transport type and address family is selected. It is instructed to establish a new connection to the destination IP address and port.
Connection-less protocol with maddr
The first configured transport matching the transport type and address family is selected.
Connection-less protocol with rport
The transport the request is received on is used as the transport for the response.
Connection-less protocol without rport
The first configured transport matching the transport type and address family is selected.

2. Message is sent

The message is provided to the selected transport and it is instructed to send it.

 

Best Configuration Strategies

IPv4 Only (Single Interface)

Configure a wildcard transport:

 

 

IPv4 Only (Multiple Interfaces)

Configure a transport for each interface. The default transport will be the first one you choose.

 

 

IPv6 Only (Single Interface)

Configure a transport with the IPv6 address.

 

 

IPv4+IPv6 Combined (Single Interface)

Configure two transports, one with the IPv4 address and one with the IPv6 address.

 

 

Common Issues

Changeover to TCP when sending via UDP

If you turn the "disable_tcp_switch" option off in the pjsip.conf system section it is possible for an automatic switch to TCP to occur when sending a large message out using UDP. If your system has not been configured with a TCP transport this will fail. The sending of the message may also fail if the remote side is not listening on TCP.

Sending using a transport that is not available

If a transport can not be found during the transport selection process you will receive a warning message:

 

 

This can occur due to using a transport type (such as TCP) or address family when a transport meeting the requirements does not exist.

 

  • No labels