mirror of
https://github.com/espressif/openthread.git
synced 2026-08-13 22:27:47 +00:00
[thread-cert] refactor case 9.2.9 using pktverify (#5962)
This commit is contained in:
@@ -211,8 +211,8 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
# Step 2: Commissioner sends MGMT_ACTIVE_SET.req to Leader RLOC or Anycast Locator
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(LEADER_RLOC, LEADER_ALOC).filter_coap_request(
|
||||
MGMT_ACTIVE_SET_URI).filter(lambda p: p.thread_meshcop.tlv.xpan_id == '000db70000000000' and p.
|
||||
thread_meshcop.tlv.net_name == 'GRL' and p.thread_meshcop.tlv.chan_mask_mask ==
|
||||
'001fffe0' and p.thread_meshcop.tlv.active_tstamp == 101).must_next()
|
||||
thread_meshcop.tlv.net_name == ['GRL'] and p.thread_meshcop.tlv.chan_mask_mask
|
||||
== '001fffe0' and p.thread_meshcop.tlv.active_tstamp == 101).must_next()
|
||||
|
||||
# Step 3: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -225,15 +225,15 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
# Step 5: The Leader MUST send MGMT_ACTIVE_GET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(
|
||||
MGMT_ACTIVE_GET_URI).filter(lambda p: p.thread_meshcop.tlv.active_tstamp == 101 and p.thread_meshcop.tlv.
|
||||
xpan_id == '000db70000000000' and p.thread_meshcop.tlv.net_name == 'GRL' and p.
|
||||
thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
xpan_id == '000db70000000000' and p.thread_meshcop.tlv.net_name == ['GRL'] and
|
||||
p.thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
|
||||
# Step 6: Commissioner sends MGMT_ACTIVE_SET.req to Leader RLOC or Anycast Locator
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 102 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000001' and p.thread_meshcop.tlv.net_name == 'threadcert' and p.thread_meshcop.tlv.
|
||||
chan_mask_mask == '001fffe0' and p.thread_meshcop.tlv.channel == 18).must_next()
|
||||
'000db70000000001' and p.thread_meshcop.tlv.net_name == ['threadcert'] and p.thread_meshcop.tlv.
|
||||
chan_mask_mask == '001fffe0' and p.thread_meshcop.tlv.channel == [18]).must_next()
|
||||
|
||||
# Step 7: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -243,8 +243,8 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 103 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'UL' and p.thread_meshcop.tlv.chan_mask_mask ==
|
||||
'001fffe0' and p.thread_meshcop.tlv.ml_prefix == 'fd000db700000000').must_next()
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['UL'] and p.thread_meshcop.tlv.chan_mask_mask
|
||||
== '001fffe0' and p.thread_meshcop.tlv.ml_prefix == 'fd000db700000000').must_next()
|
||||
|
||||
# Step 9: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -254,7 +254,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 104 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'GRL' and p.thread_meshcop.tlv.master_key ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['GRL'] and p.thread_meshcop.tlv.master_key ==
|
||||
'ffeeddccbbaa99887766554433221100' and p.thread_meshcop.tlv.chan_mask_mask == '001fffe0' and p.
|
||||
thread_meshcop.tlv.ml_prefix == 'fd000db700000000').must_next()
|
||||
|
||||
@@ -266,9 +266,9 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 105 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'UL' and p.thread_meshcop.tlv.master_key ==
|
||||
'00112233445566778899aabbccddeeff' and p.thread_meshcop.tlv.pan_id == 0xafce and p.thread_meshcop.tlv.
|
||||
chan_mask_mask == '001fffe0' and p.thread_meshcop.tlv.ml_prefix == 'fd000db700000000').must_next()
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['UL'] and p.thread_meshcop.tlv.master_key ==
|
||||
'00112233445566778899aabbccddeeff' and p.thread_meshcop.tlv.pan_id == [0xafce] and p.thread_meshcop.tlv
|
||||
.chan_mask_mask == '001fffe0' and p.thread_meshcop.tlv.ml_prefix == 'fd000db700000000').must_next()
|
||||
|
||||
# Step 13: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -278,7 +278,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 106 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'UL' and p.thread_meshcop.tlv.
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['UL'] and p.thread_meshcop.tlv.
|
||||
commissioner_sess_id == 0xabcd and p.thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
|
||||
# Step 15: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
@@ -288,8 +288,8 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
# Step 16: Commissioner sends MGMT_ACTIVE_SET.req to Leader RLOC or Leader Anycast Locator
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(LEADER_RLOC, LEADER_ALOC).filter_coap_request(
|
||||
MGMT_ACTIVE_SET_URI).filter(lambda p: p.thread_meshcop.tlv.active_tstamp == 101 and p.thread_meshcop.tlv.
|
||||
xpan_id == '000db70000000000' and p.thread_meshcop.tlv.net_name == 'UL' and p.
|
||||
thread_meshcop.tlv.chan_mask_mask == '001fff80').must_next()
|
||||
xpan_id == '000db70000000000' and p.thread_meshcop.tlv.net_name == ['UL'] and p
|
||||
.thread_meshcop.tlv.chan_mask_mask == '001fff80').must_next()
|
||||
|
||||
# Step 17: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -299,8 +299,8 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 107 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'UL' and p.thread_meshcop.tlv.steering_data ==
|
||||
Bytes('113320440000') and p.thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['UL'] and p.thread_meshcop.tlv.steering_data
|
||||
== Bytes('113320440000') and p.thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
|
||||
# Step 19: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
pkts.filter_wpan_src64(LEADER).filter_ipv6_dst(COMMISSIONER_RLOC).filter_coap_ack(MGMT_ACTIVE_SET_URI).filter(
|
||||
@@ -310,7 +310,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
|
||||
pkts.filter_wpan_src64(COMMISSIONER).filter_ipv6_2dsts(
|
||||
LEADER_RLOC, LEADER_ALOC).filter_coap_request(MGMT_ACTIVE_SET_URI).filter(
|
||||
lambda p: p.thread_meshcop.tlv.active_tstamp == 108 and p.thread_meshcop.tlv.xpan_id ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == 'GRL' and p.thread_meshcop.tlv.unknown ==
|
||||
'000db70000000000' and p.thread_meshcop.tlv.net_name == ['GRL'] and p.thread_meshcop.tlv.unknown ==
|
||||
'aa55' and p.thread_meshcop.tlv.chan_mask_mask == '001fffe0').must_next()
|
||||
|
||||
# Step 21: Leader MUST send MGMT_ACTIVE_SET.rsp to the Commissioner
|
||||
|
||||
@@ -249,7 +249,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
|
||||
p.mle.tlv.active_tstamp == 100 and\
|
||||
p.thread_meshcop.tlv.chan_mask_mask == '001fffc0' and\
|
||||
p.thread_meshcop.tlv.xpan_id == '000db80000000001' and\
|
||||
p.thread_meshcop.tlv.net_name == 'TEST_1' and\
|
||||
p.thread_meshcop.tlv.net_name == ['TEST_1'] and\
|
||||
p.thread_meshcop.tlv.pskc == 'd2aa9cd8dff7919122d77d37ec3c1b5f'
|
||||
).\
|
||||
must_next()
|
||||
@@ -342,7 +342,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
|
||||
p.mle.tlv.active_tstamp == 101 and\
|
||||
p.thread_meshcop.tlv.chan_mask_mask == '001fff00' and\
|
||||
p.thread_meshcop.tlv.xpan_id == '000db80000000003' and\
|
||||
p.thread_meshcop.tlv.net_name == 'TEST_3' and\
|
||||
p.thread_meshcop.tlv.net_name == ['TEST_3'] and\
|
||||
p.thread_meshcop.tlv.pskc == '08f4e9531e8efa8e852d5f4fb951b13e'
|
||||
).\
|
||||
must_next()
|
||||
|
||||
@@ -223,7 +223,7 @@ class Cert_9_2_7_DelayTimer(thread_cert.TestCase):
|
||||
p.mle.tlv.type) and {NM_CHANNEL_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_PAN_ID_TLV, NM_DELAY_TIMER_TLV} <=
|
||||
set(p.thread_meshcop.tlv.type) and p.mle.tlv.active_tstamp == ROUTER_ACTIVE_TIMESTAMP and p.mle.
|
||||
tlv.pending_tstamp == COMMISSIONER_PENDING_TIMESTAMP and p.thread_meshcop.tlv.pan_id ==
|
||||
COMMISSIONER_PENDING_PANID and p.thread_meshcop.tlv.channel == COMMISSIONER_PENDING_CHANNEL)
|
||||
[COMMISSIONER_PENDING_PANID] and p.thread_meshcop.tlv.channel == [COMMISSIONER_PENDING_CHANNEL])
|
||||
|
||||
# Step 21: Router MUST respond with an ICMPv6 Echo Reply
|
||||
pkts.filter_wpan_src16_dst16(ROUTER_RLOC16, LEADER_RLOC16).filter_ping_reply().must_next()
|
||||
|
||||
@@ -206,9 +206,9 @@ class Cert_9_2_8_PersistentDatasets_Base(thread_cert.TestCase):
|
||||
p.thread_meshcop.tlv.delay_timer ==
|
||||
COMMISSIONER_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.channel ==
|
||||
COMMISSIONER_PENDING_CHANNEL and\
|
||||
[COMMISSIONER_PENDING_CHANNEL] and\
|
||||
p.thread_meshcop.tlv.pan_id ==
|
||||
COMMISSIONER_PENDING_PANID and\
|
||||
[COMMISSIONER_PENDING_PANID] and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
@@ -29,27 +29,66 @@
|
||||
|
||||
import unittest
|
||||
|
||||
import config
|
||||
import thread_cert
|
||||
from pktverify.consts import MLE_CHILD_ID_REQUEST, MLE_CHILD_ID_RESPONSE, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_PENDING_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_DATASET_CHANGED_URI, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, TLV_REQUEST_TLV, NETWORK_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_DELAY_TIMER_TLV, PENDING_OPERATION_DATASET_TLV, NWD_COMMISSIONING_DATA_TLV, LEADER_ALOC, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
|
||||
from pktverify.packet_verifier import PacketVerifier
|
||||
from pktverify.null_field import nullField
|
||||
|
||||
CHANNEL_INIT = 19
|
||||
PANID_INIT = 0xface
|
||||
TIMESTAMP_INIT = 10
|
||||
CHANNEL_SECOND = 20
|
||||
|
||||
CHANNEL_FINAL = 19
|
||||
PANID_FINAL = 0xabcd
|
||||
|
||||
ROUTER2_ACTIVE_TIMESTAMP = 15
|
||||
ROUTER2_PENDING_ACTIVE_TIMESTAMP = 410
|
||||
ROUTER2_PENDING_TIMESTAMP = 50
|
||||
ROUTER2_DELAY_TIMER = 200000
|
||||
ROUTER2_NET_NAME = 'TEST'
|
||||
|
||||
COMM_PENDING_ACTIVE_TIMESTAMP = 210
|
||||
COMM_PENDING_TIMESTAMP = 30
|
||||
COMM_DELAY_TIMER = 1000000
|
||||
|
||||
COMMISSIONER = 1
|
||||
LEADER = 2
|
||||
ROUTER1 = 3
|
||||
ROUTER2 = 4
|
||||
|
||||
# Test Purpose and Description:
|
||||
# -----------------------------
|
||||
# The purpose of this test case is to verify how Pending Operational Datasets
|
||||
# are synchronized when two partitions merge.
|
||||
#
|
||||
# Test Topology:
|
||||
# -------------
|
||||
# Commissioner
|
||||
# |
|
||||
# Leader
|
||||
# |
|
||||
# Router_1
|
||||
# |
|
||||
# Router_2
|
||||
#
|
||||
# Note: Router_1 and Router_2 will be in&out RF shield box
|
||||
#
|
||||
# DUT Types:
|
||||
# ----------
|
||||
# Leader
|
||||
# Router
|
||||
|
||||
|
||||
class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
SUPPORT_NCP = False
|
||||
|
||||
TOPOLOGY = {
|
||||
COMMISSIONER: {
|
||||
'name': 'COMMISSIONER',
|
||||
'active_dataset': {
|
||||
'timestamp': 10,
|
||||
'timestamp': TIMESTAMP_INIT,
|
||||
'panid': PANID_INIT,
|
||||
'channel': CHANNEL_INIT
|
||||
},
|
||||
@@ -58,8 +97,9 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
'allowlist': [LEADER]
|
||||
},
|
||||
LEADER: {
|
||||
'name': 'LEADER',
|
||||
'active_dataset': {
|
||||
'timestamp': 10,
|
||||
'timestamp': TIMESTAMP_INIT,
|
||||
'panid': PANID_INIT,
|
||||
'channel': CHANNEL_INIT
|
||||
},
|
||||
@@ -69,8 +109,9 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
'allowlist': [COMMISSIONER, ROUTER1]
|
||||
},
|
||||
ROUTER1: {
|
||||
'name': 'ROUTER_1',
|
||||
'active_dataset': {
|
||||
'timestamp': 10,
|
||||
'timestamp': TIMESTAMP_INIT,
|
||||
'panid': PANID_INIT,
|
||||
'channel': CHANNEL_INIT
|
||||
},
|
||||
@@ -79,13 +120,14 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
'allowlist': [LEADER, ROUTER2]
|
||||
},
|
||||
ROUTER2: {
|
||||
'name': 'ROUTER_2',
|
||||
'active_dataset': {
|
||||
'timestamp': 10,
|
||||
'timestamp': TIMESTAMP_INIT,
|
||||
'panid': PANID_INIT,
|
||||
'channel': CHANNEL_INIT
|
||||
},
|
||||
'mode': 'rdn',
|
||||
'network_id_timeout': 100,
|
||||
'network_id_timeout': 70,
|
||||
'router_selection_jitter': 1,
|
||||
'allowlist': [ROUTER1]
|
||||
},
|
||||
@@ -111,25 +153,34 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.nodes[COMMISSIONER].send_mgmt_pending_set(
|
||||
pending_timestamp=30,
|
||||
active_timestamp=210,
|
||||
delay_timer=500000,
|
||||
channel=20,
|
||||
panid=0xafce,
|
||||
pending_timestamp=COMM_PENDING_TIMESTAMP,
|
||||
active_timestamp=COMM_PENDING_ACTIVE_TIMESTAMP,
|
||||
delay_timer=COMM_DELAY_TIMER,
|
||||
channel=CHANNEL_SECOND,
|
||||
panid=PANID_INIT,
|
||||
)
|
||||
self.simulator.go(5)
|
||||
|
||||
self.nodes[LEADER].remove_allowlist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER1].remove_allowlist(self.nodes[LEADER].get_addr64())
|
||||
self.simulator.go(140)
|
||||
self.nodes[ROUTER2].set_preferred_partition_id(1)
|
||||
self.simulator.go(250)
|
||||
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'leader')
|
||||
|
||||
self.nodes[ROUTER2].commissioner_start()
|
||||
self.simulator.go(3)
|
||||
self.nodes[ROUTER2].send_mgmt_active_set(
|
||||
active_timestamp=ROUTER2_ACTIVE_TIMESTAMP,
|
||||
network_name=ROUTER2_NET_NAME,
|
||||
)
|
||||
self.simulator.go(5)
|
||||
|
||||
self.nodes[ROUTER2].send_mgmt_pending_set(
|
||||
pending_timestamp=50,
|
||||
active_timestamp=410,
|
||||
delay_timer=200000,
|
||||
pending_timestamp=ROUTER2_PENDING_TIMESTAMP,
|
||||
active_timestamp=ROUTER2_PENDING_ACTIVE_TIMESTAMP,
|
||||
delay_timer=ROUTER2_DELAY_TIMER,
|
||||
channel=CHANNEL_FINAL,
|
||||
panid=PANID_FINAL,
|
||||
)
|
||||
@@ -137,11 +188,14 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
|
||||
self.nodes[LEADER].add_allowlist(self.nodes[ROUTER1].get_addr64())
|
||||
self.nodes[ROUTER1].add_allowlist(self.nodes[LEADER].get_addr64())
|
||||
self.simulator.go(200)
|
||||
self.simulator.go(260)
|
||||
|
||||
self.assertEqual(self.nodes[ROUTER1].get_state(), 'router')
|
||||
self.assertEqual(self.nodes[ROUTER2].get_state(), 'router')
|
||||
|
||||
self.collect_rlocs()
|
||||
self.collect_rloc16s()
|
||||
self.collect_ipaddrs()
|
||||
self.assertEqual(self.nodes[COMMISSIONER].get_panid(), PANID_FINAL)
|
||||
self.assertEqual(self.nodes[LEADER].get_panid(), PANID_FINAL)
|
||||
self.assertEqual(self.nodes[ROUTER1].get_panid(), PANID_FINAL)
|
||||
@@ -152,12 +206,546 @@ class Cert_9_2_09_PendingPartition(thread_cert.TestCase):
|
||||
self.assertEqual(self.nodes[ROUTER1].get_channel(), CHANNEL_FINAL)
|
||||
self.assertEqual(self.nodes[ROUTER2].get_channel(), CHANNEL_FINAL)
|
||||
|
||||
ipaddrs = self.nodes[ROUTER2].get_addrs()
|
||||
for ipaddr in ipaddrs:
|
||||
if ipaddr[0:4] != 'fe80':
|
||||
break
|
||||
leader_addr = self.nodes[LEADER].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
|
||||
router1_addr = self.nodes[ROUTER1].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
|
||||
self.assertTrue(self.nodes[ROUTER2].ping(leader_addr))
|
||||
self.assertTrue(self.nodes[COMMISSIONER].ping(router1_addr))
|
||||
|
||||
self.assertTrue(self.nodes[LEADER].ping(ipaddr))
|
||||
def verify(self, pv):
|
||||
pkts = pv.pkts
|
||||
pv.summary.show()
|
||||
|
||||
LEADER = pv.vars['LEADER']
|
||||
LEADER_RLOC = pv.vars['LEADER_RLOC']
|
||||
LEADER_MLEID = pv.vars['LEADER_MLEID']
|
||||
COMMISSIONER = pv.vars['COMMISSIONER']
|
||||
COMMISSIONER_MLEID = pv.vars['COMMISSIONER_MLEID']
|
||||
COMMISSIONER_RLOC = pv.vars['COMMISSIONER_RLOC']
|
||||
COMMISSIONER_RLOC16 = pv.vars['COMMISSIONER_RLOC16']
|
||||
ROUTER_1 = pv.vars['ROUTER_1']
|
||||
ROUTER_1_RLOC = pv.vars['ROUTER_1_RLOC']
|
||||
ROUTER_1_MLEID = pv.vars['ROUTER_1_MLEID']
|
||||
ROUTER_2 = pv.vars['ROUTER_2']
|
||||
ROUTER_2_RLOC = pv.vars['ROUTER_2_RLOC']
|
||||
ROUTER_2_MLEID = pv.vars['ROUTER_2_MLEID']
|
||||
|
||||
# Step 1: Ensure the topology is formed correctly
|
||||
for node in ('COMMISSIONER', 'ROUTER_1'):
|
||||
pv.verify_attached(node, 'LEADER')
|
||||
pv.verify_attached('ROUTER_2', 'ROUTER_1')
|
||||
_pkt = pkts.last()
|
||||
|
||||
# Step 3: Leader sends MGMT_PENDING_SET.rsq to the Commissioner:
|
||||
# CoAP Response Code
|
||||
# 2.04 Changed
|
||||
# CoAP Payload
|
||||
# - State TLV (value = Accept)
|
||||
pkts.filter_coap_ack(MGMT_PENDING_SET_URI).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_ipv6_dst(COMMISSIONER_RLOC).\
|
||||
must_next().\
|
||||
must_verify(lambda p: p.thread_meshcop.tlv.state == 1)
|
||||
|
||||
# Step 4: Leader MUST multicast MLE Data Response with the new network data,
|
||||
# including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV:
|
||||
# Data Version field incremented
|
||||
# Stable Version field incremented
|
||||
# - Network Data TLV:
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 10s
|
||||
# - Pending Timestamp TLV: 30s
|
||||
#
|
||||
# Router_1 MUST send a unicast MLE Data Request to the Leader, including the
|
||||
# following TLVs:
|
||||
# - TLV Request TLV:
|
||||
# - Network Data TLV
|
||||
# - Active Timestamp TLV (10s)
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_LLANMA().\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
(p.mle.tlv.leader_data.data_version -
|
||||
_pkt.mle.tlv.leader_data.data_version) % 256 <= 127 and\
|
||||
(p.mle.tlv.leader_data.stable_data_version -
|
||||
_pkt.mle.tlv.leader_data.stable_data_version) % 256 <= 127 and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(MLE_DATA_REQUEST).\
|
||||
filter(lambda p: {
|
||||
TLV_REQUEST_TLV,
|
||||
NETWORK_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.thread_meshcop.tlv.type is nullField
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 5: Leader sends a MLE Data Response to Router_1 including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV
|
||||
# - Network Data TLV
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 10s
|
||||
# - Pending Timestamp TLV: 30s
|
||||
# - Pending Operational Dataset TLV
|
||||
# - Active Timestamp TLV <210s>
|
||||
# - Delay Timer TLV <~ 1000s>
|
||||
# - Channel TLV : ‘Secondary’
|
||||
# - PAN ID TLV : 0xAFCE
|
||||
_dr_pkt = pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(ROUTER_1).\
|
||||
filter(lambda p: {
|
||||
SOURCE_ADDRESS_TLV,
|
||||
LEADER_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV,
|
||||
PENDING_TIMESTAMP_TLV,
|
||||
PENDING_OPERATION_DATASET_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type and\
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.delay_timer < COMM_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.active_tstamp == COMM_PENDING_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.channel == [CHANNEL_SECOND] and\
|
||||
p.thread_meshcop.tlv.pan_id == [PANID_INIT]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 6: Router_1 MUST multicast MLE Data Response with the new network data,
|
||||
# including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV:
|
||||
# Data Version field incremented
|
||||
# Stable Version field incremented
|
||||
# - Network Data TLV:
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 10s
|
||||
# - Pending Timestamp TLV: 30s
|
||||
with pkts.save_index():
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(ROUTER_1).\
|
||||
filter_LLANMA().\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
(p.mle.tlv.leader_data.data_version -
|
||||
_pkt.mle.tlv.leader_data.data_version) % 256 <= 127 and\
|
||||
(p.mle.tlv.leader_data.stable_data_version -
|
||||
_pkt.mle.tlv.leader_data.stable_data_version) % 256 <= 127 and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 8: Router_1 sends a MLE Data Response to Router_2 including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV
|
||||
# - Network Data TLV
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 10s
|
||||
# - Pending Timestamp TLV: 30s
|
||||
# - Pending Operational Dataset TLV
|
||||
# - Active Timestamp TLV <210s>
|
||||
# - Delay Timer TLV <~ 1000s>
|
||||
# - Channel TLV : ‘Secondary’
|
||||
# - PAN ID TLV : 0xAFCE
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(ROUTER_2).\
|
||||
filter(lambda p: {
|
||||
SOURCE_ADDRESS_TLV,
|
||||
LEADER_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV,
|
||||
PENDING_TIMESTAMP_TLV,
|
||||
PENDING_OPERATION_DATASET_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type and\
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.delay_timer < COMM_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.active_tstamp == COMM_PENDING_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.channel == [CHANNEL_SECOND] and\
|
||||
p.thread_meshcop.tlv.pan_id == [PANID_INIT]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 10: Router_1 MUST attach to the new partition formed by Router_2
|
||||
pv.verify_attached('ROUTER_1', 'ROUTER_2')
|
||||
_pkt = pkts.last()
|
||||
|
||||
# Step 12: Router_1 MUST send a unicast MLE Data Request to the Router_2, including the
|
||||
# following TLVs:
|
||||
# - TLV Request TLV:
|
||||
# - Network Data TLV
|
||||
# - Active Timestamp TLV (10s)
|
||||
# - Pending Timestamp TLV (30s)
|
||||
with pkts.save_index():
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(MLE_DATA_REQUEST).\
|
||||
filter(lambda p: {
|
||||
TLV_REQUEST_TLV,
|
||||
NETWORK_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.type is nullField
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 14: Router_1 MUST multicast MLE Data Response with the new network data,
|
||||
# including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV:
|
||||
# Data Version field incremented
|
||||
# Stable Version field incremented
|
||||
# - Network Data TLV:
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Pending Timestamp TLV: 30s
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(ROUTER_1).\
|
||||
filter_LLANMA().\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
(p.mle.tlv.leader_data.data_version -
|
||||
_pkt.mle.tlv.leader_data.data_version) % 256 <= 127 and\
|
||||
(p.mle.tlv.leader_data.stable_data_version -
|
||||
_pkt.mle.tlv.leader_data.stable_data_version) % 256 <= 127 and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 17: Router_1 MUST send a unicast MLE Data Request to the Router_2, including the
|
||||
# following TLVs:
|
||||
# - TLV Request TLV:
|
||||
# - Network Data TLV
|
||||
# - Active Timestamp TLV (15s)
|
||||
# - Pending Timestamp TLV (30s)
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(ROUTER_2).\
|
||||
filter_mle_cmd(MLE_DATA_REQUEST).\
|
||||
filter(lambda p: {
|
||||
TLV_REQUEST_TLV,
|
||||
NETWORK_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.type is nullField
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 19: Router_1 MUST multicast MLE Data Response with the new network data,
|
||||
# including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV:
|
||||
# Data Version field incremented
|
||||
# Stable Version field incremented
|
||||
# - Network Data TLV:
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Pending Timestamp TLV: 50s
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(ROUTER_1).\
|
||||
filter_LLANMA().\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == ROUTER2_PENDING_TIMESTAMP and\
|
||||
(p.mle.tlv.leader_data.data_version -
|
||||
_pkt.mle.tlv.leader_data.data_version) % 256 <= 127 and\
|
||||
(p.mle.tlv.leader_data.stable_data_version -
|
||||
_pkt.mle.tlv.leader_data.stable_data_version) % 256 <= 127 and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 21: Router_1 MUST go through the attachment process and send MLE Child ID
|
||||
# Request to the Leader, including the following TLV:
|
||||
# - Active Timestamp TLV: 15s
|
||||
pkts.filter_mle_cmd(MLE_CHILD_ID_REQUEST).\
|
||||
filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP).\
|
||||
must_next()
|
||||
|
||||
# Step 22: Leader MUST send MLE Child ID Response to Router_1, including its current
|
||||
# active timestamp and active configuration set:
|
||||
# - Active Timestamp TLV: 10s
|
||||
# - Active Operational Dataset TLV:
|
||||
# - Pending Timestamp TLV: 30s
|
||||
# - Pending Operational Dataset TLV:
|
||||
# - Active Timestamp TLV:210s
|
||||
_pkt = pkts.filter_mle_cmd(MLE_CHILD_ID_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(ROUTER_1).\
|
||||
filter(lambda p:
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.active_tstamp == COMM_PENDING_ACTIVE_TIMESTAMP
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 23: Router_1 MUST send MGMT_ACTIVE_SET.req to the Leader RLOC or Anycast Locator:
|
||||
# CoAP Request URI
|
||||
# coap://[Leader]:MM/c/as
|
||||
# CoAP Payload
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Network Name TLV: “TEST”
|
||||
# - PAN ID TLV
|
||||
# - Channel TLV
|
||||
with pkts.save_index():
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_ipv6_2dsts(LEADER_ALOC, LEADER_RLOC).\
|
||||
filter_coap_request(MGMT_ACTIVE_SET_URI) .\
|
||||
filter(lambda p: {
|
||||
NM_ACTIVE_TIMESTAMP_TLV,
|
||||
NM_CHANNEL_TLV,
|
||||
NM_NETWORK_NAME_TLV,
|
||||
NM_PAN_ID_TLV,
|
||||
} <= set(p.thread_meshcop.tlv.type) and\
|
||||
p.thread_meshcop.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.net_name == [ROUTER2_NET_NAME]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 24: Leader sends MGMT_ACTIVE_SET.rsp to the Router_1:
|
||||
# CoAP Response Code
|
||||
# 2.04 Changed
|
||||
# CoAP Payload
|
||||
# - State TLV (value = Accept)
|
||||
# TODO: this ack can not be parsed by pktverify
|
||||
|
||||
# Step 25: Leader MUST send MGMT_DATASET_CHANGED.ntf to Commissioner:
|
||||
# CoAP Request URI
|
||||
# coap://[ Commissioner]:MM/c/dc
|
||||
# CoAP Payload
|
||||
# <empty>
|
||||
with pkts.save_index():
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst16(COMMISSIONER_RLOC16).\
|
||||
filter_coap_request(MGMT_DATASET_CHANGED_URI) .\
|
||||
filter(lambda p: p.thread_meshcop.tlv.type is nullField).\
|
||||
must_next()
|
||||
|
||||
# Step 27: Router_1 MUST send MGMT_PENDING_SET.req to the Leader RLOC or Anycast Locator:
|
||||
# CoAP Request URI
|
||||
# coap://[Leader]:MM/c/ps
|
||||
# CoAP Payload
|
||||
# - Delay Timer TLV: ~200s
|
||||
# - Channel TLV : ‘Primary’
|
||||
# - PAN ID TLV : 0xABCD
|
||||
# - Network Name TLV: ‘TEST’
|
||||
# - Active Timestamp TLV: 410s
|
||||
# - Pending Timestamp TLV: 50s
|
||||
with pkts.save_index():
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_ipv6_2dsts(LEADER_ALOC, LEADER_RLOC).\
|
||||
filter_coap_request(MGMT_PENDING_SET_URI) .\
|
||||
filter(lambda p:
|
||||
p.thread_meshcop.tlv.delay_timer < ROUTER2_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.channel == [CHANNEL_FINAL] and\
|
||||
p.thread_meshcop.tlv.pan_id == [PANID_FINAL] and\
|
||||
p.thread_meshcop.tlv.active_tstamp == ROUTER2_PENDING_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.pending_tstamp == ROUTER2_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.net_name == [ROUTER2_NET_NAME]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 28: Leader sends MGMT_PENDING_SET.rsq to the Router_1:
|
||||
# CoAP Response Code
|
||||
# 2.04 Changed
|
||||
# CoAP Payload
|
||||
# - State TLV (value = Accept)
|
||||
# TODO: this ack can not be parsed by pktverify
|
||||
|
||||
# Step 29: Leader MUST send MGMT_DATASET_CHANGED.ntf to Commissioner:
|
||||
# CoAP Request URI
|
||||
# coap://[ Commissioner]:MM/c/dc
|
||||
# CoAP Payload
|
||||
# <empty>
|
||||
pkts.filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst16(COMMISSIONER_RLOC16).\
|
||||
filter_coap_request(MGMT_DATASET_CHANGED_URI) .\
|
||||
filter(lambda p: p.thread_meshcop.tlv.type is nullField).\
|
||||
must_next()
|
||||
|
||||
# Step 30: Leader MUST multicast MLE Data Response with the new network data,
|
||||
# including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV:
|
||||
# Data Version field incremented
|
||||
# Stable Version field incremented
|
||||
# - Network Data TLV:
|
||||
# - Commissioner Data TLV:
|
||||
# Stable flag set to 0
|
||||
# Border Agent Locator TLV
|
||||
# Commissioner Session ID TLV
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Pending Timestamp TLV: 50s
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_LLANMA().\
|
||||
filter(lambda p: p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == ROUTER2_PENDING_TIMESTAMP and\
|
||||
(p.mle.tlv.leader_data.data_version -
|
||||
_pkt.mle.tlv.leader_data.data_version) % 256 <= 127 and\
|
||||
(p.mle.tlv.leader_data.stable_data_version -
|
||||
_pkt.mle.tlv.leader_data.stable_data_version) % 256 <= 127 and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 32: Leader sends a MLE Data Response to Commissioner including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Active Operational Dataset TLV:
|
||||
# - Network Name TLV : ‘TEST’
|
||||
# - Pending Timestamp TLV: 50s
|
||||
# - Pending Operational Dataset TLV
|
||||
# - Active Timestamp TLV <410s>
|
||||
# - Delay Timer TLV <~ 200s>
|
||||
# - Channel TLV : ‘Primary’
|
||||
# - PAN ID TLV : 0xABCD
|
||||
# - Network Name TLV : 'TEST'
|
||||
with pkts.save_index():
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(COMMISSIONER).\
|
||||
filter(lambda p: {
|
||||
SOURCE_ADDRESS_TLV,
|
||||
LEADER_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV,
|
||||
PENDING_TIMESTAMP_TLV,
|
||||
PENDING_OPERATION_DATASET_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.thread_nwd.tlv.stable == [0] and\
|
||||
NWD_COMMISSIONING_DATA_TLV in p.thread_nwd.tlv.type and\
|
||||
NM_COMMISSIONER_SESSION_ID_TLV in p.thread_meshcop.tlv.type and\
|
||||
NM_BORDER_AGENT_LOCATOR_TLV in p.thread_meshcop.tlv.type and\
|
||||
p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == ROUTER2_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.net_name == [ROUTER2_NET_NAME, ROUTER2_NET_NAME] and\
|
||||
p.thread_meshcop.tlv.delay_timer < ROUTER2_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.active_tstamp == ROUTER2_PENDING_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.channel == [CHANNEL_INIT, CHANNEL_FINAL] and\
|
||||
p.thread_meshcop.tlv.pan_id == [PANID_INIT, PANID_FINAL]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 33: Router_1 MUST send a unicast MLE Data Request to the Leader, including the
|
||||
# following TLVs:
|
||||
# - TLV Request TLV:
|
||||
# - Network Data TLV
|
||||
# - Active Timestamp TLV (10s)
|
||||
# - Pending Timestamp TLV (30s)
|
||||
pkts.filter_wpan_src64(ROUTER_1).\
|
||||
filter_wpan_dst64(LEADER).\
|
||||
filter_mle_cmd(MLE_DATA_REQUEST).\
|
||||
filter(lambda p: {
|
||||
TLV_REQUEST_TLV,
|
||||
NETWORK_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.mle.tlv.active_tstamp == TIMESTAMP_INIT and\
|
||||
p.mle.tlv.pending_tstamp == COMM_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.type is nullField
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 34: Leader sends a MLE Data Response to Router_1 including the following TLVs:
|
||||
# - Source Address TLV
|
||||
# - Leader Data TLV
|
||||
# - Active Timestamp TLV: 15s
|
||||
# - Active Operational Dataset TLV:
|
||||
# - Network Name TLV : ‘TEST’
|
||||
# - Pending Timestamp TLV: 50s
|
||||
# - Pending Operational Dataset TLV
|
||||
# - Active Timestamp TLV <410s>
|
||||
# - Delay Timer TLV <~ 200s>
|
||||
# - Channel TLV : ‘Primary’
|
||||
# - PAN ID TLV : 0xABCD
|
||||
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
|
||||
filter_wpan_src64(LEADER).\
|
||||
filter_wpan_dst64(ROUTER_1).\
|
||||
filter(lambda p: {
|
||||
SOURCE_ADDRESS_TLV,
|
||||
LEADER_DATA_TLV,
|
||||
ACTIVE_TIMESTAMP_TLV,
|
||||
PENDING_TIMESTAMP_TLV,
|
||||
PENDING_OPERATION_DATASET_TLV
|
||||
} <= set(p.mle.tlv.type) and\
|
||||
p.mle.tlv.active_tstamp == ROUTER2_ACTIVE_TIMESTAMP and\
|
||||
p.mle.tlv.pending_tstamp == ROUTER2_PENDING_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.delay_timer < ROUTER2_DELAY_TIMER and\
|
||||
p.thread_meshcop.tlv.active_tstamp == ROUTER2_PENDING_ACTIVE_TIMESTAMP and\
|
||||
p.thread_meshcop.tlv.channel == [CHANNEL_INIT, CHANNEL_FINAL] and\
|
||||
p.thread_meshcop.tlv.pan_id == [PANID_INIT, PANID_FINAL]
|
||||
).\
|
||||
must_next()
|
||||
|
||||
# Step 36: The DUT MUST respond with an ICMPv6 Echo Reply
|
||||
_pkt = pkts.filter_ping_request().\
|
||||
filter_ipv6_src_dst(ROUTER_2_MLEID, LEADER_MLEID).\
|
||||
filter_ipv6_dst(LEADER_MLEID).\
|
||||
must_next()
|
||||
pkts.filter_ping_reply(identifier=_pkt.icmpv6.echo.identifier).\
|
||||
filter_ipv6_src_dst(LEADER_MLEID, ROUTER_2_MLEID).\
|
||||
must_next()
|
||||
|
||||
_pkt = pkts.filter_ping_request().\
|
||||
filter_ipv6_src_dst(COMMISSIONER_MLEID, ROUTER_1_MLEID).\
|
||||
must_next()
|
||||
pkts.filter_ping_reply(identifier=_pkt.icmpv6.echo.identifier).\
|
||||
filter_ipv6_src_dst(ROUTER_1_MLEID, COMMISSIONER_MLEID).\
|
||||
must_next()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -119,7 +119,7 @@ class Cert_9_2_17_Orphan(thread_cert.TestCase):
|
||||
# Step 1: Ensure the topology is formed correctly
|
||||
# Verify that Leader_1 & Leader_2 are sending MLE Advertisements on separate channels.
|
||||
pkts.filter_wpan_src64(LEADER_1).filter_mle_cmd(MLE_CHILD_ID_RESPONSE).must_next().must_verify(
|
||||
lambda p: p.wpan.dst64 == ED and p.thread_meshcop.tlv.channel == CHANNEL1)
|
||||
lambda p: p.wpan.dst64 == ED and p.thread_meshcop.tlv.channel == [CHANNEL1])
|
||||
pkts.filter_wpan_src64(LEADER_1).filter_mle_cmd(MLE_ADVERTISEMENT).must_next()
|
||||
pkts.copy().filter_wpan_src64(LEADER_2).filter_mle_cmd(MLE_ADVERTISEMENT).must_next()
|
||||
|
||||
|
||||
@@ -249,8 +249,8 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
|
||||
} <= set(p.mle.tlv.type) and {
|
||||
NM_CHANNEL_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_DELAY_TIMER_TLV,
|
||||
NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MASTER_KEY_TLV
|
||||
} <= set(p.thread_meshcop.tlv.type) and p.thread_meshcop.tlv.net_name == "MyHouse" and p.thread_meshcop
|
||||
.tlv.master_key == KEY2)
|
||||
} <= set(p.thread_meshcop.tlv.type) and p.thread_meshcop.tlv.net_name == ["MyHouse"] and p.
|
||||
thread_meshcop.tlv.master_key == KEY2)
|
||||
|
||||
# Step 17: MED and SED MUST respond with an ICMPv6 Echo Reply
|
||||
pkts.filter_ipv6_src_dst(ED_RLOC, COMMISSIONER_RLOC).filter_ping_reply().must_next()
|
||||
|
||||
@@ -168,7 +168,7 @@ class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase):
|
||||
NM_PAN_ID_TLV
|
||||
} <= set(p.thread_meshcop.tlv.type) and\
|
||||
p.thread_meshcop.tlv.active_tstamp == 60 and\
|
||||
p.thread_meshcop.tlv.pan_id == 0xafce and\
|
||||
p.thread_meshcop.tlv.pan_id == [0xafce] and\
|
||||
p.thread_meshcop.tlv.delay_timer == 60000
|
||||
).\
|
||||
must_next()
|
||||
@@ -263,7 +263,7 @@ class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase):
|
||||
NM_DELAY_TIMER_TLV,
|
||||
NM_PAN_ID_TLV
|
||||
} == set(p.coap.tlv.type) and\
|
||||
p.thread_meshcop.tlv.pan_id == 0xafce and\
|
||||
p.thread_meshcop.tlv.pan_id == [0xafce] and\
|
||||
p.thread_meshcop.tlv.delay_timer < 60000
|
||||
).\
|
||||
must_next()
|
||||
|
||||
@@ -261,7 +261,7 @@ class TestDuaDad(thread_cert.TestCase):
|
||||
ba.must_verify("""
|
||||
set(thread_bl.tlv.type) == {tlvs}
|
||||
and thread_bl.tlv.last_transaction_time > 0
|
||||
and thread_meshcop.tlv.net_name == {NET_NAME}
|
||||
and thread_meshcop.tlv.net_name == [{NET_NAME}]
|
||||
""",
|
||||
tlvs={0, 3, 6, 12},
|
||||
**pv.vars)
|
||||
|
||||
@@ -565,11 +565,11 @@ _LAYER_FIELDS = {
|
||||
'thread_meshcop.len_size_mismatch': _str,
|
||||
'thread_meshcop.tlv.type': _list(_auto),
|
||||
'thread_meshcop.tlv.len8': _list(_auto),
|
||||
'thread_meshcop.tlv.net_name': _str, # from thread_bl
|
||||
'thread_meshcop.tlv.net_name': _list(_str), # from thread_bl
|
||||
'thread_meshcop.tlv.commissioner_id': _str,
|
||||
'thread_meshcop.tlv.commissioner_sess_id': _auto, # from mle
|
||||
"thread_meshcop.tlv.channel_page": _auto, # from ble
|
||||
"thread_meshcop.tlv.channel": _auto, # from ble
|
||||
"thread_meshcop.tlv.channel": _list(_auto), # from ble
|
||||
"thread_meshcop.tlv.chan_mask": _str, # from ble
|
||||
'thread_meshcop.tlv.chan_mask_page': _auto,
|
||||
'thread_meshcop.tlv.chan_mask_len': _auto,
|
||||
@@ -577,7 +577,7 @@ _LAYER_FIELDS = {
|
||||
'thread_meshcop.tlv.discovery_req_ver': _auto,
|
||||
'thread_meshcop.tlv.discovery_rsp_ver': _auto,
|
||||
'thread_meshcop.tlv.energy_list': _list(_auto),
|
||||
'thread_meshcop.tlv.pan_id': _auto,
|
||||
'thread_meshcop.tlv.pan_id': _list(_auto),
|
||||
'thread_meshcop.tlv.xpan_id': _bytes,
|
||||
'thread_meshcop.tlv.ml_prefix': _bytes,
|
||||
'thread_meshcop.tlv.master_key': _bytes,
|
||||
|
||||
@@ -164,7 +164,7 @@ class TestLayerFields(unittest.TestCase):
|
||||
self.assertIsInstanceOrNull(thread_bl.tlv.target_eid, Ipv6Addr)
|
||||
self.assertIsInstanceOrNull(thread_bl.tlv.ml_eid, ExtAddr)
|
||||
self.assertIsInstanceOrNull(thread_bl.tlv.last_transaction_time, int)
|
||||
self.assertIsInstanceOrNull(p.thread_meshcop.tlv.net_name, str)
|
||||
self.assertIsInstanceOrNull(p.thread_meshcop.tlv.net_name, list)
|
||||
|
||||
def _test_thread_meshcop(self, p: Packet):
|
||||
thread_meshcop = p.thread_meshcop
|
||||
@@ -174,13 +174,13 @@ class TestLayerFields(unittest.TestCase):
|
||||
self.assertIsInstance(thread_meshcop.tlv.commissioner_sess_id, int)
|
||||
|
||||
if 'thread_meshcop.tlv.net_name' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.net_name, str)
|
||||
self.assertIsInstance(thread_meshcop.tlv.net_name, list)
|
||||
|
||||
if 'thread_meshcop.tlv.channel_page' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.channel_page, int)
|
||||
|
||||
if 'thread_meshcop.tlv.channel' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.channel, int)
|
||||
self.assertIsInstance(thread_meshcop.tlv.channel, list)
|
||||
|
||||
if 'thread_meshcop.tlv.chan_mask_page' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.chan_mask_page, int)
|
||||
@@ -220,7 +220,7 @@ class TestLayerFields(unittest.TestCase):
|
||||
self.assertIsInstance(thread_meshcop.tlv.sec_policy_b, int)
|
||||
|
||||
if 'thread_meshcop.tlv.pan_id' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.pan_id, int)
|
||||
self.assertIsInstance(thread_meshcop.tlv.pan_id, list)
|
||||
|
||||
if 'thread_meshcop.tlv.xpan_id' in layer._layer._all_fields:
|
||||
self.assertIsInstance(thread_meshcop.tlv.xpan_id, Bytes)
|
||||
|
||||
Reference in New Issue
Block a user