Sending Messages
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)
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.
...
Note |
---|
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)
Source matches source in message
Source differs from message
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 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
Connection-less protocol with rport
Connection-less protocol without rport
2. Message is sent
Best Configuration Strategies
IPv4 Only (Single Interface)
Code Block |
---|
[system-udp] type=transport protocol=udp bind=0.0.0.0 [system-tcp] type=transport protocol=tcp bind=0.0.0.0 |
IPv4 Only (Multiple Interfaces)
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-udp6] type=transport protocol=udp bind=[2001:470:e20f:42::42] [system-tcp6] type=transport protocol=tcp bind=[2001:470:e20f:42::42] |
IPv4+IPv6 Combined (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] |
Common Issues
Changeover to TCP when sending via UDP
Sending using a transport that is not available
Code Block |
---|
Failed to send Request msg INVITE/cseq=7846 (tdta0x7fa920002e50)! err=171060 (Unsupported transport (PJSIP_EUNSUPTRANSPORT)) |