mirror of
https://github.com/espressif/openthread.git
synced 2026-08-04 18:07:47 +00:00
[thread-cert] add low power case 5_3_01 (#5522)
This commit is contained in:
@@ -99,6 +99,53 @@ jobs:
|
||||
run: |
|
||||
bash <(curl -s https://codecov.io/bash) -x "${{ matrix.compiler.gcov }}" -Z
|
||||
|
||||
packet-verification-low-power:
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
REFERENCE_DEVICE: 1
|
||||
VIRTUAL_TIME: 1
|
||||
COVERAGE: 1
|
||||
PACKET_VERIFICATION: 1
|
||||
THREAD_VERSION: 1.2
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Bootstrap
|
||||
run: |
|
||||
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
|
||||
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel ninja-build
|
||||
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
|
||||
- name: Build
|
||||
run: |
|
||||
./script/test build
|
||||
- name: Run
|
||||
run: |
|
||||
for i in {1..10}
|
||||
do
|
||||
./script/test cert_suite ./tests/scripts/thread-cert/v1_2_LowPower*.py
|
||||
done
|
||||
- uses: actions/upload-artifact@v2
|
||||
if: ${{ failure() }}
|
||||
with:
|
||||
name: packet-verification-low-power-pcaps
|
||||
path: |
|
||||
*.pcap
|
||||
*.json
|
||||
- name: Keep-1-2-only
|
||||
run: |
|
||||
./script/test tar simulation 1.2-bbr
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
- name: Keep-1-2-bbr-only
|
||||
run: |
|
||||
./script/test tar simulation 1.2
|
||||
./script/test untar simulation 1.2-bbr
|
||||
- name: Codecov
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
fail_ci_if_error: true
|
||||
|
||||
expects:
|
||||
runs-on: ubuntu-18.04
|
||||
env:
|
||||
|
||||
@@ -121,6 +121,7 @@ PENDING_TIMESTAMP_TLV = 23
|
||||
ACTIVE_OPERATION_DATASET_TLV = 24
|
||||
PENDING_OPERATION_DATASET_TLV = 25
|
||||
THREAD_DISCOVERY_TLV = 26
|
||||
CSL_SYNCHRONIZED_TIMEOUT = 85
|
||||
|
||||
# Network Layer TLVs
|
||||
NL_TARGET_EID_TLV = 0
|
||||
@@ -257,6 +258,16 @@ TIMEOUT_HOST_READY = 10
|
||||
TIMEOUT_CHILD_DETACH = 120
|
||||
TIMEOUT_REGISTER_MA = 5
|
||||
|
||||
# 802.15.4 Frame Version
|
||||
MAC_FRAME_VERSION_2006 = 1
|
||||
MAC_FRAME_VERSION_2015 = 2
|
||||
|
||||
# CSL
|
||||
CSL_DEFAULT_PERIOD = 3125 # 0.5s, 3125 in units of ten symbols
|
||||
CSL_DEFAULT_PERIOD_IN_SECOND = 0.5
|
||||
US_PER_TEN_SYMBOLS = 160
|
||||
CSL_IE_ID = 0x1a
|
||||
|
||||
if __name__ == '__main__':
|
||||
from pktverify.addrs import Ipv6Addr
|
||||
|
||||
|
||||
@@ -207,6 +207,7 @@ class _list(object):
|
||||
_LAYER_FIELDS = {
|
||||
# WPAN
|
||||
'wpan.fcf': _raw_hex_rev,
|
||||
'wpan.cmd': _auto,
|
||||
'wpan.security': _auto,
|
||||
'wpan.frame_type': _auto,
|
||||
'wpan.pending': _auto,
|
||||
@@ -240,6 +241,8 @@ _LAYER_FIELDS = {
|
||||
'wpan.aux_sec.hdr': _str,
|
||||
'wpan.mic': _auto,
|
||||
'wpan.channel': _auto,
|
||||
'wpan.header_ie.id': _list(_auto),
|
||||
'wpan.header_ie.csl.period': _auto,
|
||||
|
||||
# MLE
|
||||
'mle.cmd': _auto,
|
||||
|
||||
@@ -395,6 +395,16 @@ class PacketFilter(object):
|
||||
"""
|
||||
return self.filter(attrgetter('wpan'), **kwargs)
|
||||
|
||||
def filter_wpan_version(self, version: int, **kwargs):
|
||||
"""
|
||||
Create a new PacketFilter for filter WPAN packets of a given version.
|
||||
|
||||
:param version: The version to filter.
|
||||
:param kwargs: Extra arguments for `filter`.
|
||||
:return: The new PacketFilter to filter WPAN packets.
|
||||
"""
|
||||
return self.filter(lambda p: p.wpan.version == version, **kwargs)
|
||||
|
||||
def filter_wpan_channel(self, channel: int, **kwargs):
|
||||
"""
|
||||
Create a new PacketFilter for filter WPAN packets of a given channel.
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
#!/usr/bin/env python3
|
||||
#
|
||||
# Copyright (c) 2020, 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.
|
||||
#
|
||||
|
||||
import unittest
|
||||
|
||||
from config import ADDRESS_TYPE
|
||||
from mac802154 import MacHeader
|
||||
from pktverify import consts
|
||||
from pktverify.packet_verifier import PacketVerifier
|
||||
|
||||
import thread_cert
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
SSED_1 = 3
|
||||
|
||||
|
||||
class LowPower_5_3_01_SSEDAttachment(thread_cert.TestCase):
|
||||
TOPOLOGY = {
|
||||
LEADER: {
|
||||
'version': '1.2',
|
||||
'name': 'LEADER',
|
||||
'mode': 'rsdn',
|
||||
'panid': 0xface,
|
||||
'allowlist': [ROUTER, SSED_1]
|
||||
},
|
||||
ROUTER: {
|
||||
'version': '1.2',
|
||||
'name': 'ROUTER',
|
||||
'mode': 'rsdn',
|
||||
'panid': 0xface,
|
||||
'router_selection_jitter': 1,
|
||||
'allowlist': [LEADER],
|
||||
},
|
||||
SSED_1: {
|
||||
'version': '1.2',
|
||||
'name': 'SSED_1',
|
||||
'mode': 's',
|
||||
'panid': 0xface,
|
||||
'allowlist': [LEADER],
|
||||
},
|
||||
}
|
||||
|
||||
def test(self):
|
||||
self.nodes[LEADER].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[LEADER].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[ROUTER].get_state(), 'router')
|
||||
|
||||
self.nodes[SSED_1].set_csl_period(consts.CSL_DEFAULT_PERIOD)
|
||||
self.nodes[SSED_1].start()
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[SSED_1].get_state(), 'child')
|
||||
|
||||
self.simulator.go(5)
|
||||
|
||||
self.collect_rloc16s()
|
||||
self.collect_rlocs()
|
||||
|
||||
# Verify connectivity by sending an ICMP Echo Request from the Router to SSED_1 mesh-local address via the DUT
|
||||
# Set ping timeout as two CSL periods.
|
||||
timeout = 2 * consts.CSL_DEFAULT_PERIOD_IN_SECOND
|
||||
self.assertTrue(self.nodes[ROUTER].ping(self.nodes[SSED_1].get_ip6_address(ADDRESS_TYPE.RLOC),
|
||||
timeout=timeout))
|
||||
|
||||
# Verify fragmented CSL transmission
|
||||
self.assertTrue(self.nodes[ROUTER].ping(self.nodes[SSED_1].get_ip6_address(ADDRESS_TYPE.RLOC),
|
||||
size=128,
|
||||
timeout=timeout * 2))
|
||||
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
LEADER = pv.vars['LEADER']
|
||||
ROUTER = pv.vars['ROUTER']
|
||||
SSED_1 = pv.vars['SSED_1']
|
||||
|
||||
# Step 1: ensure the Leader is sending MLE Advertisements
|
||||
pkts.filter_wpan_src64(LEADER) \
|
||||
.filter_mle_cmd(consts.MLE_ADVERTISEMENT) \
|
||||
.must_next()
|
||||
|
||||
# Step 2: Verify that the frame version is IEEE Std 802.15.4-2015 of the MLE Child Update Response from the
|
||||
# DUT to SSED_1
|
||||
pkts.filter_wpan_src64(LEADER) \
|
||||
.filter_wpan_dst64(SSED_1) \
|
||||
.filter_mle_cmd(consts.MLE_CHILD_UPDATE_RESPONSE) \
|
||||
.filter_wpan_version(consts.MAC_FRAME_VERSION_2015) \
|
||||
.must_next()
|
||||
|
||||
# Step 3:
|
||||
# Verify that SSED_1 does not send a MAC Data Request prior to receiving the ICMP Echo Request from the Leader.
|
||||
# Verify that the frame version is IEEE Std 802.15.4-2015 of the ICMP Echo Request sent to SSED_1 from the DUT
|
||||
# Verify that the Router successfully receives an Echo Response from SSED_1
|
||||
ssed_rloc16 = pv.vars['SSED_1_RLOC16']
|
||||
ssed_rloc = pv.vars['SSED_1_RLOC']
|
||||
leader_rloc16 = pv.vars['LEADER_RLOC16']
|
||||
router_rloc16 = pv.vars['ROUTER_RLOC16']
|
||||
router_rloc = pv.vars['ROUTER_RLOC']
|
||||
pkts.filter_wpan_src64(LEADER) \
|
||||
.filter('wpan.dst16 == {rloc16}', rloc16 = ssed_rloc16) \
|
||||
.filter_ipv6_dst(ssed_rloc) \
|
||||
.filter_ping_request() \
|
||||
.filter_wpan_version(consts.MAC_FRAME_VERSION_2015) \
|
||||
.must_next()
|
||||
idx1 = pkts.index
|
||||
pkts.filter_wpan_src64(SSED_1) \
|
||||
.filter('wpan.dst16 == {rloc16}', rloc16 = leader_rloc16) \
|
||||
.filter_ipv6_dst(router_rloc) \
|
||||
.filter_ping_reply() \
|
||||
.filter_wpan_version(consts.MAC_FRAME_VERSION_2015) \
|
||||
.must_next() \
|
||||
.must_verify(lambda p: (p.wpan.ie_present == 1) and (consts.CSL_IE_ID in p.wpan.header_ie.id))
|
||||
idx2 = pkts.index
|
||||
pkts.range(idx1, idx2).filter(lambda p: p.wpan.cmd == MacHeader.CommandIdentifier.DATA_REQUEST) \
|
||||
.must_not_next()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Reference in New Issue
Block a user