mirror of
https://github.com/espressif/openthread.git
synced 2026-07-28 14:47:46 +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:
@@ -183,12 +183,15 @@ void Notifier::EmitEvents(void)
|
||||
#if OPENTHREAD_CONFIG_BORDER_ROUTING_ENABLE
|
||||
Get<BorderRouter::RoutingManager>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_SRP_SERVER_ENABLE
|
||||
Get<Srp::Server>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_SRP_CLIENT_ENABLE
|
||||
Get<Srp::Client>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
#if OPENTHREAD_CONFIG_NETDATA_PUBLISHER_ENABLE
|
||||
// The `NetworkData::Publisher` is notified last (e.g., after SRP
|
||||
// client) to allow other modules to request changes to what is
|
||||
// being published (if needed).
|
||||
Get<NetworkData::Publisher>().HandleNotifierEvents(events);
|
||||
#endif
|
||||
|
||||
for (ExternalCallback &callback : mExternalCallbacks)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user