[libnice] how does libnice keep a connection alive

Philip Withnall philip at tecnocode.co.uk
Mon Sep 28 15:19:04 PDT 2015

On Fri, 2015-09-25 at 08:02 -0700, Tom Chen wrote:
> Philip,
> 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()?

Yup, if you want to use TURN (which is necessary for being able to
guarantee connectivity).

> 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.

I know other pieces of software have got around this by creating a
local loopback socket for their SIP stack, then splicing the listening
end of that socket to nice_agent_[send|receive]_messages().

Isn’t networking fun? :-)


> 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
> Hey,
> 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_agent_receive_messages().
> Philip
> _______________________________________________ nice mailing list
> nice at lists.freedesktop.org 
> http://lists.freedesktop.org/mailman/listinfo/nice
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: This is a digitally signed message part
URL: <http://lists.freedesktop.org/archives/nice/attachments/20150928/e28b3c91/attachment.sig>

More information about the nice mailing list