[jitsi-dev] [ice4j] Starting with Ice4j


#1

Hi everyone,

I would like to do a very simple test application using Ice4j but I
couldn't find any documentation.

What I intend to do is pretty simple :
- a Server behind a NAT
- a Mediator that is available to the world
- a Client that is also behind a NAT

I would like the Server to connect to the Mediator and register its address.
Then the Client would connect to the Mediator to initiate a connection to
the Server.
Finally I would like the server to return a "Hello World!" message for the
Client to display.

My problem is that I don't really know where to start. I know the very
basics of NAT traversals, but don't know for sure how it is translated in
Ice4j implementation.

Could you give me some starting hints ?

If you think it is relevant, I could also write a tutorial based on this
very simple use case and make it available to the community

Kind regards,

Ben


#2

Hi Ben,

What I intend to do is pretty simple :
- a Server behind a NAT
- a Mediator that is available to the world
- a Client that is also behind a NAT

I would like the Server to connect to the Mediator and register its
address.
Then the Client would connect to the Mediator to initiate a connection to
the Server.
Finally I would like the server to return a "Hello World!" message for the
Client to display.

My problem is that I don't really know where to start. I know the very
basics of NAT traversals, but don't know for sure how it is translated in
Ice4j implementation.

Please take a look on files in "test" folder in package "test". There are
few examples how to use ice4j.

In few sentences how ice is organized in the ice4j lib:

The main class is Agent. It is used to start and controll the process. You
will need to register state listener to get notified when the process is
complete or when it fails.

Also there have to be provided candidates sources that will be used during
negotiations. For this purpose there are few types of "candidate
harvesters" which reside in package "org.ice4j.ice.harvest". You can
configure UPnP, STUN, TURN and few other candidate sources.

