[Nice] Making sense of it all...
Youness Alaoui
youness.alaoui at collabora.co.uk
Thu Aug 19 17:38:52 PDT 2010
On 08/19/2010 08:03 PM, Tony Di Croce wrote:
> Ok, let me see if I have this right.
>
> In a typical "chat" client setup, you might have 2 clients that initally
> open tcp connections to a central server somewhere. Now, if one of those
> clients wants to open a direct connection to the other it can use a STUN
> server to learn about it's own public facing IP... It then sends its
> public facing IP address information to the server, who forwards it to
> the other client. The other client responds by sending a message to the
> first client (which is blocked by his nat, but it serves to open up his
> own nat for a direct connection).. The first client then can connect
> directly... Is this correct?
Yes, it's pretty much correct.. the slight difference I would say is that both
clients would use STUN to get their own public IP, then both clients would send
messages to the other side in order to establish a connection.. with ICE, you
create a bidirectional link, and each ice agent (each client) is independent and
works in pretty much the same way. There is no 'initiator' or 'sender'..
(although there is a 'controller' and a 'controlled' agent, but that's a bit
different).
>
> If the above is more or less correct, I have some more questions. In the
> above scenario, the first client sends some information that it got
> about itself from a stun server to the central server who then forwards
> it to the other client.
yes
> I would expect, then, to see a way to provide
> that information to libnice, so that the two clients can begin
> negotiating the best connection method...
libnice is the one that will do the STUN requests, so you don't need to do it
yourself, and you don't need to give the result to libnice.
All you need to do is set the 'stun-server' and 'stun-server-port' properties on
the NiceAgent object :
http://nice.freedesktop.org/libnice/NiceAgent.html#NiceAgent--stun-server
Then libnice will do the STUN mechanism when you call the
nice_agent_gather_candidates() method
> In fact, I would think you
> would need a libnice method for acquiring stun information about
> yourself (prefereably, in some pre serialized form) and another method
> for providing that information about the other client... Do these
> methods exists, or am I just fundamentally wrong?
Yes, you tell libnice to acquire that information by calling
nice_agent_gather_candidates() and once you get the 'candidate-gathering-done'
signal, you can fetch all the candidates libnice found by calling
nice_agent_get_local_candidates().
And for the other client, you simply call nice_agent_set_remote_candidates().
>
> I saw the simple example in the agent documentation. One thing that
> confuses me: where does it specify the IP of the stun server?
Yes, it's because it's a 'simple example', it doesn't contain *everything*.
But I'm sure you could have found your answer if you searched for 'stun' in that
page.
>
> Thanks in advance btw! I volunteer to write some documentation (if you'd
> like) once I understand all this... :)
Yes, the API reference documentation is good I think (I wrote it:p) but there
really isn't some sort of guide or tutorial, and I'm not really sure I'm
qualified to write one because I already understand it all, so having a fresh
look from someone with no experience with libnice would be nice because you
would be able to explain things that newcomers might be confused about, and that
I wouldn't even think about explaining.
So yes, we would appreciate it if someone write some documentation for libnice.
p.s.: don't forget to keep the mailing list CC-ed in the discussion. Others
might learn from it, or might want to help you further.
Youness.
>
> td
>
> On Thu, Aug 19, 2010 at 4:26 PM, Youness Alaoui
> <youness.alaoui at collabora.co.uk <mailto:youness.alaoui at collabora.co.uk>>
> wrote:
>
> Hi Tony,
>
> I think you're misunderstanding how this all works. The STUN server
> doesn't act
> as a relay, all it does is let you punch a hole in your router's
> NAT, so when
> you receive packets from the peer, it gets through.
> You might want to have a look at my presentation for last year's
> GUADEC :
> http://people.collabora.co.uk/~kakaroto/libnice-talk-gcds2009.pdf
> <http://people.collabora.co.uk/%7Ekakaroto/libnice-talk-gcds2009.pdf>
> It doesn't explain everything, but you can probably follow up on
> what it all
> means. Unfortunately, the video of my talk is missing, so I can't
> show you that.
>
> About having the simplest example, look at the documentation of
> libnice, there
> is an example code on the description section of the NiceAgent :
> http://nice.freedesktop.org/libnice/NiceAgent.html#NiceAgent.description
>
> Youness.
>
> On 08/19/2010 05:39 PM, Tony Di Croce wrote:
> > I'm just getting started in learning about libnice and Stun and
> > everything and I have what I believe is a simple question.
> >
> > How does the stun server know who I am talking about?
> >
> > For example, if I know that an endpoint is connected to a particular
> > stun server, how do I query that stun server for that endpoint? Do
> > endpoints register some kind of name with the stun server?
> >
> > Also, are there any simple examples? A useful example would be the
> > worlds simplest chat client.. If such a thing doesn't exist, I'll
> > volunteer to write it once I know what I'm doing! Thanks in
> advance for
> > any help.
> >
> > td
> >
> >
> >
> > _______________________________________________
> > Nice mailing list
> > Nice at lists.freedesktop.org <mailto: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: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freedesktop.org/archives/nice/attachments/20100819/1edbaedd/attachment.pgp>
More information about the Nice
mailing list