Actually, this title is not very descriptive, as sharing music across the LAN with Rhythmbox takes only one click of the mouse. However, this article intends to provide an overview of what happens behind the scenes after this mouse button has been pressed and how Rhythmbox and Avahi work together in order to make the sharing of music such an easy task.
Some General Info
The traditional way of sharing a collection of audio files across a local home network is by sharing the directory that contains them, so that everybody can access these files. This works well, but I guess it’s time to move on to the next level of music sharing through the Digital Audio Access Protocol (DAAP).
A very interesting article, published on Linux.com, was the motive in order to start reading about DAAP. In brief, this protocol was originally developed by Apple and is implemented in the company’s popular audio player, iTunes. What makes DAAP so important is the fact that it uses ZeroConf, also developed by Apple and originally called Rendezvous, to announce and discover the music shares across the LAN. All this is done automatically, usually requiring zero configuration by the user.
Τhe requirements for using DAAP in order to share your music are:
- an implementation of the protocol itself, either in the form of a daemon or have it built-in within a music management application.
- an implementation of ZeroConf.
Hopefully, as you might have already read in the linked pages above, there is just enough native linux software that satisfies both of the above requirements. This small article will deal with the Avahi daemon, a promising implementation of ZeroConf, and Rhythmbox, built with DAAP support. These are available OOTB in FC5 and will most probably be included in the upcoming releases of the major Linux distributions, if not already included (this is beyond my knowledge).
How To Share Across The LAN
Rhythmbox, if built with DAAP support, includes a new tab in the preferences panel, called “Sharing“. This is where the user can enable music collection sharing, set a name for the share and even set a password in order to control access.
Having enabled this, when Rhythmbox is started, it uses D-Bus to send a message to the Avahi daemon informing it that the player implements a service based on the DAAP protocol, which gives access to the user’s music collection and can also recognize other users’ music shares. Avahi, after collecting all the needed information about that service, it publishes it as a mDNS/DNS-SD service and makes it available in the local subnet, so that all other workstations are notified about the new available service. All this is accomplished without any user intervention, which makes it very convenient even for unexperienced users.
Even if Rhythmbox does not share its music collection, it, if built with DAAP support, still informs Avahi through D-Bus, that it can recognize other users’ music shares and, eventually, all these available shares are displayed in Rhythmbox’ music sources list. Each of these shares includes the whole music database, which by the way can be searched as if it was the local music collection, plus any playlists. The outcome of all these operations is that all the available music on the local network is viewable and searchable from within Rhythmbox’ user interface!
More Than A Mouse Click
Although enabling the sharing of the music collection in Rhythmbox should be enough, it requires one more step so that other workstations on the LAN can actually read the published music. Actually, this is only required in the case that the workstation which shares the music is protected by a firewall. The fact that this aspect is not even mentioned in the Rhythmbox documentation is, at least, surprising.
So, which port should be open? Hopefully, Rhythmbox’ DAAP service uses the DAAP protocol’s default port:
Opening this port on the workstation that shares the music is mandatory. A workstation, which is supposed to only read music shares, is not required to have port 3689 open.
But, what about if the service did not use the standard port? How to find information about the available services on the local machine or accross the local network? Read on…
As it was previously mentioned, Avahi’s responsibilities, by default, are to publish and announce any local services to the whole subnet (Multicast Server) and also to collect information about other services that are available on the subnet and make it available to the workstation it runs on (Service Discovery). Furthermore, Avahi can publish services that run on workstations on which Avahi is not installed.
The Avahi distribution, among others, includes some utilities in order to assist users in finding information about the available ZeroConf services on the network. A command-line tool (
avahi-browse) and a graphical one (
avahi-discover) are provided.
You can use
avahi-browse like in the example below:
# avahi-browse -a -r -t
Some info about the parameters:
-a : Show all services, regardless of the type.
-r : Resolve the services and provide detailed information about their parameters.
-t : Terminate when an apparently complete list has been printed to stdout.
The information, that the above command provides, includes the port number on which a service is run.
If you like it graphically, you can use the
avahi-discover-standalone utility. Run it from a terminal:
Select any of the services that are shown and the service’s information will be displayed.
The implementation of the DAAP protocol that is built in Rhythmbox makes it possible to share music with Apple’s music management application, iTunes, which cannot run natively in Linux. Apart from that, a UNIX server implementation of the DAAP protocol, mt-daapd, can be used to share your audio files from a central location. The importance of DAAP is that it makes the synchronization of music across a local network extremely easy.
This small article is also a small introduction to Avahi and to what a user can achieve with it. It seems that I just discovered multicast DNS and automatic service discovery. Well, this is not absolutely true. I just discovered some useful things a user can do with it, so I intend to spend some more time with Avahi and hopefully post some more info about its usage in future articles.
The Music Collection Sharing With Rhythmbox by George Notaras, unless otherwise expressly stated, is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License.