[Tinyos-beta-commits] CVS: tinyos-1.x/beta/SystemCore/MementoMori AggressiveSendControl.nc, NONE, 1.1 AggressiveSendM.nc, NONE, 1.1 HeartBeatHandler.nc, NONE, 1.1 RollCallC.nc, 1.1, 1.2 RollCallM.nc, 1.1, 1.2 DFDTypes.h, 1.1, NONE LocalConsensusHandler.nc, 1.1, NONE WatcherCoreC.nc, 1.1, NONE WatcherCoreM.nc, 1.1, NONE WatcherState.nc, 1.1, NONE

Stan Rost stanrost at users.sourceforge.net
Mon Sep 20 09:44:39 PDT 2004


Update of /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10769

Modified Files:
	RollCallC.nc RollCallM.nc 
Added Files:
	AggressiveSendControl.nc AggressiveSendM.nc 
	HeartBeatHandler.nc 
Removed Files:
	DFDTypes.h LocalConsensusHandler.nc WatcherCoreC.nc 
	WatcherCoreM.nc WatcherState.nc 
Log Message:
- Incorporated the new failure detection scheme 
  (sans the history/tree rebuilding)
- Incorporated aggressive transmission
- Fixed a ton of bugs


--- NEW FILE: AggressiveSendControl.nc ---
interface AggressiveSendControl {

  command void setRetries(uint8_t numRetries);

}

--- NEW FILE: AggressiveSendM.nc ---
module AggressiveSendM {
  provides {
    interface SendMsg[uint8_t id];

    interface AggressiveSendControl;
  }
  uses {
    interface SendMsg as SendExt[uint8_t id];
  }
}
implementation {

#define AGGRESSIVE_INIT_RETRIES 3

  uint8_t maxRetries = AGGRESSIVE_INIT_RETRIES;

  uint8_t retriesLeft = 0;
  TOS_MsgPtr _msg = NULL;

  command void AggressiveSendControl.setRetries(uint8_t numRetries) {
    maxRetries = numRetries;
  }

  command result_t SendMsg.send[uint8_t id](uint16_t addr,
					    uint8_t length,
					    TOS_MsgPtr msg) {
    if (_msg != NULL)
      return FAIL;
    else {
      result_t res;

      dbg(DBG_USR1, "^^^ SHIPPING 2!!!\n");

      if ((res = call SendExt.send[id](addr, length, msg)) == SUCCESS) {

	retriesLeft = maxRetries;
	_msg = msg;
	_msg->ack = 0;

      } 

      dbg(DBG_USR1, "^^^ SHIPPED 2!!!\n");

      return res;
    }
  }

  result_t finish(uint8_t id, TOS_MsgPtr msg, result_t success) {

    _msg = NULL;
    retriesLeft = 0;

    return signal SendMsg.sendDone[id](msg, success);
  }

  default event result_t SendMsg.sendDone[uint8_t id](TOS_MsgPtr msg,
						      result_t success) {

    dbg(DBG_USR1, "DEFAULT SendDone[%d]!\n", id);

    return SUCCESS;
  }
  
  default command result_t SendExt.send[uint8_t id](uint16_t addr,
						    uint8_t length,
						    TOS_MsgPtr msg) {

    dbg(DBG_USR1, "DEFAULT Send[%d]!\n", id);

    return SUCCESS;
  }

  event result_t SendExt.sendDone[uint8_t id](TOS_MsgPtr msg, 
					      result_t success) {

    if (msg != _msg)
      return signal SendMsg.sendDone[id](msg, success);
    else if (msg->addr == TOS_BCAST_ADDR ||
	     msg->addr == TOS_UART_ADDR) {
      dbg(DBG_USR1, "*** RETRIES RESET: BROADCAST\n");

      return finish(id, msg, success);

    } else if (!msg->ack) {
      if (retriesLeft == 0) {

	dbg(DBG_USR1, "*** FAILED AFTER %d RETRIES\n", maxRetries);
	
	return finish(id, msg, FAIL);
	
      } else {
	--retriesLeft;

	//	dbg(DBG_USR1, "*** RETRIES LEFT: %d\n", retriesLeft);

	// Cannot return FAIL here
	if (call SendExt.send[id](msg->addr,
				  msg->length,
				  msg) == FAIL) {
	  dbg(DBG_USR1, "*** RETRIES RESEND FAILED!!!\n");
	}

	return SUCCESS;
      }
    } else {

      dbg(DBG_USR1, "*** SUCCESS AT %d RETRIES\n", maxRetries - retriesLeft);

      return finish(id, msg, success);
    }

  }


}

--- NEW FILE: HeartBeatHandler.nc ---
includes DFDTypes;

/**
 *  This interfaces allows many components to
 *  handle the arrival of periodic heartbeat
 *  packets, whatever they may be.  Provisions
 *  are also made for snooping non-heartbeat packets.
 *
 * @author Stan Rost
 **/
interface HeartBeatHandler {

  /**
   * Provides the average period of this heartbeat 
   *
   **/
  command uint32_t getPeriod();

