Bonjour

From PsiWiki

Contents

Introduction

Many chat clients (iChat, Trillian, Adium X, Miranda, Gizmo) have a so-called 'RendezVous' mode these days. The concept was introduced by Apple in their iChat client. It basically uses zeroconf (an IETF protocol) to allow 2 iChat clients to talk to each other, without needing any configuration or anything else but the chat client itself (so no server, no account configuration, ...). Besides making it easy to chat on a small network without the hassle to set up fully fledged Jabber servers, it also makes it easy to quickly send files between each other.

This page is about bringing RendezVous (or 'Bonjour' these days) chatting to Jabber (and more specific, to Psi).

Approach

Basically, there are 2 approaches that can be taken to bring this zero configuration chatting to Jabber:

  1. Implement it directly into Jabber clients. This is the 'easiest' approach. The up side of this approach is that you can directly manipulate rosters (when contacts become available/unavailable), and can send the messages directly without transforming them to XMPP. The downside is that it requires hacking directly into a client and adding more code to the codebase, and is not a very modular approach. This makes it less 'the Jabber way', where all clients have to do is implement XMPP and have full functionality.
  2. Create a 'proxy' which talks Jabber on one side, and talks RendezVous on the other side. The idea is that you start a little daemon on your computer which acts as a tiny XMPP server to which you (and only you) can connect. These proxies talk to each other using their own (RendezVous) protocol (like normal Jabber servers do). This protocol is used to discover new proxies and to route messages between the proxies.

The up side of this approach is that you can use this proxy with every Jabber client out of the box. It is also very modular: if you want to use a different RendezVous protocol than the one used by iChat (and the other clients), you just have to change the RendezVous side of the proxy, and all the Jabber clients can talk to each other using this special protocol. The down side of this approach is that you have to start this little proxy yourself (of course, this can be automated from inside the Jabber client).

On this page, we'll talk about the last approach in more depth.

Proxy implementation

  • The proxy must detect new RendezVous clients, and notify this to the connected client. The detection is done using broadcasted zeroconf packets, which include some extended presence information (see next point). The notification of new clients can simply be done by pushing a subscription of a new contact to the connected client. For convenience, a more advanced protocols such as roster-subsync (see 'Roster Pushes' on this page) can be used to alleviate the burden of having to acknowledge every new subscription. When the client goes offline, the authorization is removed again. Instead of actually removing contacts from the roster the presence can just be changed to offline; when the contact becomes available again, the proxy should check if the contact is already on the roster, and just change presence if it is (so not send subscription requests).
  • Status changes are also done using broadcasted zeroconf packets, which include information on status, photo hash, nickname, ... On the XMPP side, this translated to XMPP presence packets.
  • Messages, Chats and IQ's are done by sending the XMPP stanzas directly to the contact's client.
  • When the proxy is started, it has to detect all the currently present RendezVous clients on the network. This is done by broadcasting zeroconf queries. The result will be a roster push for every contact on the network, such as in the first bullet.

No persistence is needed in the proxy implementation. Other extended features (e.g. file transfer) can easily be implemented in the same way as above.

Client requirements

In principle, nothing. The dynamic nature of the roster should be handled server-side by adding/removing people to the roster dynamically.

Practical

From the Psi perspective, it's probably the most interesting to implement the proxy using Iris. The Ambrosia experiment showed that it's relatively easy to implement an XMPP server using this library. The nice thing about this is that it would probably be easy to modify the code of the proxy to be integrated directly into Psi at a later stage (approach 1 from the introduction). Since Iris is written in C++, it also makes it possible to use the zeroconf code provided by Apple (written in C) to do the RendezVous side.

Gareth Simpson has done a analysis of the iChat's Bonjour protocol.

There was an opensource Zeroconf library called Howl, that could be used instead of the libraries from Apple.

Avahi is going to be the standard zeroconf implementation on linux. It has some compatibility layers for Howl and mDNSresponder.