[mac] add "Radio Filter" mechanism (#7156)

This commit implements new radio filter mechanism in OpenThread. The
radio filter is mainly intended for testing. It can be used to
temporarily block all tx/rx on the IEEE 802.15.4 radio. When radio
filter is enabled, radio is put to sleep instead of receive (to
ensure that the device does not receive any frame and/or potentially
send ack). Also the frame transmission requests return immediately
without sending the frame over the air (return "no ack" error if ack
is requested, otherwise return success). This commit also add CLI
command `radiofilter` for this feature. It also adds test-case
`test_radio_filter` to validate the behavior of the new feature.
This feature requires `OPENTHREAD_CONFIG_MAC_FILTER_ENABLE`.
This commit is contained in:
Abtin Keshavarzian
2021-11-29 12:45:11 -08:00
committed by GitHub
parent e4da1f6c71
commit 912eca181d
13 changed files with 404 additions and 14 deletions
+27
View File
@@ -839,6 +839,21 @@ class NodeImpl:
self.send_command(cmd)
self._expect_done()
def radiofilter_is_enabled(self) -> bool:
states = [r'Disabled', r'Enabled']
self.send_command('radiofilter')
return self._expect_result(states) == 'Enabled'
def radiofilter_enable(self):
cmd = 'radiofilter enable'
self.send_command(cmd)
self._expect_done()
def radiofilter_disable(self):
cmd = 'radiofilter disable'
self.send_command(cmd)
self._expect_done()
def get_bbr_registration_jitter(self):
self.send_command('bbr jitter')
return int(self._expect_result(r'\d+'))
@@ -2000,6 +2015,18 @@ class NodeImpl:
})
return networks
def scan_energy(self, timeout=10):
self.send_command('scan energy')
self.simulator.go(timeout)
rssi_list = []
for line in self._expect_command_output()[2:]:
_, channel, rssi, _ = line.split('|')
rssi_list.append({
'channel': int(channel.strip()),
'rssi': int(rssi.strip()),
})
return rssi_list
def ping(self, ipaddr, num_responses=1, size=8, timeout=5, count=1, interval=1, hoplimit=64, interface=None):
args = f'{ipaddr} {size} {count} {interval} {hoplimit} {timeout}'
if interface is not None: