I've been working on debugging a live feed issue that originates from multiple regions.
Setup: Our current setup is as follows:
1. The presenter can be located anywhere in the world and relay the media via chrome.
2. Our media servers, which store the media, are located in the Mumbai region. We're currently using Kurento for the same. Kurento provides building blocks such as WebRTC and RTP senders & receivers, audio/video mixers, media recording, and more.
3. Our turn servers(coturn) are located in the Singapore region. TURN servers are required in WebRTC to facilitate communication between peers when direct peer-to-peer connections are not possible or restricted due to network configurations such as firewalls, or symmetric NAT traversal issues.
Tests: Media Server is in Mumbai region and Turnserver is in Singapore region.
1. Presenter is in Sao Paulo BRAZIL.
2. Presenter is in Bangalore, India
3. Presenter is in Morristown NJ, US
Test Result: After conducting above 3 tests, I have observed the following results:
1. Presenters located in India(Test2) and the US(Test3) have established the direct connections with the media servers in the Mumbai region.
2. Despite the ability of presenters in Brazil to establish direct connections with the Media servers in the Mumbai region, the media traffic was flowing through the TURN server located in the Singapore region.
3. In my latency tests for Brazil, I found that the ping latency was lower for the media servers in the Mumbai region compared to the TURN servers in the Singapore region.
Observations:
1. In tests ran from US/India region, I found that no prflx candidates are available at all during the ice pair selection process. I checked the pairs in chrome://webrtc-internals.
2. In tests ran from Brazil region, I've seen that the turn servers are coming as prflx candidates and relay candidates and it has higher ICE candidate pair priority(turnserver as prflx) as well in comparison to the direct connection pair(Presenter and Media Servers).
Question:
1. Why do we always get a prflx (peer reflexive) candidate for the Brazil presenter, but none from India or the US in the same setup? Under what scenarios do we get prflx candidates? I have checked the ice pair selection process in chrome://webrtc-internals and can provide a screenshot if needed. I read the relevant spec as well and understand that these are discovered during the connectivity checks.
2. How is the ICE candidate priority calculated? I have examined the priority formula and attempted to understand the implementation(point 3), but I couldn't pinpoint the main factors that affect the final priority. The ICE specifications mention three main parameters: topological awareness(is it related to network topology?), security(what specific conditions), and the use of media intermediaries. Can someone explain or direct me to documentation that discusses these parameters in detail?
3. In webrtc
implementation, I came across the formula(GetPriority) for ICE
candidate priority, but I have limited understanding.
local_preference
= ((network_adapter_preference << 8) | addr_pref) + relay_preference
Can someone help me out in understanding the factors affecting this parameter(network_adapter_preference) in
simpler terms? There could be lot of factors that might be affecting this. I
just want to know what primary factors are considered in the
calculation.
4. Is there any better way to know about these scenarios(Brazil - Test1) or if we could filter out the prflx candidate?
Let me know if there's any confusion or more information is required from my end.