mDNS Device Discovery

This example demonstrates how to find the module on the network using a network discovery protocol such as mDNS, LLMNR or Netbios (ZentriOS includes support for all of these protocols). Network discovery enables you to connect with the module using a known domain, rather than a dynamically allocated IP address.

Note: mDNS is not available with some Android apps. See Networking and Security, Network Discovery, Android.


This example demonstrates how to:


Setup

To run this example follow these steps:

Connect Your Module to the Local Network

To configure mDNS, use a ZentriOS terminal - see Getting Started. Once you have a terminal connected, issue the following ZentriOS command to configure the credentials for the local network:

network_up -s

Enable the mDNS Daemon

Enable mDNS and specify the domain advertised by the module using the following commands:

set mdns.enabled 1
set mdns.name mymodule

Save the mDNS configuration, then restart the network:

save
network_down
network_up

The module automatically starts the network discovery service after connecting to the network.

The response from ZentriOS is similar to the following:

ZentriOS-2.1.0.x, Built:2015-01-14 21:34:43 for AMW004.3, Board:AMW004-E03.3
[Ready]
[Associating to mynetwork]
> Obtaining IPv4 address via DHCP
IPv4 address: 10.5.6.59
Starting mDNS
mDNS domain: mymodule.local
[Associated]

Ping the Module using the mDNS Domain

From a command line on a Mac or Windows PC connected to the same local network, send an ICMP ping to the module.

C:\> ping mymodule.local
Pinging mymodule.local [10.5.6.59] with 32 bytes of data:
Reply from 10.5.6.59: bytes=32 time=308ms TTL=128
Reply from 10.5.6.59: bytes=32 time=8ms TTL=128
Reply from 10.5.6.59: bytes=32 time=4ms TTL=128
Reply from 10.5.6.59: bytes=32 time=96ms TTL=128

NOTE: Some ISPs hijack the .local domain which confuses Microsoft Windows, so it may be necessary to omit .local from the name on Windows platforms.

If there is no response (on a Windows PC), try sending the ping directly to the module name instead.

C:\> ping mymodule
Pinging mymodule [10.5.6.59] with 32 bytes of data:
Reply from 10.5.6.59: bytes=32 time=33ms TTL=128
Reply from 10.5.6.59: bytes=32 time=17ms TTL=128
Reply from 10.5.6.59: bytes=32 time=5ms TTL=128
Reply from 10.5.6.59: bytes=32 time=29ms TTL=128

This example assumes the network credentials are set up as described in Connect Your Module to the Local Network.

To advertise an mDNS service, you need to start a ZentriOS server. This example uses the HTTP server. To enable the HTTP server, issue the ZentriOS commands:

set http.server.enabled     1
set http.server.api_enabled 1

Advertise the service using the mdns.service variable:

> set md s http "Test Server" "record1=on.record2=off.another=21"

The server name and TXT record name=value pairs are arbitrary in this case. For specific applications, there may be a required naming convention and format for the TXT record information.

Restart the network to begin advertising:

network_down
network_up

The response is similar to the following:

[Associating to Zentri]
In progress
> Obtaining IPv4 address via DHCP
IPv4 address: 10.5.6.82
Starting mDNS
mDNS domain: mymodule.local
Adding mDNS service: Test Server._http._tcp.local
HTTP and REST API server listening on port: 80
[Associated]

Note the line Adding mDNS service: Test Server._http._tcp.local.

This means a device capable of browsing for mDNS services will be able to discover your "Test Server" service in the .local domain, among the _http._tcp. services, and read its name and TXT record for additional information.

If you have a Bonjour browser app you can view the module's advertised services.

To disable advertising of the service, set the server's name to -1: set md s http -1 Now bring the network down and back up:

network_down
network_up

The response is similar to the following:

[2015-01-29 | 06:44:48: Associating to Zentri]
In progress
> Obtaining IPv4 address via DHCP
IPv4 address: 10.5.6.82
Starting mDNS
mDNS domain: nealemodule.local
HTTP and REST API server listening on port: 80
[2015-01-29 | 06:44:51: Associated]

Note that the Adding mDNS service line no longer appears.

If you have a Bonjour browser app you can see that the module service is no longer advertised.


Supporting ZentriOS Editions and Versions

Change Log

ModifiedChanges
2015-02-03Created