  /**
   * Receive a heartbeat
   *
   * @param srcAddr Source of the heartbeat
   * @param vStats A VitalStats data structure
   *
   **/
  event void receiveHeartBeat(uint16_t srcAddr,
			      VitalStats *vStats);

  /**
   * Receive a non-heartbeat packet,
   * with no guarantees as to periodicity
   *
   * @param srcAddr Source of the packet 
   *
   **/
  //  event void receivePacket(uint16_t srcAddr);

}

Index: RollCallC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/RollCallC.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RollCallC.nc	27 Aug 2004 22:48:50 -0000	1.1
--- RollCallC.nc	20 Sep 2004 16:44:37 -0000	1.2
***************
*** 4,7 ****
--- 4,9 ----
    uses {
      interface RouteControl;
+ 
+     interface HeartBeatHandler;
    }
    provides {
***************
*** 12,16 ****
    components PowerArbiterC, EpochSchedulerC, 
      TimerC, GenericCommPromiscuous as Comm,
!     RollCallM, UsefulTimeC, RandomLFSR;
  
    StdControl = Comm;
--- 14,20 ----
    components PowerArbiterC, EpochSchedulerC, 
      TimerC, GenericCommPromiscuous as Comm,
!     RollCallM, UsefulTimeC, RandomLFSR,
!     AggressiveSendM;
!   
  
    StdControl = Comm;
***************
*** 19,31 ****
    StdControl = RollCallM;
  
    RollCallM.Time -> UsefulTimeC;
  
    RollCallM.RouteControl = RouteControl;
  
    RollCallM.SendReport -> Comm.SendMsg[ROLLCALL_AM];
    RollCallM.ReceiveReport -> Comm.ReceiveMsg[ROLLCALL_AM];
  
!   RollCallM.SendActivator -> Comm.SendMsg[ROLLCALL_ACT_AM];
!   RollCallM.ReceiveActivator -> Comm.ReceiveMsg[ROLLCALL_ACT_AM];
  
    RollCallM.EpochScheduler -> 
--- 23,46 ----
    StdControl = RollCallM;
  
+   HeartBeatHandler = RollCallM.HeartBeatHandler;
+ 
    RollCallM.Time -> UsefulTimeC;
  
    RollCallM.RouteControl = RouteControl;
  
+   /*
+     Non-aggressive reliability
+   
    RollCallM.SendReport -> Comm.SendMsg[ROLLCALL_AM];
+   */
+ 
    RollCallM.ReceiveReport -> Comm.ReceiveMsg[ROLLCALL_AM];
  
!   RollCallM.SendReport -> AggressiveSendM.SendMsg[ROLLCALL_AM];
!   AggressiveSendM.SendExt[ROLLCALL_AM] -> Comm.SendMsg[ROLLCALL_AM];
! 
!   //  RollCallM.SendReport = Send[ROLLCALL_AM];
! 
!   RollCallM.AggressiveSendControl -> AggressiveSendM;
  
    RollCallM.EpochScheduler -> 

Index: RollCallM.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-1.x/beta/SystemCore/MementoMori/RollCallM.nc,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** RollCallM.nc	27 Aug 2004 22:48:50 -0000	1.1
--- RollCallM.nc	20 Sep 2004 16:44:37 -0000	1.2
***************
*** 13,18 ****
      interface ReceiveMsg as ReceiveReport;
  
!     interface SendMsg as SendActivator;
!     interface ReceiveMsg as ReceiveActivator;
  
      interface EpochScheduler;
--- 13,17 ----
      interface ReceiveMsg as ReceiveReport;
  
!     interface AggressiveSendControl;
  
      interface EpochScheduler;
***************
*** 23,26 ****
--- 22,27 ----
  
      interface Random;
+ 
+     interface HeartBeatHandler;
    }
  }
***************
*** 30,34 ****
  #define ROLLCALL_PERIOD 10240
    
!   // and wait for at most his long, at most...
  #define MAX_ROUND_WAIT 2048
  
--- 31,35 ----
  #define ROLLCALL_PERIOD 10240
    
!   // and wait for at most his long
  #define MAX_ROUND_WAIT 2048
  
***************
*** 38,42 ****
    // before sending their reports, spread out randomly
    // over this interval
! #define STAGGER_INTERVAL 100
  
    // The buffer which stores the bitmap is at most this long
--- 39,43 ----
    // before sending their reports, spread out randomly
    // over this interval
! #define STAGGER_INTERVAL (WAIT_PER_LEVEL / 2)
  
    // The buffer which stores the bitmap is at most this long
***************
*** 50,62 ****
  
    typedef struct {
!     uint32_t round;
! 
!     Set alive;
!   } AliveMsg;
  
!   typedef struct {
!     uint32_t round;
  
!   } ActivatorMsg;
  
    uint32_t rollCallRound = 0;
--- 51,63 ----
  
    typedef struct {
!     // Round of this communication
!     uint16_t round;
  
!     // For flood-aheed
!     uint8_t ttl;
  
!     // Set of nodes that we consider alive
!     Set alive;
!   } RosterMsg;
  
    uint32_t rollCallRound = 0;
