On Linux systems, Bonjour is implemented by the “Avahi” service. This is what McLaren Labs’ rtpmidi
program uses to find Apple MIDI services on your network when you set it up. Usually rtpmidi
can find the iPhones and iPads on your network, but sometimes things do not go smoothly. That’s when you need to do some network debugging. One of the tools that you can use to learn about Bonjour services on your network is avahi-browse
.
Install avahi-browse
If you have installed McLaren Labs’ rtpmidi
, then there is a good chance that avahi-browser
is already installed. Try it out.
$ avahi-browser
If it isn’t there, you can install it like this on Ubuntu systems.
$ sudo apt-get install avahi-utils
List all Bonjour (Avahi) services on your network
You can see all of the Bonjour services on your network by using the --all
option. On my network, there are dozens of services. You may be surprised what is on your network.
$ avahi-browse --all
+ wlp3s0 IPv6 492B9BD2B213145B _appletv-v2._tcp local
+ wlp3s0 IPv4 492B9BD2B213145B _appletv-v2._tcp local
+ wlp3s0 IPv6 492B9BD2B213145B iPod Touch Music Library local
+ wlp3s0 IPv4 492B9BD2B213145B iPod Touch Music Library local
+ wlp3s0 IPv6 HP Officejet Pro 8620 [0FCF77] _uscan._tcp local
+ wlp3s0 IPv4 HP Officejet Pro 8620 [0FCF77] _uscan._tcp local
+ wlp3s0 IPv6 HP Officejet Pro 8620 [0FCF77] _http-alt._tcp local
+ wlp3s0 IPv4 HP Officejet Pro 8620 [0FCF77] _http-alt._tcp local
+ wlp3s0 IPv6 HP Officejet Pro 8620 [0FCF77] _scanner._tcp local
+ wlp3s0 IPv4 HP Officejet Pro 8620 [0FCF77] _scanner._tcp local
+ wlp3s0 IPv6 HP Officejet Pro 8620 [0FCF77] Web Site
List MIDI Services
Bonjour service types are identified with a special type of name that consists of two parts, each with underscores. Apple MIDI (Network MIDI) has the following service type name:
_apple_midi._udp
The first part before the period is called the “service type” and the part after the period is called the “transport protocol”. Valid transport protocols include “_udp” and “_tcp”. Apple MIDI (Network MIDI) is a UDP protocol.
If you want to list just the Apple MIDI (Network MIDI) Services on your network, provide is as an option to the avahi-browse
command.
$ avahi-browse _apple-midi._udp
This will list all of the active Network MIDI sessions on your network. The screenshot below shows what is initially found on our network.
Now if another Network MIDI session appears on your network, avahi-browse
will notice it and print it out. In the screenshot below, we have started “MIDI Keys” app on an iPhone. The avahi-browse
program has noticed it and prints it out.
Notice our iPhone11: it’s name is called “Tom___s iPhone11” in the listing.
Format of the Output
The default output of the avahi-browse
command is four columns:
- the networking interface the service was found on
- the network type
- the name of the computer hosting the service
- the service type
This output format is useful enough for finding out if there are services on your network.
Finding IP Addresses
When you’re debugging, you may be wanting to know the IP addresses of the computers hosting the service. To do that, you need to ask Avahi to not only LIST the computer names, but to RESOLVE the names too. For this, use the -r
option.
In the output above, we notice that “Tom’s iPhone” has a host address of 10.0.0.202 and that the Network MIDI service is listening on port 5004.
Summary
Use the avahi-browse
command on Ubuntu to learn about the Bonjour services on your network. There are graphical programs showing the same information, but this command line tool can yield powerful insights while trying to debug networking issues.