Skip to content

Commit

Permalink
Merge pull request #174 from openwsn-berkeley/develop_FW-548
Browse files Browse the repository at this point in the history
FW-548. Implementing the MSF algorithm.
  • Loading branch information
changtengfei authored Mar 20, 2018
2 parents 5e0c137 + ca71d22 commit f160414
Show file tree
Hide file tree
Showing 9 changed files with 68 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,13 @@

// Neighbors responsive table
if (hasJson) {
var tbl_body = "<table class=\"table table-striped table-bordered table-hover\" id=\"dataTables-example\"><thead><tr><th>Used</th><th>Insecure</th><th>f6PNORES</th><th>sixtopGEN</th><th>sixtopSeqNum</th><th>Parent</th><th>Stable</th><th>Stability</th><th>Address</th><th>DAG Rank</th><th>JP</th><th>RSS</th><th>RX</th><th>TX</th><th>TX ACK</th><th>Wrap</th><th>ASN</th><th>backoffExponent</th><th>backoff</th></tr></thead><tbody>";
var tbl_body = "<table class=\"table table-striped table-bordered table-hover\" id=\"dataTables-example\"><thead><tr><th>Used</th><th>Insecure</th><th>f6PNORES</th><th>inBlacklist</th><th>sixtopSeqNum</th><th>Parent</th><th>Stable</th><th>Stability</th><th>Address</th><th>DAG Rank</th><th>JP</th><th>RSS</th><th>RX</th><th>TX</th><th>TX ACK</th><th>Wrap</th><th>ASN</th><th>backoffExponent</th><th>backoff</th></tr></thead><tbody>";

$.each(nbrsJson, function() {
var tbl_row = "<td>" + this['used'] + "</td>";
tbl_row += "<td>" + this['insecure'] + "</td>";
tbl_row += "<td>" + this['f6PNORES'] + "</td>";
tbl_row += "<td>" + this['sixtopGEN'] + "</td>";
tbl_row += "<td>" + this['inBlacklist'] + "</td>";
tbl_row += "<td>" + this['sixtopSeqNum'] + "</td>";
tbl_row += "<td>" + this['parentPreference'] + "</td>";
tbl_row += "<td>" + this['stableNeighbor'] + "</td>";
Expand Down
9 changes: 7 additions & 2 deletions software/openvisualizer/openvisualizer/RPL/topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def __init__(self):
'lastUsedAsn_4', # B
'lastUsedAsn_2_3', # H
'lastUsedAsn_0_1', # H

],
)
self._addFieldsParser (
Expand Down Expand Up @@ -209,7 +210,7 @@ def __init__(self):
'asn_0_1', # H
'joinPrio', # B
'f6PNORES', # B
'sixtopGEN', # B
'inBlacklist', # B
'sixtopSeqNum', # B
'backoffExponent', # B
'backoff', # B
Expand Down
Original file line number Diff line number Diff line change
@@ -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 Mon, 12 Mar 2018 10:55:53
#

components = {
Expand All @@ -20,35 +20,32 @@
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: "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 = {
Expand Down Expand Up @@ -129,15 +126,15 @@

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",
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",
}

sixtop_statemachine = {
Expand Down
31 changes: 18 additions & 13 deletions software/openvisualizer/openvisualizer/moteProbe/moteProbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
BAUDRATE_TELOSB = 115200
BAUDRATE_GINA = 115200
BAUDRATE_WSN430 = 115200
BAUDRATE_IOTLAB = 500000

def findSerialPorts():
'''
Expand Down Expand Up @@ -68,25 +69,27 @@ def findSerialPorts():
if platform.system() == 'Darwin':
portMask = ['/dev/tty.usbserial-*']
else:
portMask = ['/dev/ttyUSB*', '/dev/ttyAMA*', '/dev/ttyA8_M3']
portMask = ['/dev/ttyUSB*']
for mask in portMask :
serialports += [(s,BAUDRATE_GINA) for s in glob.glob(mask)]
serialports += [(s,BAUDRATE_IOTLAB) for s in glob.glob(mask)]

# 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(2)
tester.test(blocking=True)
if tester.getStats()['numOk'] >= 1:
mote_ports.append((port[0],baudrate));
probe.close()
probe.join()
# for port in serialports:
# for baudrate in [port[1], BAUDRATE_IOTLAB]:
# probe = moteProbe(serialport=(port[0],baudrate))
# tester = SerialTester(probe.portname)
# tester.setNumTestPkt(1)
# tester.setTimeout(2)
# tester.test(blocking=True)
# if tester.getStats()['numOk'] >= 1:
# mote_ports.append((port[0],baudrate));
# probe.close()
# probe.join()

mote_ports = serialports

# log
log.info("discovered following COM port: {0}".format(['{0}@{1}'.format(s[0],s[1]) for s in mote_ports]))
Expand Down Expand Up @@ -246,6 +249,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)))
Expand Down
4 changes: 2 additions & 2 deletions software/openvisualizer/openvisualizer/moteState/moteState.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ def update(self,notif):
notif.asn_2_3,
notif.asn_4)
self.data[0]['f6PNORES'] = notif.f6PNORES
self.data[0]['sixtopGEN'] = notif.sixtopGEN
self.data[0]['inBlacklist'] = notif.inBlacklist
self.data[0]['sixtopSeqNum'] = notif.sixtopSeqNum
self.data[0]['backoffExponent'] = notif.backoffExponent
self.data[0]['backoff'] = notif.backoff
Expand Down Expand Up @@ -534,7 +534,7 @@ def __init__(self,moteConnector):
'asn',
'joinPrio',
'f6PNORES',
'sixtopGEN',
'inBlacklist',
'sixtopSeqNum',
'backoffExponent',
'backoff',
Expand Down
2 changes: 1 addition & 1 deletion software/openvisualizer/openvisualizer/openLbr/openLbr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1106,4 +1106,4 @@ def _formatWireshark(self,pkt):
# increment index
index += NUM_BYTES_PER_LINE

return '\n'.join(output)
return '\n'.join(output)
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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/ttyUSB*')
return json.dumps([serial for serial in serialList])

0 comments on commit f160414

Please sign in to comment.