Hi guys, I will share a document about SIP packet. I'm glad you can see it. If you have any suggestions or comments, please give me your feedback.
l Request Message For example
The following is an example of encoding a SIP request:
INVITE tel:+8675580008881 SIP/2.0
From: <sip:+867556659991@ims.hw.com>;tag=1ccb6df3
To: <sip:99500002@ims.hw.com;user=phone>
CSeq: 1 INVITE
Call-ID: 20973e49f7c52937fc6be224f9e52543@ats9900.ats.ims.hw.com
Via: SIP/2.0/UDP 222.222.222.51:5061;branch=z9hG4bKliv0vdlwdrrydvgrpix0pgx0w
Contact: <sip:+867556659991@ 222.222.222.51:5060>
Supported: 100rel
Max-Forwards:70
Allow:INVITE,ACK,CANCEL,OPTIONS,BYE,REGISTER,PRACK,INFO,UPDATE,SUBSCRIBE,
NOTIFY,MESSAGE,REFER
Content-Length:230
Content-Type: application/sdp
v=0
o=HwATS9900 1073741831 1073741831 IN IP4 222.222.222.51
s=Sip Call
c=IN IP4 191.222.222.3
t=0 0
m=audio 10002 RTP/AVP 8 0 4 18
a=rtpmap:8 PCMA/8000
a=rtpmap 0 PCMU/8000
a=rtpmap 4 G723/8000
a=rtpmap 18 G729/8000
First line: request start line. INVITE request. Request URI, that is, the current address of the invited user is tel:+8675580008881, and the SIP version is 2.0.
Second line: From field. Specifies that the address of the request initiator is < sip:+867556659991@ ims.hw.com > and 1ccb6df3 is used to distinguish users who share the same SIP address from each other when they use the same Call-ID to initiate call invitations.
Line 3: To field. The address of the request receiver is < sip:99500002@ims.hw.com;user=phone >.
Line 4: Cseq field. Associates the INVITE request with the corresponding response, ACK, and CANCEL request.
Line 5: Call-ID field. This field uniquely identifies a specific invitation. Call-ID is 20973e49f7c52937fc6be224f9e52543@ ats9900.ats.ims.hw.com, ats9900.ats.ims.hw.com is the domain name of the host that initiates the call, and 20973e49f7c52937fc6be224f9e52543 is the local ID.
Line 6: Via field. This field indicates the path that the request traverses. SIP/2.0/UDP: indicates the protocol for sending packets. The protocol name is SIP, the protocol version is 2.0, and the transport layer is UDP. 222.222.222.551:5061: The IP address of the originating ATS is 222.222.222.51 and the port number is 5061. branch=z9hG4bkbc427dad6: indicates the branch parameter. When the IMS distributes requests in parallel, each branch is marked.
Line 7: Contact field. Indicates that subsequent requests (such as BYE requests) can be directly sent to the < sip:+867556659991@ 222.222.222.51:5060> without using the Via field.
Line 8:100rel extension. This field provides a mechanism for reliable transmission of response messages of the 100 type.
Line 9: Max-Forwards. Indicates that the maximum number of transit stations that the request can pass through to the destination address is 70.
Line 10: Allow field. Lists the request types supported by the device whose IP address is 222.2222.222.51.
Line 11 to line 12: Content-Length, indicating that the message length is 230 bytes.
Line 13: Content-Type, indicating that the message body is a single message body and is SDP.
The fourteenth line is empty, indicating that the following SDP session description is displayed.
Line 15: SDP version number. Currently, the value is 0.
Line 16: session owner/creator and session ID, which provides the session initiator (user name and host address), session ID, and session version. HwATS9900 is the user name. The user name is the login name of the subscriber on the originating host. If the host does not support the concept of the subscriber ID, this field is marked with a hyphen (-). The first 1073741831 is the session ID, which is a numeric string, the multi-tuple (user name, session ID, network type, address type, and address) forms a globally unique identifier for a session. The second 1073741831 indicates the version number of the session bulletin. The proxy server checks which of several announcements of the same session is the latest one. The basic requirement is that the version number increases after the session data is modified. IN indicates the network type, which is a text string. Currently, IN is Internet. IP4 indicates the address type, which is a text string. Currently, IP4 and IP6 are defined. 222.2222.222.51: IP address of the host where the session is created. For an IP4 address, the value can be a full domain name or an IP4 address in dotted decimal notation. For an IP6 address, the value can be a full domain name or a compressed text IP6 address.
Line seventeen: session name. Each session description must have one and only one session name.
Line 18: connection data. Currently, the values of Network Type and Address Type are only IN and IP4. 191.222.222.3 is the IP address of the terminal controlled by the ATS (IP address: 222.222.222.51).
Line nineteen: Time description, which provides the time range for session activation. Sessions can be periodically generated. 0 indicates the start time. The format of this field is t:. The start time and end time are the decimal values of the Network Time Protocol (NTP) time, in seconds.
Line 20: media-level description, which provides information only applicable to the media stream. audio: indicates that the media type is audio. Currently, there are five media types: audio, video, application, data, and control. 10002 indicates the transport layer port to which media streams are sent, that is, the UDP port number of the terminal. RTP/AVP indicates the transport layer protocol. Its value depends on the address type in the "c" line. For IP4, most media service flows are transmitted over RTP/UDP. The following two protocols are defined: RTP/AVP and audio/video application documents are transmitted over UDP. UDP: indicates the UDP protocol. For audio and video, "8 0 4 18" is the media payload type defined in the RTP audio/video application document. Indicates that all of these formats may be used in a session, but the first format is the default format for the session. For details, see RFC 2327.
This line indicates that the default A-law PCM-encoded single-channel audio signal is 8 in the RTP audio/video application document and is sent to UDP port 10002.
Lines 21 to 24: rtpmap attribute line, indicating the mapping from the RTP payload type to the code. The format of this line is a: rtpmap:///. where < encoding parameter > indicates the number of audio channels. There is no encoding parameter for video signals.
2 Response Message For example
The following is an example of encoding a SIP response:
SIP/2.0 180 Ringing
From: <sip:+867556659991@ ims.hw.com>;tag=1ccb6df3
To: <sip:99500002@ims.hw.com;user=phone>;tag=58877b85
Cseq:1 INVITE
Call-ID: 20973e49f7c52937fc6be224f9e52543@ats9900.ats.ims.hw.com
Via: SIP/2.0/UDP 222.222.222.51:5061;branch=z9hG4bkbc427dad6
Require:100rel
RSeq:1
Contact:< sip:+867556659991@ 222.222.222.51:5060;transport=udp>
Content-Length:157
Content-Type:application/sdp
v=0
o= HwATS9900 1073741824 1073741824 IN IP4 222.222.222.51
s=Sip Call
c=IN IP4 191.222.222.3
t=0 0
m=audio 30016 RTP/AVP 8
a=rtpmap:8 PCMA/8000
The first line indicates the SIP protocol. The version number is 2.0. The status code is 180. Ringing is a comment phrase. Indicates that the called party is alerted.
Second and third lines: For details, see section "SIP Request Type."
Line 4: Cseq field. Associates the INVITE request with the corresponding response, ACK, and CANCEL request. The Cseq field in the response message is the same as that in the preceding request message, that is, both are "1 INVITE", indicating that the response message is triggered by the preceding request message.
Lines 5 to 11: See section "SIP Request Type."
Line 12: blank line, indicating that the following SDP session description is displayed.
Line 13: SDP version number. Currently, the value is 0.
Line 14: session owner/creator and session ID, which are used to provide the session initiator (user name and host address), session ID, and session version number. HwATS9900 is the user name. The user name is the login name of the subscriber on the originating host. If the host does not support the concept of the subscriber ID, this field is marked with a hyphen (-). The first 1073741824 is the session ID, which is a numeric string, the multi-tuple (user name, session ID, network type, address type, and address) forms a globally unique identifier for a session. The second 1073741824 indicates the version number of the session bulletin. The proxy server checks which of several announcements of the same session is the latest one. The basic requirement is that the version number increases after the session data is modified. IN indicates the network type, which is a text string. Currently, IN is Internet. IP4 indicates the address type, which is a text string. Currently, IP4 and IP6 are defined. 222.2222.222.51: IP address of the host where the session is created.
Line 15: session name. Each session description must have one and only one session name.
Line sixteen: connection data. Currently, the values of Network Type and Address Type are only IN and IP4. 191.222.222.3 is the IP address of the terminal controlled by the ATS (IP address: 222.222.222.51).
Line 17: Time description, which provides the time range for session activation. Sessions can be periodically generated.
Line 18: media-level description, which provides information only applicable to the media stream. audio: indicates that the media type is audio. 30016 indicates the transport layer port to which media streams are sent, that is, the UDP port number of the terminal. RTP/AVP indicates the transport layer protocol. Its value depends on the address type in the "c" line. For IP4, most media service flows are transmitted over RTP/UDP. The following two protocols are defined: RTP/AVP and audio/video application documents are transmitted over UDP. UDP: indicates the UDP protocol. 8 indicates the media payload type defined in the RTP audio/video application document.
Line nineteen: rtpmap attribute line, indicating the mapping from the RTP payload type to the code. The code corresponding to the RTP payload type 8 is PCMA.