<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Segment7: Service Discovery Protocols</title>
    <link>http://blog.segment7.net/articles/2009/08/19/service-discovery-protocols</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>The Blog</description>
    <item>
      <title>Service Discovery Protocols</title>
      <description>&lt;p&gt;I&amp;#8217;ve worked on two different service discovery libraries for ruby, one for &lt;span class="caps"&gt;SSPD&lt;/span&gt; and one for mDNS, and I&amp;#8217;d like to share the differences between them with you.

&lt;p&gt;Both &lt;span class="caps"&gt;SSDP&lt;/span&gt; and mDNS are designed to be used with self-configuring networks and to automatically discover and connect to other devices.  Both use &lt;a href="http://en.wikipedia.org/wiki/IP_multicast"&gt;multicast&lt;/a&gt; to advertise and search.

&lt;h3&gt;&lt;span class="caps"&gt;SSPD&lt;/span&gt;&lt;/h3&gt;

&lt;p&gt;The Simple Service Discovery Protocol is used primarily by &lt;a href="http://upnp.org/"&gt;UPnP&lt;/a&gt; for network devices to discover each other.  UPnP is designed for consumer electronics and appliances that need to communicate with each other automatically.

&lt;p&gt;The description of &lt;span class="caps"&gt;SSPD&lt;/span&gt; fits on a twelve of pages when written in (relatively) plain English (section 1 in the &lt;a href="http://upnp.org/specs/arch/UPnP-arch-DeviceArchitecture-v1.0.pdf"&gt;&lt;span class="caps"&gt;UPNP&lt;/span&gt; Device Architecture&lt;/a&gt;).  The protocol itself looks much like &lt;span class="caps"&gt;HTTP&lt;/span&gt; and can be implemented largely using simple text processing.  (Strangely, &lt;span class="caps"&gt;SOAP&lt;/span&gt; is the higher-level communication layer for UPnP.)

&lt;p&gt;Unfortunately there&amp;#8217;s no way for multiple devices to share the same &lt;span class="caps"&gt;SSPD&lt;/span&gt; socket without being designed to work with each other.  Since UPnP is focused on simple devices, this fits well with their design goals.  Most UPnP devices are routers, media servers, game consoles, televisions, etc.  If you built your own router and media server on the same host it will probably be impossible for both devices to show up on the network, nor will you be able to run a media server and media viewer on the same host without the two being designed to work with each other.

&lt;h3&gt;mDNS&lt;/h3&gt;

&lt;p&gt;Multicast &lt;span class="caps"&gt;DNS&lt;/span&gt; is used primarily by Apple and (basically) has a &lt;span class="caps"&gt;DNS&lt;/span&gt; server on each host.  Hosts speak the &lt;span class="caps"&gt;DNS&lt;/span&gt; protocol to each other over multicast and have a central daemon that handles communication on the network much like the libc &lt;span class="caps"&gt;DNS&lt;/span&gt; resolver.

&lt;p&gt;Even though there&amp;#8217;s plenty of &lt;span class="caps"&gt;DNS&lt;/span&gt; clients around for code reuse, implementing a &lt;span class="caps"&gt;DNS&lt;/span&gt; client form scratch is a large undertaking (my &lt;span class="caps"&gt;SSDP&lt;/span&gt; implementation is around 750 lines with documentation, ruby&amp;#8217;s Resolv &lt;span class="caps"&gt;DNS&lt;/span&gt; resolver is around 2200 lines and doesn&amp;#8217;t include a server or multicast code).  The entirety of the &lt;span class="caps"&gt;DNS&lt;/span&gt; system is spread across several RFCs, not including the documentation for mDNS itself.

&lt;p&gt;Fortunately mDNS libraries provide a daemon for handling network communication and a client library you can use to register and browse for devices (the dnssd gem uses Apple&amp;#8217;s &lt;span class="caps"&gt;DNS&lt;/span&gt; Service Discovery &lt;span class="caps"&gt;API&lt;/span&gt;).  mDNS is focused on computers rather than devices, so multiple services can all coexist on the same host.

&lt;p&gt;Unfortunately, due to the complexity of mDNS, there&amp;#8217;s no single &lt;span class="caps"&gt;API&lt;/span&gt; for applications to use.  Apple&amp;#8217;s &lt;span class="caps"&gt;DNS&lt;/span&gt;-SD works across multiple platforms including windows.  For unix-like operating systems there  is also &lt;a href="http://www.avahi.org/"&gt;avahi&lt;/a&gt; which has a limited dnssd compatibility shim.
</description>
      <pubDate>Wed, 19 Aug 2009 14:42:03 -0700</pubDate>
      <guid isPermaLink="false">urn:uuid:9aa73e2a-cb7b-4f16-b647-d0552bfc185c</guid>
      <author>drbrain@segment7.net (Eric Hodel)</author>
      <link>http://blog.segment7.net/articles/2009/08/19/service-discovery-protocols</link>
      <category>Misc</category>
    </item>
  </channel>
</rss>