The other thing is to create the media streams. The stream identifies
communication channel specifying protocol and port range used. They can(but
don't have to) consist of multiple components like for example RTP and
RTCP. As far as I know only UDP streams are now supported. Media streams
are identified by name type of String. You create the stream for given
name. Later you can retrive it with that name.

Once the process is started and agents will finish gathering candidates
they have to be exchanged between them using Madiator's channel.

The other important thing is to use sockets provided by the Agent and not
to open own sockets on selected addresses. Application data and ice packets
will be multiplexed there so that ice Agent can keep the connection alive.

You can see how it looks in few examples like the one in file
IcePseudoTcp.java. It's an example of some data transfer using PseudoTCP on
local sockets that are handled by two different threads. Try to look how
these things are done there.

···

2012/11/28 Benoît Thiébault <benoit.thiebault@gmail.com>

--
Regards,
Pawel


#3

Thanks Pawel, I will have a look at those tests.

···

Le 28 nov. 2012 18:49, "Paweł Domas" <paweldomas@gmail.com> a écrit :

Hi Ben,

2012/11/28 Benoît Thiébault <benoit.thiebault@gmail.com>

What I intend to do is pretty simple :
- a Server behind a NAT
- a Mediator that is available to the world
- a Client that is also behind a NAT

I would like the Server to connect to the Mediator and register its
address.
Then the Client would connect to the Mediator to initiate a connection to
the Server.
Finally I would like the server to return a "Hello World!" message for
the Client to display.

My problem is that I don't really know where to start. I know the very
basics of NAT traversals, but don't know for sure how it is translated in
Ice4j implementation.

Please take a look on files in "test" folder in package "test". There are
few examples how to use ice4j.

In few sentences how ice is organized in the ice4j lib:

The main class is Agent. It is used to start and controll the process. You
will need to register state listener to get notified when the process is
complete or when it fails.

Also there have to be provided candidates sources that will be used during
negotiations. For this purpose there are few types of "candidate
harvesters" which reside in package "org.ice4j.ice.harvest". You can
configure UPnP, STUN, TURN and few other candidate sources.

The other thing is to create the media streams. The stream identifies
communication channel specifying protocol and port range used. They can(but
don't have to) consist of multiple components like for example RTP and
RTCP. As far as I know only UDP streams are now supported. Media streams
are identified by name type of String. You create the stream for given
name. Later you can retrive it with that name.

Once the process is started and agents will finish gathering candidates
they have to be exchanged between them using Madiator's channel.

The other important thing is to use sockets provided by the Agent and not
to open own sockets on selected addresses. Application data and ice packets
will be multiplexed there so that ice Agent can keep the connection alive.

You can see how it looks in few examples like the one in file
IcePseudoTcp.java. It's an example of some data transfer using PseudoTCP on
local sockets that are handled by two different threads. Try to look how
these things are done there.

--
Regards,
Pawel


#4

Hi Pawel,

I have finally found some time to look at the tests of Ice4j, and in
particular the one you pointed to me, namely IcePseudoTcp.java.

When I run this test, I however encounter warning and severe messages:
[...]
INFO: Local agent entered the Terminated state.
26 déc. 2012 17:31:42 test.IcePseudoTcp$LocalPseudoTcpJob run
INFO: Local pseudotcp is using:
/fe80:0:0:0:e2f8:47ff:fe3b:9ef6%5:7999org.ice4j.socket.MultiplexingDatagramSocket@97d01f
26 déc. 2012 17:31:42 org.ice4j.pseudotcp.PseudoTCPBase parseOptions
WARNING: Peer doesn't support window scaling
26 déc. 2012 17:31:42 org.ice4j.pseudotcp.PseudoTCPBase parseOptions
WARNING: Peer doesn't support window scaling
26 déc. 2012 17:31:43 test.IcePseudoTcp$RemotePseudoTcpJob run
INFO: Transferred 15000000 bytes in 0 sec
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: Free ICE agent
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: remove streams
26 déc. 2012 17:31:43 org.ice4j.ice.Agent runInStunKeepAliveThread
INFO: KeepAliveThread ends
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: remove stream data
26 déc. 2012 17:31:43 org.ice4j.pseudotcp.PseudoTcpSocketImpl receivePackets
SEVERE: ReceivePackets exception: java.net.SocketException: Socket closed
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: ICE agent freed
26 déc. 2012 17:31:43 org.ice4j.pseudotcp.PseudoTcpSocketImpl onTcpClosed
SEVERE: PseudoTcp closed: java.net.SocketException: Socket closed
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: Free ICE agent
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: remove streams
26 déc. 2012 17:31:43 org.ice4j.ice.Agent runInStunKeepAliveThread
INFO: KeepAliveThread ends
26 déc. 2012 17:31:43 org.ice4j.pseudotcp.PseudoTcpSocketImpl receivePackets
SEVERE: ReceivePackets exception: java.net.SocketException: Socket closed
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: remove stream data
26 déc. 2012 17:31:43 org.ice4j.pseudotcp.PseudoTcpSocketImpl onTcpClosed
SEVERE: PseudoTcp closed: java.net.SocketException: Socket closed
26 déc. 2012 17:31:43 org.ice4j.ice.Agent free
INFO: ICE agent freed

Is this expected?

Kind regards,

Ben

···

On Wed, Nov 28, 2012 at 6:46 PM, Paweł Domas <paweldomas@gmail.com> wrote:

Hi Ben,

2012/11/28 Benoît Thiébault <benoit.thiebault@gmail.com>

What I intend to do is pretty simple :
- a Server behind a NAT
- a Mediator that is available to the world
- a Client that is also behind a NAT

I would like the Server to connect to the Mediator and register its
address.
Then the Client would connect to the Mediator to initiate a connection to
the Server.
Finally I would like the server to return a "Hello World!" message for
the Client to display.

My problem is that I don't really know where to start. I know the very
basics of NAT traversals, but don't know for sure how it is translated in
Ice4j implementation.

Please take a look on files in "test" folder in package "test". There are
few examples how to use ice4j.

In few sentences how ice is organized in the ice4j lib:

The main class is Agent. It is used to start and controll the process. You
will need to register state listener to get notified when the process is
complete or when it fails.

Also there have to be provided candidates sources that will be used during
negotiations. For this purpose there are few types of "candidate
harvesters" which reside in package "org.ice4j.ice.harvest". You can
configure UPnP, STUN, TURN and few other candidate sources.

The other thing is to create the media streams. The stream identifies
communication channel specifying protocol and port range used. They can(but
don't have to) consist of multiple components like for example RTP and
RTCP. As far as I know only UDP streams are now supported. Media streams
are identified by name type of String. You create the stream for given
name. Later you can retrive it with that name.

Once the process is started and agents will finish gathering candidates
they have to be exchanged between them using Madiator's channel.

The other important thing is to use sockets provided by the Agent and not
to open own sockets on selected addresses. Application data and ice packets
will be multiplexed there so that ice Agent can keep the connection alive.

You can see how it looks in few examples like the one in file
IcePseudoTcp.java. It's an example of some data transfer using PseudoTCP on
local sockets that are handled by two different threads. Try to look how
these things are done there.

--
Regards,
Pawel