[libnice] how does libnice keep a connection alive

Tom Chen chentom60 at hotmail.com
Fri Sep 25 08:02:11 PDT 2015

Thank you for the reply! you are always willing to help others.

"You must send all packets through it", do you mean that upper level packets, like media stream data, must be sent through ICE transmission functions like nice_agent_send()?

I always thought that ICE is to find the optimal path to the remote clients and once the path has been found, ice will give up the connection  or use some ways to duplicate its  socket for others, like media streams, to use. If so, i may have to drastically change our software architecture as our current SIP stack needs ip, port numbers to create socket itself, that is why i am asking how we can bind two sockets to the same ip & port number if ICE continues to hold them.


From: philip at tecnocode.co.uk
To: nice at lists.freedesktop.org
Date: Thu, 24 Sep 2015 23:54:21 +0100
Subject: Re: [libnice] how does libnice keep a connection alive

On Tue, 2015-09-22 at 21:36 -0700, tom chen wrote:
> I am very new to ICE, I am confused how libnice keep alive the
> selected IP and port number? I am wondering if libnice creates a
> socket using the local candidate’s port number, binds with the
> candidates’s IP address, then use the socket to periodically send
> some commands to keep the connection alive. If so, since the
> candidates’ IP address and port number have been used by libnice
> refreshing thread, how can we create a socket to use that candidate’s
> IP & port to transport media stream?
There is a whole section on this in the ICE specification (RFC 5245,
¡×10): https://tools.ietf.org/html/rfc5245#section-10
Basically, if you¡¯re using ICE over UDP, all your data is wrapped in
the STUN protocol, which means libnice can send no-op STUN binding
messages as keepalives.
This works because to use libnice, you must send all your packets
through it, using nice_agent_send_messages_nonblocking() and

nice mailing list
nice at lists.freedesktop.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/nice/attachments/20150925/efef62aa/attachment.html>

More information about the nice mailing list