WebRTC: Introduction to data transmission related agreements

Network protocol, it usually needs to be done on two things: 1, the connection is established, 2, transmission of data, WebRTC is no exception.

Assuming that both ends of the WebRTC application has established a connection, then the rest is the problem of how to transmit the data.

WebRTC support both audio and video data transmission, custom application data. Among these, involving a variety of protocols, including UDP, RTP / SRTP, RTCP / SRTCP, DTLS, SCTP.

These agreements name is quite similar, very confusing, a brief summary follows:

  1. Related audio and video data transmission protocols: UDP, DTLS, RTP / SRTCP;
  2. Transfer data related to custom application protocols: UDP, DTLS, SCTP;

Here's a brief introduction, these agreements is what to do, what difference there is any contact.

Encryption channel establishment: UDP, DTLS

For WebRTC application, whether it is audio and video data, data or custom applications, require transmission channel based encryption. DTLS somewhat similar to the TLS, on the basis of UDP, encryption channel.

DTLS main purpose is to allow both parties communicate key used to encrypt and decrypt data.

  1. Communicating parties: by DTLS handshake negotiation to generate a pair of keys;
  2. Sender: encrypting data;
  3. Sender: the encrypted data over UDP;
  4. The recipient: decrypting the encrypted data;

Audio and video data transmission: RTP / SRTP, RTCP / SRTCP

First, let's look at the RTP, RTCP probably use:

  1. RTP (Realtime Transport Protocol): Real-time Transport Protocol, is mainly used to transmit real-time data requirements are relatively high, such as audio and video data.
  2. RTCP (RTP Trasport Control Protocol): RTP transmission control protocol, defined in the same with a RTP RFC mainly used to monitor the quality of data transmission, the data transmission side and give feedback.

In other words:

  1. RTP is used to transmit audio and video data;
  2. RTCP is used to transmit (by mass) of control data; such as transmission quality monitoring, and synchronization between both sessions, WebRTC facilitate dynamically adjusted based on the quality of the transmission, such as transmission rate, code rate, etc. video.

As for SRTP, SRTCP, respectively, on the basis of RTP, RTCP on added a S (Secure), represents the meaning of security, this is the thing to do a DTLS.

Combined with the previous contents, summarize the process of sending audio and video data:

  1. Communicating parties: by DTLS handshake negotiation to generate a pair of keys;
  2. Data sender: audio and video data is encapsulated into RTP packets, RTCP control data packet encapsulated;
  3. Data sender: using the encryption key, an RTP packet, the RTCP packet is encrypted, to generate SRTP packet, packet SRTCP;
  4. Data sender: SRTP packets are transmitted via UDP, SRTCP packet;

Note: SRTP / SRTCP package, in addition to data encryption, as well as additional information, not to proceed with the details here.

Custom application data transfer: SCTP

SCTP (Stream Control Transmission Protocol): Stream Control Transmission Protocol.

Introduced before, RTP / RTCP is mainly used to transmit audio and video, is designed to stream media. For custom application data transmission, WebRTC using the SCTP protocol.

Similarly, the encrypted channel dependent on the SCTP DTLS established custom applications for data transmission process is as follows:

  1. Communicating parties: by DTLS handshake negotiation to generate a pair of keys;
  2. Data sender: custom application data, encrypted by the key generating SCTP packet;
  3. Data sender: SCTP over UDP packet;

Written on the back

For ease of explanation, skipped a lot of the details of the agreement, some places might not rigorous enough, interested students can conduct further research, such as the following questions:

  1. Transport layer with the UDP, UDP itself is not reliable, then the audio and video data, from a user-defined data timing, is how to ensure the quality?
  2. RTP is used to transmit audio and video data, why the need for RTCP?
  3. Why not suitable for transmission RTP custom user data?
  4. How SCTP balance between efficiency and mass transfer from the protocol level? How efficient transfer of custom data?
  5. other

Related Links

RTP: A Transport Protocol for Real-Time Applications
https://tools.ietf.org/html/rfc3550

Stream Control Transmission Protocol
https://tools.ietf.org/html/rfc4960

Datagram Transport Layer Security
https://tools.ietf.org/html/rfc4347

Guess you like

Origin www.cnblogs.com/chyingp/p/11198874.html