SIP (Session Initiation Protocol) beginning to understand

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/weixin_43608153/article/details/90677006

At work, often in contact with the transmission of audio and video streams, so sort out some common agreement on the audio and video transmission. The first and most simple sip protocol to the number of the application layer.

SIP (Session Initiation Protocol)
SIP, which is a text-based application-layer control protocol for creating, modifying and releasing one or more participants in the session. It is applied broadly, it can be said that there exists an IP network of local SIP protocol. Our company is mainly used in audio and video data transmission.

sip mainly consists of four parts:

  1. SIP user agent
    user agent, end-user devices, it simply is the device used by the user, the device and the user agent server interaction.
  2. SIP registrar server
    SIP registration server is a database of all users of the domain that contains the proxy position. In the SIP communication, these servers will be retrieved each other's IP address and other relevant information, and sends it to the SIP proxy server.
  3. SIP proxy server
    SIP proxy server accepts session requests and queries SIP UA SIP registration server to obtain the recipient UA address information. It then forwards the session invitation message directly to the recipient UA (if it is in the same domain) or proxy server (if UA is located in another domain).
  4. SIP Redirect Server
    SIP redirect server allows SIP proxy server SIP session invite message directed to the external domain. SIP redirect server can be registered with the SIP server and SIP proxy server on the same hardware.

The figure below is the process of two user places a call through dialogue sip service.
Here Insert Picture Description

  1. 1 user sends a session message to the proxy server, indicating that the user wants to find 2
  2. Proxy server does not have information of the user 2, that can not find the user 2, request help from the registration server, look for user 2
  3. After the registration server by a registered user of the message used to find information 2 is returned to the proxy server, the proxy server at this time with the user 1 and user information 2
  4. The proxy server sends a message to the user 2,
  5. 2 in response to a user request to the proxy server
  6. Proxy server response to a call request of the user 1,
  7. Because users 1 and 2 can not be direct dialogue, dialogue can only be through a proxy server, so steps 1 through 6 that is both in the process of interaction. When completed steps 1-6, users 1 and 2 can know each other's location, will be able to dialogue alone, and no longer rely on a proxy server messenger.

SIP protocol is a Client / Sever protocol, two types of SIP messages: request and response messages. Request message is a message of the SIP client to activate a given operation to the server side.

Common SIP request message is as follows:

  1. INVITE: is the calling user initiates a session request, invite other users to join a session. It can also be used after call setup for updating a session (INVITE yet the case Re-invite).
  2. ACK: The client to the server confirmed that it has received a final response to an INVITE request.
  3. PRACK: 1xx response message indicates an acknowledgment request message.
  4. BYE: it means the end of a call has been established.
  5. CANCEL: cancel the request expressed before receiving a final response to the request, there was no effect on the request has been completed.
  6. REGISTER: means that the client registered address information is listed in the To field to the SIP server.
  7. OPTIONS: indicates that the associated information and queries the called party.

In the process of using the sip server, each message in the process often run into some code, here are some common interactions result code, we can familiarize yourself with:

100 test calls (the Trying)
180 [Ringing (a Ringing)
181 is call forwarding (Call Being Forwarded IS)
200 is successful response (the OK)
302 temporary migration (Moved Temporarily The)
400 Bad Request (the Request of Bad)
401 Unauthorized (Unauthorized The)
403 prohibited (Forbidden)
404 user does not exist (not Found)
408 request timeout (the request the timeout)
480 temporarily no answer (temporarily The Unavailable Papers with)
486 line is busy (the busy Here)
504 server timeout (the timeout server)
600 are busy (busy Everywhere )

For sip service, I just used in data transmission of audio and video interactive, practical application, nvr send video stream to the server, the process of establishing a video stream on the first sip to use the service. Then be adp protocol interaction, eventually sending the video stream. Video streaming to achieve the object of the specified address.

Guess you like

Origin blog.csdn.net/weixin_43608153/article/details/90677006
sip