Overview of ICE for WebRTC
When ICE is started, each side gathers local candidates for each socket. A candidate is an IP address and port pair that a remote endpoint might use to send data to the socket. These can be gathered by querying local network interfaces, contacting STUN servers, or other methods. Once the local candidates are gathered, they are sent to the remote end through an established communication channel, usually a websocket. After the candidates are exchanged, each endpoint begins testing the candidates it received from the other side. This is done by sending a simple request to the IP address and port and listening for a response. If the expected response is received, the check for that candidate has succeeded. Eventually, both ends must agree on which candidates will be used for communication. Once this agreement is reached, the communication session can be started.