当前位置:网站首页>Audio and video learning (III) -- SIP protocol

Audio and video learning (III) -- SIP protocol

2022-06-26 15:32:00 But the sky is cold_ Good autumn

1. Concept

SIP agreement Full name “ Session initiation protocol ”, It belongs to the application layer control protocol . It specifies the standard for interactive communication between the terminals of one or more participants , can establish 、 Modify and disconnect the connection to realize video 、 voice 、 im etc. , stay OSI The model is located in the session layer , As shown in the figure below :

 Insert picture description here

  What kind of agreement is it ?

  • SIP It's a Based on text Application layer control protocol , Strictly speaking, it belongs to the conversation layer , Used to create 、 Modify and release the session of one or more participants . These conversations can be Internet Multimedia Conference 、IP Telephone or multimedia distribution . The participants of the session can use multicast (multicast)、 Mesh unicast (unicast) Or a mixture of both ;
  • SIP It's a kind of signaling protocols , For initial 、 management 、 Terminate voice and video conferencing on the network , Specifically, it is used to generate 、 Modify and terminate the session between one or more participants ;
  • SIP yes Point to point protocol ;
  • SIP The terminal of the protocol can be PC machine 、 Intercom terminal 、 Mobile phones with specific software installed 、 Flat 、 Customized devices such as web pages or voice robots . Mainly used for instant messaging ;
  • SIP It is a kind of from the Internet IP Voice session control protocol , Have flexibility 、 Easy to implement 、 Easy to expand ;
  • It's an application layer protocol , Work with other application layer protocols , adopt Internet Control multimedia communication session ;
  • SIP With the reservation agreement responsible for voice quality (RSVP) interoperability . It also works with several other protocols , Including lightweight directory access protocol for location (LDAP)、 The Remote Authentication Dial in user service responsible for authentication (RADIUS) And responsible for real-time transmission RTP Waiting for multiple agreements ;

2. function

  • User positioning :SIP In the protocol, the called party can move in different positions , When the caller user requests to establish a session with the called party , towards SIP The server sends a request to find the user's location ;
  • User effectiveness : There can be more than one session participant , After receiving the call request , You can voluntarily choose whether to participate in the session ;
  • User capability description : The requesting party is at SDP Describes which media data or session parameters it supports ;
  • Establish a conversation : When a user sends a session request , After some necessary media parameters have been described clearly , The called party user accepts the request , And according to... In the request information SDP Description to configure , Need to send “Ringing" A ringing message establishes a session ;
  • session management : add to 、 Modify media stream parameters or other parameters ; Keep the conversation waiting 、 Activate a session and terminate an existing session .

3. Message type

SIP Protocol messages are text-based protocols , The standard message starts with a line 、 Message header and message body , It is divided into request message and response message , The difference is whether the starting line of the message contains status information .SIP The request message defines 6 Methods :

  • REGISTER register :UAC Tell the location of the registration server itself at startup
  • INVITE The invitation :UA Initiate session invitation
  • ACK: After receiving the invitation, the called party , Respond 200 or 180 confirm ,ACK Indicates that the caller has received a confirmation message , Session successfully established
  • CANCEL: The called party cancels the session invitation of the calling party
  • BYE: One of the session participants wants to exit the successfully established session , launch BYE news
  • OPTIONS: Query the capacity and load of the proxy server

The response message is 6 Kind of , Including temporary response 、 The request is successful 、 Location exception notification 、 Request failure notification 、 Server failure or global error .

SIP The protocol supports message extension , Message type 、 Both the message header and the message body can be expanded , Such as the following situations

  • Integrate telephone signaling into sip In the news , To solve the problems of public switched telephone network and sip Network and interconnection ;
  • Solve cross domain firewall and NAT Communication problems ;
  • refer Event expansion , Support call forwarding ;