***************
*** 102,106 ****
  
    event TOS_MsgPtr ReceiveReport.receive(TOS_MsgPtr msg) {
!     AliveMsg *aMsg = (AliveMsg *)msg->data;
      uint8_t buf2[MAX_LIVE_BITMAP_BYTES];
      Set *aliveSet = (Set *)rollCallLive;
--- 103,107 ----
  
    event TOS_MsgPtr ReceiveReport.receive(TOS_MsgPtr msg) {
!     RosterMsg *aMsg = (RosterMsg *)msg->data;
      uint8_t buf2[MAX_LIVE_BITMAP_BYTES];
      Set *aliveSet = (Set *)rollCallLive;
***************
*** 132,144 ****
    }
  
-   event TOS_MsgPtr ReceiveActivator.receive(TOS_MsgPtr msg) {
- 
-     return msg;
-   }
- 
    event void EpochScheduler.beginEpoch() {
      TimeStamp ts;
  
!     call PowerArbiter.useResource(PWR_RADIO);
  
      tos2timeStamp(call Time.get(), ts);
--- 133,140 ----
    }
  
    event void EpochScheduler.beginEpoch() {
      TimeStamp ts;
  
!     //    call PowerArbiter.useResource(PWR_RADIO);
  
      tos2timeStamp(call Time.get(), ts);
***************
*** 174,178 ****
  
    event result_t Timer.fired() {
!     AliveMsg *aliveMsg = (AliveMsg *)rollCallMsg.data;
      Set *aliveSet = (Set *)rollCallLive;
      // Variables for compression of the bitmap
--- 170,176 ----
  
    event result_t Timer.fired() {
!     uint16_t maxLen;
!     RosterMsg *aliveMsg = 
!       (RosterMsg *)rollCallMsg.data;
      Set *aliveSet = (Set *)rollCallLive;
      // Variables for compression of the bitmap
***************
*** 186,189 ****
--- 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
***************
*** 196,210 ****
        copySet(&aliveMsg->alive, aliveSet);
      }
  
!     dbg(DBG_USR3, "^^ READY TO SHIP %d bytes:\n", 
! 	sizeof(AliveMsg) - sizeof(Set) +
! 	sizeOfSet(aliveSet));
!     printSet(&aliveMsg->alive);
  
!     if (call SendReport.send(call RouteControl.getParent(),
! 			     sizeof(AliveMsg) - sizeof(Set) +
! 			     sizeOfSet(aliveSet),
! 			     &rollCallMsg) == FAIL) {
!       finishRound();
      }
  
--- 197,239 ----
        copySet(&aliveMsg->alive, aliveSet);
      }
+     
  
!     dbg(DBG_USR3, "neighbor message SIZE OF ALIVE SET = %u, maxLen is %u\n", 
! 	sizeOfSet(aliveSet),
! 	maxLen);
  
!     {
!       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);
!       
!       if (call RouteControl.getDepth() > 0) {
! 	tgtAddr = call RouteControl.getParent();
!       } else {
! 	tgtAddr = TOS_UART_ADDR;
!       }
! 
!       dbg(DBG_USR3, "^^ SHIPPING!!!\n");
!       fflush(stdout);
! 
!       
!       if (call SendReport.send(tgtAddr,
! 			       sizeof(RosterMsg) - sizeof(Set) +
! 			       sizeOfSet(&aliveMsg->alive),
! 			       &rollCallMsg) == FAIL) {
! 	
! 	dbg(DBG_USR3, "^^ send FAILED to SHIP!\n");
! 	fflush(stdout);
! 	
! 	finishRound();
!       } else {
! 	dbg(DBG_USR3, "^^ send SHIPPED successfully!\n");	
! 	fflush(stdout);
!       }
!       
      }
  
***************
*** 214,232 ****
    event result_t SendReport.sendDone(TOS_MsgPtr msg,
  				     result_t status) {
-     finishRound();
  
!     return SUCCESS;
!   }
  
-   event result_t SendActivator.sendDone(TOS_MsgPtr msg,
- 					result_t status) {
      return SUCCESS;
    }
  
- 
    void finishRound() {
      Set *aliveBitmap;
  
!     call PowerArbiter.releaseResource(PWR_RADIO);
  
      // Clear the bitmap
--- 243,258 ----
    event result_t SendReport.sendDone(TOS_MsgPtr msg,
  				     result_t status) {
  
!     dbg(DBG_USR3, "^^ sendDone\n");    
! 
!     finishRound();
  
      return SUCCESS;
    }
  
    void finishRound() {
      Set *aliveBitmap;
  
!     //    call PowerArbiter.releaseResource(PWR_RADIO);
  
      // Clear the bitmap
***************
*** 240,242 ****
--- 266,278 ----
    }
  
+   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);
+ 
+     setBit(aliveBitmap, srcAddr);
+   }
+ 
+ 
  }

--- DFDTypes.h DELETED ---

--- LocalConsensusHandler.nc DELETED ---

--- WatcherCoreC.nc DELETED ---

--- WatcherCoreM.nc DELETED ---

--- WatcherState.nc DELETED ---



More information about the Tinyos-beta-commits mailing list