[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250/mac
SpeckMacDP.nc, NONE, 1.1 SpeckMacDC.nc, NONE,
1.1 DuplicateP.nc, NONE, 1.1 DuplicateC.nc, NONE,
1.1 Duplicate.nc, NONE, 1.1 Duplicate.h, NONE, 1.1 RedMacP.nc,
1.12, 1.13 RedMacC.nc, 1.6, 1.7 CsmaMacP.nc, 1.12,
1.13 CsmaMacC.nc, 1.5, 1.6
akoepke
andreaskoepke at users.sourceforge.net
Mon Oct 1 08:49:02 PDT 2007
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/eyesIFX
LocalTimeP.nc, NONE, 1.1 LocalTimeC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250/mac
TimeDiffC.nc, NONE, 1.1 TimeDiff32.nc, NONE, 1.1 TimeDiff16.nc,
NONE, 1.1 TimeDiff.nc, NONE, 1.1 SpeckMacDP.nc, 1.1,
1.2 SpeckMacDC.nc, 1.1, 1.2 RedMacP.nc, 1.13, 1.14 RedMacC.nc,
1.7, 1.8 CsmaMacP.nc, 1.13, 1.14 CsmaMacC.nc, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31502/chips/tda5250/mac
Modified Files:
RedMacP.nc RedMacC.nc CsmaMacP.nc CsmaMacC.nc
Added Files:
SpeckMacDP.nc SpeckMacDC.nc DuplicateP.nc DuplicateC.nc
Duplicate.nc Duplicate.h
Log Message:
added SpeckMac
refactor MAC protocols:
- separate duplicate suppression component
- separate LocalTime component
--- NEW FILE: SpeckMacDP.nc ---
/* -*- mode:c++; indent-tabs-mode: nil -*-
* Copyright (c) 2006, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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
[...1190 lines suppressed...]
}
else if(ms == INIT) {
// sdDebug(301);
call ChannelMonitorControl.updateNoiseFloor();
}
else {
// sdDebug(302);
post ReleaseAdcTask();
}
}
default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
/***** unused Radio Modes events **************************/
async event void RadioModes.TimerModeDone() {}
async event void RadioModes.SelfPollingModeDone() {}
async event void RadioModes.PWDDDInterrupt() {}
}
--- NEW FILE: SpeckMacDC.nc ---
/* -*- mode:c++; indent-tabs-mode:nil -*-
* Copyright (c) 2006, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 THE COPYRIGHT
* OWNER 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.
*
* - Description ---------------------------------------------------------
* low power nonpersistent CSMA MAC, rendez-vous via redundantly sent packets
* - Author --------------------------------------------------------------
* @author: Andreas Koepke (koepke at tkn.tu-berlin.de)
* ========================================================================
*/
// #define SPECKMAC_DEBUG
#ifdef SPECKMAC_PERFORMANCE
#include <Performance.h>
#endif
configuration SpeckMacDC {
provides {
interface SplitControl;
interface MacSend;
interface MacReceive;
interface Packet;
interface Sleeptime;
interface ChannelCongestion;
}
uses {
interface PhySend as PacketSend;
interface PhyReceive as PacketReceive;
interface Packet as SubPacket;
interface Tda5250Control;
interface UartPhyControl;
interface RadioTimeStamping;
}
}
implementation {
components MainC,
SpeckMacDP,
RssiFixedThresholdCMC as Cca,
new Alarm32khz16C() as Timer,
new Alarm32khz16C() as SampleTimer,
RandomLfsrC,
LocalTimeC, DuplicateC;
components ActiveMessageAddressC;
SpeckMacDP.amAddress -> ActiveMessageAddressC;
MainC.SoftwareInit -> SpeckMacDP;
SplitControl = SpeckMacDP;
MacSend = SpeckMacDP;
MacReceive = SpeckMacDP;
Tda5250Control = SpeckMacDP;
UartPhyControl = SpeckMacDP;
RadioTimeStamping = SpeckMacDP;
ChannelCongestion = SpeckMacDP;
SpeckMacDP = PacketSend;
SpeckMacDP = PacketReceive;
SpeckMacDP = SubPacket;
SpeckMacDP = Packet;
SpeckMacDP = Sleeptime;
SpeckMacDP.CcaStdControl -> Cca.StdControl;
SpeckMacDP.ChannelMonitor -> Cca.ChannelMonitor;
SpeckMacDP.ChannelMonitorData -> Cca.ChannelMonitorData;
SpeckMacDP.ChannelMonitorControl -> Cca.ChannelMonitorControl;
SpeckMacDP.RssiAdcResource -> Cca.RssiAdcResource;
MainC.SoftwareInit -> RandomLfsrC;
SpeckMacDP.Random -> RandomLfsrC;
SpeckMacDP.Timer -> Timer;
SpeckMacDP.SampleTimer -> SampleTimer;
SpeckMacDP.LocalTime32kHz -> LocalTimeC;
SpeckMacDP.Duplicate -> DuplicateC;
/* components PlatformLedsC;
SpeckMacDP.Led0 -> PlatformLedsC.Led0;
SpeckMacDP.Led1 -> PlatformLedsC.Led1;
SpeckMacDP.Led2 -> PlatformLedsC.Led2;
SpeckMacDP.Led3 -> PlatformLedsC.Led3;
*/
#ifdef SPECKMAC_DEBUG
components new SerialDebugC() as SD;
SpeckMacDP.SerialDebug -> SD;
#endif
#ifdef SPECKMAC_PERFORMANCE
components new PerformanceC() as Perf;
SpeckMacDP.Performance -> Perf;
#endif
}
--- NEW FILE: DuplicateP.nc ---
/* -*- mode:c++; indent-tabs-mode:nil -*-
* Copyright (c) 2007, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 THE COPYRIGHT
* OWNER 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.
*/
/**
* Helper component for MAC protocols to suppress duplicates
* To do: turn it into a generic?
* @author: Andreas Koepke (koepke at tkn.tu-berlin.de)
*/
module DuplicateP {
provides {
interface Duplicate;
interface Init;
}
uses {
interface Timer<TMilli> as Timer;
}
}
implementation {
known_t knownTable[TABLE_ENTRIES];
/** helper functions */
task void ageMsgsTask() {
unsigned i;
for(i = 0; i < TABLE_ENTRIES; i++) {
atomic {
if(knownTable[i].age < MAX_AGE) ++knownTable[i].age;
}
}
}
unsigned findOldest() {
unsigned i;
unsigned oldIndex = 0;
unsigned age = knownTable[oldIndex].age;
for(i = 1; i < TABLE_ENTRIES; i++) {
if(age < knownTable[i].age) {
oldIndex = i;
age = knownTable[i].age;
}
}
return oldIndex;
}
/*** duplicate interface */
async command bool Duplicate.isNew(am_addr_t src, uint8_t seqno) {
bool rVal = TRUE;
unsigned i;
for(i=0; i < TABLE_ENTRIES; i++) {
if((knownTable[i].age < MAX_AGE) &&
(src == knownTable[i].src) &&
(seqno == knownTable[i].seqno)) {
knownTable[i].age = 0;
rVal = FALSE;
break;
}
}
return rVal;
}
async command void Duplicate.remember(am_addr_t src, uint8_t seqno) {
unsigned oldest = findOldest();
knownTable[oldest].src = src;
knownTable[oldest].seqno = seqno;
knownTable[oldest].age = 0;
}
/** helper interfaces */
event void Timer.fired() {
post ageMsgsTask();
}
command error_t Init.init(){
uint8_t i;
for(i = 0; i < TABLE_ENTRIES; i++) {
atomic {
knownTable[i].age = MAX_AGE;
}
}
call Timer.startPeriodic(AGE_INTERVALL);
return SUCCESS;
}
}
--- NEW FILE: DuplicateC.nc ---
/* -*- mode:c++; indent-tabs-mode:nil -*-
* Copyright (c) 2007, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 THE COPYRIGHT
* OWNER 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.
*/
/**
* Helper component for MAC protocols to suppress duplicates
* To do: turn it into a generic?
* @author: Andreas Koepke (koepke at tkn.tu-berlin.de)
*/
#include "Duplicate.h"
configuration DuplicateC {
provides {
interface Duplicate;
}
}
implementation {
components MainC;
components new TimerMilliC() as Timer;
components DuplicateP;
Duplicate = DuplicateP;
DuplicateP.Timer -> Timer; // make information soft state
MainC.SoftwareInit -> DuplicateP;
}
--- NEW FILE: Duplicate.nc ---
/* -*- mode:c++; indent-tabs-mode: nil -*-
* Copyright (c) 2007, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 THE COPYRIGHT
* OWNER 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.
*
*/
/**
* Keep information for the MAC protocols to suppress duplicates.
* @author Andreas Koepke (koepke at tkn.tu-berlin.de)
*/
interface Duplicate {
/** check whether this message is a new message, does not store anything */
async command bool isNew(am_addr_t src, uint8_t seqno);
/** remember the fingerprint of this message, stores/updates the information */
async command void remember(am_addr_t src, uint8_t seqno);
}
--- NEW FILE: Duplicate.h ---
/* -*- mode:c++; indent-tabs-mode: nil -*-
* Copyright (c) 2007, Technische Universitaet Berlin
* 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 Technische Universitaet Berlin 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 THE COPYRIGHT
* OWNER 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.
*/
/**
* constants and definitions for duplicate detector
* @author: Andreas Koepke (koepke at tkn.tu-berlin.de)
*/
#ifndef DUPLICATE_H
#define DUPLICATE_H
typedef struct known_t {
am_addr_t src;
uint8_t seqno;
uint8_t age;
} known_t;
enum {
TABLE_ENTRIES=16,
MAX_AGE=0xff,
AGE_INTERVALL = 1024, // every second increase the age of the messages
};
#endif
Index: RedMacP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/RedMacP.nc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** RedMacP.nc 29 Aug 2007 14:22:50 -0000 1.12
--- RedMacP.nc 1 Oct 2007 15:48:59 -0000 1.13
***************
*** 47,51 ****
interface MacReceive;
interface Packet;
- interface LocalTime<T32khz> as LocalTime32khz;
interface Sleeptime;
interface Teamgeist;
--- 47,50 ----
***************
*** 73,77 ****
interface Alarm<T32khz, uint16_t> as Timer;
interface Alarm<T32khz, uint16_t> as SampleTimer;
! interface Counter<T32khz,uint16_t> as Counter32khz16;
async command am_addr_t amAddress();
/*
--- 72,79 ----
interface Alarm<T32khz, uint16_t> as Timer;
interface Alarm<T32khz, uint16_t> as SampleTimer;
! interface LocalTime<T32khz> as LocalTime32kHz;
!
! interface Duplicate;
!
async command am_addr_t amAddress();
/*
***************
*** 138,143 ****
// DEFAULT_SLEEP_TIME=6500,
// DEFAULT_SLEEP_TIME=8192,
! DEFAULT_SLEEP_TIME=16384,
! // DEFAULT_SLEEP_TIME=32768U,
// DEFAULT_SLEEP_TIME=65535U,
DATA_DETECT_TIME=17,
--- 140,145 ----
// DEFAULT_SLEEP_TIME=6500,
// DEFAULT_SLEEP_TIME=8192,
! // DEFAULT_SLEEP_TIME=16384,
! DEFAULT_SLEEP_TIME=32768U,
// DEFAULT_SLEEP_TIME=65535U,
DATA_DETECT_TIME=17,
***************
*** 151,156 ****
MAX_SHORT_RETRY=9,
MAX_LONG_RETRY=3,
- MAX_AGE=0xff,
- MSG_TABLE_ENTRIES=16,
TOKEN_ACK_FLAG = 64,
TOKEN_ACK_MASK = 0x3f,
--- 153,156 ----
***************
*** 163,175 ****
/**************** Module Global Variables *****************/
- typedef union
- {
- uint32_t op;
- struct {
- uint16_t lo;
- uint16_t hi;
- };
- } ui32parts_t;
-
/* flags */
typedef enum {
--- 163,166 ----
***************
*** 184,195 ****
} flags_t;
- /* duplicate suppression */
- typedef struct knownMessage_t {
- am_addr_t src;
- uint8_t token;
- uint8_t age;
- } knownMessage_t;
-
- knownMessage_t knownMsgTable[MSG_TABLE_ENTRIES];
uint8_t flags = 0;
uint8_t checkCounter = 0;
--- 175,178 ----
***************
*** 200,205 ****
uint16_t rssiValue = 0;
uint32_t restLaufzeit = 0;
!
! uint16_t counter2sec = 127;
uint32_t rxTime = 0;
--- 183,187 ----
uint16_t rssiValue = 0;
uint32_t restLaufzeit = 0;
!
uint32_t rxTime = 0;
***************
*** 216,236 ****
uint16_t MIN_BACKOFF_MASK;
- #ifdef REDMAC_DEBUG
- uint8_t dupOldest;
- task void dumpLast() {
- knownMessage_t mem;
- unsigned i;
- atomic {
- i = dupOldest;
- mem = knownMsgTable[i];
- }
- sdDebug(5000);
- sdDebug(i);
- sdDebug(mem.src);
- sdDebug(mem.token);
- sdDebug(mem.age);
- }
- #endif
-
/****** Secure switching of radio modes ***/
void interruptBackoffTimer();
--- 198,201 ----
***************
*** 320,333 ****
}
! /**************** Helper functions ************************/
! task void ageMsgsTask() {
! unsigned i;
! atomic {
! for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
! if(knownMsgTable[i].age < MAX_AGE) ++knownMsgTable[i].age;
! }
! }
! }
!
void computeBackoff();
--- 285,289 ----
}
! /**************** Helper functions ************************/
void computeBackoff();
***************
*** 403,407 ****
}
if(msg == NULL) return;
! macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, NULL);
macHdr->repetitionCounter = sT/(length * BYTE_TIME + SUB_HEADER_TIME + SUB_FOOTER_TIME +
TX_GAP_TIME) + 1;
--- 359,363 ----
}
if(msg == NULL) return;
! macHdr = (red_mac_header_t *)call SubPacket.getPayload(msg, sizeof(red_mac_header_t) + length);
macHdr->repetitionCounter = sT/(length * BYTE_TIME + SUB_HEADER_TIME + SUB_FOOTER_TIME +
TX_GAP_TIME) + 1;
***************
*** 436,439 ****
--- 392,409 ----
}
+ void storeStrength(message_t *m) {
+ if(rssiValue != INVALID_SNR) {
+ (getMetadata(txBufPtr))->strength = rssiValue;
+ }
+ else {
+ if(call RssiAdcResource.isOwner()) {
+ (getMetadata(txBufPtr))->strength = call ChannelMonitorData.readSnr();
+ }
+ else {
+ (getMetadata(txBufPtr))->strength = 1;
+ }
+ }
+ }
+
bool prepareRepetition() {
bool repeat;
***************
*** 449,453 ****
return repeat;
}
!
void signalSendDone(error_t error) {
message_t *m;
--- 419,423 ----
return repeat;
}
!
void signalSendDone(error_t error) {
message_t *m;
***************
*** 465,474 ****
longRetryCounter = 0;
shortRetryCounter = 0;
! if(rssiValue != INVALID_SNR) {
! (getMetadata(m))->strength = rssiValue;
! }
! else {
! (getMetadata(m))->strength = call ChannelMonitorData.readSnr();
! }
if(isFlagSet(&flags, CANCEL_SEND)) {
e = ECANCEL;
--- 435,439 ----
longRetryCounter = 0;
shortRetryCounter = 0;
! storeStrength(m);
if(isFlagSet(&flags, CANCEL_SEND)) {
e = ECANCEL;
***************
*** 560,599 ****
bool isNewMsg(message_t* msg) {
! bool rVal = TRUE;
! uint8_t i;
! for(i=0; i < MSG_TABLE_ENTRIES; i++) {
! if((knownMsgTable[i].age < MAX_AGE) &&
! (getHeader(msg)->src == knownMsgTable[i].src) &&
! (((getHeader(msg)->token) & TOKEN_ACK_MASK) == knownMsgTable[i].token)) {
! knownMsgTable[i].age = 0;
! rVal = FALSE;
! break;
! }
! }
! return rVal;
! }
!
! unsigned findOldest() {
! unsigned i;
! unsigned oldIndex = 0;
! unsigned age = knownMsgTable[oldIndex].age;
! for(i = 1; i < MSG_TABLE_ENTRIES; i++) {
! if(age < knownMsgTable[i].age) {
! oldIndex = i;
! age = knownMsgTable[i].age;
! }
! }
! return oldIndex;
! }
void rememberMsg(message_t* msg) {
! unsigned oldest = findOldest();
! knownMsgTable[oldest].src = getHeader(msg)->src;
! knownMsgTable[oldest].token = (getHeader(msg)->token) & TOKEN_ACK_MASK;
! knownMsgTable[oldest].age = 0;
! #ifdef REDMAC_DEBUG
! dupOldest = oldest;
! post dumpLast();
! #endif
}
--- 525,533 ----
bool isNewMsg(message_t* msg) {
! return call Duplicate.isNew(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
! }
void rememberMsg(message_t* msg) {
! call Duplicate.remember(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
}
***************
*** 606,610 ****
getHeader(&ackMsg)->type = getHeader(msg)->type;
#ifdef REDMAC_DEBUG
! repCounter = ((red_mac_header_t *)call SubPacket.getPayload(msg, NULL))->repetitionCounter;
#endif
}
--- 540,545 ----
getHeader(&ackMsg)->type = getHeader(msg)->type;
#ifdef REDMAC_DEBUG
! repCounter = ((red_mac_header_t *)
! call SubPacket.getPayload(msg, sizeof(red_mac_header_t)))->repetitionCounter;
#endif
}
***************
*** 613,627 ****
return rxTime - m->time - TIME_CORRECTION;
}
-
/**************** Init ************************/
command error_t Init.init(){
- uint8_t i;
atomic {
macState = INIT;
seqNo = call Random.rand16() % TOKEN_ACK_FLAG;
- for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
- knownMsgTable[i].age = MAX_AGE;
- }
for(MIN_BACKOFF_MASK = 1; MIN_BACKOFF_MASK < networkSleeptime; ) {
MIN_BACKOFF_MASK = (MIN_BACKOFF_MASK << 1) + 1;
--- 548,557 ----
***************
*** 699,707 ****
}
! command void* Packet.getPayload(message_t* msg, uint8_t* len) {
! nx_uint8_t *payload = (nx_uint8_t *)call SubPacket.getPayload(msg, len);
! if (len != NULL) {
! *len -= sizeof(red_mac_header_t);
! }
return (void*)(payload + sizeof(red_mac_header_t));
}
--- 629,634 ----
}
! command void* Packet.getPayload(message_t* msg, uint8_t len) {
! nx_uint8_t *payload = (nx_uint8_t *)call SubPacket.getPayload(msg, len + sizeof(red_mac_header_t));
return (void*)(payload + sizeof(red_mac_header_t));
}
***************
*** 829,833 ****
#ifdef REDMAC_PERFORMANCE
txStat.payloadLength = txLen;
! txStat.interfaceTime = call LocalTime32khz.get();
#endif
}
--- 756,760 ----
#ifdef REDMAC_PERFORMANCE
txStat.payloadLength = txLen;
! txStat.interfaceTime = call LocalTime32kHz.get();
#endif
}
***************
*** 908,912 ****
// sdDebug(191);
if(error == SUCCESS) {
- post ageMsgsTask();
// sdDebug(192);
isCnt = isControl(msg);
--- 835,838 ----
***************
*** 919,933 ****
#endif
// sdDebug(194);
! if(rssiValue != INVALID_SNR) {
! (getMetadata(m))->strength = rssiValue;
! }
! else {
! if(call RssiAdcResource.isOwner()) {
! (getMetadata(m))->strength = call ChannelMonitorData.readSnr();
! }
! else {
! (getMetadata(m))->strength = 1;
! }
! }
getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload);
getMetadata(msg)->ack = WAS_NOT_ACKED;
--- 845,849 ----
#endif
// sdDebug(194);
! storeStrength(msg);
getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload);
getMetadata(msg)->ack = WAS_NOT_ACKED;
***************
*** 990,1004 ****
if(ackIsForMe(msg)) {
// sdDebug(202);
- if(rssiValue != INVALID_SNR) {
- (getMetadata(txBufPtr))->strength = rssiValue;
- }
- else {
- if(call RssiAdcResource.isOwner()) {
- (getMetadata(txBufPtr))->strength = call ChannelMonitorData.readSnr();
- }
- else {
- (getMetadata(txBufPtr))->strength = 1;
- }
- }
getMetadata(txBufPtr)->ack = WAS_ACKED;
getMetadata(txBufPtr)->repetitions = txMacHdr->repetitionCounter;
--- 906,909 ----
***************
*** 1113,1117 ****
if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
if(macState == RX_P) {
! rxTime = call LocalTime32khz.get();
call ChannelMonitor.rxSuccess();
}
--- 1018,1022 ----
if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
if(macState == RX_P) {
! rxTime = call LocalTime32kHz.get();
call ChannelMonitor.rxSuccess();
}
***************
*** 1122,1126 ****
uint32_t mTime;
if((macState == TX) && (p_msg == txBufPtr)) {
! now = call LocalTime32khz.get();
mTime = getMetadata(p_msg)->time;
if(now >= mTime) {
--- 1027,1031 ----
uint32_t mTime;
if((macState == TX) && (p_msg == txBufPtr)) {
! now = call LocalTime32kHz.get();
mTime = getMetadata(p_msg)->time;
if(now >= mTime) {
***************
*** 1134,1152 ****
}
- async command uint32_t LocalTime32khz.get() {
- ui32parts_t time;
- atomic {
- time.lo = call Counter32khz16.get();
- time.hi = counter2sec;
- if(call Counter32khz16.isOverflowPending()) ++time.hi;
- }
- return time.op;
- }
-
- async event void Counter32khz16.overflow() {
- ++counter2sec;
- }
-
-
/****** Timer ******************************/
--- 1039,1042 ----
***************
*** 1195,1199 ****
#ifdef REDMAC_PERFORMANCE
call Performance.macIdleOnCca();
! txStat.txModeTime = call LocalTime32khz.get();
#endif
}
--- 1085,1089 ----
#ifdef REDMAC_PERFORMANCE
call Performance.macIdleOnCca();
! txStat.txModeTime = call LocalTime32kHz.get();
#endif
}
***************
*** 1295,1299 ****
call Timer.stop();
}
- post ageMsgsTask();
}
--- 1185,1188 ----
Index: RedMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/RedMacC.nc,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** RedMacC.nc 30 Apr 2007 11:03:26 -0000 1.6
--- RedMacC.nc 1 Oct 2007 15:48:59 -0000 1.7
***************
*** 46,50 ****
interface MacReceive;
interface Packet;
- interface LocalTime<T32khz> as LocalTime;
interface Sleeptime;
interface ChannelCongestion;
--- 46,49 ----
***************
*** 65,70 ****
new Alarm32khz16C() as Timer,
new Alarm32khz16C() as SampleTimer,
! RandomLfsrC,
! Counter32khz16C as Counter;
components ActiveMessageAddressC;
--- 64,68 ----
new Alarm32khz16C() as Timer,
new Alarm32khz16C() as SampleTimer,
! RandomLfsrC, LocalTimeC, DuplicateC;
components ActiveMessageAddressC;
***************
*** 79,83 ****
UartPhyControl = RedMacP;
RadioTimeStamping = RedMacP;
- LocalTime = RedMacP;
ChannelCongestion = RedMacP;
--- 77,80 ----
***************
*** 99,103 ****
RedMacP.Timer -> Timer;
RedMacP.SampleTimer -> SampleTimer;
! RedMacP.Counter32khz16 -> Counter;
/* components PlatformLedsC;
--- 96,102 ----
RedMacP.Timer -> Timer;
RedMacP.SampleTimer -> SampleTimer;
! RedMacP.LocalTime32kHz -> LocalTimeC;
!
! RedMacP.Duplicate -> DuplicateC;
/* components PlatformLedsC;
Index: CsmaMacP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/CsmaMacP.nc,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** CsmaMacP.nc 13 Sep 2007 23:10:16 -0000 1.12
--- CsmaMacP.nc 1 Oct 2007 15:48:59 -0000 1.13
***************
*** 72,75 ****
--- 72,76 ----
interface Timer<TMilli> as ReRxTimer;
+ interface Duplicate;
interface Alarm<T32khz, uint16_t> as Timer;
***************
*** 107,113 ****
TOKEN_ACK_FLAG = 64,
TOKEN_ACK_MASK = 0x3f,
! INVALID_SNR = 0xffff,
! MSG_TABLE_ENTRIES=16,
! MAX_AGE=0xff
};
--- 108,112 ----
TOKEN_ACK_FLAG = 64,
TOKEN_ACK_MASK = 0x3f,
! INVALID_SNR = 0xffff
};
***************
*** 155,176 ****
uint16_t restLaufzeit;
! /* duplicate suppression */
! typedef struct knownMessage_t {
! am_addr_t src;
! uint8_t token;
! uint8_t age;
! } knownMessage_t;
- knownMessage_t knownMsgTable[MSG_TABLE_ENTRIES];
-
- task void ageMsgsTask() {
- unsigned i;
- atomic {
- for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
- if(knownMsgTable[i].age < MAX_AGE) ++knownMsgTable[i].age;
- }
- }
- }
-
/****** debug vars & defs & functions ***********************/
#ifdef MACM_DEBUG
--- 154,159 ----
uint16_t restLaufzeit;
! uint16_t rssiValue = 0;
/****** debug vars & defs & functions ***********************/
#ifdef MACM_DEBUG
***************
*** 275,278 ****
--- 258,262 ----
void setRxMode() {
+ rssiValue = INVALID_SNR;
if(call RadioModes.RxMode() == FAIL) {
post SetRxModeTask();
***************
*** 337,341 ****
}
}
!
void signalSendDone(error_t error) {
message_t *m;
--- 321,339 ----
}
}
!
! void storeStrength(message_t *m) {
! if(rssiValue != INVALID_SNR) {
! (getMetadata(m))->strength = rssiValue;
! }
! else {
! if(call RssiAdcResource.isOwner()) {
! (getMetadata(m))->strength = call ChannelMonitorData.readSnr();
! }
! else {
! (getMetadata(m))->strength = 1;
! }
! }
! }
!
void signalSendDone(error_t error) {
message_t *m;
***************
*** 350,353 ****
--- 348,352 ----
e = ECANCEL;
}
+ storeStrength(m);
clearFlag(&flags, CANCEL_SEND);
}
***************
*** 387,420 ****
bool isNewMsg(message_t* msg) {
! uint8_t i;
! for(i=0; i < MSG_TABLE_ENTRIES; i++) {
! if((getHeader(msg)->src == knownMsgTable[i].src) &&
! (((getHeader(msg)->token) & TOKEN_ACK_MASK) == knownMsgTable[i].token) &&
! (knownMsgTable[i].age < MAX_AGE)) {
! knownMsgTable[i].age = 0;
! return FALSE;
! }
! }
! return TRUE;
! }
!
! unsigned findOldest() {
! unsigned i;
! unsigned oldIndex = 0;
! unsigned age = knownMsgTable[oldIndex].age;
! for(i = 1; i < MSG_TABLE_ENTRIES; i++) {
! if(age < knownMsgTable[i].age) {
! oldIndex = i;
! age = knownMsgTable[i].age;
! }
! }
! return oldIndex;
}
void rememberMsg(message_t* msg) {
! unsigned oldest = findOldest();
! knownMsgTable[oldest].src = getHeader(msg)->src;
! knownMsgTable[oldest].token = (getHeader(msg)->token) & TOKEN_ACK_MASK;
! knownMsgTable[oldest].age = 0;
}
--- 386,394 ----
bool isNewMsg(message_t* msg) {
! return call Duplicate.isNew(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
}
void rememberMsg(message_t* msg) {
! call Duplicate.remember(getHeader(msg)->src, (getHeader(msg)->token) & TOKEN_ACK_MASK);
}
***************
*** 484,488 ****
command error_t Init.init(){
- unsigned i;
atomic {
txBufPtr = NULL;
--- 458,461 ----
***************
*** 492,498 ****
longRetryCounter = 0;
flags = 0;
- for(i = 0; i < MSG_TABLE_ENTRIES; i++) {
- knownMsgTable[i].age = MAX_AGE;
- }
#ifdef MACM_DEBUG
histIndex = 0;
--- 465,468 ----
***************
*** 688,691 ****
--- 658,662 ----
/****** PacketSerializer events **********************/
async event void PacketReceive.receiveDetected() {
+ rssiValue = INVALID_SNR;
if(macState <= RX_ACK) {
storeOldState(60);
***************
*** 694,704 ****
}
if(macState <= RX) {
! post ReleaseAdcTask();
! storeOldState(61);
macState = RX_P;
signalMacState();
}
else if(macState <= RX_ACK) {
- post ReleaseAdcTask();
storeOldState(62);
macState = RX_ACK_P;
--- 665,673 ----
}
if(macState <= RX) {
! storeOldState(61);
macState = RX_P;
signalMacState();
}
else if(macState <= RX_ACK) {
storeOldState(62);
macState = RX_ACK_P;
***************
*** 721,730 ****
if(macState == RX_P) {
if(error == SUCCESS) {
- post ageMsgsTask();
storeOldState(82);
isCnt = isControl(msg);
if(msgIsForMe(msg)) {
if(!isCnt) {
! (getMetadata(m))->strength = 10;
if(isNewMsg(m)) {
m = signal MacReceive.receiveDone(msg);
--- 690,698 ----
if(macState == RX_P) {
if(error == SUCCESS) {
storeOldState(82);
isCnt = isControl(msg);
if(msgIsForMe(msg)) {
if(!isCnt) {
! storeStrength(msg);
if(isNewMsg(m)) {
m = signal MacReceive.receiveDone(msg);
***************
*** 754,758 ****
if(ackIsForMe(msg)) {
storeOldState(92);
- (getMetadata(txBufPtr))->strength = 10;
(getMetadata(txBufPtr))->ack = WAS_ACKED;
signalSendDone(SUCCESS);
--- 722,725 ----
***************
*** 957,960 ****
--- 924,929 ----
async event void ChannelMonitorData.getSnrDone(int16_t data) {
+ atomic if((macState == RX_P) || (macState == RX_ACK_P)) rssiValue = data;
+ post ReleaseAdcTask();
}
***************
*** 983,986 ****
--- 952,956 ----
/***** abused TimeStamping events **************************/
async event void RadioTimeStamping.receivedSFD( uint16_t time ) {
+ if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
if(macState == RX_P) call ChannelMonitor.rxSuccess();
}
Index: CsmaMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/CsmaMacC.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** CsmaMacC.nc 24 Jan 2007 19:40:27 -0000 1.5
--- CsmaMacC.nc 1 Oct 2007 15:48:59 -0000 1.6
***************
*** 60,63 ****
--- 60,64 ----
new Alarm32khz16C() as Timer,
new TimerMilliC() as ReRxTimer,
+ DuplicateC,
RandomLfsrC
#ifdef MAC_DEBUG
***************
*** 97,100 ****
--- 98,103 ----
CsmaMacP.ReRxTimer -> ReRxTimer;
+
+ CsmaMacP.Duplicate -> DuplicateC;
#ifdef MAC_DEBUG
- Previous message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/platforms/eyesIFX
LocalTimeP.nc, NONE, 1.1 LocalTimeC.nc, NONE, 1.1
- Next message: [Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250/mac
TimeDiffC.nc, NONE, 1.1 TimeDiff32.nc, NONE, 1.1 TimeDiff16.nc,
NONE, 1.1 TimeDiff.nc, NONE, 1.1 SpeckMacDP.nc, 1.1,
1.2 SpeckMacDC.nc, 1.1, 1.2 RedMacP.nc, 1.13, 1.14 RedMacC.nc,
1.7, 1.8 CsmaMacP.nc, 1.13, 1.14 CsmaMacC.nc, 1.6, 1.7
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Tinyos-2-commits
mailing list