[Tinyos-beta-commits] CVS: tinyos-1.x/beta/SystemCore/MementoMori
CompressedSet.h, 1.1, 1.2 HeartBeatHandler.nc, 1.1,
1.2 RollCallM.nc, 1.2, 1.3
Stan Rost
stanrost at users.sourceforge.net
Mon Oct 4 16:24:46 PDT 2004
Update of /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3700
Modified Files:
CompressedSet.h HeartBeatHandler.nc RollCallM.nc
Log Message:
- Fixed the transmission scheduling bug, now levels of the tree
communicate in proper order
- Added differences
Index: CompressedSet.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/CompressedSet.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** CompressedSet.h 27 Aug 2004 22:48:50 -0000 1.1
--- CompressedSet.h 4 Oct 2004 23:24:44 -0000 1.2
***************
*** 293,296 ****
--- 293,298 ----
return;
+ s1->len = 0;
+
minLen = (s1->len > s2->len ?
s2-> len : s1->len);
***************
*** 304,307 ****
--- 306,332 ----
}
+
+ // Calculate the intersection of sets, store in s1
+ void subtractSets(Set *s1,
+ Set *s2) {
+ // Add all unique elements of s2 to s1
+ uint8_t i, maxLen;
+
+ if (s1 == NULL || s2 == NULL)
+ return;
+
+ s1->len = 0;
+
+ maxLen = (s1->len < s2->len ?
+ s2-> len : s1->len);
+
+ // For every element of s2 that is not
+ // in s1, add that element
+ for (i = 0; i < maxLen; i++) {
+ if ((s1->data[i] &= ~(s2->data[i])) != 0)
+ s1->len = i+1;
+ }
+ }
+
// Initialize the set to blank
Set *initSet(uint8_t *buf, uint16_t szBytes) {
Index: HeartBeatHandler.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/HeartBeatHandler.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** HeartBeatHandler.nc 20 Sep 2004 16:44:37 -0000 1.1
--- HeartBeatHandler.nc 4 Oct 2004 23:24:44 -0000 1.2
***************
*** 1,3 ****
! includes DFDTypes;
/**
--- 1,3 ----
! includes VitalStats;
/**
Index: RollCallM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/RollCallM.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** RollCallM.nc 20 Sep 2004 16:44:37 -0000 1.2
--- RollCallM.nc 4 Oct 2004 23:24:44 -0000 1.3
***************
*** 43,47 ****
// The buffer which stores the bitmap is at most this long
// max nodes = (MAX_LIVE_BITMAP_BYTES - 1) * 8
! #define MAX_LIVE_BITMAP_BYTES 65
// Forward decls ----------------------------
--- 43,50 ----
// The buffer which stores the bitmap is at most this long
// max nodes = (MAX_LIVE_BITMAP_BYTES - 1) * 8
! #define MAX_LIVE_BITMAP_BYTES 20
!
! // The length of the history (for suppressing stray packets)
! #define MAX_LIVE_SET_HISTORY 1
// Forward decls ----------------------------
***************
*** 54,60 ****
uint16_t round;
- // For flood-aheed
- uint8_t ttl;
-
// Set of nodes that we consider alive
Set alive;
--- 57,60 ----
***************
*** 65,69 ****
// Buffer for the liveness bitmap
// To be recast into Set
! uint8_t rollCallLive[MAX_LIVE_BITMAP_BYTES];
// Remember my old tree level so if that
--- 65,145 ----
// Buffer for the liveness bitmap
// To be recast into Set
! uint8_t lastLiveSet[MAX_LIVE_BITMAP_BYTES];
!
! uint8_t liveSetHistory[MAX_LIVE_SET_HISTORY][MAX_LIVE_BITMAP_BYTES];
! int8_t curLiveSet = 0;
!
! void initLiveSets() {
! for (curLiveSet = 0;
! curLiveSet < MAX_LIVE_SET_HISTORY;
! curLiveSet++) {
! initSet(liveSetHistory[curLiveSet],
! MAX_LIVE_BITMAP_BYTES);
! }
!
! initSet(lastLiveSet, MAX_LIVE_BITMAP_BYTES);
!
! curLiveSet = 0;
! }
!
! // Get the pointer to the current live Set
! Set *getLiveSet() {
! return (Set *)&liveSetHistory[curLiveSet][0];
! }
!
! // Fast forward the live set to the next one
! void switchLiveSet() {
! if (++curLiveSet == MAX_LIVE_SET_HISTORY) {
! curLiveSet = 0;
! }
! initSet(&liveSetHistory[curLiveSet][0],
! MAX_LIVE_BITMAP_BYTES);
! }
!
! void aggregateHistory() {
! int8_t temp;
! uint8_t idx;
!
! initSet(lastLiveSet, MAX_LIVE_BITMAP_BYTES);
!
! for (temp = curLiveSet - MAX_LIVE_SET_HISTORY,
! idx = curLiveSet - MAX_LIVE_SET_HISTORY;
! temp < curLiveSet;
! temp++, idx++) {
! unionSets((Set *)lastLiveSet,
! (Set *)&liveSetHistory[idx % MAX_LIVE_SET_HISTORY][0]);
! }
! }
!
! bool liveSetChanged() {
! aggregateHistory();
!
! return !setsEqual((Set *)lastLiveSet,
! (Set *)&liveSetHistory[curLiveSet][0]);
! }
!
! bool collectDiscoveredNodes(Set *newNodeSet) {
! aggregateHistory();
!
! copySet(newNodeSet,
! (Set *)&liveSetHistory[curLiveSet][0]);
!
! subtractSets((Set *)newNodeSet,
! (Set *)lastLiveSet);
!
! return (newNodeSet->len == 0);
! }
!
! bool collectFailedNodes(Set *failedNodeSet) {
! aggregateHistory();
!
! copySet(failedNodeSet,
! (Set *)lastLiveSet);
!
! subtractSets((Set *)failedNodeSet,
! (Set *)lastLiveSet);
!
! return (failedNodeSet->len == 0);
! }
// Remember my old tree level so if that
***************
*** 75,78 ****
--- 151,157 ----
command result_t StdControl.init() {
+
+ initLiveSets();
+
return SUCCESS;
}
***************
*** 85,89 ****
// Prime the bitmap
{
! Set *aliveBitmap = initSet(rollCallLive, MAX_LIVE_BITMAP_BYTES);
// Note that I am alive :)
--- 164,168 ----
// Prime the bitmap
{
! Set *aliveBitmap = getLiveSet();
// Note that I am alive :)
***************
*** 105,109 ****
RosterMsg *aMsg = (RosterMsg *)msg->data;
uint8_t buf2[MAX_LIVE_BITMAP_BYTES];
! Set *aliveSet = (Set *)rollCallLive;
Set *newSet = initSet(buf2, MAX_LIVE_BITMAP_BYTES);
--- 184,188 ----
RosterMsg *aMsg = (RosterMsg *)msg->data;
uint8_t buf2[MAX_LIVE_BITMAP_BYTES];
! Set *aliveSet = getLiveSet();
Set *newSet = initSet(buf2, MAX_LIVE_BITMAP_BYTES);
***************
*** 151,158 ****
// if so
if (curTreeLevel != treeLevel) {
! uint32_t waitingTime = treeLevel * WAIT_PER_LEVEL;
! if (waitingTime > MAX_ROUND_WAIT)
waitingTime = MAX_ROUND_WAIT;
treeLevel = curTreeLevel;
--- 230,244 ----
// if so
if (curTreeLevel != treeLevel) {
! uint32_t waitingTime = curTreeLevel * WAIT_PER_LEVEL;
! dbg(DBG_USR1, "^^^^ Tree level change: from %u to %u!!!\n",
! treeLevel, curTreeLevel);
!
! if (waitingTime > MAX_ROUND_WAIT) {
waitingTime = MAX_ROUND_WAIT;
+
+ }
+
+ dbg(DBG_USR1, "^^^^ Tree level sets wait to %u\n", waitingTime);;
treeLevel = curTreeLevel;
***************
*** 163,166 ****
--- 249,254 ----
MAX_ROUND_WAIT -
waitingTime);
+
+ call EpochScheduler.start();
}
***************
*** 173,177 ****
RosterMsg *aliveMsg =
(RosterMsg *)rollCallMsg.data;
! Set *aliveSet = (Set *)rollCallLive;
// Variables for compression of the bitmap
uint8_t projLen, idxLen;
--- 261,265 ----
RosterMsg *aliveMsg =
(RosterMsg *)rollCallMsg.data;
! Set *aliveSet = (Set *)getLiveSet();
// Variables for compression of the bitmap
uint8_t projLen, idxLen;
***************
*** 184,190 ****
aliveMsg->round = rollCallRound;
- // This can be changed to increase the reach
- aliveMsg->floodAhead = 0;
-
// XXX: Projected length might exceed
// the size of the packet
--- 272,275 ----
***************
*** 206,213 ****
uint16_t tgtAddr = TOS_BCAST_ADDR;
! dbg(DBG_USR3, "^^ READY TO SHIP %d bytes to parent: %u:\n",
sizeof(RosterMsg) - sizeof(Set) +
sizeOfSet(&aliveMsg->alive),
! call RouteControl.getParent());
printSet(&aliveMsg->alive);
--- 291,300 ----
uint16_t tgtAddr = TOS_BCAST_ADDR;
! dbg(DBG_USR3, "^^ level %d READY TO SHIP %d bytes to parent: %u%s",
! call RouteControl.getDepth(),
sizeof(RosterMsg) - sizeof(Set) +
sizeOfSet(&aliveMsg->alive),
! call RouteControl.getParent(),
! (call RouteControl.getDepth() == 0 ? "-------\n" : "\n"));
printSet(&aliveMsg->alive);
***************
*** 254,261 ****
Set *aliveBitmap;
! // call PowerArbiter.releaseResource(PWR_RADIO);
! // Clear the bitmap
! aliveBitmap = initSet(rollCallLive, MAX_LIVE_BITMAP_BYTES);
// Note that I am alive :)
--- 341,350 ----
Set *aliveBitmap;
! switchLiveSet();
! // Note: this function clears the live set
! aliveBitmap = getLiveSet();
!
! // call PowerArbiter.releaseResource(PWR_RADIO);
// Note that I am alive :)
***************
*** 268,272 ****
event void HeartBeatHandler.receiveHeartBeat(uint16_t srcAddr,
VitalStats *vStats) {
! Set *aliveBitmap = (Set *)rollCallLive;
dbg(DBG_USR1, "Overheard heartbeat from %u as alive\n\n", srcAddr);
--- 357,361 ----
event void HeartBeatHandler.receiveHeartBeat(uint16_t srcAddr,
VitalStats *vStats) {
! Set *aliveBitmap = getLiveSet();
dbg(DBG_USR1, "Overheard heartbeat from %u as alive\n\n", srcAddr);
More information about the Tinyos-beta-commits
mailing list