SIP call flow
SIP protocol is defined in RFC3261 and use INVITE sip message to initial a call.
Here are some introduction about SIP messages:
INVITE
Caller party use to initial a call
180 Ring
Called party is in ringing state
200OK with SDP
Called party has answered the call
ACK
Caller party has received the 200OK with SDP from called party
After Called party received ACK from Caller party we can say the call is established.
Important SIP headers
Request-Line
The called party URI
Via
Indicates where to send the response to
When an Agent receive a request it will send the response for the request to the address in Via header.
From
Indicates the originator of the request
To
It is the address of record of the target of this request
Contact
Provides a URI that used to contact that specific instance of the UA for subsequent requests
For example the contact header in 200OK with sdp will be used by the Caller party to send the ACK request and this will impact the sip call establishment.
Call-ID
Use to identifies a particular invitation
User-Agent
Indicates which endpoint send this message
SDP parameters
IP PBX and IP Phone use SIP to establish calls and use SDP to negotiate the parameters of media stream (audio, video).
Here are some related parameters in SDP Media description
- m=media name, port, proto and payload
media name: audio, video
port: the port to receive media stream
proto: RTP/AVP, RTP/SAVP
RTP/AVP represents RTP
RTP/SAVP represents SRTP.
payload represents the codecs in the attribute
- c=connection information
the address to receive media stream.
- a=media attribute lines (directions: sendrecv, sendonly, recvonly, inactive)
The port in m line and IP address in c line is use to tell other peer where to send the RTP stream.
IP Address in SIP message
SIP is an application layer protocol. Means what list in the headers and SDP might not match the actual IP packet.
Below are two examples may help you understand how the IP address in sip message impact the call establishment and voice transmission.
1) PBX makes a call to extension which registers from outside network.
|
Inside |
Outside(when IP phone receive) |
Source IP & Port |
192.168.9.150 |
112.89.98.68:34232 |
IP & Port in contact header |
192.168.9.150:5060 |
192.168.9.150:5060 |
IP & Port in SDP |
192.168.9.150:4046 |
192.168.9.150:4046 |
When sip INVITE message sends out to outside network the source IP address changed but the IP address in the headers and SDP remain the same.
The c(connection type and address) parameter in SDP is the IP address used for sip entity sending RTP stream.
The m(media definitions including media type e.g.'audio', transport details and formats) parameter in SDP contains the port for sip entity sending RTP stream.
For this INVITE message is like PBX tell another side that: Please send me the audio to 192.168.9.150:4060, and send me the next request to 192.168.9.150:5060.
So the problem comes, there is no route for the device from outside network sending the voice to a private IP address.
The solution for this one way audio problem is to set NAT and INVITE will use public IP address in SDP.
2) PBX receives a call from extension which registers from outside network.
PBX will send 200OK when called party answered the call.
The contact header use private IP address when send 200OK to IP Phone.
I may cause the call hangup issue after around 30 seconds. When you analyze the pcap file with Wireshark you will see the call flow like below.
Because there is private IP address in contact header 200OK message so IP Phone will send the ACK message to there instead of the public address of PBX.
The solution for this problem is to set NAT so that 200OK contact header will use public IP address.
0 Comments