[libnice] udp ttl on windows

Emanuele Bizzarri emabiz76 at gmail.com
Thu Oct 23 06:10:43 PDT 2014


Hi,
I use libnice inside a webrtc windows application in order to 
communicate (mainly) with chrome, using udp.
Since chrome 38 was released, I noticed a strange behaviour when the 
application is over internet.
Very often chrome stop sending data.
The reason signalled inside webrtc-internals is:

ICEConnectionStateDisconnected

I've implemented  the content of nice_debug (agent-priv.h), in order to 
have a log:
static __inline void nice_debug (const char *fmt, ...) {
     FILE *ofp;
     va_list argptr;
     time_t mytime;
     char s[1000];
     struct tm * p;
     SYSTEMTIME t;

     ofp = fopen("nice.log", "a");

     if (ofp){
         va_start(argptr, fmt);

         GetSystemTime(&t);
         fprintf(ofp,"%02d:%02d:%02d.%03d: ",t.wHour, t.wMinute, 
t.wSecond, t.wMilliseconds);

         vfprintf(ofp, fmt, argptr);
         fprintf(ofp, "\n");
         va_end(argptr);
         fclose(ofp);

     }


}

I discovered that systematically I got this condition:
...
10:08:44.982: component_io_cb: 021C9010: received -1 valid messages with 
0 bytes
10:08:45.063: ema g_socket_receive_message Error receiving message: The 
connection has been broken due to keep-alive activity detecting a 
failure while the operation was in progress.: 0
10:08:45.063: agent_recv_message_unlocked: Received -1 valid messages of 
length 0 from base socket 021C8248.
10:08:45.063: Agent 021C9010: agent_recv_message_unlocked returned -1, 
errno (0) : No error
10:08:45.063: component_io_cb: 021C9010: received -2 valid messages with 
0 bytes
10:08:45.063: component_io_cb: error receiving message
10:08:45.142: Agent 021C9010 :STUN transaction retransmitted (timeout 
397ms).
10:08:45.142: Agent 021C9010 :STUN transaction retransmitted (timeout 
393ms).
10:08:45.542: Agent 021C9010 :STUN transaction retransmitted (timeout 
798ms).
10:08:45.542: Agent 021C9010 :STUN transaction retransmitted (timeout 
794ms).
10:08:45.822: Agent 021C9010 : timer tick #51: 0 frozen, 2 in-progress, 
0 waiting, 1 succeeded, 0 discovered, 1 nominated, 0 waiting-for-nom.
10:08:46.342: Agent 021C9010 : Retransmissions failed, giving up on 
connectivity check 021E00D8
10:08:46.342: Agent 021C9010 : pair 021E00D8 state FAILED
10:08:46.342: Agent 021C9010 : Retransmissions failed, giving up on 
connectivity check 021DFB10
...

I found that this kind of error is related to ttl settings.
The default value on my windows machine is 128.

Inside nice_udp_bsd_socket_new (udp-bsd.c) I've modified the ttl settings:

...
/* GSocket: All socket file descriptors are set to be close-on-exec. */
   g_socket_set_blocking (gsock, false);
   //ema
   ttl=g_socket_get_ttl(gsock);
   nice_debug ("ema g_socket_get_ttl before: %d", ttl);
   g_socket_set_ttl(gsock,255);
   ttl=g_socket_get_ttl(gsock);
   nice_debug ("ema g_socket_get_ttl after: %d", ttl);
...

ttl is of guint type.

With this modification I have no more problems.
I don't know the reason why I got this error because I think that the 
default value 128 should be enough.
Also maybe the patch has to be applied in other points of your code.
Maybe it could be better if you expose an API to configure ttl. I 
didn't' find a way to do it.

I'm using libnice 0.1.7, but I get the same error using the new 0.1.8.

I hope that this report will be useful for someone else.
Please tell me if you want that I make other test in order to understand 
this kind of problem.


Thank you,
Emanuele





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/nice/attachments/20141023/673dfaeb/attachment.html>


More information about the nice mailing list