Just An Application

November 3, 2013

Service Discovery In Android And iOS: Part Three – If You Want Something Done Properly … mDNS And DNS Service Discovery Basics

To continue with the wild over simplifications, Multicast DNS (mDNS) defines a special node with the label

    local

immediately beneath the root ot the DNS name space.

The DNS name space sub-tree beneath the local node is not global but confined to the hosts directly attached to a given network.

There is no dedicated DNS server responsible for managing a local sub-tree.

Instead individual hosts attached to a network can each allocate nodes within the local sub-tree themselves. This means that different hosts can allocate nodes with the same name with associated resource records of the same type and class.

For queries to work in this context they are sent via multicast UDP so that they can be seen by all the hosts in the local network which may have allocated nodes in the sub-tree. Queries may result in multiple responses each from a different host.

2.0 Service Discovery Using DNS

RFC 6763 DNS-Based Service Discovery specifies how the DNS name space and DNS resource records can be used to make services discoverable.

2.1 Service Types

The label of a node which represents a service type starts with an underscore (‘_’).

A node which represents a service type is either a child of a node with the label

    _tcp

meaning that the service is available via TCP, or a child of a node with the label

    _udp

which, curiously, does not necessarily mean that the service is available via UDP, although it can be, but that the service is available via some protocol other than TCP.

For example the node

    _ipp._tcp.local.

represents the IPP over TCP service type in the local domain

2.2 Service Instances

A service instance, i.e., an entity which implements a service of a given type, is represented by child node of the service type node, e.g.,

    ipp-printer._ipp._tcp.local.

2.3 Service Type Resource Records

A service type node has an associated PTR record for each service instance of that service type. The data in each PTR record is the name of the node representing the service instance.

2.4 Service Instance Records

A service instance node has an associated SRV record.

The SRV record data identifies the host on which the service instance is running and the port it is listening on.

A service instance node also has an associated TXT record.

2.4.1 Service Instance TXT Records

The data of a service instance TXT record comprises one or more of strings of the form

    key=value

The key value pairs provide additional information about the service.

2.5 Service Discovery

To discover all the instances of a given service type it is only necessary to query the appropriate service type node for its PTR records.

Each PTR record in the answer will identify a service instance.

The node for each service instance can then be queried for its SRV and TXT records.

2.6 Service Discovery And The Additional Records Section

The standard recommends that the associated SRV and TXT records of the service instancea be included in the additional records section of the response to the query to the service type node for its PTR records.

In theory therefore it is possible to obtain all the information about the available instances of a given service type with a single query, subject to limits on the datagram size.


Copyright (c) 2013 By Simon Lewis. All Rights Reserved.

Unauthorized use and/or duplication of this material without express and written permission from this blog’s author and owner Simon Lewis is strictly prohibited.

Excerpts and links may be used, provided that full and clear credit is given to Simon Lewis and justanapplication.wordpress.com with appropriate and specific direction to the original content.

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: