Establishing peer-to-peer connections with Jami
Jami always attempts to use the most direct available link between peers, by avoiding any relays between them. When it succeeds, the speed and size of transfers is not restricted by a server’s limited capacity (especially in times of high traffic), since there isn’t one. It allows our users to take full advantage of the bandwidth made available to them by their Internet service provider and send files at the maximum possible speed or make video calls at full HD quality. Moreover, because no server is needed, communications can also work without any Internet connection if both users are on the same network and data privacy is increased, as explained in this previous article. We aim to establish a completely peer-to-peer connection in order to take advantage of the aforementioned benefits on every single occasion, but sometimes it is not possible and this article will explain why.
When devices communicate on the Jami network, they first send each other the set of public and local IP addresses they can be reached at through OpenDHT. It is the technology that allows devices to find each other on the Internet and establish a first connection without previously knowing their respective IP addresses. Jami then uses Interactive Connectivity Establishment (ICE) in order to find the most direct route to create a link between the two peers using their respective addresses. It is not always possible to create a direct link between peers because of firewalls and other issues, which is why a Traversal Using Relays around NAT (TURN) server is sometimes necessary to use as a fallback. As the name indicates, it is a way of getting around NATs (routers) by relaying data through a server in between the peers. If the option is activated in the advanced Jami account settings (it is by default), a relayed address (from the TURN server) will be sent along with the device’s local and public IP addresses in the first message sent through OpenDHT.
As much as we like to say that Jami is completely without server, sometimes it is not exactly right as we have seen. However, TURN is the perfect compromise for situations where a fully peer-to-peer connection is not possible, because it is an open standard (RFC 5766) managed by the The Internet Engineering Task Force (IETF). This gives users the possibility to use their own if they want to, since it is configurable in the Jami settings. The default settings point to a TURN server that we provide for convenience (turn.jami.net), but you can use any other available on the web or even your own. If this is something that you are interested in, the one that we use is coturn TURN server project and you can install it yourself if you have the technical know-how.
By Sébastien Blin and François Naggar-Tremblay