From 310e2c03397186f878ac789d0edcc51df4af09a7 Mon Sep 17 00:00:00 2001 From: scipio Date: Sat, 7 Apr 2007 01:58:04 +0000 Subject: [PATCH] Move to be 119 compliant. --- tos/lib/net/SendVirtualizerP.nc | 192 +++++++++ tos/lib/net/lqi/CollectionC.nc | 77 ++-- tos/lib/net/lqi/CollectionSenderC.nc | 40 +- tos/lib/net/lqi/CollectionSenderP.nc | 61 +++ tos/lib/net/lqi/LQIMultiHopRouter.nc | 100 ----- tos/lib/net/lqi/LqiForwardingEngineP.nc | 395 ++++++++++++++++++ tos/lib/net/lqi/LqiRouteStats.nc | 32 ++ .../{MultiHopLQI.nc => LqiRoutingEngineP.nc} | 21 +- tos/lib/net/lqi/{MultiHop.h => MultiHopLqi.h} | 50 ++- tos/lib/net/lqi/MultiHopLqiP.nc | 133 ++++++ tos/lib/net/lqi/RouteControl.nc | 31 ++ tos/lib/net/lqi/RouteSelect.nc | 29 ++ 12 files changed, 1010 insertions(+), 151 deletions(-) create mode 100644 tos/lib/net/SendVirtualizerP.nc create mode 100644 tos/lib/net/lqi/CollectionSenderP.nc delete mode 100644 tos/lib/net/lqi/LQIMultiHopRouter.nc create mode 100644 tos/lib/net/lqi/LqiForwardingEngineP.nc rename tos/lib/net/lqi/{MultiHopLQI.nc => LqiRoutingEngineP.nc} (95%) rename tos/lib/net/lqi/{MultiHop.h => MultiHopLqi.h} (57%) create mode 100644 tos/lib/net/lqi/MultiHopLqiP.nc diff --git a/tos/lib/net/SendVirtualizerP.nc b/tos/lib/net/SendVirtualizerP.nc new file mode 100644 index 00000000..1e291bb3 --- /dev/null +++ b/tos/lib/net/SendVirtualizerP.nc @@ -0,0 +1,192 @@ +// $Id$ +/* +* "Copyright (c) 2005 Stanford University. All rights reserved. +* +* Permission to use, copy, modify, and distribute this software and +* its documentation for any purpose, without fee, and without written +* agreement is hereby granted, provided that the above copyright +* notice, the following two paragraphs and the author appear in all +* copies of this software. +* +* IN NO EVENT SHALL STANFORD UNIVERSITY BE LIABLE TO ANY PARTY FOR +* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES +* ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN +* IF STANFORD UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +* DAMAGE. +* +* STANFORD UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, +* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE +* PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND STANFORD UNIVERSITY +* HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, +* ENHANCEMENTS, OR MODIFICATIONS." +*/ + +/** + * A Send queue that provides a Service Instance pattern for formatted + * packets and calls an underlying Send in a round-robin fashion. Used + * to share L3 bandwidth between different communication clients. + * + * @author Philip Levis + * @date April 6 2007 + */ + +#include "AM.h" + +generic module SendVirtualizerP(int numClients) { + provides interface Send[uint8_t client]; + uses { + interface Send as SubSend; + interface Packet; + } +} + +implementation { + typedef struct { + message_t* msg; + } queue_entry_t; + + uint8_t current = numClients; // mark as empty + queue_entry_t queue[numClients]; + uint8_t cancelMask[numClients/8 + 1]; + + void tryToSend(); + + void nextPacket() { + uint8_t i; + current = (current + 1) % numClients; + for(i = 0; i < numClients; i++) { + if((queue[current].msg == NULL) || + (cancelMask[current/8] & (1 << current%8))) + { + current = (current + 1) % numClients; + } + else { + break; + } + } + if(i >= numClients) current = numClients; + } + + /** + * Accepts a properly formatted AM packet for later sending. + * Assumes that someone has filled in the AM packet fields + * (destination, AM type). + * + * @param msg - the message to send + * @param len - the length of the payload + * + */ + command error_t Send.send[uint8_t clientId](message_t* msg, + uint8_t len) { + if (clientId >= numClients) { + return FAIL; + } + if (queue[clientId].msg != NULL) { + return EBUSY; + } + dbg("AMQueue", "AMQueue: request to send from %hhu (%p): passed checks\n", clientId, msg); + + queue[clientId].msg = msg; + call Packet.setPayloadLength(msg, len); + + if (current >= numClients) { // queue empty + error_t err; + current = clientId; + + err = call SubSend.send(msg, len); + if (err != SUCCESS) { + dbg("AMQueue", "%s: underlying send failed.\n", __FUNCTION__); + current = numClients; + queue[clientId].msg = NULL; + } + return err; + } + else { + dbg("AMQueue", "AMQueue: request to send from %hhu (%p): queue not empty\n", clientId, msg); + } + return SUCCESS; + } + + task void CancelTask() { + uint8_t i,j,mask,last; + message_t *msg; + for(i = 0; i < numClients/8 + 1; i++) { + if(cancelMask[i]) { + for(mask = 1, j = 0; j < 8; j++) { + if(cancelMask[i] & mask) { + last = i*8 + j; + msg = queue[last].msg; + queue[last].msg = NULL; + cancelMask[i] &= ~mask; + signal Send.sendDone[last](msg, ECANCEL); + } + mask <<= 1; + } + } + } + } + + command error_t Send.cancel[uint8_t clientId](message_t* msg) { + if (clientId >= numClients || // Not a valid client + queue[clientId].msg == NULL || // No packet pending + queue[clientId].msg != msg) { // Not the right packet + return FAIL; + } + if(current == clientId) { + error_t err = call SubSend.cancel(msg); + return err; + } + else { + cancelMask[clientId/8] |= 1 << clientId % 8; + post CancelTask(); + return SUCCESS; + } + } + + void sendDone(uint8_t last, message_t *msg, error_t err) { + queue[last].msg = NULL; + tryToSend(); + signal Send.sendDone[last](msg, err); + } + + task void errorTask() { + sendDone(current, queue[current].msg, FAIL); + } + + // NOTE: Increments current! + void tryToSend() { + nextPacket(); + if (current < numClients) { // queue not empty + error_t nextErr; + message_t* nextMsg = queue[current].msg; + uint8_t len = call Packet.payloadLength(nextMsg); + nextErr = call SubSend.send(nextMsg, len); + if(nextErr != SUCCESS) { + post errorTask(); + } + } + } + + event void SubSend.sendDone(message_t* msg, error_t err) { + if(queue[current].msg == msg) { + sendDone(current, msg, err); + } + else { + dbg("PointerBug", "%s received send done for %p, signaling for %p.\n", + __FUNCTION__, msg, queue[current].msg); + } + } + + command uint8_t Send.maxPayloadLength[uint8_t id]() { + return call SubSend.maxPayloadLength(); + } + + command void* Send.getPayload[uint8_t id](message_t* m) { + return call SubSend.getPayload(m); + } + + default event void Send.sendDone[uint8_t id](message_t* msg, error_t err) { + // Do nothing + } +} diff --git a/tos/lib/net/lqi/CollectionC.nc b/tos/lib/net/lqi/CollectionC.nc index 554af6ab..88667c39 100644 --- a/tos/lib/net/lqi/CollectionC.nc +++ b/tos/lib/net/lqi/CollectionC.nc @@ -1,55 +1,68 @@ -/* tab:4 - * "Copyright (c) 2000-2003 The Regents of the University of California. +/* + * Copyright (c) 2006 Stanford University. * All rights reserved. * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - * - * Copyright (c) 2002-2003 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. + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. */ + /** - * @author Joe Polastre + * @author Philip Levis */ -#include "MultiHop.h" +#include "MultiHopLqi.h" configuration CollectionC { provides { interface StdControl; - interface Receive; - interface Send; + interface Send[uint8_t client]; + interface Receive[collection_id_t id]; + interface Receive as Snoop[collection_id_t]; + interface Intercept[collection_id_t id]; interface Packet; + interface CollectionPacket; interface RootControl; } } implementation { - components LQIMultiHopRouter as Router; - + components MultiHopLqiP as Router; + components new SendVirtualizerP(NUM_LQI_CLIENTS); + + Send = SendVirtualizerP; + SendVirtualizerP.SubSend -> Router.Send; + SendVirtualizerP.Packet -> Router; + StdControl = Router; - Receive = Router; - Send = Router; + Receive = Router.Receive; RootControl = Router; Packet = Router; + Snoop = Router.Snoop; + Intercept = Router.Intercept; + CollectionPacket = Router; } diff --git a/tos/lib/net/lqi/CollectionSenderC.nc b/tos/lib/net/lqi/CollectionSenderC.nc index c5ed5901..374d2e67 100644 --- a/tos/lib/net/lqi/CollectionSenderC.nc +++ b/tos/lib/net/lqi/CollectionSenderC.nc @@ -1,3 +1,33 @@ +/* + * Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ /** * The virtualized collection sender abstraction. * @@ -7,7 +37,7 @@ * @see TinyOS Net2-WG */ -#include +#include generic configuration CollectionSenderC(collection_id_t collectid) { provides { @@ -16,7 +46,9 @@ generic configuration CollectionSenderC(collection_id_t collectid) { } } implementation { - components CollectionC as Router; - Send = Router; - Packet = Router; + components new CollectionSenderP(collectid), CollectionC; + Send = CollectionSenderP; + Packet = CollectionC; + CollectionSenderP.SubSend -> CollectionC.Send[unique(UQ_LQI_CLIENT)]; + CollectionSenderP.CollectionPacket -> CollectionC; } diff --git a/tos/lib/net/lqi/CollectionSenderP.nc b/tos/lib/net/lqi/CollectionSenderP.nc new file mode 100644 index 00000000..708085ae --- /dev/null +++ b/tos/lib/net/lqi/CollectionSenderP.nc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ + +#include "Collection.h" + +generic module CollectionSenderP(collection_id_t collectid) { + provides interface Send; + uses interface Send as SubSend; + uses interface CollectionPacket; +} + +implementation { + command error_t Send.send(message_t* msg, uint8_t len) { + call CollectionPacket.setType(msg, collectid); + return call SubSend.send(msg, len); + } + + command error_t Send.cancel(message_t* msg) { + return call SubSend.cancel(msg); + } + + command void* Send.getPayload(message_t* m) { + return call SubSend.getPayload(m); + } + + command uint8_t Send.maxPayloadLength() { + return call SubSend.maxPayloadLength(); + } + + event void SubSend.sendDone(message_t* m, error_t err) { + signal Send.sendDone(m, err); + } +} diff --git a/tos/lib/net/lqi/LQIMultiHopRouter.nc b/tos/lib/net/lqi/LQIMultiHopRouter.nc deleted file mode 100644 index 28467f7a..00000000 --- a/tos/lib/net/lqi/LQIMultiHopRouter.nc +++ /dev/null @@ -1,100 +0,0 @@ -/* tab:4 - * "Copyright (c) 2000-2003 The Regents of the University of California. - * All rights reserved. - * - * Permission to use, copy, modify, and distribute this software and its - * documentation for any purpose, without fee, and without written agreement is - * hereby granted, provided that the above copyright notice, the following - * two paragraphs and the author appear in all copies of this software. - * - * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR - * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT - * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF - * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, - * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS - * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO - * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." - * - * Copyright (c) 2002-2003 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 Joe Polastre - */ - -#include "MultiHop.h" - -configuration LQIMultiHopRouter { - - provides { - interface StdControl; - interface Receive; - interface Send; - interface RouteControl; - interface LqiRouteStats; - interface Packet; - interface RootControl; - interface CollectionPacket; - } - -} - -implementation { - - components - MultiHopEngineM, - MultiHopLQI, - new AMSenderC(AM_BEACONMSG) as BeaconSender, - new AMReceiverC(AM_BEACONMSG) as BeaconReceiver, - new AMSenderC(AM_DATAMSG) as DataSender, - new AMReceiverC(AM_DATAMSG) as DataReceiver, - new TimerMilliC(), - NoLedsC, LedsC, - RandomC, - ActiveMessageC, - MainC; - - MainC.SoftwareInit -> MultiHopEngineM; - MainC.SoftwareInit -> MultiHopLQI; - - components CC2420ActiveMessageC as CC2420; - - StdControl = MultiHopLQI.StdControl; - - Receive = MultiHopEngineM; - Send = MultiHopEngineM; - RouteControl = MultiHopEngineM; - LqiRouteStats = MultiHopEngineM; - Packet = MultiHopEngineM; - CollectionPacket = MultiHopEngineM; - RootControl = MultiHopLQI; - - MultiHopEngineM.RouteSelectCntl -> MultiHopLQI.RouteControl; - MultiHopEngineM.RouteSelect -> MultiHopLQI; - MultiHopEngineM.SubSend -> DataSender; - MultiHopEngineM.SubReceive -> DataReceiver; - MultiHopEngineM.Leds -> LedsC; - MultiHopEngineM.AMPacket -> ActiveMessageC; - MultiHopEngineM.SubPacket -> ActiveMessageC; - MultiHopEngineM.PacketAcknowledgements -> ActiveMessageC; - MultiHopEngineM.RootControl -> MultiHopLQI; - - MultiHopLQI.AMSend -> BeaconSender; - MultiHopLQI.Receive -> BeaconReceiver; - MultiHopLQI.Random -> RandomC; - MultiHopLQI.Timer -> TimerMilliC; - MultiHopLQI.LqiRouteStats -> MultiHopEngineM; - MultiHopLQI.CC2420Packet -> CC2420; - MultiHopLQI.AMPacket -> ActiveMessageC; - MultiHopLQI.Packet -> ActiveMessageC; - MultiHopLQI.Leds -> NoLedsC; -} diff --git a/tos/lib/net/lqi/LqiForwardingEngineP.nc b/tos/lib/net/lqi/LqiForwardingEngineP.nc new file mode 100644 index 00000000..e3dc5d00 --- /dev/null +++ b/tos/lib/net/lqi/LqiForwardingEngineP.nc @@ -0,0 +1,395 @@ +// $Id$ + + +/* Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ + +/* tab:4 + * "Copyright (c) 2000-2003 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + * Copyright (c) 2002-2003 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. + */ + +/* + * A simple module that handles multihop packet movement. It accepts + * messages from both applications and the network and does the necessary + * interception and forwarding. + * It interfaces to an algorithmic componenet via RouteSelect. It also acts + * as a front end for RouteControl + */ + + +/** + * @author Philip Buonadonna + * @auihor Alec Woo + * @author Crossbow Inc. + * @author Philip Levis (port from TinyOS 1.x) + */ + +#include "AM.h" +#include "MultiHopLqi.h" + +module LqiForwardingEngineP { + provides { + interface Init; + interface Send; + interface Receive[collection_id_t id]; + interface Receive as Snoop[collection_id_t]; + interface Intercept[collection_id_t id]; + interface CollectionPacket; + interface RouteControl; + interface LqiRouteStats; + interface Packet; + } + uses { + interface Receive as SubReceive; + interface AMSend as SubSend; + interface RouteControl as RouteSelectCntl; + interface RouteSelect; + interface Leds; + interface Packet as SubPacket; + interface AMPacket; + interface RootControl; + interface PacketAcknowledgements; + } +} + +implementation { + + enum { + FWD_QUEUE_SIZE = MHOP_QUEUE_SIZE, // Forwarding Queue + EMPTY = 0xff + }; + + /* Internal storage and scheduling state */ + message_t FwdBuffers[FWD_QUEUE_SIZE]; + message_t *FwdBufList[FWD_QUEUE_SIZE]; + uint8_t FwdBufBusy[FWD_QUEUE_SIZE]; + uint8_t iFwdBufHead, iFwdBufTail; + uint16_t sendFailures = 0; + uint8_t fail_count = 0; + + lqi_header_t* getHeader(message_t* msg) { + return (lqi_header_t*) call SubPacket.getPayload(msg, NULL); + } + + /*********************************************************************** + * Initialization + ***********************************************************************/ + + + static void initialize() { + int n; + + for (n=0; n < FWD_QUEUE_SIZE; n++) { + FwdBufList[n] = &FwdBuffers[n]; + FwdBufBusy[n] = 0; + } + iFwdBufHead = iFwdBufTail = 0; + + sendFailures = 0; + } + + command error_t Init.init() { + initialize(); + return SUCCESS; + } + + + /*********************************************************************** + * Commands and events + ***********************************************************************/ + command error_t Send.send(message_t* pMsg, uint8_t len) { + len += sizeof(lqi_header_t); + if (len > call SubPacket.maxPayloadLength()) { + call Leds.led0On(); + return ESIZE; + } + if (call RootControl.isRoot()) { + call Leds.led1On(); + return FAIL; + } + call RouteSelect.initializeFields(pMsg); + + if (call RouteSelect.selectRoute(pMsg, 0) != SUCCESS) { + call Leds.led2On(); + return FAIL; + } + call PacketAcknowledgements.requestAck(pMsg); + if (call SubSend.send(call AMPacket.destination(pMsg), pMsg, len) != SUCCESS) { + sendFailures++; + return FAIL; + } + + return SUCCESS; + } + + int8_t get_buff(){ + uint8_t n; + for (n=0; n < FWD_QUEUE_SIZE; n++) { + uint8_t done = 0; + atomic{ + if(FwdBufBusy[n] == 0){ + FwdBufBusy[n] = 1; + done = 1; + } + } + if(done == 1) return n; + + } + return -1; + } + + int8_t is_ours(message_t* ptr){ + uint8_t n; + for (n=0; n < FWD_QUEUE_SIZE; n++) { + if(FwdBufList[n] == ptr){ + return n; + } + } + return -1; + } + + static message_t* mForward(message_t* msg) { + message_t* newMsg = msg; + int8_t buf = get_buff(); + call Leds.led2Toggle(); + + if (buf == -1) { + dbg("LQI", "Dropped packet due to no space in queue.\n"); + return msg; + } + + if ((call RouteSelect.selectRoute(msg, 0)) != SUCCESS) { + FwdBufBusy[(uint8_t)buf] = 0; + return msg; + } + + // Failures at the send level do not cause the seq. number space to be + // rolled back properly. This is somewhat broken. + call PacketAcknowledgements.requestAck(msg); + if (call SubSend.send(call AMPacket.destination(msg), + msg, + call SubPacket.payloadLength(msg) == SUCCESS)) { + newMsg = FwdBufList[(uint8_t)buf]; + FwdBufList[(uint8_t)buf] = msg; + } + else{ + FwdBufBusy[(uint8_t)buf] = 0; + sendFailures++; + } + return newMsg; + } + + event message_t* SubReceive.receive(message_t* msg, void* payload, uint8_t len) { + collection_id_t id = call CollectionPacket.getType(msg); + payload += sizeof(lqi_header_t); + len -= sizeof(lqi_header_t); + + if (call RootControl.isRoot()) { + return signal Receive.receive[id](msg, payload, len); + } + else if (signal Intercept.forward[id](msg, payload, len)) { + return mForward(msg); + } + else { + return msg; + } + } + + + event void SubSend.sendDone(message_t* msg, error_t success) { + int8_t buf; + if (!call PacketAcknowledgements.wasAcked(msg) && + call AMPacket.destination(msg) != TOS_BCAST_ADDR && + fail_count < 5){ + call RouteSelect.selectRoute(msg, 1); + if (call SubSend.send(call AMPacket.destination(msg), + msg, + call SubPacket.payloadLength(msg)) == SUCCESS) { + fail_count ++; + } else { + sendFailures++; + } + } + + fail_count = 0; + + buf = is_ours(msg); + + if (buf != -1) { // Msg was from forwarding queue + FwdBufBusy[(uint8_t)buf] = 0; + } else { + signal Send.sendDone(msg, success); + } + } + + + command uint16_t RouteControl.getParent() { + return call RouteSelectCntl.getParent(); + } + + command uint8_t RouteControl.getQuality() { + return call RouteSelectCntl.getQuality(); + } + + command uint8_t RouteControl.getDepth() { + return call RouteSelectCntl.getDepth(); + } + + command uint8_t RouteControl.getOccupancy() { + uint16_t uiOutstanding = (uint16_t)iFwdBufTail - (uint16_t)iFwdBufHead; + uiOutstanding %= FWD_QUEUE_SIZE; + return (uint8_t)uiOutstanding; + } + + + command error_t RouteControl.setUpdateInterval(uint16_t Interval) { + return call RouteSelectCntl.setUpdateInterval(Interval); + } + + command error_t RouteControl.manualUpdate() { + return call RouteSelectCntl.manualUpdate(); + } + + command uint16_t LqiRouteStats.getSendFailures() { + return sendFailures; + } + + command void Packet.clear(message_t* msg) { + + } + + command void* Send.getPayload(message_t* m) { + return call Packet.getPayload(m, NULL); + } + + command uint8_t Send.maxPayloadLength() { + return call Packet.maxPayloadLength(); + } + + command error_t Send.cancel(message_t* m) { + return FAIL; + } + + + command void* Receive.getPayload[collection_id_t id](message_t* msg, uint8_t* len) { + return call Packet.getPayload(msg, len); + } + + command uint8_t Receive.payloadLength[collection_id_t id](message_t* m) { + return call Packet.payloadLength(m); + } + + command void* Snoop.getPayload[collection_id_t id](message_t* msg, uint8_t* len) { + return call Packet.getPayload(msg, len); + } + + command uint8_t Snoop.payloadLength[collection_id_t id](message_t* m) { + return call Packet.payloadLength(m); + } + + command uint8_t Packet.payloadLength(message_t* msg) { + return call SubPacket.payloadLength(msg) - sizeof(lqi_header_t); + } + command void Packet.setPayloadLength(message_t* msg, uint8_t len) { + call SubPacket.setPayloadLength(msg, len + sizeof(lqi_header_t)); + } + command uint8_t Packet.maxPayloadLength() { + return (call SubPacket.maxPayloadLength() - sizeof(lqi_header_t)); + } + command void* Packet.getPayload(message_t* msg, uint8_t* len) { + void* rval = call SubPacket.getPayload(msg, len); + *len -= sizeof(lqi_header_t); + rval += sizeof(lqi_header_t); + return rval; + } + + command am_addr_t CollectionPacket.getOrigin(message_t* msg) { + lqi_header_t* hdr = getHeader(msg); + return hdr->originaddr; + } + + command void CollectionPacket.setOrigin(message_t* msg, am_addr_t addr) { + lqi_header_t* hdr = getHeader(msg); + hdr->originaddr = addr; + } + + command collection_id_t CollectionPacket.getType(message_t* msg) { + return getHeader(msg)->collectId; + } + + command void CollectionPacket.setType(message_t* msg, collection_id_t id) { + getHeader(msg)->collectId = id; + } + + command uint8_t CollectionPacket.getSequenceNumber(message_t* msg) { + lqi_header_t* hdr = getHeader(msg); + return hdr->originseqno; + } + + command void CollectionPacket.setSequenceNumber(message_t* msg, uint8_t seqno) { + lqi_header_t* hdr = getHeader(msg); + hdr->originseqno = seqno; + } + + default event void Send.sendDone(message_t* pMsg, error_t success) {} + default event message_t* Snoop.receive[collection_id_t id](message_t* pMsg, void* payload, uint8_t len) {return pMsg;} + default event message_t* Receive.receive[collection_id_t id](message_t* pMsg, void* payload, uint8_t len) { + return pMsg; + } + default event bool Intercept.forward[collection_id_t id](message_t* pMsg, void* payload, uint16_t len) { + return 1; + } +} + diff --git a/tos/lib/net/lqi/LqiRouteStats.nc b/tos/lib/net/lqi/LqiRouteStats.nc index 02cc56a6..c03f7fba 100644 --- a/tos/lib/net/lqi/LqiRouteStats.nc +++ b/tos/lib/net/lqi/LqiRouteStats.nc @@ -1,3 +1,34 @@ + +/* Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ + /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. @@ -32,6 +63,7 @@ /** * Provides information on how many send failures there have been. * @author Joe Polastre + * @author Philip Levis (port from TinyOS 1.x) */ diff --git a/tos/lib/net/lqi/MultiHopLQI.nc b/tos/lib/net/lqi/LqiRoutingEngineP.nc similarity index 95% rename from tos/lib/net/lqi/MultiHopLQI.nc rename to tos/lib/net/lqi/LqiRoutingEngineP.nc index f1c18dfb..8a099e88 100644 --- a/tos/lib/net/lqi/MultiHopLQI.nc +++ b/tos/lib/net/lqi/LqiRoutingEngineP.nc @@ -29,14 +29,16 @@ -/* - * Authors: Gilman Tolle +/** + * + * @author Gilman Tolle + * @author Philip Levis (port to TinyOS 2.x) */ -#include "MultiHop.h" +#include "MultiHopLqi.h" -module MultiHopLQI { +module LqiRoutingEngineP { provides { interface Init; @@ -105,13 +107,14 @@ implementation { lqi_header_t* getHeader(message_t* msg) { return (lqi_header_t*)call Packet.getPayload(msg, NULL); } - beacon_msg_t* getBeacon(message_t* msg) { - return (beacon_msg_t*)call Packet.getPayload(msg, NULL); + + lqi_beacon_msg_t* getBeacon(message_t* msg) { + return (lqi_beacon_msg_t*)call Packet.getPayload(msg, NULL); } task void SendRouteTask() { - beacon_msg_t* bMsg = getBeacon(&msgBuf); - uint8_t length = sizeof(beacon_msg_t); + lqi_beacon_msg_t* bMsg = getBeacon(&msgBuf); + uint8_t length = sizeof(lqi_beacon_msg_t); dbg("LQI","MultiHopRSSI Sending route update msg.\n"); @@ -324,7 +327,7 @@ implementation { return msg; } else { - beacon_msg_t* bMsg = (beacon_msg_t*)payload; + lqi_beacon_msg_t* bMsg = (lqi_beacon_msg_t*)payload; am_addr_t source = call AMPacket.source(msg); uint8_t lqi = call CC2420Packet.getLqi(msg); diff --git a/tos/lib/net/lqi/MultiHop.h b/tos/lib/net/lqi/MultiHopLqi.h similarity index 57% rename from tos/lib/net/lqi/MultiHop.h rename to tos/lib/net/lqi/MultiHopLqi.h index e1d2c765..a7d1e82a 100644 --- a/tos/lib/net/lqi/MultiHop.h +++ b/tos/lib/net/lqi/MultiHopLqi.h @@ -1,5 +1,36 @@ // $Id$ + +/* Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ + /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. @@ -38,6 +69,7 @@ /** * @author Philip Buonadonna + * @author Philip Levis (port from TinyOS 1.x) */ @@ -53,10 +85,15 @@ #endif #include "AM.h" +#include "Collection.h" + +#define UQ_LQI_CLIENT "LqiForwardingEngineP.Send" + enum { - AM_BEACONMSG = 250, - AM_DATAMSG = 251, - AM_DEBUGPACKET = 3 + AM_LQI_BEACON_MSG = 250, + AM_LQI_DATA_MSG = 251, + AM_LQI_DEBUG_PACKET = 3, + NUM_LQI_CLIENTS = uniqueCount(UQ_LQI_CLIENT), }; /* Fields of neighbor table */ @@ -69,21 +106,22 @@ typedef struct TOS_MHopNeighbor { uint8_t timeouts; // since last recv } TOS_MHopNeighbor; -typedef nx_struct lqi_header { +typedef nx_struct lqi_data_msg { nx_uint16_t originaddr; nx_int16_t seqno; nx_int16_t originseqno; nx_uint16_t hopcount; + nx_collection_id_t collectId; } lqi_header_t; -typedef nx_struct beacon_msg { +typedef nx_struct lqi_beacon_msg { nx_uint16_t originaddr; nx_int16_t seqno; nx_int16_t originseqno; nx_uint16_t parent; nx_uint16_t cost; nx_uint16_t hopcount; -} beacon_msg_t; +} lqi_beacon_msg_t; typedef struct DBGEstEntry { uint16_t id; diff --git a/tos/lib/net/lqi/MultiHopLqiP.nc b/tos/lib/net/lqi/MultiHopLqiP.nc new file mode 100644 index 00000000..4b84194a --- /dev/null +++ b/tos/lib/net/lqi/MultiHopLqiP.nc @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ +/* tab:4 + * "Copyright (c) 2000-2003 The Regents of the University of California. + * All rights reserved. + * + * Permission to use, copy, modify, and distribute this software and its + * documentation for any purpose, without fee, and without written agreement is + * hereby granted, provided that the above copyright notice, the following + * two paragraphs and the author appear in all copies of this software. + * + * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR + * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT + * OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF + * CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS + * ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO + * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS." + * + * Copyright (c) 2002-2003 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 Joe Polastre + * @author Philip Levis (port to TinyOS 2.x) + */ + +#include "MultiHopLqi.h" + +configuration MultiHopLqiP { + provides { + interface StdControl; + interface Send; + interface Receive[collection_id_t id]; + interface Receive as Snoop[collection_id_t]; + interface Intercept[collection_id_t id]; + interface RouteControl; + interface LqiRouteStats; + interface Packet; + interface RootControl; + interface CollectionPacket; + } + +} + +implementation { + + components LqiForwardingEngineP as Forwarder, LqiRoutingEngineP as Router; + components + new AMSenderC(AM_LQI_BEACON_MSG) as BeaconSender, + new AMReceiverC(AM_LQI_BEACON_MSG) as BeaconReceiver, + new AMSenderC(AM_LQI_DATA_MSG) as DataSender, + new AMReceiverC(AM_LQI_DATA_MSG) as DataReceiver, + new TimerMilliC(), + NoLedsC, LedsC, + RandomC, + ActiveMessageC, + MainC; + + MainC.SoftwareInit -> Forwarder; + MainC.SoftwareInit -> Router; + + components CC2420ActiveMessageC as CC2420; + + StdControl = Router.StdControl; + + Receive = Forwarder.Receive; + Send = Forwarder; + Intercept = Forwarder.Intercept; + Snoop = Forwarder.Snoop; + RouteControl = Forwarder; + LqiRouteStats = Forwarder; + Packet = Forwarder; + CollectionPacket = Forwarder; + RootControl = Router; + + Forwarder.RouteSelectCntl -> Router.RouteControl; + Forwarder.RouteSelect -> Router; + Forwarder.SubSend -> DataSender; + Forwarder.SubReceive -> DataReceiver; + Forwarder.Leds -> LedsC; + Forwarder.AMPacket -> ActiveMessageC; + Forwarder.SubPacket -> ActiveMessageC; + Forwarder.PacketAcknowledgements -> ActiveMessageC; + Forwarder.RootControl -> Router; + + Router.AMSend -> BeaconSender; + Router.Receive -> BeaconReceiver; + Router.Random -> RandomC; + Router.Timer -> TimerMilliC; + Router.LqiRouteStats -> Forwarder; + Router.CC2420Packet -> CC2420; + Router.AMPacket -> ActiveMessageC; + Router.Packet -> ActiveMessageC; + Router.Leds -> NoLedsC; +} diff --git a/tos/lib/net/lqi/RouteControl.nc b/tos/lib/net/lqi/RouteControl.nc index fecba989..4345af03 100644 --- a/tos/lib/net/lqi/RouteControl.nc +++ b/tos/lib/net/lqi/RouteControl.nc @@ -1,5 +1,35 @@ // $Id$ +/* + * Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. @@ -37,6 +67,7 @@ /** * Control/Monitor interface to a routing component * @author Phil Buonadonna + * @author Philip Levis (port from TinyOS 1.x) */ interface RouteControl { diff --git a/tos/lib/net/lqi/RouteSelect.nc b/tos/lib/net/lqi/RouteSelect.nc index ab63783a..db69a35e 100644 --- a/tos/lib/net/lqi/RouteSelect.nc +++ b/tos/lib/net/lqi/RouteSelect.nc @@ -1,5 +1,34 @@ // $Id$ +/* Copyright (c) 2007 Stanford University. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * - 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. + * - Neither the name of the Stanford University 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 COPYRIGHT HOLDERS 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 STANFORD + * UNIVERSITY OR ITS 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. + */ /* tab:4 * "Copyright (c) 2000-2003 The Regents of the University of California. * All rights reserved. -- 2.39.2