From c0442e88e8eccbb30238741310eba12d82a91e57 Mon Sep 17 00:00:00 2001 From: Rongli Sun Date: Tue, 21 Jul 2020 14:07:29 +0800 Subject: [PATCH] [address-resolver] TimeSinceLastTransaction should be in seconds (#5264) --- src/core/thread/address_resolver.cpp | 3 ++- tests/toranj/test-039-address-cache-table-snoop.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 7d17bcea0..d216a282e 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -42,6 +42,7 @@ #include "common/instance.hpp" #include "common/locator-getters.hpp" #include "common/logging.hpp" +#include "common/time.hpp" #include "mac/mac_types.hpp" #include "thread/mesh_forwarder.hpp" #include "thread/mle_router.hpp" @@ -787,7 +788,7 @@ void AddressResolver::HandleAddressQuery(Coap::Message &aMessage, const Ip6::Mes if (child.HasIp6Address(target)) { - lastTransactionTime = TimerMilli::GetNow() - child.GetLastHeard(); + lastTransactionTime = Time::MsecToSec(TimerMilli::GetNow() - child.GetLastHeard()); SendAddressQueryResponse(target, child.GetMeshLocalIid(), &lastTransactionTime, aMessageInfo.GetPeerAddr()); ExitNow(); } diff --git a/tests/toranj/test-039-address-cache-table-snoop.py b/tests/toranj/test-039-address-cache-table-snoop.py index 846496ff9..ad07c2fa7 100644 --- a/tests/toranj/test-039-address-cache-table-snoop.py +++ b/tests/toranj/test-039-address-cache-table-snoop.py @@ -322,7 +322,9 @@ for index in range(NUM_ADDRESSES): str(NUM_ADDRESSES - index - 1)) verify(cache_table[index].rloc16 == r3_rloc) verify(cache_table[index].state == wpan.ADDRESS_CACHE_ENTRY_STATE_CACHED) - verify(cache_table[index].last_trans > 0) + # SED's keep-alive period (`POLL_PERIOD`) is 200ms, `last_trans` should always be 0 as it is + # the number of seconds since a keep-alive was last received from the child. + verify(cache_table[index].last_trans == 0) # Send again to r2. This should cause the related cache entries to be moved to top of the list: