[Nice] Starting with libnice

Youness Alaoui youness.alaoui at collabora.co.uk
Fri Nov 4 07:03:46 PDT 2011


Hi again Tiago,

For the remote candidates, you will need a third party server to exchange that
information, usually the candidates would be sent over SIP or XMPP for example.
ICE cannot work if you don't have a third party server with which you can
reliably exchange candidates. For testing purposes you could have it print the
candidates to stdout, and you could copy/paste that into stdin of the other
instance and have it parse the input.. or you could hardcode a port to connect
to and do the candidate exchange.. there's no easy way of doing that though.
You cannot hardcode the candidates because the port used will be random
everytime, also, you will need to exchange the randomly generated
username/password (nice_agent_get_local_credentials +
nice_agent_set_remote_credentials) to make the connectivity checks work.

As for your example, here are a few comments :
1 - you call the nice_agent_set_relay_info with stream_id being uninitialized,
you must call it *after* you do the nice_agent_add_stream...
2 - you don't need those GValues, you can just do
  g_object_set (G_OBJECT(agent),
                "stun-server", "66.228.45.110",
                "stun-server-port", 3478,
                 NULL);
3 - You shouldn't set the remote credentials as the same as the local ones
4 - In your print_candidate_info, you may also want to print the port used.

I hope this helps, let me know if you have further questions.

Youness.


On 11/03/2011 12:57 PM, Tiago Sá wrote:
> Hi Youness,
> 
> I have been trying to create a simple application based on the first link you
> pointed before.
> Thanks for the tips you gave me. I have a couple of questions though, if you can
> help me.
> 
> I need to find a way to get the remote candidates passed from a peer to another.
> Can you point an easy way to do that?
> Could I hardcode the remote candidates list, for testing purposes?
> 
> Right now, I only get two local candidates (HOST and SERVER_REFLEXIVE).
> I am trying to use the numb TURN server, shouldn't I get a RELAYED candidate too?
> 
> I am attaching the code. Can you please have a look at the code and check where
> the error could be?
> 
> Thanks for helping!
> 
> Regards,
> Tiago Sá
> 
> 
> On Wed, Oct 19, 2011 at 10:53 PM, Youness Alaoui <youness.alaoui at collabora.co.uk
> <mailto:youness.alaoui at collabora.co.uk>> wrote:
> 
>     Hi,
> 
>     Welcome to the world of libnice :)
>     Yes, doing NAT traversal is far from being easy, the only solution is pretty
>     much to use the ICE specification and that's not easy to implement, so that's
>     why you'd need to use libnice.
> 
>     For an example, you can have a look at the unit tests, like
>     tests/test-fullmode.c for example, although that does a lot of stuff. You can
>     see a quick example  in the documentation for NiceAgent :
>     http://nice.freedesktop.org/libnice/NiceAgent.html
> 
>     For smaller examples, you can look at the libnice mailing list archives, some
>     people posted their example code where they were having problems. For example, a
>     very simple example can be seen here :
>     http://lists.freedesktop.org/archives/nice/2011-January/000404.html
>     But make sure to click on the "Next message" to read the whole thread because
>     that example had a bug that I explained how to fix in the following emails.
>     Same for this thread :
>     http://lists.freedesktop.org/archives/nice/2011-October/000434.html
> 
>     I hope that helps,
>     Youness.
> 
>     On 10/19/2011 09:58 AM, Tiago Sá wrote:
>     > Hi all,
>     >
>     > my name is Tiago Sá, I am a junior researcher from Portugal and this is my
>     first
>     > mail to this list.
>     > I have a NAT traversal problem to solve and I have been looking for a solution
>     > during the last weeks, which, as I found out, is not so trivial as I
>     thought before.
>     > As stated on the libnice homepage, libnice seems to be what I am looking for:
>     >
>     >     "ICE is useful for applications that want to establish peer-to-peer
>     UDP data
>     >     streams. It automates the process of traversing NATs and provides security
>     >     against some attacks. It also allows applications to create reliable
>     streams
>     >     using a TCP over UDP layer."
>     >
>     >
>     > I have been looking for the provided documentation and I am feeling kind
>     of lost.
>     > Is there any example application or tutorial to get started?
>     > Could you please share a basic application of this kind or point me a
>     direction?
>     >
>     >
>     > Thanks in advance for your help.
>     >
>     > Regards,
>     > Tiago Sá
>     >
>     > --
>     > Tiago Sá
>     > Universidade do Minho, Braga - Portugal
>     >
>     >  http://about.me/tiagosa/
>     >
>     >
>     >
>     > _______________________________________________
>     > Nice mailing list
>     > Nice at lists.freedesktop.org <mailto:Nice at lists.freedesktop.org>
>     > http://lists.freedesktop.org/mailman/listinfo/nice
> 
> 
> 
>     _______________________________________________
>     Nice mailing list
>     Nice at lists.freedesktop.org <mailto:Nice at lists.freedesktop.org>
>     http://lists.freedesktop.org/mailman/listinfo/nice
> 
> 
> 
> 
> -- 
> Tiago Sá
> Universidade do Minho, Braga - Portugal
>  www.tiagosa.com <http://www.tiagosa.com>
> 


-------------- 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/20111104/e8d89c67/attachment.pgp>


More information about the nice mailing list