Packet and iPhone Brocade agrees to acquire Foundry
Jul 28

if you have an iPhone, you may already play iTunes Remote which is a tool released by Apple to remote control the Apple TV and iTunes from the iPhone/iPod Touch directly.  If you didn’t tried that, I suggest you go to AppStore to download one, it is free and very easy to use.

remote_icon20080711The remote control has no limit on distance, in theory, even at Office, you can directly remote control your home iTunes in real time. How it implemented? Is that a magic? Let’s look into the actual packets.

My iPhone got a LAN address at 172.16.0.102, the iTunes PC got 172.16.0.106.  When the iPhone remote starts, it began to send  a Multicast-DNS packet to 224.0.0.251. This is a multicast which means the devices and computers in the same group will hear this packet.

The computer with iTunes installed will reply packets if it received the multicast packet. The reply is a multicast-DNS response too which provides the information about the iTunes version and capacities.

One of the replies indicates the service port of the iTunes, by default , it uses TCP port 3689. Then, the iPhone will happily connect to iTunes talking through a protocol similar to Digital Audio Access Protocol. More information about RAOP can be seen http://en.wikipedia.org/wiki/Digital_Audio_Access_Protocol

iPhone also send some discardable broadcast packet in the meanwhile which seems not make any sense.

image

Here, we are not going to dig into the protocol specification, but just go through the packets payload roughly, we can see the protocol is actually encapsulated by HTTP.

the login sequence is as below

iPhone   –>     iTunes       :             GET /server-info HTTP/1.1
iTunes   –>      iPhone      :                         HTTP/1.1 200 OK
iPhone   –>     iTunes       :             GET /login?pairing-guid=* HTTP/1.1
iTunes   –>      iPhone      :                         HTTP/1.1 200 OK

After the login, the iTunes and iPhone will exchange some library information. if you play a song remotely on iTunes, many calls related to  /ctrl-int are involved.

The implementation is compact and efficient. The multicast implementation is quite good and adaptive even to a routed complex network.

Share this story:
  • Slashdot
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • LinkedIn
  • Sphinn
  • Mixx

4 Responses to “Secrets behind Apple iTunes Remote with iPhone”

  1. soulshift Says:

    I’ve been trying to “debug” my intermittent Remote connection (I think my router is eating up multicast packets coming from the WLAN side…)

    However I found out while doing this that the iPhone is actually sending out the wake-on-lan magic packet on port 9. So in theory it should be able to wake your PC from sleep! (this is also interesting because it means that the Remote app caches your PCs mac address…)

  2. incorrect Says:

    I found my firewall (CyberGuard SG300) was locking me out when using the Remote app.

    The IDS by default triggers a global block for any IP which hits it 10 times on UDP port 9 (among others). Removing ‘discard’ from the UDP list fixed this for me.

  3. Websites tagged "multicast" on Postsaver Says:

    [...] - Whitefish IPv6 Preparation Unicast, Multicast, and Anycast Addresses saved by wookie2009-07-17 - Secrets behind iTunes Remote with iPhone saved by hegemonic2009-07-05 - Late July Update… saved by SK8erchick002009-07-02 - NEC “RGB [...]

  4. Getting the Apple iPhone Remote App Working With a XyZEL Router | Gothick.org.uk Says:

    [...] big clue came from this blog entry at packetevents.com, which goes into some really geeky detail about what happens when you fire up the Remote [...]

Leave a Reply

You must be logged in to post a comment.