Removed Deluge and associated test files.
This commit is contained in:
parent
7586195b79
commit
fb5f0f66dd
12 changed files with 540 additions and 1668 deletions
|
@ -1 +0,0 @@
|
|||
deluge_src = deluge.c
|
|
@ -1,698 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* An implementation of the Deluge protocol.
|
||||
* (Hui and Culler: The dynamic behavior of a data
|
||||
* dissemination protocol for network programming at scale,
|
||||
* ACM SenSys 2004)
|
||||
* \author
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "net/rime/rime.h"
|
||||
#include "cfs/cfs.h"
|
||||
#include "loader/elfloader.h"
|
||||
#include "lib/crc16.h"
|
||||
#include "lib/random.h"
|
||||
#include "sys/node-id.h"
|
||||
#include "deluge.h"
|
||||
|
||||
#if NETSIM
|
||||
#include "ether.h"
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
|
||||
#include "dev/leds.h"
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define DEBUG 0
|
||||
#if DEBUG
|
||||
#include <stdio.h>
|
||||
#define PRINTF(...) printf(__VA_ARGS__)
|
||||
#else
|
||||
#define PRINTF(...)
|
||||
#endif
|
||||
|
||||
/* Implementation-specific variables. */
|
||||
static struct broadcast_conn deluge_broadcast;
|
||||
static struct unicast_conn deluge_uc;
|
||||
static struct deluge_object current_object;
|
||||
static process_event_t deluge_event;
|
||||
|
||||
/* Deluge variables. */
|
||||
static int deluge_state;
|
||||
static int old_summary;
|
||||
static int neighbor_inconsistency;
|
||||
static unsigned r_interval;
|
||||
static unsigned recv_adv;
|
||||
static int broadcast_profile;
|
||||
|
||||
/* Deluge timers. */
|
||||
static struct ctimer rx_timer;
|
||||
static struct ctimer tx_timer;
|
||||
static struct ctimer summary_timer;
|
||||
static struct ctimer profile_timer;
|
||||
|
||||
/* Deluge objects will get an ID that defaults to the current value of
|
||||
the next_object_id parameter. */
|
||||
static deluge_object_id_t next_object_id;
|
||||
|
||||
/* Rime callbacks. */
|
||||
static void broadcast_recv(struct broadcast_conn *, const linkaddr_t *);
|
||||
static void unicast_recv(struct unicast_conn *, const linkaddr_t *);
|
||||
|
||||
static const struct broadcast_callbacks broadcast_call = {broadcast_recv, NULL};
|
||||
static const struct unicast_callbacks unicast_call = {unicast_recv, NULL};
|
||||
|
||||
/* The Deluge process manages the main Deluge timer. */
|
||||
PROCESS(deluge_process, "Deluge");
|
||||
|
||||
static void
|
||||
transition(int state)
|
||||
{
|
||||
if(state != deluge_state) {
|
||||
switch(deluge_state) {
|
||||
case DELUGE_STATE_MAINTAIN:
|
||||
ctimer_stop(&summary_timer);
|
||||
ctimer_stop(&profile_timer);
|
||||
break;
|
||||
case DELUGE_STATE_RX:
|
||||
ctimer_stop(&rx_timer);
|
||||
break;
|
||||
case DELUGE_STATE_TX:
|
||||
ctimer_stop(&tx_timer);
|
||||
break;
|
||||
}
|
||||
deluge_state = state;
|
||||
}
|
||||
}
|
||||
|
||||
static int
|
||||
write_page(struct deluge_object *obj, unsigned pagenum, unsigned char *data)
|
||||
{
|
||||
cfs_offset_t offset;
|
||||
|
||||
offset = pagenum * S_PAGE;
|
||||
|
||||
if(cfs_seek(obj->cfs_fd, offset, CFS_SEEK_SET) != offset) {
|
||||
return -1;
|
||||
}
|
||||
return cfs_write(obj->cfs_fd, (char *)data, S_PAGE);
|
||||
}
|
||||
|
||||
static int
|
||||
read_page(struct deluge_object *obj, unsigned pagenum, unsigned char *buf)
|
||||
{
|
||||
cfs_offset_t offset;
|
||||
|
||||
offset = pagenum * S_PAGE;
|
||||
|
||||
if(cfs_seek(obj->cfs_fd, offset, CFS_SEEK_SET) != offset) {
|
||||
return -1;
|
||||
}
|
||||
return cfs_read(obj->cfs_fd, (char *)buf, S_PAGE);
|
||||
}
|
||||
|
||||
static void
|
||||
init_page(struct deluge_object *obj, int pagenum, int have)
|
||||
{
|
||||
struct deluge_page *page;
|
||||
unsigned char buf[S_PAGE];
|
||||
|
||||
page = &obj->pages[pagenum];
|
||||
|
||||
page->flags = 0;
|
||||
page->last_request = 0;
|
||||
page->last_data = 0;
|
||||
|
||||
if(have) {
|
||||
page->version = obj->version;
|
||||
page->packet_set = ALL_PACKETS;
|
||||
page->flags |= PAGE_COMPLETE;
|
||||
read_page(obj, pagenum, buf);
|
||||
page->crc = crc16_data(buf, S_PAGE, 0);
|
||||
} else {
|
||||
page->version = 0;
|
||||
page->packet_set = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static cfs_offset_t
|
||||
file_size(const char *file)
|
||||
{
|
||||
int fd;
|
||||
cfs_offset_t size;
|
||||
|
||||
fd = cfs_open(file, CFS_READ);
|
||||
if(fd < 0) {
|
||||
return (cfs_offset_t)-1;
|
||||
}
|
||||
|
||||
size = cfs_seek(fd, 0, CFS_SEEK_END);
|
||||
cfs_close(fd);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
init_object(struct deluge_object *obj, char *filename, unsigned version)
|
||||
{
|
||||
static struct deluge_page *page;
|
||||
int i;
|
||||
|
||||
obj->cfs_fd = cfs_open(filename, CFS_READ | CFS_WRITE);
|
||||
if(obj->cfs_fd < 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
obj->filename = filename;
|
||||
obj->object_id = next_object_id++;
|
||||
obj->size = file_size(filename);
|
||||
obj->version = obj->update_version = version;
|
||||
obj->current_rx_page = 0;
|
||||
obj->nrequests = 0;
|
||||
obj->tx_set = 0;
|
||||
|
||||
obj->pages = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof(*obj->pages));
|
||||
if(obj->pages == NULL) {
|
||||
cfs_close(obj->cfs_fd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
for(i = 0; i < OBJECT_PAGE_COUNT(current_object); i++) {
|
||||
page = ¤t_object.pages[i];
|
||||
init_page(¤t_object, i, 1);
|
||||
}
|
||||
|
||||
memset(obj->current_page, 0, sizeof(obj->current_page));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
highest_available_page(struct deluge_object *obj)
|
||||
{
|
||||
int i;
|
||||
|
||||
for(i = 0; i < OBJECT_PAGE_COUNT(*obj); i++) {
|
||||
if(!(obj->pages[i].flags & PAGE_COMPLETE)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
static void
|
||||
send_request(void *arg)
|
||||
{
|
||||
struct deluge_object *obj;
|
||||
struct deluge_msg_request request;
|
||||
|
||||
obj = (struct deluge_object *)arg;
|
||||
|
||||
request.cmd = DELUGE_CMD_REQUEST;
|
||||
request.pagenum = obj->current_rx_page;
|
||||
request.version = obj->pages[request.pagenum].version;
|
||||
request.request_set = ~obj->pages[obj->current_rx_page].packet_set;
|
||||
request.object_id = obj->object_id;
|
||||
|
||||
PRINTF("Sending request for page %d, version %u, request_set %u\n",
|
||||
request.pagenum, request.version, request.request_set);
|
||||
packetbuf_copyfrom(&request, sizeof(request));
|
||||
unicast_send(&deluge_uc, &obj->summary_from);
|
||||
|
||||
/* Deluge R.2 */
|
||||
if(++obj->nrequests == CONST_LAMBDA) {
|
||||
/* XXX check rate here too. */
|
||||
obj->nrequests = 0;
|
||||
transition(DELUGE_STATE_MAINTAIN);
|
||||
} else {
|
||||
ctimer_reset(&rx_timer);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
advertise_summary(struct deluge_object *obj)
|
||||
{
|
||||
struct deluge_msg_summary summary;
|
||||
|
||||
if(recv_adv >= CONST_K) {
|
||||
ctimer_stop(&summary_timer);
|
||||
return;
|
||||
}
|
||||
|
||||
summary.cmd = DELUGE_CMD_SUMMARY;
|
||||
summary.version = obj->update_version;
|
||||
summary.highest_available = highest_available_page(obj);
|
||||
summary.object_id = obj->object_id;
|
||||
|
||||
PRINTF("Advertising summary for object id %u: version=%u, available=%u\n",
|
||||
(unsigned)obj->object_id, summary.version, summary.highest_available);
|
||||
|
||||
packetbuf_copyfrom(&summary, sizeof(summary));
|
||||
broadcast_send(&deluge_broadcast);
|
||||
}
|
||||
|
||||
static void
|
||||
handle_summary(struct deluge_msg_summary *msg, const linkaddr_t *sender)
|
||||
{
|
||||
int highest_available, i;
|
||||
clock_time_t oldest_request, oldest_data, now;
|
||||
struct deluge_page *page;
|
||||
|
||||
highest_available = highest_available_page(¤t_object);
|
||||
|
||||
if(msg->version != current_object.version ||
|
||||
msg->highest_available != highest_available) {
|
||||
neighbor_inconsistency = 1;
|
||||
} else {
|
||||
recv_adv++;
|
||||
}
|
||||
|
||||
if(msg->version < current_object.version) {
|
||||
old_summary = 1;
|
||||
broadcast_profile = 1;
|
||||
}
|
||||
|
||||
/* Deluge M.5 */
|
||||
if(msg->version == current_object.update_version &&
|
||||
msg->highest_available > highest_available) {
|
||||
if(msg->highest_available > OBJECT_PAGE_COUNT(current_object)) {
|
||||
PRINTF("Error: highest available is above object page count!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
oldest_request = oldest_data = now = clock_time();
|
||||
for(i = 0; i < msg->highest_available; i++) {
|
||||
page = ¤t_object.pages[i];
|
||||
if(page->last_request < oldest_request) {
|
||||
oldest_request = page->last_request;
|
||||
}
|
||||
if(page->last_request < oldest_data) {
|
||||
oldest_data = page->last_data;
|
||||
}
|
||||
}
|
||||
|
||||
if(((now - oldest_request) / CLOCK_SECOND) <= 2 * r_interval ||
|
||||
((now - oldest_data) / CLOCK_SECOND) <= r_interval) {
|
||||
return;
|
||||
}
|
||||
|
||||
linkaddr_copy(¤t_object.summary_from, sender);
|
||||
transition(DELUGE_STATE_RX);
|
||||
|
||||
if(ctimer_expired(&rx_timer)) {
|
||||
ctimer_set(&rx_timer,
|
||||
CONST_OMEGA * ESTIMATED_TX_TIME + ((unsigned)random_rand() % T_R),
|
||||
send_request, ¤t_object);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_page(struct deluge_object *obj, unsigned pagenum)
|
||||
{
|
||||
unsigned char buf[S_PAGE];
|
||||
struct deluge_msg_packet pkt;
|
||||
unsigned char *cp;
|
||||
|
||||
pkt.cmd = DELUGE_CMD_PACKET;
|
||||
pkt.pagenum = pagenum;
|
||||
pkt.version = obj->pages[pagenum].version;
|
||||
pkt.packetnum = 0;
|
||||
pkt.object_id = obj->object_id;
|
||||
pkt.crc = 0;
|
||||
|
||||
read_page(obj, pagenum, buf);
|
||||
|
||||
/* Divide the page into packets and send them one at a time. */
|
||||
for(cp = buf; cp + S_PKT <= (unsigned char *)&buf[S_PAGE]; cp += S_PKT) {
|
||||
if(obj->tx_set & (1 << pkt.packetnum)) {
|
||||
pkt.crc = crc16_data(cp, S_PKT, 0);
|
||||
memcpy(pkt.payload, cp, S_PKT);
|
||||
packetbuf_copyfrom(&pkt, sizeof(pkt));
|
||||
broadcast_send(&deluge_broadcast);
|
||||
}
|
||||
pkt.packetnum++;
|
||||
}
|
||||
obj->tx_set = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
tx_callback(void *arg)
|
||||
{
|
||||
struct deluge_object *obj;
|
||||
|
||||
obj = (struct deluge_object *)arg;
|
||||
if(obj->current_tx_page >= 0 && obj->tx_set) {
|
||||
send_page(obj, obj->current_tx_page);
|
||||
/* Deluge T.2. */
|
||||
if(obj->tx_set) {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||
PACKETBUF_ATTR_PACKET_TYPE_STREAM);
|
||||
ctimer_reset(&tx_timer);
|
||||
} else {
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||
PACKETBUF_ATTR_PACKET_TYPE_STREAM_END);
|
||||
obj->current_tx_page = -1;
|
||||
transition(DELUGE_STATE_MAINTAIN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_request(struct deluge_msg_request *msg)
|
||||
{
|
||||
int highest_available;
|
||||
|
||||
if(msg->pagenum >= OBJECT_PAGE_COUNT(current_object)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(msg->version != current_object.version) {
|
||||
neighbor_inconsistency = 1;
|
||||
}
|
||||
|
||||
highest_available = highest_available_page(¤t_object);
|
||||
|
||||
/* Deluge M.6 */
|
||||
if(msg->version == current_object.version &&
|
||||
msg->pagenum <= highest_available) {
|
||||
current_object.pages[msg->pagenum].last_request = clock_time();
|
||||
|
||||
/* Deluge T.1 */
|
||||
if(msg->pagenum == current_object.current_tx_page) {
|
||||
current_object.tx_set |= msg->request_set;
|
||||
} else {
|
||||
current_object.current_tx_page = msg->pagenum;
|
||||
current_object.tx_set = msg->request_set;
|
||||
}
|
||||
|
||||
transition(DELUGE_STATE_TX);
|
||||
ctimer_set(&tx_timer, CLOCK_SECOND, tx_callback, ¤t_object);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_packet(struct deluge_msg_packet *msg)
|
||||
{
|
||||
struct deluge_page *page;
|
||||
uint16_t crc;
|
||||
struct deluge_msg_packet packet;
|
||||
|
||||
memcpy(&packet, msg, sizeof(packet));
|
||||
|
||||
PRINTF("Incoming packet for object id %u, version %u, page %u, packet num %u!\n",
|
||||
(unsigned)packet.object_id, (unsigned)packet.version,
|
||||
(unsigned)packet.pagenum, (unsigned)packet.packetnum);
|
||||
|
||||
if(packet.pagenum != current_object.current_rx_page) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(packet.version != current_object.version) {
|
||||
neighbor_inconsistency = 1;
|
||||
}
|
||||
|
||||
page = ¤t_object.pages[packet.pagenum];
|
||||
if(packet.version == page->version && !(page->flags & PAGE_COMPLETE)) {
|
||||
memcpy(¤t_object.current_page[S_PKT * packet.packetnum],
|
||||
packet.payload, S_PKT);
|
||||
|
||||
crc = crc16_data(packet.payload, S_PKT, 0);
|
||||
if(packet.crc != crc) {
|
||||
PRINTF("packet crc: %hu, calculated crc: %hu\n", packet.crc, crc);
|
||||
return;
|
||||
}
|
||||
|
||||
page->last_data = clock_time();
|
||||
page->packet_set |= (1 << packet.packetnum);
|
||||
|
||||
if(page->packet_set == ALL_PACKETS) {
|
||||
/* This is the last packet of the requested page; stop streaming. */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||
PACKETBUF_ATTR_PACKET_TYPE_STREAM_END);
|
||||
|
||||
write_page(¤t_object, packet.pagenum, current_object.current_page);
|
||||
page->version = packet.version;
|
||||
page->flags = PAGE_COMPLETE;
|
||||
PRINTF("Page %u completed\n", packet.pagenum);
|
||||
|
||||
current_object.current_rx_page++;
|
||||
|
||||
if(packet.pagenum == OBJECT_PAGE_COUNT(current_object) - 1) {
|
||||
current_object.version = current_object.update_version;
|
||||
leds_on(LEDS_RED);
|
||||
PRINTF("Update completed for object %u, version %u\n",
|
||||
(unsigned)current_object.object_id, packet.version);
|
||||
} else if(current_object.current_rx_page < OBJECT_PAGE_COUNT(current_object)) {
|
||||
if(ctimer_expired(&rx_timer)) {
|
||||
ctimer_set(&rx_timer,
|
||||
CONST_OMEGA * ESTIMATED_TX_TIME + (random_rand() % T_R),
|
||||
send_request, ¤t_object);
|
||||
}
|
||||
}
|
||||
/* Deluge R.3 */
|
||||
transition(DELUGE_STATE_MAINTAIN);
|
||||
} else {
|
||||
/* More packets to come. Put lower layers in streaming mode. */
|
||||
packetbuf_set_attr(PACKETBUF_ATTR_PACKET_TYPE,
|
||||
PACKETBUF_ATTR_PACKET_TYPE_STREAM);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
send_profile(struct deluge_object *obj)
|
||||
{
|
||||
struct deluge_msg_profile *msg;
|
||||
unsigned char buf[sizeof(*msg) + OBJECT_PAGE_COUNT(*obj)];
|
||||
int i;
|
||||
|
||||
if(broadcast_profile && recv_adv < CONST_K) {
|
||||
broadcast_profile = 0;
|
||||
|
||||
msg = (struct deluge_msg_profile *)buf;
|
||||
msg->cmd = DELUGE_CMD_PROFILE;
|
||||
msg->version = obj->version;
|
||||
msg->npages = OBJECT_PAGE_COUNT(*obj);
|
||||
msg->object_id = obj->object_id;
|
||||
for(i = 0; i < msg->npages; i++) {
|
||||
msg->version_vector[i] = obj->pages[i].version;
|
||||
}
|
||||
|
||||
packetbuf_copyfrom(buf, sizeof(buf));
|
||||
broadcast_send(&deluge_broadcast);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_profile(struct deluge_msg_profile *msg)
|
||||
{
|
||||
int i;
|
||||
int npages;
|
||||
struct deluge_object *obj;
|
||||
char *p;
|
||||
|
||||
obj = ¤t_object;
|
||||
if(msg->version <= current_object.update_version) {
|
||||
return;
|
||||
}
|
||||
|
||||
PRINTF("Received profile of version %u with a vector of %u pages.\n",
|
||||
msg->version, msg->npages);
|
||||
|
||||
leds_off(LEDS_RED);
|
||||
current_object.tx_set = 0;
|
||||
|
||||
npages = OBJECT_PAGE_COUNT(*obj);
|
||||
obj->size = msg->npages * S_PAGE;
|
||||
|
||||
p = malloc(OBJECT_PAGE_COUNT(*obj) * sizeof(*obj->pages));
|
||||
if(p == NULL) {
|
||||
PRINTF("Failed to reallocate memory for pages!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(p, obj->pages, npages * sizeof(*obj->pages));
|
||||
free(obj->pages);
|
||||
obj->pages = (struct deluge_page *)p;
|
||||
|
||||
if(msg->npages < npages) {
|
||||
npages = msg->npages;
|
||||
}
|
||||
|
||||
for(i = 0; i < npages; i++) {
|
||||
if(msg->version_vector[i] > obj->pages[i].version) {
|
||||
obj->pages[i].packet_set = 0;
|
||||
obj->pages[i].flags &= ~PAGE_COMPLETE;
|
||||
obj->pages[i].version = msg->version_vector[i];
|
||||
}
|
||||
}
|
||||
|
||||
for(; i < msg->npages; i++) {
|
||||
init_page(obj, i, 0);
|
||||
}
|
||||
|
||||
obj->current_rx_page = highest_available_page(obj);
|
||||
obj->update_version = msg->version;
|
||||
|
||||
transition(DELUGE_STATE_RX);
|
||||
|
||||
ctimer_set(&rx_timer,
|
||||
CONST_OMEGA * ESTIMATED_TX_TIME + ((unsigned)random_rand() % T_R),
|
||||
send_request, obj);
|
||||
}
|
||||
|
||||
static void
|
||||
command_dispatcher(const linkaddr_t *sender)
|
||||
{
|
||||
char *msg;
|
||||
int len;
|
||||
struct deluge_msg_profile *profile;
|
||||
|
||||
msg = packetbuf_dataptr();
|
||||
len = packetbuf_datalen();
|
||||
if(len < 1)
|
||||
return;
|
||||
|
||||
switch(msg[0]) {
|
||||
case DELUGE_CMD_SUMMARY:
|
||||
if(len >= sizeof(struct deluge_msg_summary))
|
||||
handle_summary((struct deluge_msg_summary *)msg, sender);
|
||||
break;
|
||||
case DELUGE_CMD_REQUEST:
|
||||
if(len >= sizeof(struct deluge_msg_request))
|
||||
handle_request((struct deluge_msg_request *)msg);
|
||||
break;
|
||||
case DELUGE_CMD_PACKET:
|
||||
if(len >= sizeof(struct deluge_msg_packet))
|
||||
handle_packet((struct deluge_msg_packet *)msg);
|
||||
break;
|
||||
case DELUGE_CMD_PROFILE:
|
||||
profile = (struct deluge_msg_profile *)msg;
|
||||
if(len >= sizeof(*profile) &&
|
||||
len >= sizeof(*profile) + profile->npages * profile->version_vector[0])
|
||||
handle_profile((struct deluge_msg_profile *)msg);
|
||||
break;
|
||||
default:
|
||||
PRINTF("Incoming packet with unknown command: %d\n", msg[0]);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
unicast_recv(struct unicast_conn *c, const linkaddr_t *sender)
|
||||
{
|
||||
command_dispatcher(sender);
|
||||
}
|
||||
|
||||
static void
|
||||
broadcast_recv(struct broadcast_conn *c, const linkaddr_t *sender)
|
||||
{
|
||||
command_dispatcher(sender);
|
||||
}
|
||||
|
||||
int
|
||||
deluge_disseminate(char *file, unsigned version)
|
||||
{
|
||||
/* This implementation disseminates at most one object. */
|
||||
if(next_object_id > 0 || init_object(¤t_object, file, version) < 0) {
|
||||
return -1;
|
||||
}
|
||||
process_start(&deluge_process, (void *)file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
PROCESS_THREAD(deluge_process, ev, data)
|
||||
{
|
||||
static struct etimer et;
|
||||
static unsigned time_counter;
|
||||
static unsigned r_rand;
|
||||
|
||||
PROCESS_EXITHANDLER(goto exit);
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
deluge_event = process_alloc_event();
|
||||
|
||||
broadcast_open(&deluge_broadcast, DELUGE_BROADCAST_CHANNEL, &broadcast_call);
|
||||
unicast_open(&deluge_uc, DELUGE_UNICAST_CHANNEL, &unicast_call);
|
||||
r_interval = T_LOW;
|
||||
|
||||
PRINTF("Maintaining state for object %s of %d pages\n",
|
||||
current_object.filename, OBJECT_PAGE_COUNT(current_object));
|
||||
|
||||
deluge_state = DELUGE_STATE_MAINTAIN;
|
||||
|
||||
for(r_interval = T_LOW;;) {
|
||||
if(neighbor_inconsistency) {
|
||||
/* Deluge M.2 */
|
||||
r_interval = T_LOW;
|
||||
neighbor_inconsistency = 0;
|
||||
} else {
|
||||
/* Deluge M.3 */
|
||||
r_interval = (2 * r_interval >= T_HIGH) ? T_HIGH : 2 * r_interval;
|
||||
}
|
||||
|
||||
r_rand = r_interval / 2 + ((unsigned)random_rand() % (r_interval / 2));
|
||||
recv_adv = 0;
|
||||
old_summary = 0;
|
||||
|
||||
/* Deluge M.1 */
|
||||
ctimer_set(&summary_timer, r_rand * CLOCK_SECOND,
|
||||
(void *)(void *)advertise_summary, ¤t_object);
|
||||
|
||||
/* Deluge M.4 */
|
||||
ctimer_set(&profile_timer, r_rand * CLOCK_SECOND,
|
||||
(void *)(void *)send_profile, ¤t_object);
|
||||
|
||||
LONG_TIMER(et, time_counter, r_interval);
|
||||
}
|
||||
|
||||
exit:
|
||||
unicast_close(&deluge_uc);
|
||||
broadcast_close(&deluge_broadcast);
|
||||
if(current_object.cfs_fd >= 0) {
|
||||
cfs_close(current_object.cfs_fd);
|
||||
}
|
||||
if(current_object.pages != NULL) {
|
||||
free(current_object.pages);
|
||||
}
|
||||
|
||||
PROCESS_END();
|
||||
}
|
|
@ -1,159 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of Computer Science
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* Header for Deluge.
|
||||
* \author
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
#ifndef DELUGE_H
|
||||
#define DELUGE_H
|
||||
|
||||
#include "net/rime/rime.h"
|
||||
|
||||
PROCESS_NAME(deluge_process);
|
||||
|
||||
#define LONG_TIMER(et, counter, time) \
|
||||
do { \
|
||||
for (counter = 0; counter < time; counter++) { \
|
||||
etimer_set(&et, CLOCK_SECOND); \
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define DELUGE_UNICAST_CHANNEL 55
|
||||
#define DELUGE_BROADCAST_CHANNEL 56
|
||||
|
||||
/* All the packets in a page have been received. */
|
||||
#define PAGE_COMPLETE 1
|
||||
/* All pages up to, and including, this page are complete. */
|
||||
#define PAGE_AVAILABLE 1
|
||||
|
||||
#define S_PKT 64 /* Deluge packet size. */
|
||||
#define N_PKT 4 /* Packets per page. */
|
||||
#define S_PAGE (S_PKT * N_PKT) /* Fixed page size. */
|
||||
|
||||
/* Bounds for the round time in seconds. */
|
||||
#define T_LOW 2
|
||||
#define T_HIGH 64
|
||||
|
||||
/* Random interval for request transmissions in jiffies. */
|
||||
#define T_R (CLOCK_SECOND * 2)
|
||||
|
||||
/* Bound for the number of advertisements. */
|
||||
#define CONST_K 1
|
||||
|
||||
/* The number of pages in this object. */
|
||||
#define OBJECT_PAGE_COUNT(obj) (((obj).size + (S_PAGE - 1)) / S_PAGE)
|
||||
|
||||
#define ALL_PACKETS ((1 << N_PKT) - 1)
|
||||
|
||||
#define DELUGE_CMD_SUMMARY 1
|
||||
#define DELUGE_CMD_REQUEST 2
|
||||
#define DELUGE_CMD_PACKET 3
|
||||
#define DELUGE_CMD_PROFILE 4
|
||||
|
||||
#define DELUGE_STATE_MAINTAIN 1
|
||||
#define DELUGE_STATE_RX 2
|
||||
#define DELUGE_STATE_TX 3
|
||||
|
||||
#define CONST_LAMBDA 2
|
||||
#define CONST_ALPHA 0.5
|
||||
|
||||
#define CONST_OMEGA 8
|
||||
#define ESTIMATED_TX_TIME (CLOCK_SECOND)
|
||||
|
||||
typedef uint8_t deluge_object_id_t;
|
||||
|
||||
struct deluge_msg_summary {
|
||||
uint8_t cmd;
|
||||
uint8_t version;
|
||||
uint8_t highest_available;
|
||||
deluge_object_id_t object_id;
|
||||
};
|
||||
|
||||
struct deluge_msg_request {
|
||||
uint8_t cmd;
|
||||
uint8_t version;
|
||||
uint8_t pagenum;
|
||||
uint8_t request_set;
|
||||
deluge_object_id_t object_id;
|
||||
};
|
||||
|
||||
struct deluge_msg_packet {
|
||||
uint8_t cmd;
|
||||
uint8_t version;
|
||||
uint8_t pagenum;
|
||||
uint8_t packetnum;
|
||||
uint16_t crc;
|
||||
deluge_object_id_t object_id;
|
||||
unsigned char payload[S_PKT];
|
||||
};
|
||||
|
||||
struct deluge_msg_profile {
|
||||
uint8_t cmd;
|
||||
uint8_t version;
|
||||
uint8_t npages;
|
||||
deluge_object_id_t object_id;
|
||||
uint8_t version_vector[];
|
||||
};
|
||||
|
||||
struct deluge_object {
|
||||
char *filename;
|
||||
uint16_t object_id;
|
||||
uint16_t size;
|
||||
uint8_t version;
|
||||
uint8_t update_version;
|
||||
struct deluge_page *pages;
|
||||
uint8_t current_rx_page;
|
||||
int8_t current_tx_page;
|
||||
uint8_t nrequests;
|
||||
uint8_t current_page[S_PAGE];
|
||||
uint8_t tx_set;
|
||||
int cfs_fd;
|
||||
linkaddr_t summary_from;
|
||||
};
|
||||
|
||||
struct deluge_page {
|
||||
uint32_t packet_set;
|
||||
uint16_t crc;
|
||||
clock_time_t last_request;
|
||||
clock_time_t last_data;
|
||||
uint8_t flags;
|
||||
uint8_t version;
|
||||
};
|
||||
|
||||
int deluge_disseminate(char *file, unsigned version);
|
||||
|
||||
#endif
|
|
@ -1,115 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2007, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
* A test program for Deluge.
|
||||
* \author
|
||||
* Nicolas Tsiftes <nvt@sics.se>
|
||||
*/
|
||||
|
||||
#include "contiki.h"
|
||||
#include "cfs/cfs.h"
|
||||
#include "deluge.h"
|
||||
#include "sys/node-id.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef SINK_ID
|
||||
#define SINK_ID 1
|
||||
#endif
|
||||
|
||||
#ifndef FILE_SIZE
|
||||
#define FILE_SIZE 1000
|
||||
#endif
|
||||
|
||||
PROCESS(deluge_test_process, "Deluge test process");
|
||||
AUTOSTART_PROCESSES(&deluge_test_process);
|
||||
/*---------------------------------------------------------------------------*/
|
||||
PROCESS_THREAD(deluge_test_process, ev, data)
|
||||
{
|
||||
int fd, r;
|
||||
char buf[32];
|
||||
static struct etimer et;
|
||||
|
||||
PROCESS_BEGIN();
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
if(node_id == SINK_ID) {
|
||||
strcpy(buf, "This is version 1 of the file");
|
||||
} else {
|
||||
strcpy(buf, "This is version 0 of the file");
|
||||
}
|
||||
|
||||
cfs_remove("test");
|
||||
fd = cfs_open("test", CFS_WRITE);
|
||||
if(fd < 0) {
|
||||
process_exit(NULL);
|
||||
}
|
||||
if(cfs_write(fd, buf, sizeof(buf)) != sizeof(buf)) {
|
||||
cfs_close(fd);
|
||||
process_exit(NULL);
|
||||
}
|
||||
|
||||
if(cfs_seek(fd, FILE_SIZE, CFS_SEEK_SET) != FILE_SIZE) {
|
||||
printf("failed to seek to the end\n");
|
||||
}
|
||||
|
||||
deluge_disseminate("test", node_id == SINK_ID);
|
||||
cfs_close(fd);
|
||||
|
||||
etimer_set(&et, CLOCK_SECOND * 5);
|
||||
for(;;) {
|
||||
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
|
||||
if(node_id != SINK_ID) {
|
||||
fd = cfs_open("test", CFS_READ);
|
||||
if(fd < 0) {
|
||||
printf("failed to open the test file\n");
|
||||
} else {
|
||||
r = cfs_read(fd, buf, sizeof(buf));
|
||||
buf[sizeof(buf) - 1] = '\0';
|
||||
if(r <= 0) {
|
||||
printf("failed to read data from the file\n");
|
||||
} else {
|
||||
printf("File contents: %s\n", buf);
|
||||
}
|
||||
cfs_close(fd);
|
||||
}
|
||||
}
|
||||
etimer_reset(&et);
|
||||
}
|
||||
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,155 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>Deluge</title>
|
||||
<randomseed>generated</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>100.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/sky/test-deluge.c</source>
|
||||
<commands EXPORT="discard">make clean TARGET=sky
|
||||
make APPS=deluge test-deluge.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/sky/test-deluge.sky</firmware>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>22.464792491653174</x>
|
||||
<y>11.3235347656354</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>16.167564578306468</x>
|
||||
<y>29.89745599030348</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>63.42409596590043</x>
|
||||
<y>12.470791515046386</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>5</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>282</width>
|
||||
<z>4</z>
|
||||
<height>212</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>4.405003166995177 0.0 0.0 4.405003166995177 -40.3007583818182 -45.78929741329485</viewport>
|
||||
</plugin_config>
|
||||
<width>283</width>
|
||||
<z>2</z>
|
||||
<height>144</height>
|
||||
<location_x>-1</location_x>
|
||||
<location_y>212</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>TIMEOUT(100000, log.log("last msg: " + msg + "\n")); /* print last msg at timeout */
|
||||
|
||||
WAIT_UNTIL(id == 3 && msg.contains("version 1"));
|
||||
log.log("Node 3 got version 1\n");
|
||||
|
||||
WAIT_UNTIL(id == 5 && msg.contains("version 1"));
|
||||
log.log("Node 5 got version 1\n");
|
||||
|
||||
log.testOK(); /* Report test success and quit */</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>600</width>
|
||||
<z>1</z>
|
||||
<height>357</height>
|
||||
<location_x>281</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<mote>2</mote>
|
||||
<showRadioRXTX />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>882</width>
|
||||
<z>3</z>
|
||||
<height>149</height>
|
||||
<location_x>-1</location_x>
|
||||
<location_y>357</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>882</width>
|
||||
<z>0</z>
|
||||
<height>195</height>
|
||||
<location_x>-1</location_x>
|
||||
<location_y>504</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
245
regression-tests/04-rime/06-sky-collect.csc
Normal file
245
regression-tests/04-rime/06-sky-collect.csc
Normal file
|
@ -0,0 +1,245 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>generated</randomseed>
|
||||
<motedelay_us>10000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>30.0</transmitting_range>
|
||||
<interference_range>40.0</interference_range>
|
||||
<success_ratio_tx>0.9</success_ratio_tx>
|
||||
<success_ratio_rx>0.9</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/sky/sky-collect.c</source>
|
||||
<commands EXPORT="discard">make clean TARGET=sky
|
||||
make sky-collect.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/sky/sky-collect.sky</firmware>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>9.333811152651393</x>
|
||||
<y>89.28114548870677</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>33.040227185226826</x>
|
||||
<y>54.184283361563054</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>-2.2559922410521516</x>
|
||||
<y>50.71648775308175</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>12.959353575718179</x>
|
||||
<y>43.874396471224806</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>4</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>15.917348901177405</x>
|
||||
<y>66.93526904376517</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>5</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>26.735174243053933</x>
|
||||
<y>35.939375910459084</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>6</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>41.5254792748469</x>
|
||||
<y>28.370611308140152</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>7</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>265</width>
|
||||
<z>3</z>
|
||||
<height>200</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>1.9551775516837413 0.0 0.0 1.9551775516837413 87.61059024269439 -50.01503690267507</viewport>
|
||||
</plugin_config>
|
||||
<width>264</width>
|
||||
<z>1</z>
|
||||
<height>185</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>200</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>TIMEOUT(300000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
|
||||
|
||||
/* Conf. */
|
||||
booted = new Array();
|
||||
count = new Array();
|
||||
nrNodes = 7;
|
||||
nodes_starting = true;
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
booted[i] = false;
|
||||
count[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");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
|
||||
while (true) {
|
||||
YIELD();
|
||||
|
||||
/* Count sensor data packets */
|
||||
source = msg.split(" ")[0];
|
||||
count[source]++;
|
||||
log.log("Got data from node " + source + ": tot=" + count[source] + "\n");
|
||||
|
||||
/* Fail if any node has transmitted more than 20 packets */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] > 20) {
|
||||
log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
|
||||
log.testFailed(); /* We are done! */
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait until we have received data from all nodes */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] < 5) break;
|
||||
if (i == nrNodes) log.testOK();
|
||||
}
|
||||
|
||||
}</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>600</width>
|
||||
<z>2</z>
|
||||
<height>385</height>
|
||||
<location_x>266</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<mote>2</mote>
|
||||
<mote>3</mote>
|
||||
<mote>4</mote>
|
||||
<mote>5</mote>
|
||||
<mote>6</mote>
|
||||
<showRadioRXTX />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>866</width>
|
||||
<z>0</z>
|
||||
<height>152</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>384</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
|
@ -9,25 +9,25 @@
|
|||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>generated</randomseed>
|
||||
<motedelay_us>10000000</motedelay_us>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>30.0</transmitting_range>
|
||||
<interference_range>40.0</interference_range>
|
||||
<success_ratio_tx>0.9</success_ratio_tx>
|
||||
<success_ratio_rx>0.9</success_ratio_rx>
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>50.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>40000</logoutput>
|
||||
<logoutput>400000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/sky/sky-collect.c</source>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/rime/example-collect.c</source>
|
||||
<commands EXPORT="discard">make clean TARGET=sky
|
||||
make sky-collect.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/sky/sky-collect.sky</firmware>
|
||||
make example-collect.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rime/example-collect.sky</firmware>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
|
@ -38,13 +38,18 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>9.333811152651393</x>
|
||||
<y>89.28114548870677</y>
|
||||
<x>87.29845932913939</x>
|
||||
<y>60.286214311723164</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -57,8 +62,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>33.040227185226826</x>
|
||||
<y>54.184283361563054</y>
|
||||
<x>94.30809966340686</x>
|
||||
<y>22.50388779326399</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -71,8 +76,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>-2.2559922410521516</x>
|
||||
<y>50.71648775308175</y>
|
||||
<x>82.40423567500785</x>
|
||||
<y>39.56979106929553</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -85,8 +90,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>12.959353575718179</x>
|
||||
<y>43.874396471224806</y>
|
||||
<x>26.185019854469438</x>
|
||||
<y>4.800834369523899</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -99,8 +104,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>15.917348901177405</x>
|
||||
<y>66.93526904376517</y>
|
||||
<x>1.9530156130507015</x>
|
||||
<y>78.3175061800706</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -113,8 +118,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>26.735174243053933</x>
|
||||
<y>35.939375910459084</y>
|
||||
<x>48.35216700543414</x>
|
||||
<y>80.36988713780997</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -127,8 +132,8 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>41.5254792748469</x>
|
||||
<y>28.370611308140152</y>
|
||||
<x>24.825985087266833</x>
|
||||
<y>74.27809432062487</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
|
@ -137,12 +142,194 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>8.356165164293616</x>
|
||||
<y>94.33967355724187</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>8</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>45.11740613004886</x>
|
||||
<y>31.7059041432301</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>9</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>68.9908548386292</x>
|
||||
<y>55.01991960639596</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>10</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>13.181122543889046</x>
|
||||
<y>55.9636533130127</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>11</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>2.1749985906538427</x>
|
||||
<y>78.39666095789707</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>12</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>37.79795217518357</x>
|
||||
<y>7.164284163506062</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>13</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>64.4595177394984</x>
|
||||
<y>72.115414337433</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>14</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>81.85663737096085</x>
|
||||
<y>89.31412706434035</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>15</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>44.74952276297882</x>
|
||||
<y>18.78566116347574</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>16</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>96.11333426285873</x>
|
||||
<y>90.64560410751824</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>17</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>21.651464136783527</x>
|
||||
<y>7.1381043251259495</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>18</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>83.6006916200628</x>
|
||||
<y>26.97170140682981</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>19</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>1.3446070721664705</x>
|
||||
<y>7.340373220385176</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>20</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>265</width>
|
||||
<z>3</z>
|
||||
<height>200</height>
|
||||
<width>247</width>
|
||||
<z>0</z>
|
||||
<height>227</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
|
@ -151,95 +338,110 @@ make sky-collect.sky TARGET=sky</commands>
|
|||
<plugin_config>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>1.9551775516837413 0.0 0.0 1.9551775516837413 87.61059024269439 -50.01503690267507</viewport>
|
||||
<viewport>1.685403700540615 0.0 0.0 1.685403700540615 23.872012513439184 -0.545889466623605</viewport>
|
||||
</plugin_config>
|
||||
<width>264</width>
|
||||
<width>224</width>
|
||||
<z>3</z>
|
||||
<height>225</height>
|
||||
<location_x>247</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>469</width>
|
||||
<z>1</z>
|
||||
<height>185</height>
|
||||
<height>473</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>200</location_y>
|
||||
<location_y>226</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>TIMEOUT(300000, log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n"));
|
||||
<script>TIMEOUT(600000);
|
||||
|
||||
/* Conf. */
|
||||
booted = new Array();
|
||||
count = new Array();
|
||||
nrNodes = 7;
|
||||
nodes_starting = true;
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
booted[i] = false;
|
||||
count[i] = 0;
|
||||
}
|
||||
num_nodes = mote.getSimulation().getMotesCount();
|
||||
|
||||
/* 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;
|
||||
function print_stats() {
|
||||
log.log("Received:\n");
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
log.log("Node " + i + " ");
|
||||
if(i == sink) {
|
||||
log.log("sink\n");
|
||||
} else {
|
||||
log.log("received: " + received[i] + " hops: " + hops[i] + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Create sink */
|
||||
log.log("All nodes booted, creating sink at node " + id + "\n");
|
||||
mote.getInterfaces().getButton().clickButton()
|
||||
/* Init */
|
||||
sink = 0;
|
||||
hops = new Array();
|
||||
dups = new Array();
|
||||
received = new Array();
|
||||
|
||||
while (true) {
|
||||
YIELD();
|
||||
doubleFormat = new java.text.DecimalFormat("0.00");
|
||||
integerFormat = new java.text.DecimalFormat("00");
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
received[i] = "__________";
|
||||
hops[i] = received[i];
|
||||
}
|
||||
|
||||
/* Count sensor data packets */
|
||||
source = msg.split(" ")[0];
|
||||
count[source]++;
|
||||
log.log("Got data from node " + source + ": tot=" + count[source] + "\n");
|
||||
log.log("Simulation has " + num_nodes + " nodes\n");
|
||||
|
||||
/* Fail if any node has transmitted more than 20 packets */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] > 20) {
|
||||
log.log("received/node: " + count[1] + " " + count[2] + " " + count[3] + " " + count[4] + " " + count[5] + " " + count[6] + " " + count[7] + "\n");
|
||||
log.testFailed(); /* We are done! */
|
||||
while(true) {
|
||||
YIELD();
|
||||
log.log(time + " " + id + " "+ msg + "\n");
|
||||
/* Count sensor data packets */
|
||||
if(msg.startsWith("Sink got message")) {
|
||||
node_text = msg.split(" ")[4];
|
||||
seqno_text = msg.split(" ")[6];
|
||||
hops_text = msg.split(" ")[8];
|
||||
if(node_text) {
|
||||
source = parseInt(node_text);
|
||||
seqno = parseInt(seqno_text);
|
||||
hop = parseInt(hops_text);
|
||||
dups = received[source].substr(seqno, 1);
|
||||
if(dups == "_") {
|
||||
dups = 1;
|
||||
} else if(dups < 9) {
|
||||
dups++;
|
||||
}
|
||||
received[source] = received[source].substr(0, seqno) + dups +
|
||||
received[source].substr(seqno + 1, 10 - seqno);
|
||||
|
||||
if(hop > 9) {
|
||||
hop = "+";
|
||||
}
|
||||
hops[source] = hops[source].substr(0, seqno) + hop +
|
||||
hops[source].substr(seqno + 1, 10 - seqno);
|
||||
print_stats();
|
||||
}
|
||||
}
|
||||
/* Signal OK if all nodes have reported 10 messages. */
|
||||
num_reported = 0;
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
if(!isNaN(received[i])) {
|
||||
num_reported++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait until we have received data from all nodes */
|
||||
for (i = 1; i <= nrNodes; i++) {
|
||||
if (count[i] < 5) break;
|
||||
if (i == nrNodes) log.testOK();
|
||||
}
|
||||
|
||||
}</script>
|
||||
if(num_reported == num_nodes) {
|
||||
print_stats();
|
||||
log.testOK();
|
||||
}
|
||||
}</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>600</width>
|
||||
<z>2</z>
|
||||
<height>385</height>
|
||||
<location_x>266</location_x>
|
||||
<height>700</height>
|
||||
<location_x>469</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.TimeLine
|
||||
<plugin_config>
|
||||
<mote>0</mote>
|
||||
<mote>1</mote>
|
||||
<mote>2</mote>
|
||||
<mote>3</mote>
|
||||
<mote>4</mote>
|
||||
<mote>5</mote>
|
||||
<mote>6</mote>
|
||||
<showRadioRXTX />
|
||||
<zoomfactor>500.0</zoomfactor>
|
||||
</plugin_config>
|
||||
<width>866</width>
|
||||
<z>0</z>
|
||||
<height>152</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>384</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
||||
|
|
|
@ -1,447 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<simconf>
|
||||
<project EXPORT="discard">[APPS_DIR]/mrm</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/mspsim</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/avrora</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/serial_socket</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/collect-view</project>
|
||||
<project EXPORT="discard">[APPS_DIR]/powertracker</project>
|
||||
<simulation>
|
||||
<title>My simulation</title>
|
||||
<randomseed>generated</randomseed>
|
||||
<motedelay_us>1000000</motedelay_us>
|
||||
<radiomedium>
|
||||
org.contikios.cooja.radiomediums.UDGM
|
||||
<transmitting_range>50.0</transmitting_range>
|
||||
<interference_range>50.0</interference_range>
|
||||
<success_ratio_tx>1.0</success_ratio_tx>
|
||||
<success_ratio_rx>1.0</success_ratio_rx>
|
||||
</radiomedium>
|
||||
<events>
|
||||
<logoutput>400000</logoutput>
|
||||
</events>
|
||||
<motetype>
|
||||
org.contikios.cooja.mspmote.SkyMoteType
|
||||
<identifier>sky1</identifier>
|
||||
<description>Sky Mote Type #1</description>
|
||||
<source EXPORT="discard">[CONTIKI_DIR]/examples/rime/example-collect.c</source>
|
||||
<commands EXPORT="discard">make clean TARGET=sky
|
||||
make example-collect.sky TARGET=sky</commands>
|
||||
<firmware EXPORT="copy">[CONTIKI_DIR]/examples/rime/example-collect.sky</firmware>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Position</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.IPAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.Mote2MoteRelations</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspClock</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspMoteID</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyButton</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyFlash</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.Msp802154Radio</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspSerial</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyLED</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.RimeAddress</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.interfaces.MoteAttributes</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyCoffeeFilesystem</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.MspDebugOutput</moteinterface>
|
||||
<moteinterface>org.contikios.cooja.mspmote.interfaces.SkyTemperature</moteinterface>
|
||||
</motetype>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>87.29845932913939</x>
|
||||
<y>60.286214311723164</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>1</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>94.30809966340686</x>
|
||||
<y>22.50388779326399</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>2</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>82.40423567500785</x>
|
||||
<y>39.56979106929553</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>3</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>26.185019854469438</x>
|
||||
<y>4.800834369523899</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>4</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>1.9530156130507015</x>
|
||||
<y>78.3175061800706</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>5</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>48.35216700543414</x>
|
||||
<y>80.36988713780997</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>6</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>24.825985087266833</x>
|
||||
<y>74.27809432062487</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>7</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>8.356165164293616</x>
|
||||
<y>94.33967355724187</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>8</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>45.11740613004886</x>
|
||||
<y>31.7059041432301</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>9</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>68.9908548386292</x>
|
||||
<y>55.01991960639596</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>10</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>13.181122543889046</x>
|
||||
<y>55.9636533130127</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>11</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>2.1749985906538427</x>
|
||||
<y>78.39666095789707</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>12</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>37.79795217518357</x>
|
||||
<y>7.164284163506062</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>13</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>64.4595177394984</x>
|
||||
<y>72.115414337433</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>14</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>81.85663737096085</x>
|
||||
<y>89.31412706434035</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>15</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>44.74952276297882</x>
|
||||
<y>18.78566116347574</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>16</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>96.11333426285873</x>
|
||||
<y>90.64560410751824</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>17</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>21.651464136783527</x>
|
||||
<y>7.1381043251259495</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>18</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>83.6006916200628</x>
|
||||
<y>26.97170140682981</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>19</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
<mote>
|
||||
<breakpoints />
|
||||
<interface_config>
|
||||
org.contikios.cooja.interfaces.Position
|
||||
<x>1.3446070721664705</x>
|
||||
<y>7.340373220385176</y>
|
||||
<z>0.0</z>
|
||||
</interface_config>
|
||||
<interface_config>
|
||||
org.contikios.cooja.mspmote.interfaces.MspMoteID
|
||||
<id>20</id>
|
||||
</interface_config>
|
||||
<motetype_identifier>sky1</motetype_identifier>
|
||||
</mote>
|
||||
</simulation>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.SimControl
|
||||
<width>247</width>
|
||||
<z>0</z>
|
||||
<height>227</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.Visualizer
|
||||
<plugin_config>
|
||||
<skin>org.contikios.cooja.plugins.skins.IDVisualizerSkin</skin>
|
||||
<skin>org.contikios.cooja.plugins.skins.UDGMVisualizerSkin</skin>
|
||||
<viewport>1.685403700540615 0.0 0.0 1.685403700540615 23.872012513439184 -0.545889466623605</viewport>
|
||||
</plugin_config>
|
||||
<width>224</width>
|
||||
<z>3</z>
|
||||
<height>225</height>
|
||||
<location_x>247</location_x>
|
||||
<location_y>1</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.LogListener
|
||||
<plugin_config>
|
||||
<filter />
|
||||
<formatted_time />
|
||||
<coloring />
|
||||
</plugin_config>
|
||||
<width>469</width>
|
||||
<z>1</z>
|
||||
<height>473</height>
|
||||
<location_x>0</location_x>
|
||||
<location_y>226</location_y>
|
||||
</plugin>
|
||||
<plugin>
|
||||
org.contikios.cooja.plugins.ScriptRunner
|
||||
<plugin_config>
|
||||
<script>TIMEOUT(600000);
|
||||
|
||||
num_nodes = mote.getSimulation().getMotesCount();
|
||||
|
||||
function print_stats() {
|
||||
log.log("Received:\n");
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
log.log("Node " + i + " ");
|
||||
if(i == sink) {
|
||||
log.log("sink\n");
|
||||
} else {
|
||||
log.log("received: " + received[i] + " hops: " + hops[i] + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Init */
|
||||
sink = 0;
|
||||
hops = new Array();
|
||||
dups = new Array();
|
||||
received = new Array();
|
||||
|
||||
doubleFormat = new java.text.DecimalFormat("0.00");
|
||||
integerFormat = new java.text.DecimalFormat("00");
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
received[i] = "__________";
|
||||
hops[i] = received[i];
|
||||
}
|
||||
|
||||
log.log("Simulation has " + num_nodes + " nodes\n");
|
||||
|
||||
while(true) {
|
||||
YIELD();
|
||||
log.log(time + " " + id + " "+ msg + "\n");
|
||||
/* Count sensor data packets */
|
||||
if(msg.startsWith("Sink got message")) {
|
||||
node_text = msg.split(" ")[4];
|
||||
seqno_text = msg.split(" ")[6];
|
||||
hops_text = msg.split(" ")[8];
|
||||
if(node_text) {
|
||||
source = parseInt(node_text);
|
||||
seqno = parseInt(seqno_text);
|
||||
hop = parseInt(hops_text);
|
||||
dups = received[source].substr(seqno, 1);
|
||||
if(dups == "_") {
|
||||
dups = 1;
|
||||
} else if(dups < 9) {
|
||||
dups++;
|
||||
}
|
||||
received[source] = received[source].substr(0, seqno) + dups +
|
||||
received[source].substr(seqno + 1, 10 - seqno);
|
||||
|
||||
if(hop > 9) {
|
||||
hop = "+";
|
||||
}
|
||||
hops[source] = hops[source].substr(0, seqno) + hop +
|
||||
hops[source].substr(seqno + 1, 10 - seqno);
|
||||
print_stats();
|
||||
}
|
||||
}
|
||||
/* Signal OK if all nodes have reported 10 messages. */
|
||||
num_reported = 0;
|
||||
for(i = 1; i <= num_nodes; i++) {
|
||||
if(!isNaN(received[i])) {
|
||||
num_reported++;
|
||||
}
|
||||
}
|
||||
|
||||
if(num_reported == num_nodes) {
|
||||
print_stats();
|
||||
log.testOK();
|
||||
}
|
||||
}</script>
|
||||
<active>true</active>
|
||||
</plugin_config>
|
||||
<width>600</width>
|
||||
<z>2</z>
|
||||
<height>700</height>
|
||||
<location_x>469</location_x>
|
||||
<location_y>0</location_y>
|
||||
</plugin>
|
||||
</simconf>
|
||||
|
Loading…
Reference in a new issue