[Tinyos-2-commits] CVS: tinyos-2.x/apps/tests/TestMultihopLqi
15-15-medium-mica2-grid.txt, NONE,
1.1 15-15-tight-mica2-grid.txt, NONE,
1.1 CC2420ActiveMessageC.nc, NONE, 1.1 Makefile, NONE,
1.1 MultihopOscilloscope.h, NONE,
1.1 MultihopOscilloscopeAppC.nc, NONE,
1.1 MultihopOscilloscopeC.nc, NONE, 1.1 README.txt, NONE,
1.1 log.txt, NONE, 1.1 meyer-heavy.txt, NONE,
1.1 meyer-short.txt, NONE, 1.1 script.py, NONE, 1.1 topo.txt,
NONE, 1.1
Phil Levis
scipio at users.sourceforge.net
Thu Apr 12 16:24:02 PDT 2007
Update of /cvsroot/tinyos/tinyos-2.x/apps/tests/TestMultihopLqi
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv12169/TestMultihopLqi
Added Files:
15-15-medium-mica2-grid.txt 15-15-tight-mica2-grid.txt
CC2420ActiveMessageC.nc Makefile MultihopOscilloscope.h
MultihopOscilloscopeAppC.nc MultihopOscilloscopeC.nc
README.txt log.txt meyer-heavy.txt meyer-short.txt script.py
topo.txt
Log Message:
Test app for MultihopLQI.
--- NEW FILE: 15-15-medium-mica2-grid.txt ---
gain 0 1 -87.04
gain 1 0 -88.02
gain 0 2 -89.58
gain 2 0 -90.40
gain 0 3 -96.56
gain 3 0 -98.69
gain 0 4 -108.45
gain 4 0 -112.72
gain 0 5 -99.72
gain 5 0 -104.43
gain 0 6 -107.02
gain 6 0 -108.16
gain 0 7 -112.03
gain 7 0 -110.56
gain 0 8 -106.75
gain 8 0 -111.25
gain 0 9 -107.25
gain 9 0 -107.24
gain 0 10 -115.74
[...50586 lines suppressed...]
noise 205 -104.23 4.00
noise 206 -106.02 4.00
noise 207 -104.12 4.00
noise 208 -104.44 4.00
noise 209 -105.64 4.00
noise 210 -101.45 4.00
noise 211 -105.37 4.00
noise 212 -105.30 4.00
noise 213 -104.10 4.00
noise 214 -105.43 4.00
noise 215 -105.24 4.00
noise 216 -104.04 4.00
noise 217 -102.31 4.00
noise 218 -110.75 4.00
noise 219 -106.03 4.00
noise 220 -106.45 4.00
noise 221 -104.91 4.00
noise 222 -102.56 4.00
noise 223 -104.23 4.00
noise 224 -102.95 4.00
--- NEW FILE: 15-15-tight-mica2-grid.txt ---
gain 0 1 -64.71
gain 1 0 -66.06
gain 0 2 -73.89
gain 2 0 -76.19
gain 0 3 -76.00
gain 3 0 -77.08
gain 0 4 -78.29
gain 4 0 -80.34
gain 0 5 -78.62
gain 5 0 -78.56
gain 0 6 -85.98
gain 6 0 -87.32
gain 0 7 -89.50
gain 7 0 -90.94
gain 0 8 -87.98
gain 8 0 -91.27
gain 0 9 -87.39
gain 9 0 -95.08
gain 0 10 -91.14
[...50586 lines suppressed...]
noise 205 -107.32 4.00
noise 206 -103.93 4.00
noise 207 -103.67 4.00
noise 208 -104.88 4.00
noise 209 -103.33 4.00
noise 210 -103.77 4.00
noise 211 -107.35 4.00
noise 212 -104.40 4.00
noise 213 -102.55 4.00
noise 214 -99.68 4.00
noise 215 -102.74 4.00
noise 216 -102.16 4.00
noise 217 -102.66 4.00
noise 218 -107.37 4.00
noise 219 -105.53 4.00
noise 220 -109.69 4.00
noise 221 -104.91 4.00
noise 222 -107.83 4.00
noise 223 -103.71 4.00
noise 224 -102.76 4.00
--- NEW FILE: CC2420ActiveMessageC.nc ---
#include <sim_gain.h>
#include <sim_tossim.h>
module CC2420ActiveMessageC {
provides interface CC2420Packet as Packet;
uses interface AMPacket as SubPacket;
}
implementation {
/**
* Get transmission power setting for current packet.
*
* @param the message
*/
async command uint8_t Packet.getPower( message_t* p_msg ) {
return 1;
}
/**
* Set transmission power for a given packet. Valid ranges are
* between 0 and 31.
*
* @param p_msg the message.
* @param power transmission power.
*/
async command void Packet.setPower( message_t* p_msg, uint8_t power ) {
return;
}
/**
* Get rssi value for a given packet. For received packets, it is
* the received signal strength when receiving that packet. For sent
* packets, it is the received signal strength of the ack if an ack
* was received.
*/
async command int8_t Packet.getRssi( message_t* p_msg ) {
uint16_t src = call SubPacket.source(p_msg);
return (int)sim_gain_value(src, TOS_NODE_ID);
}
/**
* Get lqi value for a given packet. For received packets, it is the
* link quality indicator value when receiving that packet. For sent
* packets, it is the link quality indicator value of the ack if an
* ack was received.
*/
async command uint8_t Packet.getLqi( message_t* p_msg ) {
uint16_t src = call SubPacket.source(p_msg);
int sig = (int)sim_gain_value(src, TOS_NODE_ID);
if (sig > -60) {
sig = 110;
}
else {
sig = 230 + (sig * 2);
sig += (sim_random() % 10);
}
return (uint8_t)sig;
}
}
--- NEW FILE: Makefile ---
COMPONENT=MultihopOscilloscopeAppC
CFLAGS += -I$(TOSDIR)/lib/net/ -I$(TOSDIR)/lib/net/lqi
include $(MAKERULES)
--- NEW FILE: MultihopOscilloscope.h ---
/*
* Copyright (c) 2006 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* @author David Gay
* @author Kyle Jamieson
*/
#ifndef MULTIHOP_OSCILLOSCOPE_H
#define MULTIHOP_OSCILLOSCOPE_H
enum {
/* Number of readings per message. If you increase this, you may have to
increase the message_t size. */
NREADINGS = 5,
/* Default sampling period. */
DEFAULT_INTERVAL = 1024,
AM_OSCILLOSCOPE = 0x93
};
typedef nx_struct oscilloscope {
nx_uint16_t version; /* Version of the interval. */
nx_uint16_t interval; /* Samping period. */
nx_uint16_t id; /* Mote id of sending mote. */
nx_uint16_t count; /* The readings are samples count * NREADINGS onwards */
nx_uint16_t readings[NREADINGS];
} oscilloscope_t;
#endif
--- NEW FILE: MultihopOscilloscopeAppC.nc ---
/*
* Copyright (c) 2006 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* MultihopOscilloscope demo application using the collection layer.
* See README.txt file in this directory and TEP 119: Collection.
*
* @author David Gay
* @author Kyle Jamieson
*/
configuration MultihopOscilloscopeAppC { }
implementation {
components MainC, MultihopOscilloscopeC, LedsC, new TimerMilliC(),
new DemoSensorC() as Sensor;
//MainC.SoftwareInit -> Sensor;
MultihopOscilloscopeC.Boot -> MainC;
MultihopOscilloscopeC.Timer -> TimerMilliC;
MultihopOscilloscopeC.Read -> Sensor;
MultihopOscilloscopeC.Leds -> LedsC;
//
// Communication components. These are documented in TEP 113:
// Serial Communication, and TEP 119: Collection.
//
components CollectionC as Collector, // Collection layer
ActiveMessageC, // AM layer
new CollectionSenderC(AM_OSCILLOSCOPE), // Sends multihop RF
SerialActiveMessageC, // Serial messaging
new SerialAMSenderC(AM_OSCILLOSCOPE); // Sends to the serial port
MultihopOscilloscopeC.RadioControl -> ActiveMessageC;
MultihopOscilloscopeC.SerialControl -> SerialActiveMessageC;
MultihopOscilloscopeC.RoutingControl -> Collector;
MultihopOscilloscopeC.Send -> CollectionSenderC;
MultihopOscilloscopeC.SerialSend -> SerialAMSenderC.AMSend;
MultihopOscilloscopeC.Snoop -> Collector.Snoop[AM_OSCILLOSCOPE];
MultihopOscilloscopeC.Receive -> Collector.Receive[AM_OSCILLOSCOPE];
MultihopOscilloscopeC.RootControl -> Collector;
components new PoolC(message_t, 10) as UARTMessagePoolP,
new QueueC(message_t*, 10) as UARTQueueP;
MultihopOscilloscopeC.UARTMessagePool -> UARTMessagePoolP;
MultihopOscilloscopeC.UARTQueue -> UARTQueueP;
//
// Components for debugging collection.
//
/* components new PoolC(message_t, 20) as DebugMessagePool,
new QueueC(message_t*, 20) as DebugSendQueue,
new SerialAMSenderC(AM_CTP_DEBUG) as DebugSerialSender,
UARTDebugSenderP as DebugSender;
DebugSender.Boot -> MainC;
DebugSender.UARTSend -> DebugSerialSender;
DebugSender.MessagePool -> DebugMessagePool;
DebugSender.SendQueue -> DebugSendQueue;
Collector.CollectionDebug -> DebugSender;*/
}
--- NEW FILE: MultihopOscilloscopeC.nc ---
/*
* Copyright (c) 2006 Intel Corporation
* All rights reserved.
*
* This file is distributed under the terms in the attached INTEL-LICENSE
* file. If you do not find these files, copies can be found by writing to
* Intel Research Berkeley, 2150 Shattuck Avenue, Suite 1300, Berkeley, CA,
* 94704. Attention: Intel License Inquiry.
*/
/**
* MultihopOscilloscope demo application using the collection layer.
* See README.txt file in this directory and TEP 119: Collection.
*
* @author David Gay
* @author Kyle Jamieson
*/
#include "Timer.h"
#include "MultihopOscilloscope.h"
module MultihopOscilloscopeC {
uses {
// Interfaces for initialization:
interface Boot;
interface SplitControl as RadioControl;
interface SplitControl as SerialControl;
interface StdControl as RoutingControl;
// Interfaces for communication, multihop and serial:
interface Send;
interface Receive as Snoop;
interface Receive;
interface AMSend as SerialSend;
interface CollectionPacket;
interface RootControl;
interface Queue<message_t *> as UARTQueue;
interface Pool<message_t> as UARTMessagePool;
// Miscalleny:
interface Timer<TMilli>;
interface Read<uint16_t>;
interface Leds;
}
}
implementation {
task void uartSendTask();
static void startTimer();
static void fatal_problem();
static void report_problem();
static void report_sent();
static void report_received();
uint8_t uartlen;
message_t sendbuf;
message_t uartbuf;
bool sendbusy=FALSE, uartbusy=FALSE;
/* Current local state - interval, version and accumulated readings */
oscilloscope_t local;
uint8_t reading; /* 0 to NREADINGS */
/* When we head an Oscilloscope message, we check it's sample count. If
it's ahead of ours, we "jump" forwards (set our count to the received
count). However, we must then suppress our next count increment. This
is a very simple form of "time" synchronization (for an abstract
notion of time). */
bool suppress_count_change;
//
// On bootup, initialize radio and serial communications, and our
// own state variables.
//
event void Boot.booted() {
local.interval = DEFAULT_INTERVAL;
local.id = TOS_NODE_ID;
local.version = 0;
// Beginning our initialization phases:
if (call RadioControl.start() != SUCCESS)
fatal_problem();
if (call RoutingControl.start() != SUCCESS)
fatal_problem();
}
event void RadioControl.startDone(error_t error) {
if (error != SUCCESS)
fatal_problem();
if (sizeof(local) > call Send.maxPayloadLength())
fatal_problem();
if (call SerialControl.start() != SUCCESS)
fatal_problem();
}
event void SerialControl.startDone(error_t error) {
if (error != SUCCESS)
fatal_problem();
// This is how to set yourself as a root to the collection layer:
if (local.id % 500 == 0)
call RootControl.setRoot();
startTimer();
}
static void startTimer() {
if (call Timer.isRunning()) call Timer.stop();
call Timer.startPeriodic(local.interval);
reading = 0;
}
event void RadioControl.stopDone(error_t error) { }
event void SerialControl.stopDone(error_t error) { }
//
// Only the root will receive messages from this interface; its job
// is to forward them to the serial uart for processing on the pc
// connected to the sensor network.
//
event message_t*
Receive.receive(message_t* msg, void *payload, uint8_t len) {
oscilloscope_t* in = (oscilloscope_t*)payload;
oscilloscope_t* out;
if (uartbusy == FALSE) {
out = (oscilloscope_t*)call SerialSend.getPayload(&uartbuf);
if (len != sizeof(oscilloscope_t)) {
return msg;
}
else {
memcpy(out, in, sizeof(oscilloscope_t));
}
uartlen = sizeof(oscilloscope_t);
post uartSendTask();
} else {
// The UART is busy; queue up messages and service them when the
// UART becomes free.
message_t *newmsg = call UARTMessagePool.get();
if (newmsg == NULL) {
// drop the message on the floor if we run out of queue space.
report_problem();
return msg;
}
//Prepare message to be sent over the uart
out = (oscilloscope_t*)call SerialSend.getPayload(newmsg);
memcpy(out, in, sizeof(oscilloscope_t));
if (call UARTQueue.enqueue(newmsg) != SUCCESS) {
// drop the message on the floor and hang if we run out of
// queue space without running out of queue space first (this
// should not occur).
call UARTMessagePool.put(newmsg);
fatal_problem();
return msg;
}
}
return msg;
}
task void uartSendTask() {
if (call SerialSend.send(0xffff, &uartbuf, uartlen) != SUCCESS) {
report_problem();
} else {
uartbusy = TRUE;
}
}
event void SerialSend.sendDone(message_t *msg, error_t error) {
uartbusy = FALSE;
if (call UARTQueue.empty() == FALSE) {
// We just finished a UART send, and the uart queue is
// non-empty. Let's start a new one.
message_t *queuemsg = call UARTQueue.dequeue();
if (queuemsg == NULL) {
fatal_problem();
return;
}
memcpy(&uartbuf, queuemsg, sizeof(message_t));
if (call UARTMessagePool.put(queuemsg) != SUCCESS) {
fatal_problem();
return;
}
post uartSendTask();
}
}
//
// Overhearing other traffic in the network.
//
event message_t*
Snoop.receive(message_t* msg, void* payload, uint8_t len) {
oscilloscope_t *omsg = payload;
report_received();
// If we receive a newer version, update our interval.
if (omsg->version > local.version) {
local.version = omsg->version;
local.interval = omsg->interval;
startTimer();
}
// If we hear from a future count, jump ahead but suppress our own
// change.
if (omsg->count > local.count) {
local.count = omsg->count;
suppress_count_change = TRUE;
}
return msg;
}
/* At each sample period:
- if local sample buffer is full, send accumulated samples
- read next sample
*/
event void Timer.fired() {
if (reading == NREADINGS) {
if (!sendbusy) {
oscilloscope_t *o = (oscilloscope_t *)call Send.getPayload(&sendbuf);
memcpy(o, &local, sizeof(local));
if (call Send.send(&sendbuf, sizeof(local)) == SUCCESS)
sendbusy = TRUE;
else
report_problem();
}
reading = 0;
/* Part 2 of cheap "time sync": increment our count if we didn't
jump ahead. */
if (!suppress_count_change)
local.count++;
suppress_count_change = FALSE;
}
if (call Read.read() != SUCCESS)
fatal_problem();
}
event void Send.sendDone(message_t* msg, error_t error) {
if (error == SUCCESS)
report_sent();
else
report_problem();
sendbusy = FALSE;
}
event void Read.readDone(error_t result, uint16_t data) {
if (result != SUCCESS) {
data = 0xffff;
report_problem();
}
local.readings[reading++] = data;
}
// Use LEDs to report various status issues.
static void fatal_problem() {
call Leds.led0On();
call Leds.led1On();
call Leds.led2On();
call Timer.stop();
}
static void report_problem() { call Leds.led0Toggle(); }
static void report_sent() { call Leds.led1Toggle(); }
static void report_received() { call Leds.led2Toggle(); }
}
--- NEW FILE: README.txt ---
README for TestMultihopLqi
Author/Contact: tinyos-help at millennium.berkeley.edu
Description:
TestMultihopLqi is a hacked-up version of MultihopOscilloscope whose purpose
is to test the LQI code in lib/net/lqi. It achieves this by creating a
CC2420ActiveMessageC component that generates synthetic LQI values. These
values have no resemblance to those found in the real world, and so are of
no use whatsoever when evaluating the effectiveness of a protocol that uses
them. They can be, however, useful for testing code, which is exactly
what this application does.
Known bugs/limitations:
This application is solely intended as a mechanism to test code paths
in lib/net/lqi. It is therefore of no predictive or quantitative value.
Notes:
TestMultihopLqi configures a mote whose TOS_NODE_ID modulo 500 is zero
to be a collection root. The TOSSIM script "script.py" is a sample
driver program.
--- NEW FILE: log.txt ---
time: 0.242393016815
Inserting first element.
Inserting first element.
Inserting first element.
Inserting first element.
Inserting first element.
Inserting first element.
Inserting first element.
time: -0.152559995651
DEBUG (4): LQI receiving routing beacon from 1 with LQI 97 that advertises 65534.
DEBUG (4): -- CYCLE.
DEBUG (4): Set my count to 255, my link to 32767 and my cost to 32767.
DEBUG (5): LQI receiving routing beacon from 3 with LQI 86 that advertises 65534.
DEBUG (5): -- CYCLE.
DEBUG (5): Set my count to 255, my link to 32767 and my cost to 32767.
DEBUG (4): LQI receiving routing beacon from 3 with LQI 108 that advertises 65534.
DEBUG (4): -- CYCLE.
DEBUG (4): Set my count to 255, my link to 32767 and my cost to 32767.
DEBUG (2): LQI receiving routing beacon from 3 with LQI 110 that advertises 65534.
[...47157 lines suppressed...]
DEBUG (1): LQI fwd is forwarding packet from node 6 @1:43:11.032686247
DEBUG (2): LQI fwd is forwarding packet from node 6 @1:43:11.032686247
DEBUG (0): LQI Root is receiving packet from node 6 @1:43:11.039232229
DEBUG (4): LQI fwd is forwarding packet from node 6 @1:43:11.041459999
DEBUG (2): LQI fwd is forwarding packet from node 3 @1:43:11.049720391
DEBUG (2): LQI fwd is forwarding packet from node 5 @1:43:11.054664210
DEBUG (6): LQI fwd is forwarding packet from node 3 @1:43:11.058814576
DEBUG (5): LQI fwd is forwarding packet from node 3 @1:43:11.058814576
DEBUG (1): LQI fwd is forwarding packet from node 3 @1:43:11.058814576
DEBUG (0): LQI Root is receiving packet from node 3 @1:43:11.058814576
DEBUG (4): LQI fwd is forwarding packet from node 3 @1:43:11.058814576
DEBUG (3): LQI fwd is forwarding packet from node 3 @1:43:11.058814576
DEBUG (1): LQI fwd is forwarding packet from node 3 @1:43:11.063590549
DEBUG (5): LQI fwd is forwarding packet from node 3 @1:43:11.063590549
DEBUG (0): LQI Root is receiving packet from node 3 @1:43:11.067298413
DEBUG (1): LQI fwd is forwarding packet from node 3 @1:43:11.069129457
DEBUG (3): LQI fwd is forwarding packet from node 3 @1:43:11.069129457
DEBUG (4): LQI fwd is forwarding packet from node 3 @1:43:11.070701103
DEBUG (2): LQI fwd is forwarding packet from node 3 @1:43:11.078772956
DEBUG (2): LQI fwd is forwarding packet from node 3 @1:43:11.086966878
--- NEW FILE: meyer-heavy.txt ---
-39
-98
-98
-98
-99
-98
-94
-98
-98
-98
-98
-98
-99
-98
-98
-98
-98
-98
-98
[...196569 lines suppressed...]
-80
-80
-80
-80
-80
-80
-80
-96
-98
-98
-99
-71
-98
-98
-99
-98
-98
-98
-98
-98
--- NEW FILE: meyer-short.txt ---
-39
-98
-98
-98
-99
-98
-94
-98
-98
-98
-98
-98
-99
-98
-98
-98
-98
-98
-98
[...961 lines suppressed...]
-98
-98
-97
-98
-98
-81
-80
-81
-81
-81
-68
-98
-97
-91
-81
-81
-81
-81
-67
-81
--- NEW FILE: script.py ---
from TOSSIM import *
import sys
import time
import random
t = Tossim([])
r = t.radio()
#t.addChannel("HASH", sys.stdout)
#t.addChannel("Insert", sys.stdout)
#t.addChannel("RadioCountToLedsC", sys.stdout)
#t.addChannel("CpmModelC", sys.stdout)
#t.addChannel("Gain", sys.stdout)
#t.addChannel("AM", sys.stdout)
#t.addChannel("LQI", sys.stdout)
t.addChannel("LQIRoute", sys.stdout)
t.addChannel("LQIDeliver", sys.stdout)
#t.addChannel("LQIRoute", sys.stdout)
start = time.time();
noise = open("meyer-short.txt", "r")
lines = noise.readlines()
for line in lines:
str = line.strip()
if (str != ""):
val = int(str)
for i in range(0, 7):
t.getNode(i).addNoiseTraceReading(val)
# print "adding ", int(str)
end = time.time();
duration = end - start;
print "time: ", duration;
f = open("topo.txt", "r")
lines = f.readlines()
for line in lines:
s = line.split()
if (len(s) > 0):
if (s[0] == "gain" and int(s[1]) < 8 and int(s[2]) < 8):
r.add(int(s[1]), int(s[2]), float(s[3]))
start = time.time();
for i in range(0, 7):
t.getNode(i).createNoiseModel();
t.getNode(i).bootAtTime(random.random() * 10000000 + 20000000);
duration = end - start;
print "time: ", duration;
#for i in range(0, 196607):
# print m1.generateNoise(i)
for i in range(0, 1000000):
t.runNextEvent();
--- NEW FILE: topo.txt ---
gain 0 1 -64.71
gain 1 0 -66.06
gain 0 2 -73.89
gain 2 0 -76.19
gain 0 3 -76.00
gain 3 0 -77.08
gain 0 4 -78.29
gain 4 0 -80.34
gain 0 5 -78.62
gain 5 0 -78.56
gain 0 6 -85.98
gain 6 0 -87.32
gain 0 7 -89.50
gain 7 0 -90.94
gain 0 8 -87.98
gain 8 0 -91.27
gain 0 9 -87.39
gain 9 0 -95.08
gain 0 10 -91.14
[...50586 lines suppressed...]
noise 205 -107.32 4.00
noise 206 -103.93 4.00
noise 207 -103.67 4.00
noise 208 -104.88 4.00
noise 209 -103.33 4.00
noise 210 -103.77 4.00
noise 211 -107.35 4.00
noise 212 -104.40 4.00
noise 213 -102.55 4.00
noise 214 -99.68 4.00
noise 215 -102.74 4.00
noise 216 -102.16 4.00
noise 217 -102.66 4.00
noise 218 -107.37 4.00
noise 219 -105.53 4.00
noise 220 -109.69 4.00
noise 221 -104.91 4.00
noise 222 -107.83 4.00
noise 223 -103.71 4.00
noise 224 -102.76 4.00
More information about the Tinyos-2-commits
mailing list