How the ICE decides whether to use STUN or TURN in order to find the public IP address of a device?
I am trying to establish connection between devices in WebRTC. The devices are behinf NAT, hence the public IP address has to be determined. I learnt that STUN is used to find the public IP of the device. But if STUN fails, then TURN server is used. I also learnt that ICE is the mechanism which handles this. I would like to know how ICE works? How it determines whether to use STUN or TURN? How does it determine failure of STUN and immediately switches to TURN?
Source: View source