From 54b4226f708cb22e6883f6205113229b95310955 Mon Sep 17 00:00:00 2001 From: adamdunkels Date: Sun, 8 Feb 2009 19:34:34 +0000 Subject: [PATCH] Nightly test that runs Contiki's shell collect command in much the same way as the Contiki collect program does --- .../cooja/contiki_tests/sky_shell_collect.csc | 327 ++++++++++++++++++ .../contiki_tests/sky_shell_collect.info | 1 + .../cooja/contiki_tests/sky_shell_collect.js | 183 ++++++++++ 3 files changed, 511 insertions(+) create mode 100644 tools/cooja/contiki_tests/sky_shell_collect.csc create mode 100644 tools/cooja/contiki_tests/sky_shell_collect.info create mode 100644 tools/cooja/contiki_tests/sky_shell_collect.js diff --git a/tools/cooja/contiki_tests/sky_shell_collect.csc b/tools/cooja/contiki_tests/sky_shell_collect.csc new file mode 100644 index 000000000..0f4fb478c --- /dev/null +++ b/tools/cooja/contiki_tests/sky_shell_collect.csc @@ -0,0 +1,327 @@ + + + + My simulation + 0 + 1 + 123456 + 1000 + + se.sics.cooja.radiomediums.UDGM + 50.0 + 100.0 + 1.0 + 1.0 + + + se.sics.cooja.mspmote.SkyMoteType + sky1 + Sky Mote Type #1 + ../../../examples/sky-shell/sky-shell.c + make sky-shell.sky TARGET=sky + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 87.29845932913939 + 60.286214311723164 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 1 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 94.30809966340686 + 22.50388779326399 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 2 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 82.40423567500785 + 39.56979106929553 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 3 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 26.185019854469438 + 4.800834369523899 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 4 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 1.9530156130507015 + 78.3175061800706 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 5 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 48.35216700543414 + 80.36988713780997 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 6 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 24.825985087266833 + 74.27809432062487 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 7 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 8.356165164293616 + 94.33967355724187 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 8 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 45.11740613004886 + 31.7059041432301 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 9 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 68.9908548386292 + 55.01991960639596 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 10 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 13.181122543889046 + 55.9636533130127 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 11 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 2.1749985906538427 + 78.39666095789707 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 12 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 37.79795217518357 + 7.164284163506062 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 13 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 64.4595177394984 + 72.115414337433 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 14 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 81.85663737096085 + 89.31412706434035 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 15 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 44.74952276297882 + 18.78566116347574 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 16 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 96.11333426285873 + 90.64560410751824 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 17 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 21.651464136783527 + 7.1381043251259495 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 18 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 83.6006916200628 + 26.97170140682981 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 19 + + + + se.sics.cooja.mspmote.SkyMote + sky1 + + se.sics.cooja.interfaces.Position + 1.3446070721664705 + 7.340373220385176 + 0.0 + + + se.sics.cooja.mspmote.interfaces.MspMoteID + 20 + + + + + se.sics.cooja.plugins.SimControl + 223 + 3 + 227 + 0 + 0 + false + + + se.sics.cooja.plugins.LogListener + + + 256 + + 690 + 2 + 207 + 0 + 439 + false + + + diff --git a/tools/cooja/contiki_tests/sky_shell_collect.info b/tools/cooja/contiki_tests/sky_shell_collect.info new file mode 100644 index 000000000..ddfda91a8 --- /dev/null +++ b/tools/cooja/contiki_tests/sky_shell_collect.info @@ -0,0 +1 @@ +Sky shell collect test diff --git a/tools/cooja/contiki_tests/sky_shell_collect.js b/tools/cooja/contiki_tests/sky_shell_collect.js new file mode 100644 index 000000000..f0cd8bf59 --- /dev/null +++ b/tools/cooja/contiki_tests/sky_shell_collect.js @@ -0,0 +1,183 @@ +TIMEOUT(300000, log.log("Timeout\n")); + +function +print_stats() +{ + log.log("Received " + total_received + " messages, " + + (total_received / nrNodes) + " messages/node, " + + total_lost + " lost, " + + (total_lost / nrNodes) + " lost/node, " + + total_dups + " dups, " + + (total_dups / nrNodes) + " dups/node, " + + (total_hops / total_received) + " hops/message\n"); + log.log("Seqnos: "); + for(i = 1; i <= nrNodes; i++) { + log.log(seqnos[i] + " "); + } + log.log("\n"); + log.log("Lost: "); + for(i = 1; i <= nrNodes; i++) { + log.log(lost[i] + " "); + } + log.log("\n"); + log.log("Dups: "); + for(i = 1; i <= nrNodes; i++) { + log.log(dups[i] + " "); + } + log.log("\n"); + log.log("Hops: "); + for(i = 1; i <= nrNodes; i++) { + log.log(hops[i] + " "); + } + log.log("\n"); + log.log("Received: "); + for(i = 1; i <= nrNodes; i++) { + log.log(count[i] + " "); + } + log.log("\n"); + log.log("Stats: cpu " + 100 * total_cpu / (total_cpu + total_lpm) + + "% lpm " + 100 * total_lpm / (total_cpu + total_lpm) + + "% rx " + 100 * total_listen / (total_cpu + total_lpm) + + "% tx " + 100 * total_transmit / (total_cpu + total_lpm) + + "% average latency " + total_latency / (4096 * total_received) + + " ms \n"); + +} + +/* Conf. */ +booted = new Array(); +count = new Array(); +hops = new Array(); +seqnos = new Array(); +lost = new Array(); +dups = new Array(); +nrNodes = 20; +total_received = 0; +total_lost = 0; +total_hops = 0; +total_dups = 0; + +total_cpu = total_lpm = total_listen = total_transmit = 0; + +total_latency = 0; + +nodes_starting = true; +for(i = 1; i <= nrNodes; i++) { + booted[i] = false; + count[i] = 0; + hops[i] = 0; + seqnos[i] = -1; + lost[i] = 0; + dups[i] = 0; +} + +/* Wait until all nodes have started */ +while(nodes_starting) { + YIELD_THEN_WAIT_UNTIL(msg.startsWith('Starting')); + + log.log("Node " + id + " booted\n"); + booted[id] = true; + + for(i = 1; i <= nrNodes; i++) { + if(!booted[i]) { + break; + } + if(i == nrNodes) { + nodes_starting = false; + } + } +} + +/* Create sink */ +log.log("All nodes booted, creating sink at node " + id + "\n"); +sink = id; + +/* Wait for prompt */ +YIELD_THEN_WAIT_UNTIL(id == sink); +/*mote.getInterfaces().getButton().clickButton()*/ +log.log("Writing netcmd\n"); +node.write("netcmd { repeat 0 20 { randwait 20 sky-alldata | blink | send } }"); +YIELD_THEN_WAIT_UNTIL(id == sink); +log.log("Writing collect command\n"); +node.write("collect | timestamp | blink | binprint &"); + +while(true) { + YIELD(); + + /* Count sensor data packets */ + data = msg.split(" "); + log.log("Data 24 " + data[24]); + if(data[24]) { + + len = parseInt(data[0]); + timestamp1 = parseInt(data[1]); + timestamp2 = parseInt(data[2]); + timesynched_timestamp = parseInt(data[3]); + node_id = parseInt(data[4]); + seqno = parseInt(data[5]); + hop = parseInt(data[6]); + latency = parseInt(data[7]); + data_len2 = parseInt(data[8]); + clock = parseInt(data[9]); + timesyncedtime = parseInt(data[10]); + light1 = parseInt(data[11]); + light2 = parseInt(data[12]); + temperature = parseInt(data[13]); + humidity = parseInt(data[14]); + rssi = parseInt(data[15]); + time_cpu = parseInt(data[16]); + time_lpm = parseInt(data[17]); + time_transmit = parseInt(data[18]); + time_listen = parseInt(data[19]); + best_neighbor = parseInt(data[20]); + best_neighbor_etx = parseInt(data[21]); + best_neighbor_rtmetrix = parseInt(data[22]); + battery_voltage = parseInt(data[23]); + battery_indicator = parseInt(data[24]); + + total_cpu += time_cpu; + total_lpm += time_lpm; + total_transmit += time_transmit; + total_listen += time_listen; + + total_latency += latency; + + source = node_id; + count[source]++; + hops[source] = hop; + seqno_gap = seqno - seqnos[source]; + seqnos[source] = seqno; + + total_received++; + total_hops += hop; + + if(seqno_gap == 2) { + total_lost += seqno_gap - 1; + lost[source] += seqno_gap - 1; + } else if(seqno_gap == 0) { + total_dups += 1; + dups[source] += 1; + } + } + /* Fail if the sink has received more than 10 messages from any node. */ + for(i = 1; i <= nrNodes; i++) { + if(i != sink && count[i] > 10) { + print_stats(); + log.testFailed(); /* We are done! */ + } + } + + /* Wait until the sink have received at least two messages from + every node, except the sink, which doesn't send packets. */ + for(i = 1; i <= nrNodes; i++) { + if(i != sink) { + if(count[i] < 2) { + break; + } + if(i == nrNodes) { + print_stats(); + log.testOK(); + } + } + } +}