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
Then the Client would connect to the Mediator to initiate a connection to
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
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 <firstname.lastname@example.org>