spinel-cli: Add timestamp to ping. (#658)

Now calculates real round-trip times for ping6 reply:

    12 bytes from fdde:ad00:beef::3388:cc1e:5e44:6150: icmp_seq=0 hlim=63 time=891ms

Increased pexpect timeout for ncp-sim to 4 sec to handle ping responses >2 sec.
Makes Cert_5_3_10_AddressQuery pass reliably, even on low memory Travis VMs.
Added initial stub for commissioner command.
Add env variable control of ncp-sim DEBUG output.
This commit is contained in:
Martin Turon
2016-09-21 15:30:36 -07:00
committed by Jonathan Hui
parent 43330259f1
commit ad0efaf72d
5 changed files with 48 additions and 6 deletions
-1
View File
@@ -72,7 +72,6 @@ cd /tmp || die
}
[ $BUILD_TARGET != posix-ncp ] || {
pip install blessed || die
pip install ipaddress || die
pip install scapy || die
pip install pyserial || die
-1
View File
@@ -236,7 +236,6 @@ TESTS = \
$(NULL)
XFAIL_NCP_TESTS = \
thread-cert/Cert_5_3_10_AddressQuery.py \
thread-cert/Cert_5_6_06_NetworkDataExpiration.py \
thread-cert/Cert_5_6_08_ContextManagement.py \
thread-cert/Cert_9_2_13_EnergyScan.py \
@@ -38,7 +38,7 @@ ROUTER2 = 3
ROUTER3 = 4
SED2 = 5
class Cert_5_3_9_AddressQuery(unittest.TestCase):
class Cert_5_3_10_AddressQuery(unittest.TestCase):
def setUp(self):
self.nodes = {}
for i in range(1,6):
+2 -1
View File
@@ -86,9 +86,10 @@ class Node:
cmd += ' %d' % nodeid
print ("%s" % cmd)
self.pexpect = pexpect.spawn(cmd, timeout=2)
self.pexpect = pexpect.spawn(cmd, timeout=4)
time.sleep(0.1)
self.pexpect.expect('spinel-cli >')
self.debug(int(os.getenv('DEBUG', '0')))
def __init_soc(self, nodeid):
""" Initialize a System-on-a-chip node connected via UART. """
+45 -2
View File
@@ -1322,8 +1322,10 @@ class WpanApi(SpinelCodec):
if (prop == SPINEL_PROP_STREAM_NET):
pkt = IPv6(value[2:])
if ICMPv6EchoReply in pkt:
timenow = int(round(time.time() * 1000)) & 0xFFFFFFFF
timedelta = (timenow - unpack('>I', pkt.data)[0])
print "\n%d bytes from %s: icmp_seq=%d hlim=%d time=%dms" % (
pkt.plen, pkt.src, pkt.seq, pkt.hlim, 80)
pkt.plen, pkt.src, pkt.seq, pkt.hlim, timedelta)
return
if (tid != self.tid_filter) or (prop != self.prop_filter): return
@@ -1484,6 +1486,7 @@ class WpanDiagsCmd(Cmd, SpinelCodec):
'channel',
'child',
'childtimeout',
'commissioner',
'contextreusedelay',
'counter',
'discover',
@@ -1817,6 +1820,44 @@ class WpanDiagsCmd(Cmd, SpinelCodec):
"""
self.handle_property(line, SPINEL_PROP_THREAD_CHILD_TIMEOUT, 'L')
def do_commissioner(self, line):
"""
These commands are enabled when configuring with --enable-commissioner.
\033[1m
commissioner start
\033[0m
Start the Commissioner role on this node.
\033[2m
> commissioner start
Done
\033[0m\033[1m
commissioner stop
\033[0m
Stop the Commissioner role on this node.
\033[2m
> commissioner stop
Done
\033[0m\033[1m
commissioner panid <panid> <mask> <destination>
\033[0m
Perform panid query.
\033[2m
> commissioner panid 57005 4294967295 ff33:0040:fdde:ad00:beef:0:0:1
Conflict: dead, 00000800
Done
\033[0m\033[1m
commissioner energy <mask> <count> <period> <scanDuration>
\033[0m
Perform energy scan.
\033[2m
> commissioner energy 327680 2 32 1000 fdde:ad00:beef:0:0:ff:fe00:c00
Energy: 00050000 0 0 0 0
Done
\033[0m
"""
pass
def do_contextreusedelay(self, line):
"""
contextreusedelay
@@ -2297,7 +2338,9 @@ class WpanDiagsCmd(Cmd, SpinelCodec):
# Generate local ping packet and send directly via spinel.
ML64 = self.prop_get_value(SPINEL_PROP_IPV6_ML_ADDR)
ML64 = str(ipaddress.IPv6Address(ML64))
ping_req = str(IPv6(src=ML64, dst=addr)/ICMPv6EchoRequest())
timenow = int(round(time.time() * 1000)) & 0xFFFFFFFF
timenow = pack('>I', timenow)
ping_req = str(IPv6(src=ML64, dst=addr)/ICMPv6EchoRequest()/timenow)
self.wpanApi.ip_send(ping_req)
# Let handler print result
except: