I am trying to build a online Chess game application that uses WebRTC for the 2 players to talk with. I found that OnIceCandidate was fired 4 times and thus 4 ICEs (or candidates?) are generated. This post says mulitple firing is okay. My question is, should the other player get all ICEs? Or certain ICE or any is good enough?
{'sdpMid': 'sdparta_0', 'sdpMLineIndex': 0, 'candidate': 'candidate:0
1 UDP 2122121471 1.2.3.121 57386 typ host'}
{'sdpMid': 'sdparta_0', 'sdpMLineIndex': 0, 'candidate': 'candidate:2
1 UDP 2122187007 1.2.3.112 57387 typ host'}
{'sdpMid': 'sdparta_0', 'sdpMLineIndex': 0, 'candidate': 'candidate:4
1 UDP 2122055935 192.168.56.1 57388 typ host'}
{'sdpMid': 'sdparta_0', 'sdpMLineIndex': 0, 'candidate': 'candidate:6
1 UDP 2122252543 2002:824a:1479::824a:1479 57389 typ host'}
{'sdpMid': 'sdparta_0', 'sdpMLineIndex': 0, 'candidate': 'candidate:3
1 UDP 1685987327 192.231.71.2 57387 typ srflx raddr 10.88.33.112 rport
57387'}
My question is, should the other player get all ICEs? Or certain ICE or any is good enough?
Other player should get all the candidates to perform the ICE negotiation.
Related
I wrote a simple code for testing RTCPeerconnection
peer = new RTCPeerconnection(...);
peer.onicecandidate = function(evt){
console.log(evt.candidate);
// into the console
// RTCIceCandidate {candidate: "candidate:... 1 udp ", sdpMLineIndex:0, sdpMid:"data"}
// RTCIceCandidate {candidate: "candidate:... 2 udp ", sdpMLineIndex:0, sdpMid:"data"}
}
i want send it to signaling server but i receive it 2 times and 2 different values.
Have i to record all candidate values?
When i receive candidate information from signaling server, have i to receive all the values about the same peer?
I have too, localDescription
// {type: "offer", sdp: "v=0↵o=- 6483...48 2 IN IP4 ...}
Have i to send it to signaling server and receive the description of other peer?
I think you need to do bit more reading up on WebRTC, for a single PeerConnection, there could be many ICE candidates, you usually send it to remote peer through some signaling server, no point storing it in server, as they probably expire after a period of time.
this and this might be good place to read up on the basics.
I went to chrome://webrtc-internals/ to copy the sdp. Overall, I'd like to understand the meaning.
setRemoteDescription
type: answer, sdp: v=0
o=mozilla...THIS_IS_SDPARTA-39.0 6618245136742574887 0 IN IP4 0.0.0.0
s=-
t=0 0
a=fingerprint:sha-256 27:8B:F6:1A:72:47:17:2B:23:C1:9A:85:AB:3A:E0:29:15:B9:F5:B0:B6:EA:17:C9:11:99:AA:B7:AB:45:A9:60
a=ice-options:trickle
a=msid-semantic:WMS *
m=application 9 DTLS/SCTP 5000
c=IN IP4 0.0.0.0
a=sendrecv
a=ice-pwd:a33017ce6eae687d1afdae61c9f0db55
a=ice-ufrag:f8acf035
a=mid:data
a=sctpmap:5000 webrtc-datachannel 256
a=setup:active
Specifically, I'd like the understand the meaning of
a=sctpmap:5000 webrtc-datachannel 256
The format of the sctpmap attribute is defined as:
The sctpmap attribute maps from a port number (as used in an "m="
line) to an encoding name denoting the payload format to be used on
top of the SCTP association or the actual protocol running on top of
it.
The sctpmap MUST include the app parameter indicating the application
running on top of the association.
The sctpmap line should also contain the max-message-size parameter
indicating the maximum message size, in bytes, the endpoint is
willing to accept.
So the line a=sctpmap:5000 webrtc-datachannel 256 Is indicating port 5000, an application name of 'webrtc-datachannel' and a message size of 256 bytes.
This is in your generated SDP because your application is making use of datachannels on your PeerConnection.
In ICE protocol, What is Base?
I understood Base as, for the server reflexive candidate , host candidate is the base, is it correct or not?
How to find the foundation of the candidate?
You are correct. According RFC5245 :
Base: The base of a server reflexive candidate is the host candidate
from which it was derived. A host candidate is also said to have a
base, equal to that candidate itself. Similarly, the base of a
relayed candidate is that candidate itself.
The foundation is an arbitrary value. You can find it for each ICE candidates in the SDP. It is the first value after candidate:
For example
a=candidate:1174096638 1 udp 2122194687 10.191.1.117 57105 typ host generation 0
a=candidate:2999745851 1 udp 2122129151 192.168.59.1 57106 typ host generation 0
Foundations are
1174096638
2999745851
I've found out that when I send an UDP datagram that gets fragmented (over 1452 bytes with MTU=1500), according to tcpdump, all the fragments are received on the target machine but then no message is received on the socket. This happens only with IPv6 addresses (both global and link-local), with IPv4 everything works as expected (and with non-fragmented datagrams as well).
As the datagram is discarded, there is this ICMP6 message:
05:10:59.887920 IP6 (hlim 64, next-header ICMPv6 (58) payload length: 69) 2620:52:0:105f::ffff:74 > 2620:52:0:105f::ffff:7b: [icmp6 sum ok] ICMP6, destination unreachable, length 69, unreachable port[|icmp6]
There's some repeated neighbour solicitation/advertisements going on and I see that it gets to the ARP cache (via ip neigh).
One minute later I get another ICMP6 messages saying that the fragment has timeout out.
What's wrong with the settings? The reassembled packet should not be discarded, when it can be delivered, right?
System is RHEL6 2.6.32-358.11.1.el6.x86_64
I use C# program for client UDP application. Application listens for a connection, and then communicates.
Socket udpClient = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
udpClient.Bind(new IPEndPoint(IPAddress.Any, ListenPort));
udpClient.Blocking = true;
int count = 0;
while (count == 0) udpClient.ReceiveFrom(receiveBuffer, ref ePoint);
udpClient.SendTo(data, endPoint);
udpClient.ReceiveFrom(receiveBuffer, ref ep);
...
I use Wireshark to debug the application. The problem is that after sometime my application starts sending malformed STUN packets, and I think that because of that they get rejected by a router on the internet.
The question: is it possible to prevent sending malformed UDP/STUN packets?
When your application sends malformed UDP packets, it has a bug. The minimal fragment of your code has only one SendTo call. You can add a check function for the content/length of data.
BTW: UDP is connectionless. I would say, your application waits for a request or a kind of start command not for a connection.