| Testing multicast support on Android devices | January 31, 2011 |
In my previous post, I mentioned my frustration that certain Android phones (including my HTC EVO) cannot receive multicast datagrams. I'd like to get feedback from my friends and colleagues about multicast support on their phones, so I wrote a simple app for testing multicast.
The Multicast Test Tool continually monitors the network for Multicast DNS (mDNS) packets while the app is running in the foreground, and presents the contents of these packets to the user. The app also allows the user to perform simple mDNS queries on the local network. If you run the app and touch the "Query" button, it will query for the default _services._dns-sd._udp.local name, which will solicit mDNS responses from devices on your network that advertise services via mDNS.
Mac and Linux machines will respond to this discovery query. Windows machines will also respond if you are running iTunes and have checked "Share my library on my local network" in the preferences. If you think your network may not have any of these devices which support mDNS service discovery, you can run the attached perl script to transmit a gratuitous mDNS packet.
You can also query specific hosts using the format <hostname>.local. My home network is always buzzing with mDNS traffic, so on my multicast-capable virtual machine I see lots of activity without performing any queries.
If you see any activity at all, it means that your phone supports multicast. If you see no activity, then your phone likely does not support multicast.
Downloads
- multicast_test.apk - This is the Multicast Test Tool app, which you can download and install on your Android phone.
- send_mdns.pl - This perl script transmits a single mDNS packet, which should be detected by the Multicast Test Tool. This is only needed if you don't already have devices on your network (Macs, Linux boxes, etc.) which implement the mDNS service discovery protocol.
- multicast_test_tool.tar.gz - The source code for the Multicast Test Tool. This is only needed if you are curious about the inner workings. (Added 2011-02-02.)
posted at 2011-01-31 16:46:40
by simmons
tags: multicast networking android
permalink
comments (24)


Posted by Cheema on January 31, 2011 at 07:28 PM MST #
Posted by Edward on February 01, 2011 at 04:51 PM MST #
Posted by David Simmons on February 02, 2011 at 05:06 PM MST #
Posted by Edward on February 08, 2011 at 11:57 AM MST #
Posted by Jean-Lou Dupont on February 21, 2011 at 07:24 PM MST #
Posted by Thameem on February 22, 2011 at 12:15 PM MST #
Posted by David Simmons on February 22, 2011 at 12:20 PM MST #
Posted by Thameem on February 22, 2011 at 12:47 PM MST #
I haven't tested many routers, so this is just a guess. I think that even routers that don't officially support multicast should be able to handle this sort of "dumb" multicasting. This is because no actual routing is necessary — your router is probably just bridging your wired and wireless network links. Full multicast support is needed when you want to route multicast to/from the upstream network, for applications such as IPTV. It's possible that your router could be filtering multicast to reduce unnecessary wireless traffic.
When debugging these sorts of network issues, it is invaluable to use a packet sniffer such as tcpdump or Wireshark to see exactly what is happening on a host's network interface.
I'm not sure what your need is, so it's hard to say if broadcast is a better solution. (Keep in mind, though, that phones with multicast problems may have the same problems with broadcast.)
Posted by David Simmons on February 22, 2011 at 01:11 PM MST #
Posted by Thameem on February 22, 2011 at 01:15 PM MST #
Some people seem to be able to run tcpdump on their Android devices via adb, but this may require you to have a rooted phone.
If you do use a tool like tcpdump to inspect wi-fi traffic on the phone, keep in mind that you may need an app like Multicast Test Tool running, so the wireless chip in the phone knows to change its hardware filtering to allow multicast. (It's a problem with this dance between the wireless chip and the operating system that keeps multicast from working on my HTC phone.)
Posted by David Simmons on February 22, 2011 at 01:26 PM MST #
Posted by TJ on July 12, 2011 at 03:37 PM MDT #
Posted by David Simmons on July 12, 2011 at 03:41 PM MDT #
Posted by TJ on July 12, 2011 at 04:04 PM MDT #
I was doing some Android debugging at a friend's house last night, and to my complete astonishment, both multicast and IPv6 suddenly started working on my HTC EVO phone! It makes me wonder if my wireless access points are mangling the multicast packets or my IGMP joins or something.
For a while I just assumed that Android 2.x didn't support IPv6. That could explain some strange looks I got at Google IO when telling people "Hey, look, Honeycomb finally supports IPv6!" heh.
Posted by David Simmons on July 14, 2011 at 06:10 PM MDT #
Posted by Pat Wood on August 03, 2011 at 04:07 PM MDT #
Posted by Paolo on September 29, 2011 at 06:27 AM MDT #
Paolo - I would also be surprised if the Nexus S didn't support multicast.
I've heard that some wireless access points (and wired switches) may interfere with multicast traffic. Some may outright block multicast, while others may employ IGMP snooping to only forward multicast packets to interested hosts. The Multicast Test Tool does invoke joinGroup() on the socket to subscribe to mDNS traffic, which should theoretically send an IGMP "join group" message that such WAPs should recognize.
You might want to try using a different Wi-Fi network to see if it makes a difference, or poke around in the settings of your access point. Running a packet sniffer from another computer on the Wi-Fi network may also yield some interesting results.
Due to the widespread sloppiness of multicast support in phones and WAPs, I've relegated multicast discovery functions to a "nice to have if it works" feature in my apps, instead of something that must be relied upon.
Posted by David Simmons on September 29, 2011 at 10:43 AM MDT #
Posted by Paolo on September 30, 2011 at 03:03 AM MDT #
Posted by Pat Wood on September 30, 2011 at 08:23 AM MDT #
Paolo - I think the Android operating system theoretically supports multicast fine, but the sloppiness in the drivers and/or firmware supplied by the manufacturers can make it hard for Android apps to rely on multicast in practice. The Android API supplies a WifiManager.MulticastLock() method which the app calls to ask the driver/firmware to disable any hardware multicast/broadcast packet filtering, but this doesn't seem to help on certain devices. Apple invented and relies on mDNS, so I would expect multicast to be very reliable on iOS devices.
It seems to me that the multicast weirdness may be a combination of the device's driver/firmware, and the network infrastructure. My HTC EVO failed the multicast test on most networks, but surprisingly worked at a friend's house. Unfortunately, my EVO is now kaput, so I can't perform any more tests on this behavior.
Posted by David Simmons on September 30, 2011 at 10:55 AM MDT #
Posted by pete yam on January 22, 2012 at 09:12 PM MST #
Posted by David Simmons on January 23, 2012 at 12:36 PM MST #
Posted by Martin Meel on January 25, 2012 at 06:35 AM MST #