Skip navigation
  • Low memory footprint.
  • Makes your target easily discoverable.
  • Supports protocols for Windows, MacOS and Linux.
  • Easy to implement.

embOS/IP - Domain name resolution

The embOS/IP TCP/IP stack provides a way to easily discover a target by its name. For targets used as client, both Apple multicast DNS (mDNS / Bonjour) and Microsoft Link-Local Multicast Name Resolution (LLMNR) are supported. When the target is used as server, a simple DNS server can be used. The add-on also provides a simple support for service discovery (DNS-SD).

Relevant Parts

The relevant parts of the following Request For Comments (RFC) are implemented.

RFC#Description
[RFC 6762]Multicast DNS 
Direct download: ftp://ftp.rfc-editor.org/in-notes/rfc6762.txt
[RFC 4795]Link-Local Multicast Name Resolution (LLMNR)
Direct download: ftp://ftp.rfc-editor.org/in-notes/rfc4795.txt
[RFC 6763]DNS-Based Service Discovery
Direct download: ftp://ftp.rfc-editor.org/in-notes/rfc6763.txt
[RFC 2782]A DNS RR for specifying the location of services (DNS SRV)
Direct download: ftp://ftp.rfc-editor.org/in-notes/rfc2782.txt
[RFC 1035]DOMAIN NAMES - IMPLEMENTATION AND SPECIFICATION
Direct download: ftp://ftp.rfc-editor.org/in-notes/rfc1035.txt


The following table shows the contents of the root directory: 

DirectoryContent
ApplicationContains the example application to run a simple server with embOS/IP.
IPContains the sources.

Background

The different specifications are all based on UDP messages with DNS format. They serve the same purpose to easily identify a target by its name without prior knowledge of its IP address, or to discover the service it is proposing like a web server for example.

mDNS

Apple multicast DNS (mDNS) uses multicast messages on port 5353. A target with a mDNS server could easily be found by a request with its name (by an Apple device for example). The mDNS client is part of the base embOS/IP package and is able to send such requests.

LLMNR

Microsoft Link-Local Multicast Name Resolution (LLMNR) uses multicast messages on port 5355. A target with a LLMNR server could easily be found by a request with its name (by a Windows computer for example). The LLMNR client is part of the base embOS/IP package and is able to send such requests.

Simple DNS server

When the target is used as server, for example with the embOS/IP DHCP server, a client sends unicast requests to the DNS server. The embOS/IP simple DNS server does not provide full DNS server capabilities but covers main requirements with a low memory footprint.

Example

In the following example, a device with a Web server could be easily found by a browser with its name without a prior knowledge of its IP address.

Service discovery

Along with A and AAAA records for the IPv4 and IPv6 addresses, it is also possible to configure SRV, PTR and TXT records. This allows a device to advertise a service and be found by system like Bonjour or equivalent tools (avahi on linux for example).

For example, the following configuration advertises a web server for the device mydevice.local.

//
// Web server discovery configuration
//
static const IP_DNS_SERVER_SD_CONFIG _Config[] = {
  //
  // PTR record _http._tcp.local -> mydevice._http._tcp.local
  //
  {
      .Type    = IP_DNS_SERVER_TYPE_PTR,
      .TTL     = 0,                           // Use main TTL.
      .Config  = {
                   .PTR = {
                            .sName       = "_http._tcp.local",
                            .sDomainName = "mydevice._http._tcp.local"
                          }
                 }
  },
  //
  // SRV record mydevice._http._tcp.local -> mydevice.local port 80
  //
  {
      .Type    = IP_DNS_SERVER_TYPE_SRV,
      .TTL     = 0,                           // Use main TTL.
      .Config  = {
                   .SRV = {
                            .sName       = "mydevice._http._tcp.local",
                            .Priority    = 0,
                            .Weight      = 0,
                            .Port        = 80,
                            .sTarget     = NULL  // Use default hostname mydevice.local
                          }
                 }
  },
  //
  // TXT record. Path of the web server.
  //
  {
      .Type    = IP_DNS_SERVER_TYPE_TXT,
      .TTL     = 0,                           // Use main TTL.
      .Config  = {
                   .TXT = {
                            .sName       = "mydevice._http._tcp.local",
                            .sTXT        = "PATH=/"
                          }
                 }
  }
};

static const IP_DNS_SERVER_CONFIG _DiscoverConfig = {
  .sHostname   = "mydevice.local",
  .TTL         = 120u,
  .NumConfig   = 3,
  .apSDConfig  = _Config
};

The device could then be discovered easily, for example on linux with avahi-discover tool:

In this example the discovery tool and the device exchange the following mDNS messages:

  • Tool sends request: PTR _http._tcp.local to identify web servers.
  • Device replies that it proposes the service mydevice._http._tcp.local
  • Tool sends request: SRV mydevice._http._tcp.local to get service details.
  • Device replies with the SRV information such as the port 80 and server target name mydevice.local.
  • Tool sends request: TXT mydevice._http._tcp.local to get more information.
  • Device replies with the web server path "/"
  • Tool sends request: A mydevice.local and/or AAAA mydevice.local to get the IPv4/IPv6 address.
  • Device replies with its IP address.

Resource usage

The ROM usage depends on the compiler options, the compiler version and the used CPU. The memory requirements presented below have been measured on a Cortex-M4 system with the default configuration.

Only the server is shown below as the client is part of the embOS/IP base package.

ROM usage

The following resource usage has been measured on an Cortex-M4 system using SEGGER Embedded Studio, size optimized.

Add-onROM
embOS/IP mDNS/LLMNR serverApproximately 3.1 kByte

RAM usage

The add-on uses a data for the multicast UDP management.

Add-onRAM
embOS/IP mDNS/LLMNR serverApproximately 0.2 kByte