tieto / libnice

Other
3 stars 1 forks source link

TCP relay candidates get the same base address and foundation #3

Closed xhaakon closed 10 years ago

xhaakon commented 10 years ago

When I try the latest dev branch of libnice with Pidgin on a machine with multiple host IPs, I get similar list of candidates:

a=candidate:1 1 UDP 2028994815 10.222.111.6 46150 typ host 
a=candidate:1 2 UDP 2028994814 10.222.111.6 59134 typ host 
a=candidate:2 1 TCP-ACT 1013580031 10.222.111.6 0 typ host 
a=candidate:2 2 TCP-ACT 1013580030 10.222.111.6 0 typ host 
a=candidate:3 1 TCP-PASS 1013186815 10.222.111.6 55682 typ host 
a=candidate:3 2 TCP-PASS 1013186814 10.222.111.6 59546 typ host 
a=candidate:4 1 UDP 2028994815 192.168.122.1 38474 typ host 
a=candidate:4 2 UDP 2028994814 192.168.122.1 38742 typ host 
a=candidate:5 1 TCP-ACT 1013580031 192.168.122.1 0 typ host 
a=candidate:5 2 TCP-ACT 1013580030 192.168.122.1 0 typ host 
a=candidate:6 1 TCP-PASS 1013186815 192.168.122.1 60206 typ host 
a=candidate:6 2 TCP-PASS 1013186814 192.168.122.1 45360 typ host 
a=candidate:7 1 UDP 2028994815 192.168.1.30 39799 typ host 
a=candidate:7 2 UDP 2028994814 192.168.1.30 40905 typ host 
a=candidate:8 1 TCP-ACT 1013580031 192.168.1.30 0 typ host 
a=candidate:8 2 TCP-ACT 1013580030 192.168.1.30 0 typ host 
a=candidate:9 1 TCP-PASS 1013186815 192.168.1.30 45564 typ host 
a=candidate:9 2 TCP-PASS 1013186814 192.168.1.30 50900 typ host 
a=candidate:10 1 UDP 2028994815 192.168.1.2 39865 typ host 
a=candidate:10 2 UDP 2028994814 192.168.1.2 60919 typ host 
a=candidate:11 1 TCP-ACT 1013580031 192.168.1.2 0 typ host 
a=candidate:11 2 TCP-ACT 1013580030 192.168.1.2 0 typ host 
a=candidate:12 1 TCP-PASS 1013186815 192.168.1.2 60591 typ host 
a=candidate:12 2 TCP-PASS 1013186814 192.168.1.2 37112 typ host 
a=candidate:13 1 UDP 1693450495 193.179.215.99 18088 typ srflx raddr 192.168.122.1 rport 38474
a=candidate:13 2 UDP 1693450494 193.179.215.99 18089 typ srflx raddr 192.168.122.1 rport 38742
a=candidate:14 1 UDP 183501055 140.211.166.7 53227 typ relay raddr 192.168.122.1 rport 38474 
a=candidate:14 2 UDP 183501054 140.211.166.7 50543 typ relay raddr 192.168.122.1 rport 38742 
a=candidate:15 1 UDP 1693450495 193.179.215.99 18090 typ srflx raddr 192.168.1.30 rport 39799
a=candidate:15 2 UDP 1693450494 193.179.215.99 18091 typ srflx raddr 192.168.1.30 rport 40905
a=candidate:16 1 UDP 183501055 140.211.166.7 51466 typ relay raddr 192.168.1.30 rport 39799 
a=candidate:16 2 UDP 183501054 140.211.166.7 53421 typ relay raddr 192.168.1.30 rport 40905 
a=candidate:17 1 UDP 1693450495 193.179.215.99 18092 typ srflx raddr 192.168.1.2 rport 39865
a=candidate:17 2 UDP 1693450494 193.179.215.99 18093 typ srflx raddr 192.168.1.2 rport 60919
a=candidate:18 1 UDP 183501055 140.211.166.7 53207 typ relay raddr 192.168.1.2 rport 39865 
a=candidate:18 2 UDP 183501054 140.211.166.7 55431 typ relay raddr 192.168.1.2 rport 60919 
a=candidate:19 1 TCP-ACT 90833151 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:19 1 TCP-ACT 90833151 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:19 1 TCP-ACT 90833151 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:19 1 TCP-ACT 90833151 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:19 2 TCP-ACT 90833150 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:19 2 TCP-ACT 90833150 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:19 2 TCP-ACT 90833150 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:19 2 TCP-ACT 90833150 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:20 1 TCP-PASS 90439935 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:20 1 TCP-PASS 90439935 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:20 1 TCP-PASS 90439935 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:20 1 TCP-PASS 90439935 140.211.166.7 52309 typ relay raddr 192.168.1.2 rport 49988 
a=candidate:20 2 TCP-PASS 90439934 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:20 2 TCP-PASS 90439934 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:20 2 TCP-PASS 90439934 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 
a=candidate:20 2 TCP-PASS 90439934 140.211.166.7 59932 typ relay raddr 192.168.1.2 rport 49989 

Note the repeating relay candidates with foundations 19 and 20.

I guess it's because all relay candidates are given the same base address obtained by g_socket_get_local_address() in nice_tcp_bsd_socket_new(). Please tell me what do you think about my attempt to fix this problem in tcp-bsd-local-address branch, where each relay candidate gets an IP of its respective host candidate as a base address.

Feel free to adapt the patches (maybe the g_socket_bind() call is not necessary). First commit is just my additional debug message and can be ignored.

kakaroto commented 10 years ago

Thank you Jakub, that was a good catch. The g_socket_bind was necessary to make sure the TCP connection comes from the correct interface in a multi-homed PC. The only thing I changed was set the port to 0 before sending the local_address to tcp_bsd_socket_new.