mDNS Capture for Device Typing
Design
This feature enhances the mdns_plugin (opensync/src/lib/mdns_plugin/) to collect, store and report mDNS resource records to the controller via MQTT.
When enabled by the controller, the plugin now collects mDNS responses from the mDNS supported clients.
The records are grouped by the MAC address of the sender, and reported to the controller at regular intervals.
The plugin collects records from both IPv4 and IPv6 clients.
The records are filtered for duplicates, and only reported once.
The records are stored in the firmware until their TTL expires.
The mdns_plugin was mainly implemented to provide service announcements. This feature builds on the existing mdns_plugin and extends it to collect, store and report the mDNS records.
To enable the plugin, and reporting of records, the controller would add an entry into the Flow_Service_Manager_Config table as follows:
$ ovsh s Flow_Service_Manager_Config -w handler==dev_mdns
---------------------------------------------------------------------------------------------------
_uuid | d437~1331 |
_version | a632~eee3 |
handler | dev_mdns |
if_name | br-home.tmdns |
other_config | ["map",[["dso_init","mdns_plugin_init"],["mdns_src_ip","10.0.0.100"],["mqtt_v", |
: "dev-test/MDNS/Records/dev_mdns/xxxx808DB4/xxxx194bb035943840164585"], :
: ["records_report_interval","60"],["report_records","true"]]] :
pkt_capt_filter | ["set",[]] |
plugin | /usr/osync/lib/libfsm_mdns.so |
type | ["set",[]]
Importantly, for the plugin to start recording mDNS responses and reporting them to the controller, it would need the following:
"mqtt_v": A unique MQTT topic to send the data on.
"records_report_interval": The interval at which the plugin will report the mDNS records to the controller. If this value is not provided by the controller, the plugin will use a default value of 60 seconds.
"report_records": This should be set to true for the plugin to store and report records. If this is not set, the plugin will neither store nor report the mDNS records to the controller.
The "report_records" parameter in the "other_config" allows the plugin to decouple the Service_Announcements.
If only service announcements are to be enabled, the controller will populate the Service_Announcement table as usual, and set "report_records" to be false (or don't set it at all, default it set to false).
If only records reporting is to be enabled, don't populate Service_Announcement table. Just set
"report_records" and "records_report_interval".
The mDNS plugin is different from the other FSM plugins in a way that it doesn't open a raw socket on the
port provided by "pkt_capt_filter". The mDNS plugin uses the libmdnsd library to get the mDNS responses from. The libmdnsd open two multicast sockets - one for IPv4 and another for IPv6, both on port 5353.
Look at https://github.com/plume-design/opensync/blob/osync_2.4.0/src/lib/mdns_plugin/src/mdns_daemon.c
How to Test
The first thing required to test the plugin is a mDNS-capable client, which needs to be connected to the node. A RPI or linux laptop can be made as an mDNS plugin using the following: https://github.com/troglobit/mdnsd.
The code should be downloaded onto the RPI, compiled and installed. All the instructions to compile and install the mDNS client are provided on the github page. Once installed, the client would need some Service Records to send out. These records should be placed in /etc/mdns.d/
on the client. The format and content on these records are also specified on the github page.
Once the client is ready, the best way to enable the plugin is to use the FUT scripts located at
https://github.com/plume-design/opensync/tree/osync_2.4.0/src/lib/mdns_plugin/tests/fut.
Once the script is enabled, start the mDNS client on the RPI. These records will be received on the plugin, and reported to the controller via MQTT. To check the MQTT report, use the logs.
Published Content
https://www.opensync.io/s/EDE-021-030-501_FSM_Plugins.pdf
https://www.opensync.io/s/ERE-021-061-701_FSM_Plugin_Requirements.pdf