From aae665a0a3e7d72b7b455dafd1e908f81816d372 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 19 Sep 2016 18:29:15 +0200 Subject: [PATCH 01/25] SW-IoT-Lab. record raw data file of IoT-Lab nodes. --- .../openvisualizer/openvisualizer/moteProbe/moteProbe.py | 7 +++++++ software/openvisualizer/openvisualizer/openLbr/openLbr.py | 4 +++- .../remoteConnectorRover/remoteConnectorRover.py | 2 +- .../remoteConnectorServer/remoteConnectorServer.py | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 1fbb9a308..dc07c7cdb 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -106,6 +106,9 @@ def __init__(self,serialport=None,emulatedMote=None,iotlabmote=None): self.mode = self.MODE_IOTLAB else: raise SystemError() + + hostname = socket.gethostname() + self.serialFile = open(str(hostname)+'.log','w') # store params if self.mode==self.MODE_SERIAL: @@ -241,6 +244,8 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: + if self.serialFile.closed == False: + self.serialFile.write(str([ord(c) for c in self.inputBuf])+'\n') # dispatch dispatcher.send( sender = self.name, @@ -256,6 +261,7 @@ def run(self): errMsg=u.formatCrashMessage(self.name,err) print errMsg log.critical(errMsg) + self.serialFile.close() sys.exit(-1) #======================== public ========================================== @@ -270,6 +276,7 @@ def getSerialPortBaudrate(self): def close(self): self.goOn = False + self.serialFile.close() #======================== private ========================================= diff --git a/software/openvisualizer/openvisualizer/openLbr/openLbr.py b/software/openvisualizer/openvisualizer/openLbr/openLbr.py index e8cdb93e5..d8bfdf69a 100644 --- a/software/openvisualizer/openvisualizer/openLbr/openLbr.py +++ b/software/openvisualizer/openvisualizer/openLbr/openLbr.py @@ -253,7 +253,9 @@ def _meshToV6_notif(self,sender,signal,data): log.error("detected possible downstream link on upstream route from {0}".format(",".join(str(c) for c in ipv6dic['src_addr']))) if (ipv6dic['hop_flags'] & self.R_FLAG) == self.R_FLAG: #error -- loop in the route - log.error("detected possible loop on upstream route from {0}".format(",".join(str(c) for c in ipv6dic['src_addr']))) + #log.error("detected possible loop on upstream route from {0}".format(",".join(str(c) for c in ipv6dic['src_addr']))) + print "detected possible loop on upstream route\n" + print ipv6dic #skip the header and process the rest of the message. ipv6dic['next_header'] = ipv6dic['hop_next_header'] diff --git a/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py b/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py index ff54d9b89..39bfc0334 100644 --- a/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py +++ b/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py @@ -9,7 +9,7 @@ log.addHandler(logging.NullHandler()) import threading -import zmq +# import zmq from pydispatch import dispatcher diff --git a/software/openvisualizer/openvisualizer/remoteConnectorServer/remoteConnectorServer.py b/software/openvisualizer/openvisualizer/remoteConnectorServer/remoteConnectorServer.py index 636639438..8c2500e43 100644 --- a/software/openvisualizer/openvisualizer/remoteConnectorServer/remoteConnectorServer.py +++ b/software/openvisualizer/openvisualizer/remoteConnectorServer/remoteConnectorServer.py @@ -10,7 +10,7 @@ import threading import json -import zmq +# import zmq from pydispatch import dispatcher From 4d7644488f97092a02b1a50ea0db03e4569e2f57 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 19 Sep 2016 19:01:54 +0200 Subject: [PATCH 02/25] FW-548. update serial port name of A8_M3 nodes --- software/openvisualizer/openvisualizer/moteProbe/moteProbe.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index dc07c7cdb..e5236fdee 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -68,8 +68,7 @@ def findSerialPorts(): portMask = ['/dev/tty.usbserial-*'] else: portMask = ['/dev/ttyUSB*', '/dev/ttyAMA*'] - for mask in portMask : - serialports += [(s,BAUDRATE_GINA) for s in glob.glob(mask)] + serialports = [("/dev/ttyA8_M3", 500000)] # log log.info("discovered following COM port: {0}".format(['{0}@{1}'.format(s[0],s[1]) for s in serialports])) From b68cac19a47c816567de9413d62907a4eb213475 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 19 Sep 2016 22:21:56 +0200 Subject: [PATCH 03/25] FW-548. record serial data in log file with OV. --- .../openvisualizer/openvisualizer/moteProbe/moteProbe.py | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index e5236fdee..e39c06c63 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -105,9 +105,6 @@ def __init__(self,serialport=None,emulatedMote=None,iotlabmote=None): self.mode = self.MODE_IOTLAB else: raise SystemError() - - hostname = socket.gethostname() - self.serialFile = open(str(hostname)+'.log','w') # store params if self.mode==self.MODE_SERIAL: @@ -243,8 +240,8 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: - if self.serialFile.closed == False: - self.serialFile.write(str([ord(c) for c in self.inputBuf])+'\n') + with open('~/A8/serialData/'+socket.gethostname()++'.log','a') as f: + f.write(str([ord(c) for c in self.inputBuf])+'\n') # dispatch dispatcher.send( sender = self.name, @@ -260,7 +257,6 @@ def run(self): errMsg=u.formatCrashMessage(self.name,err) print errMsg log.critical(errMsg) - self.serialFile.close() sys.exit(-1) #======================== public ========================================== @@ -275,7 +271,6 @@ def getSerialPortBaudrate(self): def close(self): self.goOn = False - self.serialFile.close() #======================== private ========================================= From 518f749bf40fa170d716a382938cc3218b018ed6 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 19 Sep 2016 22:31:55 +0200 Subject: [PATCH 04/25] FW-548. fixed. --- software/openvisualizer/openvisualizer/moteProbe/moteProbe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index e39c06c63..a2815c321 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -240,7 +240,7 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: - with open('~/A8/serialData/'+socket.gethostname()++'.log','a') as f: + with open('~/A8/serialData/'+socket.gethostname()+'.log','a') as f: f.write(str([ord(c) for c in self.inputBuf])+'\n') # dispatch dispatcher.send( From 6e64b15f949ba69fed83050e7c3015d761ac57c3 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 19 Sep 2016 22:37:15 +0200 Subject: [PATCH 05/25] FW-548. fixed. --- software/openvisualizer/openvisualizer/moteProbe/moteProbe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index a2815c321..8d6aaae71 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -240,7 +240,7 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: - with open('~/A8/serialData/'+socket.gethostname()+'.log','a') as f: + with open('/home/root/A8/serialData/'+socket.gethostname()+'.log','a') as f: f.write(str([ord(c) for c in self.inputBuf])+'\n') # dispatch dispatcher.send( From b05ddb9f89d782b446e6954b216d0118f7cd0600 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Tue, 20 Sep 2016 18:27:05 +0200 Subject: [PATCH 06/25] FW-548. change the directory storing serial data. --- software/openvisualizer/openvisualizer/moteProbe/moteProbe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 8d6aaae71..502fcb844 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -240,7 +240,7 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: - with open('/home/root/A8/serialData/'+socket.gethostname()+'.log','a') as f: + with open('/home/root/A8/experiment/'+socket.gethostname()+'.log','a') as f: f.write(str([ord(c) for c in self.inputBuf])+'\n') # dispatch dispatcher.send( From 245a0e76622bf085d626d5d935d11a92f6e3bc20 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Wed, 21 Sep 2016 18:24:33 +0200 Subject: [PATCH 07/25] FW-548. fixed. --- .../openvisualizer/moteConnector/StackDefines.py | 14 ++++++++------ .../openvisualizer/moteProbe/moteProbe.py | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py index 94fa264da..cbf8139a8 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py +++ b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py @@ -1,6 +1,6 @@ # DO NOT EDIT DIRECTLY! # This file was generated automatically by GenStackDefines.py -# on Thu, 18 Jun 2015 23:18:40 +# on Wed, 21 Sep 2016 18:22:22 # components = { @@ -43,6 +43,7 @@ 36: "UINJECT", 37: "RRT", 38: "SECURITY", + 39: "USERIALBRIDGE", } errorDescriptions = { @@ -55,7 +56,7 @@ 7: "wrong TCP state {0} (code location {1})", 8: "TCP reset while in state {0} (code location {1})", 9: "unsupported port number {0} (code location {1})", - 10: "unexpected DAO (code location {0})", + 10: "unexpected DAO (code location {0}). A change maybe happened on dagroot node.", 11: "unsupported ICMPv6 type {0} (code location {1})", 12: "unsupported 6LoWPAN parameter {1} at location {0}", 13: "no next hop", @@ -103,9 +104,10 @@ 55: "invalid packet frome radio, length {1} (code location {0})", 56: "busy receiving when stop of serial activity, buffer input length {1} (code location {0})", 57: "wrong CRC in input Buffer (input length {0})", - 58: "frame received at asn {0} with timeCorrection of {1}", + 58: "synchronized when received a packet", 59: "security error on frameType {0}, code location {1}", - 60: "sixtop return code {0} at sixtop state {1} ", - 61: "6P count command returns Number of scheduled cells: {0}", - 62: "6P List returns cells [({0},{1})]", + 60: "sixtop return code {0} at sixtop state {1}", + 61: "there are {0} cells to request mote", + 62: "the cells reserved to request mote contains slot {0} and slot {1}", + 63: "the slot {0} to be added is already in schedule", } diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 502fcb844..c5ec74b50 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -241,7 +241,7 @@ def run(self): self.serial.write(outputToWrite) else: with open('/home/root/A8/experiment/'+socket.gethostname()+'.log','a') as f: - f.write(str([ord(c) for c in self.inputBuf])+'\n') + f.write(tempBuf) # dispatch dispatcher.send( sender = self.name, From 1bccf0dffc1119b3de21b861ca28377bfbeac8a5 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Fri, 23 Sep 2016 10:03:40 +0200 Subject: [PATCH 08/25] FW-548. update StackDefines. --- .../openvisualizer/moteConnector/StackDefines.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py index cbf8139a8..481eb1121 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py +++ b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py @@ -1,6 +1,6 @@ # DO NOT EDIT DIRECTLY! # This file was generated automatically by GenStackDefines.py -# on Wed, 21 Sep 2016 18:22:22 +# on Thu, 22 Sep 2016 18:09:15 # components = { @@ -110,4 +110,5 @@ 61: "there are {0} cells to request mote", 62: "the cells reserved to request mote contains slot {0} and slot {1}", 63: "the slot {0} to be added is already in schedule", + 64: "watchdog timer fired.", } From aa1eba6a1bda61a357675ea059b54b6a90068085 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Fri, 30 Sep 2016 17:44:29 +0200 Subject: [PATCH 09/25] FW-548. shown the usageBitMap and bitMapIndex. --- .../bin/openVisualizerApp/web_files/templates/moteview.tmpl | 4 +++- .../openvisualizer/moteConnector/ParserStatus.py | 4 +++- software/openvisualizer/openvisualizer/moteState/moteState.py | 4 ++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl index f090bc578..2563c027f 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl @@ -312,7 +312,7 @@ // Slot Schedule responsive table if (hasJson) { - var tbl_body = ""; + var tbl_body = "
OffsetTypeShared?ChannelNbr TypeRXTXTX ACKLast ASN
"; $.each(schedJson, function() { var tbl_row = ""; @@ -324,6 +324,8 @@ tbl_row += ""; tbl_row += ""; tbl_row += ""; + tbl_row += ""; + tbl_row += ""; tbl_body += "" + tbl_row + ""; }); diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index 57aff3274..ee877adf2 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -127,7 +127,7 @@ def __init__(self): 3, 6, 'ScheduleRow', - ' Date: Fri, 14 Oct 2016 16:19:12 +0200 Subject: [PATCH 10/25] FW-575. add isNoRes field in neighbor table. --- .../bin/openVisualizerApp/web_files/templates/moteview.tmpl | 3 ++- .../openvisualizer/moteConnector/ParserStatus.py | 3 ++- software/openvisualizer/openvisualizer/moteState/moteState.py | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl index 2563c027f..bd161a445 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl @@ -351,10 +351,11 @@ // Neighbors responsive table if (hasJson) { - var tbl_body = "
OffsetTypeShared?ChannelNbr TypeRXTXTX ACKLast ASNusageBitMapbitMapIndex
" + this['slotOffset'] + "" + this['numTx'] + "" + this['numTxACK'] + "" + this['lastUsedAsn'] + "" + this['usageBitMap'] + "" + this['bitMapIndex'] + "
"; + var tbl_body = "
UsedParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
"; $.each(nbrsJson, function() { var tbl_row = ""; + tbl_row += ""; tbl_row += ""; tbl_row += ""; tbl_row += ""; diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index ee877adf2..fa532789d 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -189,7 +189,7 @@ def __init__(self): 3, 9, 'NeighborsRow', - ' Date: Thu, 2 Feb 2017 17:36:50 +0100 Subject: [PATCH 11/25] Revert "SW-263. Add zmq interface to send/receive events" This reverts commit ddcf5f295f60f453894967ae00642415283fa906. # Conflicts: # software/openvisualizer/openvisualizer/remoteConnectorServer/remoteConnectorServer.py --- .../openvisualizer/remoteConnectorRover/remoteConnectorRover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py b/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py index 39bfc0334..ff54d9b89 100644 --- a/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py +++ b/software/openvisualizer/openvisualizer/remoteConnectorRover/remoteConnectorRover.py @@ -9,7 +9,7 @@ log.addHandler(logging.NullHandler()) import threading -# import zmq +import zmq from pydispatch import dispatcher From c728f4cce5ed94faf7af8db4edc348c65a2f2d41 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Thu, 2 Feb 2017 17:53:39 +0100 Subject: [PATCH 12/25] FW-548. remove all other ports rather than A8. --- .../openvisualizer/remoteConnectorRover/coapserver.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/software/openvisualizer/openvisualizer/remoteConnectorRover/coapserver.py b/software/openvisualizer/openvisualizer/remoteConnectorRover/coapserver.py index 88e8f1c10..7cd07218b 100644 --- a/software/openvisualizer/openvisualizer/remoteConnectorRover/coapserver.py +++ b/software/openvisualizer/openvisualizer/remoteConnectorRover/coapserver.py @@ -57,8 +57,6 @@ def PUT(self,options=[],payload=None): def listmotes(self): - serialList = glob.glob('/dev/ttyUSB*') # Get all Serial ports - serialList += glob.glob('/dev/ttyAMA*') - serialList += glob.glob('/dev/ttyA8_M3') + serialList = glob.glob('/dev/ttyA8_M3') return json.dumps([serial for serial in serialList]) \ No newline at end of file From 74b773bba26e052b437088f7dfced4ff46264ee9 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Thu, 2 Feb 2017 18:25:31 +0100 Subject: [PATCH 13/25] FW-548. update moteProbe(only for A8) --- .../openvisualizer/moteProbe/moteProbe.py | 23 ++----------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index e5633f0fe..9cb470422 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -69,28 +69,9 @@ def findSerialPorts(): portMask = ['/dev/tty.usbserial-*'] else: portMask = ['/dev/ttyUSB*', '/dev/ttyAMA*', '/dev/ttyA8_M3'] - serialports = [("/dev/ttyA8_M3", 115200)] - - # Find all OpenWSN motes that answer to TRIGGERSERIALECHO commands - # Also test for 500000 to find IoT Lab M3 motes - mote_ports = [] - - for port in serialports: - for baudrate in [port[1], 500000]: - probe = moteProbe(serialport=(port[0],baudrate)) - tester = SerialTester(probe.portname) - tester.setNumTestPkt(1) - tester.setTimeout(1) - tester.test(blocking=True) - if tester.getStats()['numOk'] >= 1: - mote_ports.append((port[0],baudrate)); - probe.close() - probe.join() - - # log - log.info("discovered following COM port: {0}".format(['{0}@{1}'.format(s[0],s[1]) for s in mote_ports])) - return mote_ports + serialports = [('/dev/ttyA8_M3', 500000)] + return serialports #============================ class =========================================== From e518b62b51c3402d92774b3447a4cafd5db75464 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Sun, 5 Nov 2017 13:03:50 +0100 Subject: [PATCH 14/25] FW-548. clean up. --- .../openvisualizer/moteProbe/moteProbe.py | 1 + .../openvisualizer/openLbr/openLbr.py | 310 +++++++++--------- .../remoteConnectorRover/coapserver.py | 2 +- 3 files changed, 157 insertions(+), 156 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 0cca65e62..ec42ac127 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -32,6 +32,7 @@ BAUDRATE_TELOSB = 115200 BAUDRATE_GINA = 115200 BAUDRATE_WSN430 = 115200 +BAUDRATE_IOTLAB = 500000 def findSerialPorts(): ''' diff --git a/software/openvisualizer/openvisualizer/openLbr/openLbr.py b/software/openvisualizer/openvisualizer/openLbr/openLbr.py index 1c2cc0934..cfc19a4b0 100644 --- a/software/openvisualizer/openvisualizer/openLbr/openLbr.py +++ b/software/openvisualizer/openvisualizer/openLbr/openLbr.py @@ -1,6 +1,6 @@ -# Copyright (c) 2010-2013, Regents of the University of California. -# All rights reserved. -# +# Copyright (c) 2010-2013, Regents of the University of California. +# All rights reserved. +# # Released under the BSD 3-Clause license as published at the link below. # https://openwsn.atlassian.net/wiki/display/OW/License import logging @@ -18,26 +18,26 @@ class OpenLbr(eventBusClient.eventBusClient): ''' Class which is responsible for translating between 6LoWPAN and IPv6 headers. - + This class implements the following RFCs: - + * *http://tools.ietf.org/html/rfc6282* Compression Format for IPv6 Datagrams over IEEE 802.15.4-Based Networks. - * *http://tools.ietf.org/html/rfc2460* + * *http://tools.ietf.org/html/rfc2460* Internet Protocol, Version 6 (IPv6) Specification * *http://tools.ietf.org/html/draft-thubert-6man-flow-label-for-rpl-03 - The IPv6 Flow Label within a RPL domain + The IPv6 Flow Label within a RPL domain ''' #implementing http://tools.ietf.org/html/draft-thubert-6man-flow-label-for-rpl-03 - - # http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml + + # http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xml IANA_PROTOCOL_IPv6ROUTE = 43 IANA_UDP = 17 IANA_ICMPv6 = 58 IANA_IPv6HOPHEADER = 0 # there is no IANA for IPV6 HEADER right now, we use NHC identifier for it IPV6_HEADER = 0xEE #https://tools.ietf.org/html/rfc6282#section-4.2 - + #hop header flags O_FLAG = 0x10 R_FLAG = 0x08 @@ -45,7 +45,7 @@ class OpenLbr(eventBusClient.eventBusClient): I_FLAG = 0x02 K_FLAG = 0x01 FLAG_MASK = 0x1F - + #deadline hop header flags ORG_FLAG = 0x80 DELAY_FLAG = 0x40 @@ -56,9 +56,9 @@ class OpenLbr(eventBusClient.eventBusClient): # Number of bytes in an IPv6 header. IPv6_HEADER_LEN = 40 - + IPHC_DISPATCH = 3 - + IPHC_TF_4B = 0 IPHC_TF_3B = 1 IPHC_TF_1B = 2 @@ -70,7 +70,7 @@ class OpenLbr(eventBusClient.eventBusClient): IPHC_HLIM_INLINE = 0 IPHC_HLIM_1 = 1 IPHC_HLIM_64 = 2 - IPHC_HLIM_255 = 3 + IPHC_HLIM_255 = 3 IPHC_CID_NO = 0 IPHC_CID_YES = 1 @@ -95,7 +95,7 @@ class OpenLbr(eventBusClient.eventBusClient): IPHC_DAM_ELIDED = 3 NHC_DISPATCH = 0x0E - + NHC_EID_MASK = 0x0E NHC_EID_HOPBYHOP = 0 NHC_EID_ROUTING = 1 @@ -119,12 +119,12 @@ class OpenLbr(eventBusClient.eventBusClient): TYPE_6LoRH_RH3_4 = 0x04 MASK_LENGTH_6LoRH_IPINIP = 0x1F - + #=== RPL source routing header (RFC6554) SR_FIR_TYPE = 0x03 - - #=== UDP Header compression (RFC6282) - + + #=== UDP Header compression (RFC6282) + NHC_UDP_MASK = 0xF8 NHC_UDP_ID = 0xF0 NHC_UDP_PORTS_MASK = 0x03 @@ -138,18 +138,18 @@ class OpenLbr(eventBusClient.eventBusClient): #=== Errors ERR_DESTINATIONUNREACHABLE = 1 - + def __init__(self,usePageZero): # log log.info("create instance") - + # store params self.stateLock = threading.Lock() self.networkPrefix = None self.dagRootEui64 = None self.usePageZero = usePageZero - + # initialize parent class eventBusClient.eventBusClient.__init__( self, @@ -168,45 +168,45 @@ def __init__(self,usePageZero): { 'sender' : self.WILDCARD, 'signal' : 'infoDagRoot', #signal once a dagroot id is received - 'callback' : self._infoDagRoot_notif, + 'callback' : self._infoDagRoot_notif, }, { 'sender' : self.WILDCARD, #signal when a pkt from the mesh arrives and has to be forwarded to Internet (or local) 'signal' : 'fromMote.data', #only to data (any), not status nor error - 'callback' : self._meshToV6_notif, + 'callback' : self._meshToV6_notif, }, ] ) - + # local variables - + #======================== public ========================================== - + #======================== private ========================================= - + #===== IPv6 -> 6LoWPAN - + def _v6ToMesh_notif(self,sender,signal,data): ''' Converts a IPv6 packet into a 6LoWPAN packet. - + This function assumes there is a component listening on the EventBus which answers to the 'getSourceRoute' signal. - + This function dispatches the 6LoWPAN packet with signal 'bytesToMesh'. ''' - + try: - + ipv6_bytes = data - + # turn raw byte into dictionary of fields ipv6 = self.disassemble_ipv6(ipv6_bytes) # filter out multicast packets if ipv6['dst_addr'][0]==0xff: return - + if ipv6['dst_addr'][0]==0xfe and ipv6['dst_addr'][1]==0x80: isLinkLocal = True else: @@ -215,10 +215,10 @@ def _v6ToMesh_notif(self,sender,signal,data): # log if log.isEnabledFor(logging.DEBUG): log.debug(self._format_IPv6(ipv6,ipv6_bytes)) - + # convert IPv6 dictionary into 6LoWPAN dictionary lowpan = self.ipv6_to_lowpan(ipv6) - + # add the source route to this destination if len(lowpan['dst_addr'])==16: dst_addr=lowpan['dst_addr'][8:] @@ -227,28 +227,28 @@ def _v6ToMesh_notif(self,sender,signal,data): else: dst_addr=None log.warning('unsupported address format {0}'.format(lowpan['dst_addr'])) - + if isLinkLocal: lowpan['route'] = [dst_addr] else: - lowpan['route'] = self._getSourceRoute(dst_addr) - - if len(lowpan['route'])<2: - # no source route could be found + lowpan['route'] = self._getSourceRoute(dst_addr) + + if len(lowpan['route'])<2: + # no source route could be found log.error('no source route to {0}'.format(lowpan['dst_addr'])) - # TODO: return ICMPv6 message - return - - lowpan['route'].pop() #remove last as this is me. - + # TODO: return ICMPv6 message + return + + lowpan['route'].pop() #remove last as this is me. + lowpan['nextHop'] = lowpan['route'][len(lowpan['route'])-1] #get next hop as this has to be the destination address, this is the last element on the list # turn dictionary of fields into raw bytes lowpan_bytes = self.reassemble_lowpan(lowpan) - + # log if log.isEnabledFor(logging.DEBUG): log.debug(self._format_lowpan(lowpan,lowpan_bytes)) - + # don't forward the ICMPv6 packets to the motes (unsupported) if (ipv6['next_header'] == self.IANA_ICMPv6) and (ipv6['payload'][0] == self.ERR_DESTINATIONUNREACHABLE) : @@ -267,16 +267,16 @@ def _v6ToMesh_notif(self,sender,signal,data): signal = 'bytesToMesh', data = (lowpan['nextHop'],lowpan_bytes), ) - + except (ValueError,NotImplementedError) as err: log.error(err) pass - - + + def _meshToV6_notif(self,sender,signal,data): ''' Converts a 6LowPAN packet into a IPv6 packet. - + This function dispatches the IPv6 packet with signal 'according to the destination address, protocol_type and port'. ''' try: @@ -285,7 +285,7 @@ def _meshToV6_notif(self,sender,signal,data): ipv6dic = self.lowpan_to_ipv6(data) success = True dispatchSignal = None - + hopbyhop_header_present = False #read next header @@ -293,8 +293,8 @@ def _meshToV6_notif(self,sender,signal,data): # mark hop by hop header present, check hop_flags after obtaining src_addr in IPV6 header. hopbyhop_header_present = True #skip the header and process the rest of the message. - ipv6dic['next_header'] = ipv6dic['hop_next_header'] - + ipv6dic['next_header'] = ipv6dic['hop_next_header'] + #=================================================================== if ipv6dic['next_header']==self.IPV6_HEADER: @@ -310,7 +310,7 @@ def _meshToV6_notif(self,sender,signal,data): ipv6dic['hop_limit'] = ipv6dic_inner['hop_limit'] ipv6dic['dst_addr'] = ipv6dic_inner['dst_addr'] ipv6dic['flow_label'] = ipv6dic_inner['flow_label'] - + if hopbyhop_header_present: #hop by hop header present, check hop_flags if (ipv6dic['hop_flags'] & self.O_FLAG) == self.O_FLAG: @@ -326,28 +326,28 @@ def _meshToV6_notif(self,sender,signal,data): log.critical("wrong payload lenght on ICMPv6 packet {0}".format(",".join(str(c) for c in data))) print "wrong payload lenght on ICMPv6 packet {0}".format(",".join(str(c) for c in data)) return - - + + ipv6dic['icmpv6_type']=ipv6dic['payload'][0] ipv6dic['icmpv6_code']=ipv6dic['payload'][1] ipv6dic['icmpv6_checksum']=ipv6dic['payload'][2:4] ipv6dic['app_payload']=ipv6dic['payload'][4:] - + #this function does the job dispatchSignal=(tuple(ipv6dic['dst_addr']),self.PROTO_ICMPv6,ipv6dic['icmpv6_type']) - + elif ipv6dic['next_header']==self.IANA_UDP: #udp header -- can be compressed.. assume first it is not compressed. if len(ipv6dic['payload'])<5: log.critical("wrong payload lenght on UDP packet {0}".format(",".join(str(c) for c in data))) print "wrong payload lenght on UDP packet {0}".format(",".join(str(c) for c in data)) return - + if ipv6dic['payload'][0] & self.NHC_UDP_MASK==self.NHC_UDP_ID: - - lowpan_nhc = ipv6dic['payload'][0] - udp_header_length = 0 - newUdp = [] + + lowpan_nhc = ipv6dic['payload'][0] + udp_header_length = 0 + newUdp = [] newUdp_header_length = 0 if lowpan_nhc & self.NHC_UDP_PORTS_MASK == self.NHC_UDP_PORTS_INLINE: @@ -381,14 +381,14 @@ def _meshToV6_notif(self,sender,signal,data): #append payload to compute crc again newUdp += ipv6dic['payload'][udp_header_length:] # data octets - + udp_len = [0, len(ipv6dic['payload'][udp_header_length:])+8] newUdp[idxLen] = udp_len[0] newUdp[idxLen+1] = udp_len[1] checksum = u.calculatePseudoHeaderCRC(ipv6dic['src_addr'],ipv6dic['dst_addr'],udp_len,[0,ipv6dic['next_header']],newUdp) #fill crc with the right value. - newUdp[idxCS] = checksum[0] + newUdp[idxCS] = checksum[0] newUdp[idxCS+1] = checksum[1] #keep fields for later processing if needed @@ -397,12 +397,12 @@ def _meshToV6_notif(self,sender,signal,data): ipv6dic['udp_length'] = newUdp[4:6] ipv6dic['udp_checksum'] = newUdp[6:8] ipv6dic['app_payload'] = newUdp[8:] - - #substitute udp header by the uncompressed header. - ipv6dic['payload'] = newUdp + + #substitute udp header by the uncompressed header. + ipv6dic['payload'] = newUdp ipv6dic['payload_length'] = len(newUdp) else: - #No UDP header compressed + #No UDP header compressed ipv6dic['udp_src_port']=u.buf2int(ipv6dic['payload'][:2]) ipv6dic['udp_dest_port']=u.buf2int(ipv6dic['payload'][2:4]) ipv6dic['udp_length']=ipv6dic['payload'][4:6] @@ -410,50 +410,50 @@ def _meshToV6_notif(self,sender,signal,data): ipv6dic['app_payload']=ipv6dic['payload'][8:] dispatchSignal=(tuple(ipv6dic['dst_addr']),self.PROTO_UDP,ipv6dic['udp_dest_port']) - - #keep payload and app_payload in case we want to assemble the message later. + + #keep payload and app_payload in case we want to assemble the message later. #as source address is being retrieved from the IPHC header, the signal includes it in case - #receiver such as RPL DAO processing needs to know the source. + #receiver such as RPL DAO processing needs to know the source. success = self._dispatchProtocol(dispatchSignal,(ipv6dic['src_addr'],ipv6dic['app_payload'])) - + if success: return - - # assemble the packet and dispatch it again as nobody answer - ipv6pkt=self.reassemble_ipv6_packet(ipv6dic) - + + # assemble the packet and dispatch it again as nobody answer + ipv6pkt=self.reassemble_ipv6_packet(ipv6dic) + self.dispatch('v6ToInternet',ipv6pkt) - + except (ValueError,IndexError,NotImplementedError) as err: log.error(err) pass - + def disassemble_ipv6(self,ipv6): ''' Turn byte array representing IPv6 packets into into dictionary of fields. - + See http://tools.ietf.org/html/rfc2460#page-4. - + :param ipv6: [in] Byte array representing an IPv6 packet. - + :raises: ValueError when some part of the process is not defined in the standard. :raises: NotImplementedError when some part of the process is defined in the standard, but not implemented in this module. - + :returns: A dictionary of fields. ''' - + if len(ipv6)> 4 if returnVal['version']!=6: raise ValueError('Not an IPv6 packet, version=={0}'.format(returnVal['version'])) - + returnVal['traffic_class'] = ((ipv6[0] & 0x0F) << 4) + (ipv6[1] >> 4) returnVal['flow_label'] = ((ipv6[1] & 0x0F) << 16) + (ipv6[2] << 8) + ipv6[3] returnVal['payload_length'] = u.buf2int(ipv6[4:6]) @@ -462,62 +462,62 @@ def disassemble_ipv6(self,ipv6): returnVal['src_addr'] = ipv6[8:8+16] returnVal['dst_addr'] = ipv6[24:24+16] returnVal['payload'] = ipv6[40:] - + return returnVal - + def ipv6_to_lowpan(self,ipv6): ''' Compact IPv6 header into 6LowPAN header. - + :param ipv6: [in] A disassembled IPv6 packet. - + :raises: ValueError when some part of the process is not defined in the standard. :raises: NotImplementedError when some part of the process is defined in the standard, but not implemented in this module. - + :returns: A disassembled 6LoWPAN packet. ''' - + # header lowpan = {} - + # tf if ipv6['traffic_class']!=0: raise NotImplementedError('traffic_class={0} unsupported'.format(ipv6['traffic_class'])) # comment the flow_label check as it's zero in 6lowpan network. See follow RFC: - # https://tools.ietf.org/html/rfc4944#section-10.1 + # https://tools.ietf.org/html/rfc4944#section-10.1 # if ipv6['flow_label']!=0: # raise NotImplementedError('flow_label={0} unsupported'.format(ipv6['flow_label'])) lowpan['tf'] = [] - + # nh lowpan['nh'] = [ipv6['next_header']] - + # hlim lowpan['hlim'] = [ipv6['hop_limit']] - + # cid lowpan['cid'] = [] - + # src_addr lowpan['src_addr'] = ipv6['src_addr'] - + # dst_addr lowpan['dst_addr'] = ipv6['dst_addr'] - + # payload lowpan['payload'] = ipv6['payload'] - + # join return lowpan - + def reassemble_lowpan(self,lowpan): ''' Turn dictionary of 6LoWPAN header fields into byte array. - + :param lowpan: [in] dictionary of fields representing a 6LoWPAN header. - + :returns: A list of bytes representing the 6LoWPAN packet. ''' returnVal = [] @@ -533,7 +533,7 @@ def reassemble_lowpan(self,lowpan): # 3. RPI 6LoRH (maybe elided) # 4. IPinIP 6LoRH (maybe elided) # 5. IPHC inner header - + # ===================== 1. Page Dispatch (page 1) ===================== returnVal += [self.PAGE_ONE_DISPATCH] @@ -550,7 +550,7 @@ def reassemble_lowpan(self,lowpan): if len(compressReference)==16: prefix=compressReference[:8] - # =======================3. RH3 6LoRH(s) ============================== + # =======================3. RH3 6LoRH(s) ============================== sizeUnitType = 0xff size = 0 hopList = [] @@ -628,7 +628,7 @@ def reassemble_lowpan(self,lowpan): # ===================== 2. IPinIP 6LoRH =============================== if lowpan['src_addr'][:8] != [187, 187, 0, 0, 0, 0, 0, 0]: - # add RPI + # add RPI # TBD flag = self.O_FLAG | self.I_FLAG | self.K_FLAG senderRank = 0 # rank of dagroot @@ -641,7 +641,7 @@ def reassemble_lowpan(self,lowpan): compressReference = [187, 187, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1] else: compressReference = lowpan['src_addr'] - + # ========================= 4. IPHC inner header ====================== # Byte1: 011(3b) TF(2b) NH(1b) HLIM(2b) if len(lowpan['tf'])==0: @@ -662,7 +662,7 @@ def reassemble_lowpan(self,lowpan): else: hlim = self.IPHC_HLIM_INLINE returnVal += [(self.IPHC_DISPATCH<<5) + (tf<<3) + (nh<<2) + (hlim<<0)] - + # Byte2: CID(1b) SAC(1b) SAM(2b) M(1b) DAC(2b) DAM(2b) if len(lowpan['cid'])==0: cid = self.IPHC_CID_NO @@ -670,7 +670,7 @@ def reassemble_lowpan(self,lowpan): cid = self.IPHC_CID_YES if self._isLinkLocal(lowpan['src_addr']): - sac = self.IPHC_SAC_STATELESS + sac = self.IPHC_SAC_STATELESS lowpan['src_addr'] = lowpan['src_addr'][8:] else: sac = self.IPHC_SAC_STATEFUL @@ -689,7 +689,7 @@ def reassemble_lowpan(self,lowpan): raise SystemError() if self._isLinkLocal(lowpan['dst_addr']): - dac = self.IPHC_DAC_STATELESS + dac = self.IPHC_DAC_STATELESS lowpan['dst_addr'] = lowpan['dst_addr'][8:] else: dac = self.IPHC_DAC_STATEFUL @@ -714,16 +714,16 @@ def reassemble_lowpan(self,lowpan): # nh returnVal += lowpan['nh'] - + # hlim returnVal += lowpan['hlim'] - + # cid returnVal += lowpan['cid'] # src_addr returnVal += lowpan['src_addr'] - + # dst_addr returnVal += lowpan['dst_addr'] @@ -731,11 +731,11 @@ def reassemble_lowpan(self,lowpan): returnVal += lowpan['payload'] return returnVal - + #===== 6LoWPAN -> IPv6 - + def lowpan_to_ipv6(self,data): - + pkt_ipv6 = {} mac_prev_hop=data[0] pkt_lowpan=data[1] @@ -753,7 +753,7 @@ def lowpan_to_ipv6(self,data): ptr += 1 else: pkt_ipv6['hop_rplInstanceID'] = 0 - + if pkt_ipv6['hop_flags'] & self.K_FLAG==0: pkt_ipv6['hop_senderRank'] = ((pkt_lowpan[ptr]) << 8) + ((pkt_lowpan[ptr+1]) << 0) ptr += 2 @@ -827,8 +827,8 @@ def lowpan_to_ipv6(self,data): ptr = 2 if (pkt_lowpan[0] >> 5) != 0x03: log.error("ERROR not a 6LowPAN packet") - return - + return + # tf tf = ((pkt_lowpan[0]) >> 3) & 0x03 if tf == self.IPHC_TF_3B: @@ -848,7 +848,7 @@ def lowpan_to_ipv6(self,data): pass else: log.error("wrong nh field nh="+str(nh)) - + # hlim hlim = (pkt_lowpan[0]) & 0x03 if hlim == self.IPHC_HLIM_INLINE: @@ -875,14 +875,14 @@ def lowpan_to_ipv6(self,data): if sam == self.IPHC_SAM_ELIDED: #pkt from the previous hop pkt_ipv6['src_addr'] = prefix + mac_prev_hop - + elif sam == self.IPHC_SAM_16B: a1 = pkt_lowpan[ptr] a2 = pkt_lowpan[ptr+1] ptr = ptr+2 s = ''.join(['\x00','\x00','\x00','\x00','\x00','\x00',a1,a2]) pkt_ipv6['src_addr'] = prefix+s - + elif sam == self.IPHC_SAM_64B: pkt_ipv6['src_addr'] = prefix+pkt_lowpan[ptr:ptr+8] ptr = ptr + 8 @@ -891,7 +891,7 @@ def lowpan_to_ipv6(self,data): ptr = ptr + 16 else: log.error("wrong sam=="+str(sam)) - + # dac dac = ((pkt_lowpan[1]) >> 2) & 0x01 if dac == self.IPHC_DAC_STATELESS: @@ -931,8 +931,8 @@ def lowpan_to_ipv6(self,data): log.error("wrong NH_EID=="+str(eid)) elif pkt_lowpan[ptr] & self.NHC_UDP_ID == self.NHC_UDP_ID: pkt_ipv6['next_header'] = self.IANA_UDP - - #hop by hop header + + #hop by hop header #composed of NHC, NextHeader,Len + Rpl Option if pkt_ipv6['next_header'] == self.IANA_IPv6HOPHEADER: pkt_ipv6['hop_nhc'] = pkt_lowpan[ptr] @@ -969,7 +969,7 @@ def lowpan_to_ipv6(self,data): pkt_ipv6['payload_length'] = len(pkt_ipv6['payload']) pkt_ipv6['pre_hop'] = mac_prev_hop return pkt_ipv6 - + def reassemble_ipv6_packet(self, pkt): pktw = [((6 << 4) + (pkt['traffic_class'] >> 4)), (((pkt['traffic_class'] & 0x0F) << 4) + (pkt['flow_label'] >> 16)), @@ -982,37 +982,37 @@ def reassemble_ipv6_packet(self, pkt): for i in range(0,16): pktw.append( (pkt['src_addr'][i]) ) for i in range(0,16): - pktw.append( (pkt['dst_addr'][i]) ) - + pktw.append( (pkt['dst_addr'][i]) ) + return pktw + pkt['payload'] - - - + + + #======================== helpers ========================================= - + #===== source route - + def _getSourceRoute(self,destination): returnVal = self._dispatchAndGetResult( signal = 'getSourceRoute', data = destination, ) return returnVal - + def _setPrefix_notif(self,sender,signal, data): ''' Record the network prefix. ''' with self.stateLock: - self.networkPrefix = data + self.networkPrefix = data log.info('Set network prefix {0}'.format(u.formatIPv6Addr(data))) - - + + def _infoDagRoot_notif(self,sender,signal,data): ''' Record the DAGroot's EUI64 address. ''' - + if data['isDAGroot']==1: with self.stateLock: self.dagRootEui64 = data['eui64'][:] @@ -1023,7 +1023,7 @@ def _isLinkLocal(self, ipv6Address): return False #===== formatting - + def _format_IPv6(self,ipv6,ipv6_bytes): output = [] output += [''] @@ -1043,7 +1043,7 @@ def _format_IPv6(self,ipv6,ipv6_bytes): output += [self._formatWireshark(ipv6_bytes)] output += [''] return '\n'.join(output) - + def _format_lowpan(self,lowpan,lowpan_bytes): output = [] output += [''] @@ -1065,21 +1065,21 @@ def _format_lowpan(self,lowpan,lowpan_bytes): output += [self._formatWireshark(lowpan_bytes)] output += [''] return '\n'.join(output) - + def _formatWireshark(self,pkt): NUM_BYTES_PER_LINE = 16 - + output = [] index = 0 while index Date: Sun, 5 Nov 2017 13:08:44 +0100 Subject: [PATCH 15/25] FW-548. remove the recording file. --- software/openvisualizer/openvisualizer/moteProbe/moteProbe.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index ec42ac127..24014ec83 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -263,8 +263,6 @@ def run(self): outputToWrite = self.outputBuf.pop(0) self.serial.write(outputToWrite) else: - with open('/home/root/A8/experiment/'+socket.gethostname()+'.log','a') as f: - f.write(tempBuf) # dispatch dispatcher.send( sender = self.name, From cfa4e6b34b2e893cfc1b19f81d7fd046e1d4f697 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 6 Nov 2017 13:20:23 +0100 Subject: [PATCH 16/25] FW-710. remove sixtopGEN field from neighbor table. --- .../bin/openVisualizerApp/web_files/templates/moteview.tmpl | 3 +-- .../openvisualizer/moteConnector/ParserStatus.py | 3 +-- software/openvisualizer/openvisualizer/moteState/moteState.py | 2 -- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl index 7cfb62676..afff3a554 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl @@ -356,13 +356,12 @@ // Neighbors responsive table if (hasJson) { - var tbl_body = "
UsedisNoResParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
" + this['used'] + "" + this['isNoRes'] + "" + this['parentPreference'] + "" + this['stableNeighbor'] + "" + this['switchStabilityCounter'] + "
"; + var tbl_body = "
UsedInsecuref6PNORESsixtopGENsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
"; $.each(nbrsJson, function() { var tbl_row = ""; tbl_row += ""; tbl_row += ""; - tbl_row += ""; tbl_row += ""; tbl_row += ""; tbl_row += ""; diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index 51b4ff21f..6e88e4cf7 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -187,7 +187,7 @@ def __init__(self): 3, 9, 'NeighborsRow', - ' Date: Tue, 7 Nov 2017 16:59:07 +0100 Subject: [PATCH 17/25] FW-710. update backoff in neighbor table. --- .../bin/openVisualizerApp/web_files/templates/moteview.tmpl | 5 ++++- .../openvisualizer/moteConnector/ParserStatus.py | 5 ++++- .../openvisualizer/openvisualizer/moteState/moteState.py | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl index afff3a554..331bfe5f4 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl @@ -356,7 +356,8 @@ // Neighbors responsive table if (hasJson) { - var tbl_body = "
UsedInsecuref6PNORESsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
" + this['used'] + "" + this['insecure'] + "" + this['f6PNORES'] + "" + this['sixtopGEN'] + "" + this['sixtopSeqNum'] + "" + this['parentPreference'] + "" + this['stableNeighbor'] + "
"; + var tbl_body = "
UsedInsecuref6PNORESsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
"; + var tbl_body = "
UsedInsecuref6PNORESsixtopGENsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASN
"; $.each(nbrsJson, function() { var tbl_row = ""; @@ -375,6 +376,8 @@ tbl_row += ""; tbl_row += ""; tbl_row += ""; + tbl_row += ""; + tbl_row += ""; tbl_body += "" + tbl_row + ""; }); diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index 6e88e4cf7..26b46852b 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -187,7 +187,8 @@ def __init__(self): 3, 9, 'NeighborsRow', - ' Date: Tue, 7 Nov 2017 17:00:58 +0100 Subject: [PATCH 18/25] FW-710. remove additional line. --- .../openvisualizer/openvisualizer/moteConnector/ParserStatus.py | 1 - 1 file changed, 1 deletion(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index 26b46852b..ba83fedc1 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -187,7 +187,6 @@ def __init__(self): 3, 9, 'NeighborsRow', - ' Date: Wed, 8 Nov 2017 14:53:45 +0100 Subject: [PATCH 19/25] FW-548. remove the bitmap variables from moteState. --- .../openvisualizer/moteConnector/ParserStatus.py | 5 ++--- .../openvisualizer/openvisualizer/moteState/moteState.py | 2 -- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index eae0c7b67..5b21085f7 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -127,7 +127,7 @@ def __init__(self): 3, 6, 'ScheduleRow', - ' Date: Thu, 9 Nov 2017 11:20:40 +0100 Subject: [PATCH 20/25] FW-548. update stack definition. --- .../openvisualizer/moteConnector/StackDefines.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py index a3f95ff3e..cf192886c 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py +++ b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py @@ -1,6 +1,6 @@ # DO NOT EDIT DIRECTLY! # This file was generated automatically by GenStackDefines.py -# on Mon, 14 Aug 2017 10:37:31 +# on Thu, 09 Nov 2017 11:16:05 # components = { @@ -134,10 +134,11 @@ 3: "RC_RESET", 4: "RC_VER_ERR", 5: "RC_SFID_ERR", - 6: "RC_GEN_ERR", - 7: "RC_BUSY", - 8: "RC_NORES", - 9: "RC_CELLLIST_ERR", + 6: "RC_SEQNUM_ERR", + 7: "RC_CELLLIST_ERR", + 8: "RC_BUSY", + 9: "RC_LOCKED", + 10: "RC_NORES", } sixtop_statemachine = { From d384cca2d1e10f1b5f848d5eb0d1fd5629631777 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Thu, 9 Nov 2017 11:21:35 +0100 Subject: [PATCH 21/25] FW-548. record the received serial frames and DAO info. --- software/openvisualizer/openvisualizer/RPL/topology.py | 9 +++++++-- .../openvisualizer/openvisualizer/moteProbe/moteProbe.py | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/software/openvisualizer/openvisualizer/RPL/topology.py b/software/openvisualizer/openvisualizer/RPL/topology.py index b7a1161a4..d7cc1e32d 100644 --- a/software/openvisualizer/openvisualizer/RPL/topology.py +++ b/software/openvisualizer/openvisualizer/RPL/topology.py @@ -31,7 +31,8 @@ def __init__(self): self.dataLock = threading.Lock() self.parents = {} self.parentsLastSeen = {} - self.NODE_TIMEOUT_THRESHOLD = 150 + self.parentsDelay = {} + self.NODE_TIMEOUT_THRESHOLD = 900 eventBusClient.eventBusClient.__init__( self, @@ -82,7 +83,11 @@ def updateParents(self,sender,signal,data): self.parents.update({data[0]:data[1]}) self.parentsLastSeen.update({data[0]: time.time()}) - self._clearNodeTimeout() + with open("dagRecord.txt",'a') as f: + f.write("\ntotal nodes number: {0}\n".format(len(self.parents))) + for addr, timestamp in self.parentsLastSeen.iteritems(): + f.write('--addr {0} timestamp {1}\n'.format(''.join(['%02X' % x for x in addr[-2:]]), time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(timestamp)))) + # self._clearNodeTimeout() def _clearNodeTimeout(self): threshold = time.time() - self.NODE_TIMEOUT_THRESHOLD diff --git a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py index 24014ec83..1776ee139 100644 --- a/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py +++ b/software/openvisualizer/openvisualizer/moteProbe/moteProbe.py @@ -251,6 +251,8 @@ def run(self): try: tempBuf = self.inputBuf + with open(socket.gethostname()+'.log','a') as f: + f.write(self.inputBuf) self.inputBuf = self.hdlc.dehdlcify(self.inputBuf) if log.isEnabledFor(logging.DEBUG): log.debug("{0}: {2} dehdlcized input: {1}".format(self.name, u.formatStringBuf(self.inputBuf), u.formatStringBuf(tempBuf))) From 96c7c0f52b1653093634d5d916b05fbdf312931d Mon Sep 17 00:00:00 2001 From: changtengfei Date: Thu, 9 Nov 2017 11:22:09 +0100 Subject: [PATCH 22/25] FW-548. remove bitmap and update component. --- software/openvisualizer/openvisualizer/moteState/moteState.py | 2 -- .../openvisualizer/openvisualizer/openType/typeComponent.py | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteState/moteState.py b/software/openvisualizer/openvisualizer/moteState/moteState.py index 796271b65..2191e0ad0 100644 --- a/software/openvisualizer/openvisualizer/moteState/moteState.py +++ b/software/openvisualizer/openvisualizer/moteState/moteState.py @@ -509,8 +509,6 @@ def __init__(self,moteConnector): 'numTx', 'numTxACK', 'lastUsedAsn', - 'usageBitMap', - 'bitMapIndex', ] ) ) diff --git a/software/openvisualizer/openvisualizer/openType/typeComponent.py b/software/openvisualizer/openvisualizer/openType/typeComponent.py index effebf076..fd256346b 100644 --- a/software/openvisualizer/openvisualizer/openType/typeComponent.py +++ b/software/openvisualizer/openvisualizer/openType/typeComponent.py @@ -64,6 +64,8 @@ class typeComponent(openType.openType): COMPONENT_USERIALBRIDGE = 0x27 COMPONENT_UEXPIRATION = 0x28 COMPONENT_UMONITOR = 0x29 + COMPONENT_CJOIN = 0x2a + COMPONENT_OPENOSCOAP = 0x2b def __init__(self): # log From 01f059a737e673ac3f7140d5d1c9677ac06175ef Mon Sep 17 00:00:00 2001 From: changtengfei Date: Thu, 8 Mar 2018 13:55:52 +0100 Subject: [PATCH 23/25] FW-548. add isBlacklist item in neighbor table. --- .../bin/openVisualizerApp/web_files/templates/moteview.tmpl | 3 ++- .../openvisualizer/moteConnector/ParserStatus.py | 3 ++- software/openvisualizer/openvisualizer/moteState/moteState.py | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl index 3a01554a8..425f2fb87 100644 --- a/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl +++ b/software/openvisualizer/bin/openVisualizerApp/web_files/templates/moteview.tmpl @@ -356,12 +356,13 @@ // Neighbors responsive table if (hasJson) { - var tbl_body = "
UsedInsecuref6PNORESsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASNbackoffExponentbackoff
" + this['used'] + "" + this['numTxACK'] + "" + this['numWraps'] + "" + this['asn'] + "" + this['backoffExponent'] + "" + this['backoff'] + "
"; + var tbl_body = "
UsedInsecuref6PNORESsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASNbackoffExponentbackoff
"; $.each(nbrsJson, function() { var tbl_row = ""; tbl_row += ""; tbl_row += ""; + tbl_row += ""; tbl_row += ""; tbl_row += ""; tbl_row += ""; diff --git a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py index 5b21085f7..a9d2ee378 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py +++ b/software/openvisualizer/openvisualizer/moteConnector/ParserStatus.py @@ -188,7 +188,7 @@ def __init__(self): 3, 9, 'NeighborsRow', - ' Date: Mon, 12 Mar 2018 10:37:21 +0100 Subject: [PATCH 24/25] FW-548. update stackDefines.py (generated by script). --- .../moteConnector/StackDefines.py | 65 +++++++++---------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py index cf192886c..5ca727633 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py +++ b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py @@ -1,6 +1,6 @@ # DO NOT EDIT DIRECTLY! # This file was generated automatically by GenStackDefines.py -# on Thu, 09 Nov 2017 11:16:05 +# on Mon, 12 Mar 2018 10:36:03 # components = { @@ -20,35 +20,35 @@ 13: "NEIGHBORS", 14: "SCHEDULE", 15: "SIXTOP_RES", - 16: "SF", - 17: "OPENBRIDGE", - 18: "IPHC", - 19: "FORWARDING", - 20: "ICMPv6", - 21: "ICMPv6ECHO", - 22: "ICMPv6ROUTER", - 23: "ICMPv6RPL", - 24: "OPENTCP", - 25: "OPENUDP", - 26: "OPENCOAP", - 27: "C6T", - 28: "CEXAMPLE", - 29: "CINFO", - 30: "CLEDS", - 31: "CSENSORS", - 32: "CSTORM", - 33: "CWELLKNOWN", - 34: "TECHO", - 35: "TOHLONE", - 36: "UECHO", - 37: "UINJECT", - 38: "RRT", - 39: "SECURITY", - 40: "USERIALBRIDGE", - 41: "UEXPIRATION", - 42: "UMONITOR", - 43: "CJOIN", - 44: "OPENOSCOAP", + 16: "OPENBRIDGE", + 17: "IPHC", + 18: "FORWARDING", + 19: "ICMPv6", + 20: "ICMPv6ECHO", + 21: "ICMPv6ROUTER", + 22: "ICMPv6RPL", + 23: "OPENTCP", + 24: "OPENUDP", + 25: "OPENCOAP", + 26: "C6T", + 27: "CEXAMPLE", + 28: "CINFO", + 29: "CLEDS", + 30: "CSENSORS", + 31: "CSTORM", + 32: "CWELLKNOWN", + 33: "TECHO", + 34: "TOHLONE", + 35: "UECHO", + 36: "UINJECT", + 37: "RRT", + 38: "SECURITY", + 39: "USERIALBRIDGE", + 40: "UEXPIRATION", + 41: "UMONITOR", + 42: "CJOIN", + 43: "OPENOSCOAP", + 45: "CINFRARED", } errorDescriptions = { @@ -129,8 +129,8 @@ sixtop_returncode = { 0: "RC_SUCCESS", - 1: "RC_ERROR", - 2: "RC_EOL", + 1: "RC_EOL", + 2: "RC_ERROR", 3: "RC_RESET", 4: "RC_VER_ERR", 5: "RC_SFID_ERR", @@ -138,7 +138,6 @@ 7: "RC_CELLLIST_ERR", 8: "RC_BUSY", 9: "RC_LOCKED", - 10: "RC_NORES", } sixtop_statemachine = { From ca71d229de55d95ff42ea2d8c4ec2f6071465ad2 Mon Sep 17 00:00:00 2001 From: changtengfei Date: Mon, 12 Mar 2018 10:56:24 +0100 Subject: [PATCH 25/25] FW-548. update stack status. --- .../moteConnector/StackDefines.py | 43 +++++++++---------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py index 5ca727633..f1695818a 100644 --- a/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py +++ b/software/openvisualizer/openvisualizer/moteConnector/StackDefines.py @@ -1,6 +1,6 @@ # DO NOT EDIT DIRECTLY! # This file was generated automatically by GenStackDefines.py -# on Mon, 12 Mar 2018 10:36:03 +# on Mon, 12 Mar 2018 10:55:53 # components = { @@ -27,28 +27,25 @@ 20: "ICMPv6ECHO", 21: "ICMPv6ROUTER", 22: "ICMPv6RPL", - 23: "OPENTCP", - 24: "OPENUDP", - 25: "OPENCOAP", - 26: "C6T", - 27: "CEXAMPLE", - 28: "CINFO", - 29: "CLEDS", - 30: "CSENSORS", - 31: "CSTORM", - 32: "CWELLKNOWN", - 33: "TECHO", - 34: "TOHLONE", - 35: "UECHO", - 36: "UINJECT", - 37: "RRT", - 38: "SECURITY", - 39: "USERIALBRIDGE", - 40: "UEXPIRATION", - 41: "UMONITOR", - 42: "CJOIN", - 43: "OPENOSCOAP", - 45: "CINFRARED", + 23: "OPENUDP", + 24: "OPENCOAP", + 25: "C6T", + 26: "CEXAMPLE", + 27: "CINFO", + 28: "CLEDS", + 29: "CSENSORS", + 30: "CSTORM", + 31: "CWELLKNOWN", + 32: "UECHO", + 33: "UINJECT", + 34: "RRT", + 35: "SECURITY", + 36: "USERIALBRIDGE", + 37: "UEXPIRATION", + 38: "UMONITOR", + 39: "CJOIN", + 40: "OPENOSCOAP", + 41: "CINFRARED", } errorDescriptions = {
UsedInsecuref6PNORESinBlacklistsixtopSeqNumParentStableStabilityAddressDAG RankJPRSSRXTXTX ACKWrapASNbackoffExponentbackoff
" + this['used'] + "" + this['insecure'] + "" + this['f6PNORES'] + "" + this['inBlacklist'] + "" + this['sixtopSeqNum'] + "" + this['parentPreference'] + "" + this['stableNeighbor'] + "