The message body structure consists of three parts:
- Request-Line / Status-Line (Request-Line / Status-Line)
- Header (message header)
- Body (text)
Example:
Request-Line / Status-Line introduction
Request-Line format:
Method | Request-URI | SIP-Version | CRLF |
INVITE | sip:[email protected]:5060 | SIP/2.0 | /r/n |
Method: Method (message name)
REGISTER | Register contact information |
INVITE | Initiate session request |
ACK | Confirmation of response to INVITE request |
CANCEL | Cancel request |
BYE | End the session |
OPTIONS | Query server capacity |
MESSAGE | IM messages are different from the above message mechanism. See https://tools.ietf.org/html/rfc3428 for details |
Request-URI: Calling party location information
SIP-Version: sip message version information
Status-Line format:
SIP-Version | Status-Code | Reason-Phrase | CRLF |
---|---|---|---|
SIP/2.0 | 200 | OK | /r/n |
Status-Code value
1xx: | Temporary response, indicating that the request message is being processed |
2xx | Successful response, indicating that the request has been successfully received, fully understood and received |
3xx | Redirect response, indicating that further steps are needed to complete the request |
4xx | Client error, means that the request message contains syntax error information or the server cannot complete the client's request |
5xx | Server error means that the server cannot legally complete the request |
6xx | Global failure means that no server can complete the request |
Example:
100 | Trying | Try call |
180 | Ringing | Ringing |
181 | Call is Being Forwarded | Call forwarding |
200 | OK | Successful response |
302 | Moved Temporarily | Temporary migration |
400 | Bad Request | Bad request |
401 | Unauthorized | unauthorized |
403 | Forbidden | Prohibit |
404 | Not Found | User does not exist |
408 | Request Timeout | Request timed out |
480 | Temporarily Unavailable | No one answered temporarily |
486 | Busy Here | Line is busy |
504 | Server Time-out | Server timeout |
600 | Busy Everywhere | All busy |
Header (message header) introduction
Example
Via: SIP/2.0/TCP user1pc.domain.com;branch=z9hG4bK776sgdkse
From: sip:[email protected];tag=49583
To: sip:[email protected]
Call-ID: [email protected]
Max-Forwards: 70
Contact: sip:192.168.100.1:1111
Content-Type: text/plain;(application/sdp; application/cpim;)
Content-Length: 18
Field description
Via | Inserted into the request by the server. Function: 1. Check the routing ring 2. Response find the way back according to via |
From | 表示主叫信息 |
To | 表示被叫信息 |
Call-ID | 由主叫生成,全局唯一,当前呼叫这个值唯一不变 |
Max-Forwards | 用于表示这个包最多可以传送多少跳,每经过一跳都会减一当Max-Forwards==0系统会返回483。默认为70 |
Contact | 包含源的URI信息,用来给响应方直接和源建立连接用 |
Content-Type | 指明消息体的类型 (SDP会话描述协议) |
Content-Length | 指明消息体的字节大小 |
Body (正文) 介绍
正文是一个SDP,SDP是一种会话描述格式,而非传输协议。
示例:
SDP格式:
参考链接:
https://www.cnblogs.com/xiaxveliang/p/12434170.html