def test(self): self.nodes[LEADER].start() self.simulator.go(config.LEADER_STARTUP_DELAY) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') self.nodes[COMMISSIONER].start() self.simulator.go(config.ROUTER_STARTUP_DELAY) self.assertEqual(self.nodes[COMMISSIONER].get_state(), 'router') self.simulator.get_messages_sent_by(LEADER) self.nodes[COMMISSIONER].commissioner_start() self.simulator.go(3) leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04', assert_enabled=True) self.nodes[ROUTER].start() self.simulator.go(config.ROUTER_STARTUP_DELAY) self.assertEqual(self.nodes[ROUTER].get_state(), 'router') self.nodes[MED].start() self.simulator.go(5) self.assertEqual(self.nodes[MED].get_state(), 'child') self.nodes[SED].start() self.simulator.go(5) self.assertEqual(self.nodes[SED].get_state(), 'child') commissioner_session_id_tlv = command.get_sub_tlv( msg.coap.payload, mesh_cop.CommissionerSessionId) steering_data_tlv = mesh_cop.SteeringData(bytes([0xff])) # Step 2 self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [steering_data_tlv, commissioner_session_id_tlv]) self.simulator.go(10) # Step 7 self.nodes[COMMISSIONER].send_mgmt_active_set( active_timestamp=COMM_ACTIVE_TIMESTAMP, network_name=COMM_ACTIVE_NET_NAME, binary='0410' + COMM_ACTIVE_PSKC, ) self.simulator.go(10) # Step 18 self.nodes[COMMISSIONER].send_mgmt_pending_set( pending_timestamp=COMM_PENDING_TIMESTAMP, active_timestamp=COMM_PENDING_ACTIVE_TIMESTAMP, delay_timer=COMM_DELAY_TIMER, channel=CHANNEL_SECOND, ) self.simulator.go(120) self.collect_rlocs() ed_rloc = self.nodes[MED].get_rloc() sed_rloc = self.nodes[SED].get_rloc() leader_rloc = self.nodes[LEADER].get_rloc() router_rloc = self.nodes[ROUTER].get_rloc() for rloc in (leader_rloc, router_rloc, ed_rloc, sed_rloc): self.assertTrue(self.nodes[COMMISSIONER].ping(rloc)) self.simulator.go(10)
def test(self): self.nodes[LEADER].start() self.simulator.go(config.LEADER_STARTUP_DELAY) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') self.nodes[COMMISSIONER].start() self.simulator.go(config.ROUTER_STARTUP_DELAY) self.assertEqual(self.nodes[COMMISSIONER].get_state(), 'router') self.simulator.get_messages_sent_by(LEADER) self.collect_rlocs() self.collect_rloc16s() self.nodes[COMMISSIONER].commissioner_start() self.simulator.go(3) leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04', assert_enabled=True) commissioner_session_id_tlv = command.get_sub_tlv( msg.coap.payload, mesh_cop.CommissionerSessionId) steering_data_tlv = mesh_cop.SteeringData(bytes([0xff])) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [steering_data_tlv]) self.simulator.go(5) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [steering_data_tlv, commissioner_session_id_tlv]) self.simulator.go(5) border_agent_locator_tlv = mesh_cop.BorderAgentLocator(0x0400) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [commissioner_session_id_tlv, border_agent_locator_tlv]) self.simulator.go(5) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs([ steering_data_tlv, commissioner_session_id_tlv, border_agent_locator_tlv, ]) self.simulator.go(5) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [mesh_cop.CommissionerSessionId(0xffff), steering_data_tlv]) self.simulator.go(5) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs([ commissioner_session_id_tlv, steering_data_tlv, mesh_cop.Channel(0x0, 0x0), ]) self.simulator.go(5) leader_rloc = self.nodes[LEADER].get_rloc() commissioner_rloc = self.nodes[COMMISSIONER].get_rloc() self.assertTrue(self.nodes[COMMISSIONER].ping(leader_rloc)) self.simulator.go(1) self.assertTrue(self.nodes[LEADER].ping(commissioner_rloc))
def test(self): self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') self.nodes[COMMISSIONER].start() self.simulator.go(5) self.assertEqual(self.nodes[COMMISSIONER].get_state(), 'router') # Skip all other Coaps sent by Leader self.simulator.get_messages_sent_by(COMMISSIONER) self.simulator.get_messages_sent_by(LEADER) # Commissioner start self.nodes[COMMISSIONER].commissioner_start() self.simulator.go(3) self.simulator.get_messages_sent_by(COMMISSIONER) # Skip LEAD_PET.req # Get CommissionerSessionId from LEAD_PET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04', assert_enabled=True) commissioner_session_id_tlv = command.get_sub_tlv( msg.coap.payload, mesh_cop.CommissionerSessionId) # Step 2 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader steering_data_tlv = mesh_cop.SteeringData(bytes([0xff])) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [steering_data_tlv]) self.simulator.go(5) # Step 3 - Leader responds to MGMT_COMMISSIONER_SET.req with # MGMT_COMMISSIONER_SET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') # (mesh_cop.State(mesh_cop.MeshCopState.REJECT),) <- this a tuple, don't delete the comma command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.REJECT)]) self.simulator.get_messages_sent_by(COMMISSIONER) # Skip LEAD_PET.req # Step 4 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [steering_data_tlv, commissioner_session_id_tlv]) self.simulator.go(5) commissioner_messages = self.simulator.get_messages_sent_by( COMMISSIONER) msg = commissioner_messages.next_coap_message('0.02', uri_path='/c/cs') rloc = ip_address(self.nodes[LEADER].get_rloc()) leader_aloc = ip_address(self.nodes[LEADER].get_addr_leader_aloc()) command.check_coap_message( msg, [steering_data_tlv, commissioner_session_id_tlv], dest_addrs=[rloc, leader_aloc], ) # Step 5 - Leader sends MGMT_COMMISSIONER_SET.rsp to commissioner leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.ACCEPT)]) # Step 6 - Leader sends a multicast MLE Data Response msg = leader_messages.next_mle_message(mle.CommandType.DATA_RESPONSE) command.check_data_response( msg, command.NetworkDataCheck( commissioning_data_check=command.CommissioningDataCheck( stable=0, sub_tlv_type_list=[ mesh_cop.CommissionerSessionId, mesh_cop.SteeringData, mesh_cop.BorderAgentLocator, ], )), ) # Step 7 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader border_agent_locator_tlv = mesh_cop.BorderAgentLocator(0x0400) self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [commissioner_session_id_tlv, border_agent_locator_tlv]) self.simulator.go(5) # Step 8 - Leader responds to MGMT_COMMISSIONER_SET.req with # MGMT_COMMISSIONER_SET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.REJECT)]) # Step 9 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs([ steering_data_tlv, commissioner_session_id_tlv, border_agent_locator_tlv, ]) self.simulator.go(5) # Step 10 - Leader responds to MGMT_COMMISSIONER_SET.req with # MGMT_COMMISSIONER_SET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.REJECT)]) # Step 11 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs( [mesh_cop.CommissionerSessionId(0xffff), steering_data_tlv]) self.simulator.go(5) # Step 12 - Leader responds to MGMT_COMMISSIONER_SET.req with # MGMT_COMMISSIONER_SET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.REJECT)]) # Step 13 - Harness instructs commissioner to send # MGMT_COMMISSIONER_SET.req to Leader self.nodes[COMMISSIONER].commissioner_mgmtset_with_tlvs([ commissioner_session_id_tlv, steering_data_tlv, mesh_cop.Channel(0x0, 0x0), ]) self.simulator.go(5) # Step 14 - Leader responds to MGMT_COMMISSIONER_SET.req with # MGMT_COMMISSIONER_SET.rsp leader_messages = self.simulator.get_messages_sent_by(LEADER) msg = leader_messages.next_coap_message('2.04') command.check_coap_message( msg, [mesh_cop.State(mesh_cop.MeshCopState.ACCEPT)]) # Step 15 - Send ICMPv6 Echo Request to Leader leader_rloc = self.nodes[LEADER].get_rloc() self.assertTrue(self.nodes[COMMISSIONER].ping(leader_rloc))