mirror of
https://github.com/espressif/openthread.git
synced 2026-09-01 06:49:54 +00:00
[netdata] adding NetworkData::Publisher (#6768)
This commit implements a new feature "Network Data Publisher" which provides mechanisms to limit the number of similar entries (service and/or prefix) in the Thread Network Data by monitoring the Network Data and managing if or when to add or remove entries. This feature is enabled using `OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE` config, or `NETDATA_PUBLISHER` in autoconf, or `OT_NETDATA_PUBLISHER` cmake option. This commit adds support for publishing DNS/SRP anycast/unicast service, on-mesh prefix, and external route prefix entries. When there is a request to publish an entry, the `Publisher` monitors the Network Data and counts the number of similar entries. If there are fewer entries than a desired target number, the entry is added after a short random delay. If there are too many similar entries, `Publisher` starts the process of removing its own entry (again after some random wait time). When removing entries, certain entries are preferred over others (e.g., an entry from a router over one from an end-device or if they are from the same type of node, the one with smaller RLOC16). If `Publisher` determines that its own entry is a preferred one, it adds an extra wait time before removing its entry. This gives higher chance for a non-preferred entry from another device to be removed before removing a preferred entry which helps towards quicker convergence of the process to the desired number of entries. On-mesh prefix and external route entries have a "preference" field. When publishing such an entry, a matching entry in the network data is counted only if its preference is same or higher than the entry's preference. This ensures that a device with a higher preference entry publishes its entry even when there are many lower preference similar entries in the network data (potentially causing a lower preference entry to be removed). This commit also adds `test_netdata_publisher.py` to verify the behavior of the `Publisher`.
This commit is contained in:
@@ -1715,6 +1715,34 @@ class NodeImpl:
|
||||
self.send_command('netdata register')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_dnssrp_anycast(self, seqnum):
|
||||
self.send_command(f'netdata publish dnssrp anycast {seqnum}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_dnssrp_unicast(self, address, port):
|
||||
self.send_command(f'netdata publish dnssrp unicast {address} {port}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_dnssrp_unicast_mleid(self, port):
|
||||
self.send_command(f'netdata publish dnssrp unicast {port}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_unpublish_dnssrp(self):
|
||||
self.send_command('netdata unpublish dnssrp')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_prefix(self, prefix, flags='paosr', prf='med'):
|
||||
self.send_command(f'netdata publish prefix {prefix} {flags} {prf}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_publish_route(self, prefix, flags='s', prf='med'):
|
||||
self.send_command(f'netdata publish route {prefix} {flags} {prf}')
|
||||
self._expect_done()
|
||||
|
||||
def netdata_unpublish_prefix(self, prefix):
|
||||
self.send_command(f'netdata unpublish {prefix}')
|
||||
self._expect_done()
|
||||
|
||||
def send_network_diag_get(self, addr, tlv_types):
|
||||
self.send_command('networkdiagnostic get %s %s' % (addr, ' '.join([str(t.value) for t in tlv_types])))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user