Automatic Service Discovery¶
Automatic Service Discovery feature enables possibility to discover VSMs in case UgCS server and VSM is using dynamic addresses. Used SSDP protocol (https://tools.ietf.org/html/draft-cai-ssdp-v1-03) as basis and actual data from packet captures when Windows and iOS searches for various stuff on my LAN.
There are three messages invloved. They are HTTP messages without body, formatted according to HTTP specs, rfc7230.
Search. Issued by locator (UgCS server, in our case) on all interfaces using multicast address 22.214.171.124 to locate the requested service by type (ST). For example:
M-SEARCH * HTTP/1.1 Host: 126.96.36.199:1900 Man: "ssdp:discover" ST: ugcs:vsm:ardupilot MX: 3
Response to search. Sent by service as a response to M-SEARCH. Unicast. Contains service type (ST), unique service name (USN) and location (Location). For example:
HTTP/1.1 200 OK ST: ugcs:vsm:ardupilot USN: Ardupilot VSM Location: 192.168.1.33:5556 ID: 12345678
Notification. Sent by service when it becomes available. Multicast. Contains service type (NT), unique service name (USN) and location (Location). For example:
NOTIFY * HTTP/1.1 Host: 188.8.131.52:1900 NT: ugcs:vsm:ardupilot NTS: ssdp:alive USN: Ardupilot VSM Location: 192.168.1.33:5556 ID: 12345678
There is a field “ID” added to the response and notify message. It specifies the service instance. Service client can use the ID field to distinguish between several locations of the same service instance to avoud multiple simultaneous connections. The ID is randomly generated on VSM startup and does change with each restart.
Service discovery support in SDK¶
VSM SDK has support of automatic service discovery based on the above protocol.
Both ends are implemented in SDK, so developer can create both service advertisers and service locators with minimal effort. Five functions provide interface to service discovery protocol:
service_discovery_processor.h for details.
Service advertise support is already enabled by default and can be used by any VSM by adding lines to vsm.conf file.