def check_cache_entry_switch_to_query_state(): cache_table = wpan.parse_address_cache_table_result( r1.get(wpan.WPAN_THREAD_ADDRESS_CACHE_TABLE)) for index in range(NUM_QUERY_ADDRS): verify( cache_table[index].state == wpan.ADDRESS_CACHE_ENTRY_STATE_QUERY) verify(cache_table[index].can_evict() == True)
def check_cache_entry_in_retry_state_to_get_to_zero_timeout(): cache_table = wpan.parse_address_cache_table_result( r1.get(wpan.WPAN_THREAD_ADDRESS_CACHE_TABLE)) for index in range(NUM_QUERY_ADDRS): verify(cache_table[index].state == wpan.ADDRESS_CACHE_ENTRY_STATE_RETRY_QUERY) verify(cache_table[index].timeout == 0)
def check_cache_entry_switch_to_retry_state(): cache_table = wpan.parse_address_cache_table_result( r1.get(wpan.WPAN_THREAD_ADDRESS_CACHE_TABLE)) for index in range(NUM_QUERY_ADDRS): verify(cache_table[index].state == wpan.ADDRESS_CACHE_ENTRY_STATE_RETRY_QUERY) verify(cache_table[index].retry_delay == 2 * INITIAL_RETRY_DELAY)
for num in range(NUM_QUERY_ADDRS): sender = r1.prepare_tx((r1_address, PORT), (PREFIX + "800:" + str(num), PORT), "hi nobody!", 1) wpan.Node.perform_async_tx_rx() verify(sender.was_successful) # Wait before next tx to stagger the address queries # request ensuring different timeouts time.sleep(MAX_STAGGER_INTERVAL / (NUM_QUERY_ADDRS * speedup)) r2_rloc = int(r2.get(wpan.WPAN_THREAD_RLOC16), 16) c2_rloc = int(c2.get(wpan.WPAN_THREAD_RLOC16), 16) r3_rloc = int(r3.get(wpan.WPAN_THREAD_RLOC16), 16) # Verify that we do see entries in cache table for all the addresses and all are in "query" state addr_cache_table = wpan.parse_address_cache_table_result( r1.get(wpan.WPAN_THREAD_ADDRESS_CACHE_TABLE)) verify(len(addr_cache_table) == NUM_QUERY_ADDRS) for entry in addr_cache_table: verify(entry.state == wpan.ADDRESS_CACHE_ENTRY_STATE_QUERY) verify(not entry.can_evict()) verify(entry.timeout > 0) verify(entry.retry_delay == INITIAL_RETRY_DELAY) # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Check the retry-query behavior # Wait till all the address queries time out and verify they enter "retry-query" state.
sender = r1.prepare_tx(r1_address, c2_address, "Hi from r1 to c2") recver = c2.prepare_rx(sender) wpan.Node.perform_async_tx_rx() verify(sender.was_successful and recver.was_successful) # Send a single UDP message from r1 to c3 sender = r1.prepare_tx(r1_address, c3_address, "Hi from r1 to c3") recver = c3.prepare_rx(sender) wpan.Node.perform_async_tx_rx() verify(sender.was_successful and recver.was_successful) # The address cache table on r1 should contain two entries for # c2 and c3 addresses. addr_cache_table = wpan.parse_address_cache_table_result(r1.get(wpan.WPAN_THREAD_ADDRESS_CACHE_TABLE)) verify(len(addr_cache_table) == 2) for entry in addr_cache_table: if entry.address == c2_address: # Entry for c2 should point towards its parent r2. verify(entry.rloc16 == r2_rloc) elif entry.address == c3_address: # Entry for c3 should point towards c3 itself. verify(entry.rloc16 == c3_rloc) else: raise(VerifyError("Unknown entry in the address cache table")) #- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Force c2 to switch its parent from r2 to r3