Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Section
Column

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 Handling

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. If a "sips" URI scheme is used an automatic switchover to TLS will occur.

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 in pjsip.conf 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.

Column
Panel
titleOn this Page

Table of Contents
maxLevel2

...

Before the message is sent out the transport the routing table is queried to determine what interface it will be going out on.

...

Local source interface IP address matches source IP address in message

The message is left untouched and passed to the transport.

...

Local source interface IP address differs from source IP address in 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.

...


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 in URI of the topmost Via header

The first configured transport matching the transport type and address family of the URI in the topmost Via header is selected.

Connection-less protocol with rport in URI of the topmost Via header

The transport the request is received on is used as the transport for the response.

Connection-less protocol without rport in URI of the topmost Via header

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

...

Configure a transport for each interface. The default transport will be the first one you choosespecified in the configuration file.

 

Code Block
[system-internet-udp]
type=transport
protocol=udp
bind=5.5.5.5


[system-internet-tcp]
type=transport
protocol=tcp
bind=5.5.5.5


[system-local-udp]
type=transport
protocol=udp
bind=192.168.1.1


[system-udp-tcp]
type=transport
protocol=tcp
bind=192.168.1.1

 

IPv6 Only (Single Interface)

...

 

Code Block
[system-udp]
type=transport
protocol=udp
bind=192.168.1.1


[system-tcp]
type=transport
protocol=tcp
bind=192.168.1.1


[system-udp6]
type=transport
protocol=udp
bind=[2001:470:e20f:42::42]


[system-tcp6]
type=transport
protocol=tcp
bind=[2001:470:e20f:42::42]

 

Warning

It might be tempting to use a wildcard IPv6 address to bind a single transport to allow both IPv6 and IPv4. In this configuration IPv6 mapped IPv4 addresses will be used which is unsupported by PJSIP. This will cause a parsing failure.

Common Issues

Changeover to TCP when sending via UDP

...