def test(self): self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') # 1 DUT_ROUTER1: Attach to LEADER self.nodes[DUT_ROUTER1].start() self.simulator.go(5) self.assertEqual(self.nodes[DUT_ROUTER1].get_state(), 'router') # DUT_ROUTER1: Verify MLE advertisements router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_mle_message(mle.CommandType.ADVERTISEMENT) command.check_mle_advertisement(msg) # 2 REED1: Attach to DUT_ROUTER1 self.nodes[REED1].start() self.simulator.go(5) self.assertEqual(self.nodes[REED1].get_state(), 'child') # 3 DUT_ROUTER1: Verify MLE Parent Response router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_mle_message(mle.CommandType.PARENT_RESPONSE) msg.assertSentToNode(self.nodes[REED1]) command.check_parent_response(msg) # 4 DUT_ROUTER1: Verify MLE Child ID Response msg = router1_messages.next_mle_message(mle.CommandType.CHILD_ID_RESPONSE) msg.assertSentToNode(self.nodes[REED1]) command.check_child_id_response(msg) # 5 Omitted # 6 MED1: Attach to REED1 self.nodes[MED1].start() self.simulator.go(5) self.assertEqual(self.nodes[MED1].get_state(), 'child') # 7 REED1: Verify sending Address Solicit Request to DUT_ROUTER1 reed1_messages = self.simulator.get_messages_sent_by(REED1) msg = reed1_messages.next_coap_message('0.02') reed1_ipv6_address = msg.ipv6_packet.ipv6_header.source_address.compressed msg.assertSentToNode(self.nodes[DUT_ROUTER1]); msg.assertCoapMessageRequestUriPath('/a/as') # 8 DUT_ROUTER1: Verify forwarding REED1's Address Solicit Request to LEADER router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_coap_message('0.02') msg.assertSentToNode(self.nodes[LEADER]); msg.assertCoapMessageRequestUriPath('/a/as') # DUT_ROUTER1: Verify forwarding LEADER's Address Solicit Response to REED1 msg = router1_messages.next_coap_message('2.04') msg.assertSentToDestinationAddress(reed1_ipv6_address) # 9 LEADER: Verify connectivity by sending an ICMPv6 Echo Request to REED1 for addr in self.nodes[REED1].get_addrs(): if addr[0:4] != 'fe80': self.assertTrue(self.nodes[LEADER].ping(addr))
def test(self): self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') self.nodes[LEADER].add_prefix('2001:2:0:1::/64', 'paros') self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paro') self.nodes[LEADER].register_netdata() # Set lowpan context of sniffer self.simulator.set_lowpan_context(1, '2001:2:0:1::/64') self.simulator.set_lowpan_context(2, '2001:2:0:2::/64') self.nodes[ROUTER].start() self.simulator.go(5) self.assertEqual(self.nodes[ROUTER].get_state(), 'router') self.nodes[SED1].start() self.simulator.go(5) self.assertEqual(self.nodes[SED1].get_state(), 'child') self.nodes[MED1].start() self.simulator.go(5) self.assertEqual(self.nodes[MED1].get_state(), 'child') addrs = self.nodes[SED1].get_addrs() self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs)) self.assertFalse(any('2001:2:0:2' in addr[0:10] for addr in addrs)) for addr in addrs: if addr[0:10] == '2001:2:0:1' or addr[0:10] == '2001:2:0:2': self.assertTrue(self.nodes[LEADER].ping(addr)) addrs = self.nodes[MED1].get_addrs() self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs)) self.assertTrue(any('2001:2:0:2' in addr[0:10] for addr in addrs)) for addr in addrs: if addr[0:10] == '2001:2:0:1' or addr[0:10] == '2001:2:0:2': self.assertTrue(self.nodes[LEADER].ping(addr)) leader_messages = self.simulator.get_messages_sent_by(LEADER) med1_messages = self.simulator.get_messages_sent_by(MED1) sed1_messages = self.simulator.get_messages_sent_by(SED1) # Step 1 - DUT sends MLE Advertisements msg = leader_messages.next_mle_message(mle.CommandType.ADVERTISEMENT) # Step 2 - DUT creates network data msg = leader_messages.next_mle_message(mle.CommandType.DATA_RESPONSE) check_data_response( msg, network_data_check=(NetworkDataCheckType.PREFIX_CONTENT, [{ network_data.TlvType.PREFIX: b'2001000200000001' }, { network_data.TlvType.PREFIX: b'2001000200000002' }])) # Step 4 - DUT sends a MLE Child ID Response to Router1 msg = leader_messages.next_mle_message( mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response( msg, network_data_check=(NetworkDataCheckType.PREFIX_CNT, 2)) # Step 6 - DUT sends a MLE Child ID Response to SED1 msg = leader_messages.next_mle_message( mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response( msg, network_data_check=(NetworkDataCheckType.PREFIX_CONTENT, [{ network_data.TlvType.BORDER_ROUTER: 0xFFFE }])) # For Step 10 msg_chd_upd_res_to_sed = leader_messages.next_mle_message( mle.CommandType.CHILD_UPDATE_RESPONSE) # Step 8 - DUT sends a MLE Child ID Response to MED1 msg = leader_messages.next_mle_message( mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response( msg, network_data_check=(NetworkDataCheckType.PREFIX_CNT, 2)) # Step 10 - DUT sends Child Update Response msg_chd_upd_res_to_med = leader_messages.next_mle_message( mle.CommandType.CHILD_UPDATE_RESPONSE) msg = med1_messages.next_mle_message( mle.CommandType.CHILD_UPDATE_REQUEST) check_child_update_request_from_child( msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1, 2]) check_child_update_response(msg_chd_upd_res_to_med, address_registration=CheckType.CONTAIN, CIDs=[1, 2]) msg = sed1_messages.next_mle_message( mle.CommandType.CHILD_UPDATE_REQUEST) check_child_update_request_from_child( msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1]) check_child_update_response(msg_chd_upd_res_to_sed, address_registration=CheckType.CONTAIN, CIDs=[1])
def test(self): self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') # 1 DUT_ROUTER1: Attach to LEADER self.nodes[DUT_ROUTER1].start() self.simulator.go(5) self.assertEqual(self.nodes[DUT_ROUTER1].get_state(), 'router') # DUT_ROUTER1: Verify MLE advertisements router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_mle_message(mle.CommandType.ADVERTISEMENT) command.check_mle_advertisement(msg) # 2 REED1: Attach to DUT_ROUTER1 self.nodes[REED1].start() self.simulator.go(5) self.assertEqual(self.nodes[REED1].get_state(), 'child') # 3 DUT_ROUTER1: Verify MLE Parent Response router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_mle_message(mle.CommandType.PARENT_RESPONSE) msg.assertSentToNode(self.nodes[REED1]) command.check_parent_response(msg) # 4 DUT_ROUTER1: Verify MLE Child ID Response msg = router1_messages.next_mle_message(mle.CommandType.CHILD_ID_RESPONSE) msg.assertSentToNode(self.nodes[REED1]) command.check_child_id_response(msg) # 5 Omitted # 6 MED1: Attach to REED1 self.nodes[MED1].start() self.simulator.go(5) self.assertEqual(self.nodes[MED1].get_state(), 'child') # 7 REED1: Verify sending Address Solicit Request to DUT_ROUTER1 reed1_messages = self.simulator.get_messages_sent_by(REED1) msg = reed1_messages.next_coap_message('0.02') reed1_ipv6_address = msg.ipv6_packet.ipv6_header.source_address.compressed msg.assertSentToNode(self.nodes[DUT_ROUTER1]); msg.assertCoapMessageRequestUriPath('/a/as') # 8 DUT_ROUTER1: Verify forwarding REED1's Address Solicit Request to LEADER router1_messages = self.simulator.get_messages_sent_by(DUT_ROUTER1) msg = router1_messages.next_coap_message('0.02') msg.assertSentToNode(self.nodes[LEADER]); msg.assertCoapMessageRequestUriPath('/a/as') # DUT_ROUTER1: Verify forwarding LEADER's Address Solicit Response to REED1 msg = router1_messages.next_coap_message('2.04') msg.assertSentToDestinationAddress(reed1_ipv6_address) self.simulator.go(config.MAX_ADVERTISEMENT_INTERVAL) # 9 LEADER: Verify connectivity by sending an ICMPv6 Echo Request to REED1 for addr in self.nodes[REED1].get_addrs(): if addr[0:4] != 'fe80': self.assertTrue(self.nodes[LEADER].ping(addr))
def test(self): self.nodes[LEADER].start() self.simulator.go(5) self.assertEqual(self.nodes[LEADER].get_state(), 'leader') self.nodes[LEADER].add_prefix('2001:2:0:1::/64', 'paros') self.nodes[LEADER].add_prefix('2001:2:0:2::/64', 'paro') self.nodes[LEADER].register_netdata() # Set lowpan context of sniffer self.simulator.set_lowpan_context(1, '2001:2:0:1::/64') self.simulator.set_lowpan_context(2, '2001:2:0:2::/64') self.nodes[ROUTER].start() self.simulator.go(5) self.assertEqual(self.nodes[ROUTER].get_state(), 'router') self.nodes[SED1].start() self.simulator.go(5) self.assertEqual(self.nodes[SED1].get_state(), 'child') self.nodes[MED1].start() self.simulator.go(5) self.assertEqual(self.nodes[MED1].get_state(), 'child') addrs = self.nodes[SED1].get_addrs() self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs)) self.assertFalse(any('2001:2:0:2' in addr[0:10] for addr in addrs)) for addr in addrs: if addr[0:10] == '2001:2:0:1' or addr[0:10] == '2001:2:0:2': self.assertTrue(self.nodes[LEADER].ping(addr)) addrs = self.nodes[MED1].get_addrs() self.assertTrue(any('2001:2:0:1' in addr[0:10] for addr in addrs)) self.assertTrue(any('2001:2:0:2' in addr[0:10] for addr in addrs)) for addr in addrs: if addr[0:10] == '2001:2:0:1' or addr[0:10] == '2001:2:0:2': self.assertTrue(self.nodes[LEADER].ping(addr)) leader_messages = self.simulator.get_messages_sent_by(LEADER) med1_messages = self.simulator.get_messages_sent_by(MED1) sed1_messages = self.simulator.get_messages_sent_by(SED1) # Step 1 - DUT sends MLE Advertisements msg = leader_messages.next_mle_message(mle.CommandType.ADVERTISEMENT) # Step 2 - DUT creates network data msg = leader_messages.next_mle_message(mle.CommandType.DATA_RESPONSE) check_data_response(msg, network_data_check=NetworkDataCheck( prefixes_check=PrefixesCheck(prefix_check_list=[ SinglePrefixCheck(prefix=b'2001000200000001'), SinglePrefixCheck(prefix=b'2001000200000002') ]) ) ) # Step 4 - DUT sends a MLE Child ID Response to Router1 msg = leader_messages.next_mle_message(mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response(msg, network_data_check=NetworkDataCheck( prefixes_check=PrefixesCheck(prefix_cnt=2) ) ) # Step 6 - DUT sends a MLE Child ID Response to SED1 msg = leader_messages.next_mle_message(mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response(msg, network_data_check=NetworkDataCheck( prefixes_check=PrefixesCheck(prefix_check_list=[ SinglePrefixCheck(border_router_16=0xFFFE) ]) ) ) # For Step 10 msg_chd_upd_res_to_sed = leader_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_RESPONSE) # Step 8 - DUT sends a MLE Child ID Response to MED1 msg = leader_messages.next_mle_message(mle.CommandType.CHILD_ID_RESPONSE) check_child_id_response(msg, network_data_check=NetworkDataCheck( prefixes_check=PrefixesCheck(prefix_cnt=2) ) ) # Step 10 - DUT sends Child Update Response msg_chd_upd_res_to_med = leader_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_RESPONSE) msg = med1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST) check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1, 2]) check_child_update_response(msg_chd_upd_res_to_med, address_registration=CheckType.CONTAIN, CIDs=[1, 2]) msg = sed1_messages.next_mle_message(mle.CommandType.CHILD_UPDATE_REQUEST) check_child_update_request_from_child(msg, address_registration=CheckType.CONTAIN, CIDs=[0, 1]) check_child_update_response(msg_chd_upd_res_to_sed, address_registration=CheckType.CONTAIN, CIDs=[1])