[routing-manager] introduce MultiAilDetector (#11400)

This commit introduces the `MultiAilDetector` feature within the
`RoutingManager`. This feature detects whether Border Routers(BRs) on
the Thread mesh might be connected to different Adjacent
Infrastructure Links (AILs).

The feature can be enabled using the configuration option
`OPENTHREAD_CONFIG_BORDER_ROUTING_MULTI_AIL_DETECTION_ENABLE`.

The detection mechanism operates as follows: The Routing Manager
monitors the number of peer BRs listed in the Thread Network Data and
compares this with the number of peer BRs discovered by processing
received Router Advertisements (RAs) on its local AIL.

If the count derived from Network Data consistently exceeds the count
derived from RAs for a detection period of 5 minutes, the detector
concludes that BRs are likely connected to different AILs. This
triggers a detection state change, and a registered callback is
invoked. To clear this state, a shorter window of 1 minute is used.

Public APIs and corresponding CLI commands have been added to allow
checking the current detection state and registering a callback for
state change notifications.

This commit also includes test coverage for the newly added feature.
This commit is contained in:
Abtin Keshavarzian
2025-04-22 13:44:12 -07:00
committed by GitHub
parent 16bafadb59
commit 283edc0bd5
12 changed files with 565 additions and 1 deletions
+3
View File
@@ -851,6 +851,9 @@ class Node(object):
def br_count_peers(self):
return self._cli_single_output('br peers count')
def br_get_multiail(self):
return self._cli_single_output('br multiail')
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# trel
+142
View File
@@ -0,0 +1,142 @@
#!/usr/bin/env python3
#
# Copyright (c) 2025, The OpenThread Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
from cli import verify
from cli import verify_within
import cli
import time
# -----------------------------------------------------------------------------------------------------------------------
# Test description:
#
# Check multi AIL detection
#
# -+- _______
# | / \
# br1 --- br2 --- br3
#
test_name = __file__[:-3] if __file__.endswith('.py') else __file__
print('-' * 120)
print('Starting \'{}\''.format(test_name))
# -----------------------------------------------------------------------------------------------------------------------
# Creating `cli.Nodes` instances
speedup = 60
cli.Node.set_time_speedup_factor(speedup)
one_minute = 60
br1 = cli.Node()
br2 = cli.Node()
br3 = cli.Node()
IF_INDEX_1 = 1
IF_INDEX_2 = 2
# -----------------------------------------------------------------------------------------------------------------------
# Form topology
br1.form("multiail")
br2.join(br1)
br3.join(br2)
verify(br1.get_state() == 'leader')
verify(br2.get_state() == 'router')
verify(br3.get_state() == 'router')
# -----------------------------------------------------------------------------------------------------------------------
# Test implementation
# Start first border router `br1`
br1.srp_server_set_addr_mode('unicast')
br1.srp_server_auto_enable()
br1.br_init(IF_INDEX_1, 1)
br1.br_enable()
time.sleep(one_minute / speedup)
verify(br1.br_get_state() == 'running')
verify(br1.br_get_multiail() == 'not detected')
# Start `br2` and `br3` together on a different AIL
br2.br_init(IF_INDEX_2, 1)
br2.br_enable()
br3.br_init(IF_INDEX_2, 1)
br3.br_enable()
time.sleep(one_minute / speedup)
verify(br2.br_get_state() == 'running')
verify(br3.br_get_state() == 'running')
verify(br2.br_get_multiail() == 'not detected')
verify(br3.br_get_multiail() == 'not detected')
# wait for longer than 10 minutes and check that multi AIL is detected
time.sleep(10.01 * one_minute / speedup)
verify(br1.br_get_multiail() == 'detected')
verify(br2.br_get_multiail() == 'detected')
verify(br3.br_get_multiail() == 'detected')
# Disable `br1`
br1.br_disable()
verify(br1.br_get_state() == 'disabled')
time.sleep(9 * one_minute / speedup)
verify(br2.br_get_multiail() == 'not detected')
verify(br3.br_get_multiail() == 'not detected')
# Enable `br` again, wait for a short time (before detection) and disable it
br1.br_enable()
time.sleep(2 * one_minute / speedup)
verify(br1.br_get_state() == 'running')
br1.br_disable()
verify(br1.br_get_state() == 'disabled')
time.sleep(10 * one_minute / speedup)
verify(br2.br_get_multiail() == 'not detected')
verify(br3.br_get_multiail() == 'not detected')
# -----------------------------------------------------------------------------------------------------------------------
# Test finished
cli.Node.finalize_all_nodes()
print('\'{}\' passed.'.format(test_name))
+1
View File
@@ -208,6 +208,7 @@ if [ "$TORANJ_CLI" = 1 ]; then
run cli/test-502-multi-br-leader-failure-recovery.py
run cli/test-503-peer-tbr-discovery.py
run cli/test-504-br-icmp-unreach-err.py
run cli/test-505-multi-ail-detection.py
run cli/test-601-channel-manager-channel-change.py
# Skip the "channel-select" test on a TREL only radio link, since it
# requires energy scan which is not supported in this case.