4. Main components

  • End user equipment UA: For creation and management SIP Protocol session device ;
  • Location server : Record and manage UA Location information for ;
  • Register the server  : To determine where the user is ,UA The terminal registers with a registration server , The registration server will assign a specific address to the terminal UA , The address has a life cycle ,UA The registration status needs to be refreshed regularly to keep alive ;
  • proxy server : Accept UA Session request and query the registration server , Get recipient UA Address information for . then , It forwards the session invitation information directly to the recipient UA( In the same domain ) Or proxy server (UA In another domain ). According to the processing method of the request, it is divided into stateful proxy server and stateless proxy server , Stateless proxy servers only deliver simple messages , The stateful proxy server will retain the relevant information of the received request and response , Used to process subsequent messages related to this message . Manage the whole life cycle of messages by creating a transaction state machine , Each is handled by the transaction state machine , Until the transaction is complete ;
  • Redirecting servers : After receiving the request, query the location information of the requester , Then create a location list in the reply message. Please return this information , allow SIP The proxy server will SIP The protocol session invitation information is directed to the external domain ;

5. Standard agreement

SIP The protocol is designed to be very simple , Has a limited set of commands . It is also text-based , So anyone can read in SIP Passed between endpoints in a session SIP news .

SIP Our standard protocols are IETF To formulate the , therefore SIP All the standard protocols are passed through RFCXXXX The way to publish , Each agreement sets out some SIP Characteristics of :

  • RFC3261:SIP The basic agreement of , Defined SIP Basic functions of , Characteristics, etc. . We need to SIP Words , This agreement cannot be ignored . Someone on the Internet has translated it into Chinese , Combined with the original English agreement , It should be easier to understand .
  • RFC3262:SIP in , How to locate the server . There is not much research on this , General SIP The protocol stack can support , Just let them do it .
  • RFC3265: Event notification mechanism , Some event monitoring can be carried out through this protocol .
  • RFC3515: Call forwarding .
  • RFC3666: And PSTN Description of some features when connecting .
  • RFC3911: adopt Join To conduct the meeting .

6. Implementation mechanism

SIP Is a layered protocol , Its behavior is described by a set of equal and independent processing stages , There is a loose coupling relationship between each stage .

 Insert picture description here

 

  • SIP The lowest level of is its syntax and coding . Its encoding uses an extended background - Noel form Syntax (BNF) Appoint .
  • The second layer is the transport layer . It defines how the client sends requests and receives responses , And how the server receives requests and sends responses over the network . all SIP The elements contain the transport layer .
  • Next is the trading floor . Transactions are client transactions ( Using the transport layer ) Requests sent to server transactions , And all responses to the request sent back to the client from the server transaction . User agent client (UAC) Any task completed is performed using a series of transactions . Stateless agents do not contain a transaction layer .
  • The layer above the transaction layer is called the transaction user . Except for stateless agents , Every SIP Entities are transaction users .

7. Conversation process

SIP The agreement is the same as HTTP The protocol is similar and adopts some of the same design principles, such as client UAC/ Server side UAS Model , The active initiating requester is UAC End , The receiving end is UAS End , The integrity of a request is called a transaction , End with one or more responses , Multiple temporary responses can be supported in the middle , In the process UAC and UAS Your roles are interchangeable , As in a call transaction A Make a call ,A yes UAC, The other end is UAS; Who hangs up first at the end of the call is UAC, The other end is UAS.

SIP By agreement INVITE request , With SIP URL The method of means to initiate , With BYE Request to end . There are three ways according to different network structures : Two UA Call directly between 、 Call through proxy server and call through redirection .SIP Generally, the following protocols need to be used to complete the communication at one time :

  • SDP: Session name 、 Conversation time 、 Which one? IP port 、 Types of multimedia supported by session participants 、 Transport protocol type 、 Encoding and decoding algorithm and other information
  • RTP: Real time transmission protocol
  • RTCP: Real time transmission control protocol , and RTP Control protocol for working together
  • TLS: Provide security and integrity protection

7.1 One to one call

Session creation process without proxy server , Direct realization SIP Message initiation and response process .

7.2  Call... Through a proxy server

7.3  By redirecting the call

UAC It's really UAS After the address , The subsequent communication process is the same as the one-to-one call process .

stay 200 OK In the transmission process, if the opposite end does not receive after timeout , Then it means that the lost message needs to be sent again , until UAS received ACK request , Ensure the complete completion of reliable transmission .

原网站

版权声明
本文为[But the sky is cold_ Good autumn]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/177/202206261514160886.html