mirror of
https://github.com/espressif/openthread.git
synced 2026-08-14 22:57:46 +00:00
[thread-cert] refactor case 6.3.1 and 6.3.2 using pktverify (#5372)
This commit is contained in:
@@ -186,8 +186,8 @@ class Cert_5_1_07_MaxChildCount(thread_cert.TestCase):
|
||||
_pkts.filter_mle_cmd(MLE_PARENT_RESPONSE).must_next()
|
||||
_pkts.filter_mle_cmd(MLE_CHILD_ID_RESPONSE).must_next()
|
||||
|
||||
# Step 2:The DUT MUST properly forward ICMPv6 Echo Requests to all MED children
|
||||
# The DUT MUST properly forward ICMPv6 Echo Replies to the Leader
|
||||
# Step 2: The DUT MUST properly forward ICMPv6 Echo Requests to all MED children
|
||||
# The DUT MUST properly forward ICMPv6 Echo Replies to the Leader
|
||||
leader_rloc16 = pv.vars['LEADER_RLOC16']
|
||||
for i in range(1, 5):
|
||||
rloc16 = pv.vars['MED%d_RLOC16' % i]
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
import unittest
|
||||
|
||||
import thread_cert
|
||||
from pktverify.consts import MLE_PARENT_REQUEST, MLE_CHILD_ID_REQUEST, MLE_CHILD_UPDATE_REQUEST, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, MODE_TLV
|
||||
from pktverify.packet_verifier import PacketVerifier
|
||||
|
||||
LEADER = 1
|
||||
ROUTER = 2
|
||||
@@ -39,17 +41,20 @@ ED = 3
|
||||
class Cert_6_3_1_OrphanReattach(thread_cert.TestCase):
|
||||
TOPOLOGY = {
|
||||
LEADER: {
|
||||
'name': 'LEADER',
|
||||
'mode': 'rsdn',
|
||||
'panid': 0xface,
|
||||
'whitelist': [ROUTER]
|
||||
},
|
||||
ROUTER: {
|
||||
'name': 'ROUTER',
|
||||
'mode': 'rsdn',
|
||||
'panid': 0xface,
|
||||
'router_selection_jitter': 1,
|
||||
'whitelist': [LEADER, ED]
|
||||
},
|
||||
ED: {
|
||||
'name': 'ED',
|
||||
'is_mtd': True,
|
||||
'mode': 'rsn',
|
||||
'panid': 0xface,
|
||||
@@ -71,6 +76,7 @@ class Cert_6_3_1_OrphanReattach(thread_cert.TestCase):
|
||||
self.simulator.go(5)
|
||||
self.assertEqual(self.nodes[ED].get_state(), 'child')
|
||||
|
||||
self.collect_ipaddrs()
|
||||
self.nodes[ROUTER].stop()
|
||||
self.nodes[LEADER].add_whitelist(self.nodes[ED].get_addr64())
|
||||
self.nodes[ED].add_whitelist(self.nodes[LEADER].get_addr64())
|
||||
@@ -82,6 +88,31 @@ class Cert_6_3_1_OrphanReattach(thread_cert.TestCase):
|
||||
for addr in addrs:
|
||||
self.assertTrue(self.nodes[LEADER].ping(addr))
|
||||
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
|
||||
LEADER = pv.vars['LEADER']
|
||||
ROUTER = pv.vars['ROUTER']
|
||||
ED = pv.vars['ED']
|
||||
_epkts = pkts.filter_wpan_src64(ED)
|
||||
|
||||
_epkts.filter_mle_cmd(MLE_CHILD_ID_REQUEST).must_next()
|
||||
|
||||
# Step 2: Remove Router from the network
|
||||
# Step 3: The DUT MUST send three MLE Child Update Requests to its parent
|
||||
for i in range(1, 3):
|
||||
_epkts.filter_mle_cmd(MLE_CHILD_UPDATE_REQUEST).filter_wpan_dst64(ROUTER).must_next().must_verify(
|
||||
lambda p: {SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, MODE_TLV} <= set(p.mle.tlv.type))
|
||||
|
||||
# Step 5: The DUT MUST perform the attach procedure with the Leader
|
||||
_epkts.filter_mle_cmd(MLE_PARENT_REQUEST).must_next()
|
||||
_epkts.filter_mle_cmd(MLE_CHILD_ID_REQUEST).filter_wpan_dst64(LEADER).must_next()
|
||||
|
||||
# Step 6: The DUT MUST respond with ICMPv6 Echo Reply
|
||||
_epkts.filter('ipv6.src == {ED_MLEID} and ipv6.dst == {LEADER_MLEID}',
|
||||
**pv.vars).filter_ping_reply().must_next()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
import unittest
|
||||
|
||||
import thread_cert
|
||||
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_DATA_REQUEST, MLE_CHILD_UPDATE_REQUEST, LEADER_DATA_TLV, ADDRESS_REGISTRATION_TLV, MODE_TLV, TIMEOUT_TLV, TLV_REQUEST_TLV, NETWORK_DATA_TLV
|
||||
from pktverify.packet_verifier import PacketVerifier
|
||||
|
||||
LEADER = 1
|
||||
ED = 2
|
||||
@@ -38,11 +40,13 @@ ED = 2
|
||||
class Cert_6_3_2_NetworkDataUpdate(thread_cert.TestCase):
|
||||
TOPOLOGY = {
|
||||
LEADER: {
|
||||
'name': 'LEADER',
|
||||
'mode': 'rsdn',
|
||||
'panid': 0xface,
|
||||
'whitelist': [ED]
|
||||
},
|
||||
ED: {
|
||||
'name': 'MED',
|
||||
'is_mtd': True,
|
||||
'mode': 'rsn',
|
||||
'panid': 0xface,
|
||||
@@ -96,6 +100,31 @@ class Cert_6_3_2_NetworkDataUpdate(thread_cert.TestCase):
|
||||
if addr[0:10] == '2001:2:0:1' or addr[0:10] == '2001:2:0:2':
|
||||
self.assertTrue(self.nodes[LEADER].ping(addr))
|
||||
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
|
||||
LEADER = pv.vars['LEADER']
|
||||
MED = pv.vars['MED']
|
||||
_epkts = pkts.filter_wpan_src64(MED)
|
||||
|
||||
# Step 1: Ensure the topology is formed correctly
|
||||
pkts.filter_mle_cmd(MLE_CHILD_ID_RESPONSE).filter_wpan_src64(LEADER).must_next()
|
||||
|
||||
# Step 3: The DUT MUST send a MLE Child Update Request to the Leader
|
||||
_epkts.range(pkts.index).filter_mle_cmd(MLE_CHILD_UPDATE_REQUEST).must_next().must_verify(
|
||||
lambda p: p.wpan.dst64 == LEADER and {LEADER_DATA_TLV, ADDRESS_REGISTRATION_TLV, MODE_TLV, TIMEOUT_TLV
|
||||
} < set(p.mle.tlv.type))
|
||||
|
||||
# Step 10: The DUT MUST send a MLE Data Request frame to
|
||||
# request the updated Network Data
|
||||
_epkts.filter_mle_cmd(MLE_DATA_REQUEST).must_next().must_verify(
|
||||
lambda p: {TLV_REQUEST_TLV, NETWORK_DATA_TLV} < set(p.mle.tlv.type))
|
||||
|
||||
# Step 12: The DUT MUST send a MLE Child Update Request to the Leader
|
||||
_epkts.filter_mle_cmd(MLE_CHILD_UPDATE_REQUEST).filter_wpan_dst64(LEADER).must_next().must_verify(
|
||||
lambda p: {ADDRESS_REGISTRATION_TLV, MODE_TLV, TIMEOUT_TLV} < set(p.mle.tlv.type))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
@@ -64,6 +64,7 @@ MLE_LINK_REQUEST = 0
|
||||
MLE_LINK_ACCEPT = 1
|
||||
MLE_LINK_ACCEPT_AND_REQUEST = 2
|
||||
MLE_ADVERTISEMENT = 4
|
||||
MLE_DATA_REQUEST = 7
|
||||
MLE_DATA_RESPONSE = 8
|
||||
MLE_PARENT_REQUEST = 9
|
||||
MLE_PARENT_RESPONSE = 10
|
||||
|
||||
Reference in New Issue
Block a user