当前位置:网站首页>Technology sharing | anyrtc service single port design
Technology sharing | anyrtc service single port design
2022-06-30 15:05:00 【anyRTC】
Conventional CDN such as RTMP live broadcast , Is based on tcp Service for , There is no case of too many ports ; and RTC Most services use udp port , such Udp The model has many advantages , But compared to RTMP The single port of the live broadcast server goes around the world ,RTC The service needs to open hundreds of ports, which is a little embarrassing .
RTC Most of them are udp Communications , Many ports need to be opened during interworking , One sound / The video channel needs to open multiple channels , If it is a multi person audio and video call, more ports need to be opened . It is a great waste of port resources , Some firewalls limit the number of udp The opening of ports . If you want to deploy on the server , The development of multi ports will cause great inconvenience to the operation and maintenance .
Some people would say , There's nothing wrong with opening multiple ports , There is no problem in using it in the actual scene . Indeed, there is no problem with multiport itself , Safe to use , We just propose an optimization scheme on this basis .
What are the disadvantages of so many ports ?
1) Many network exit firewalls can pass through UDP Ports are limited .
2) For the server, open up so many ports , Security itself has some problems , It's easy to be scanned by hackers to attack , Especially my classmates , Even more refuse .
3) Open up so many ports in Server carry carefully , Port overhead and performance have a certain impact .
4) Industry specific requirements , Especially finance 、 Public security and other industries with particularly high security requirements , Multi port is not acceptable .
How to reduce RTC Use of ports in services , Can you even just use 1 There are two ports ?
So far, there are many mature strategies to reduce port use :
1)Rtp/Rtcp Scheme of multiplexing ports Rtcp-mux.
2) Audio and video Boundle, You can reuse the audio and video connection channel .
3) Multiplexed stream with single connection plan b and unified plan programme ;PS:WebRTC Of M89 The version is officially abandoned plan b, all WebRTC Standards have shifted unified plan.
These strategies are constantly reducing the use of ports , But even if all of the above strategies are turned on , A single user still needs to occupy at least one port , If one RTC The server should serve 500 Users , It's about to open 500 Ports .
How to realize single port , Because we need to know some technical points , In this way, the idea will be clearer :
1)SDP offer and answer Internally configured ice-ufrag The content in the field ,STUN Binding Request Inside USERNAME The field is from the top Offer and answer Of ice-ufrag The content is spliced , This is used as stun Packet authentication , Therefore, it can be used as a logo for us .
2) send out STUN Binding Request Client local udp socket, And ice Sending media data after successful connection establishment udp socket Is the same , So for the server , Client's ip port Is the same .

Let's look at the implementation details :
1) From the server to the client SDP Answer Set in ice-ufrag The only in this service ID, among ID It can be designed as the content allocated by the business layer , It can also be used to distinguish between each pair of calls and participants . Go ahead and do Ice candidate negotiation , The client starts to do connectivity detection , That is to say stun binding request Inside USERNAME by SDP local and remote Of ice-ufrag Specify content .
2) Server received stun binding request The client of ip And port , And normal return stun binding response.
3) The server records the mapping relationship between the client address and the user's information .
4) The server received a rtp/rtcp Media packets , Through the source of the package ip And port , Query the mapping table to identify which connected stream the package belongs to .
In this way, a single port mode can be realized RTC service , Very simple . Here's another tip for closing the pit , In the real world , The client's network is prone to change , For example, cell phones wifi Switch to 4/5G The Internet , At this time, the external exit of the mobile phone ip The port has changed , It needs to be updated on the server in time , Otherwise, a black screen will appear .

边栏推荐
- 数控加工中心打刀缸工作原理及故障处理
- How many questions can you answer for the interview of Mechanical Engineer?
- CCF command line options (Full Score code + problem solving ideas + skill summary) March 3, 2014
- Binary rotation array (2)
- 1132: stone scissors cloth
- Invalid argument during startup: Failed to open the . conf file: redis-window
- Component communication mode
- Color classification of sorting
- IO interview questions
- CCF date calculation (Full Score code + skill summary) February 2, 2015
猜你喜欢
![[extensive reading of papers] multimodal attribute extraction](/img/ec/546c107ac0d31deded7ca94fdf0e2d.jpg)
[extensive reading of papers] multimodal attribute extraction

2021-07-14 mybaitsplus

How to realize selective screen recording for EV screen recording

Shangpinhui knowledge points of large e-commerce projects

Sum of CCF digits (full mark code + problem solving idea) 201512-1

Zero basic C language learning notes -- first introduction -- 2 data types & variables and constants

Knowledge learned from the water resources institute project

CCF date calculation (Full Score code + skill summary) February 2, 2015

Matlab judge palindrome number (only numbers)

CCF Z-scan (full mark code + problem solving ideas) 201412-2
随机推荐
浅析卧式加工中心上不规则台阶孔存在问题
Minimum covering substring of two pointers
ES6 notes
文本匹配——【NAACL 2021】AugSBERT
Detailed explanation of settimeout() and setinterval()
Matlab function for limit, definite integral, first-order derivative, second-order derivative (classic examples)
先锋期货安全么?现在期货开户都是哪些流程?期货手续费怎么降低?
1031 Hello world for u (20 points)
Svn password forgetting solution
O - ACM contest and blackout (minimum spanning tree, Kruskal)
1134: Legal C identifier query
Tetris source code (color version)
Binary rotation array (1)
HD mechanical principle · classic dynamic drawing of mechanical design
In situ merging of two arrays with two pointers
Win10 one click Reset win10 to solve all system bugs without deleting any files and Applications
1030 travel plan (30 points)
Matlab to find prime pairs within 100
高精度CNC加工中心为什么会出现误差?这4个原因你要注意!
高清机械原理 · 机械设计经典动图