[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/tda5250/mac SpeckMacDP.nc, 1.4, 1.5 SpeckMacDC.nc, 1.2, 1.3 RedMacP.nc, 1.15, 1.16 RedMacC.nc, 1.8, 1.9 CsmaMacP.nc, 1.14, 1.15

akoepke andreaskoepke at users.sourceforge.net
Wed Feb 13 02:32:17 PST 2008


Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv9786/mac

Modified Files:
	SpeckMacDP.nc SpeckMacDC.nc RedMacP.nc RedMacC.nc CsmaMacP.nc 
Log Message:
increase link speed, keep intermediate state in case I have to backtrack


Index: SpeckMacDP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/SpeckMacDP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** SpeckMacDP.nc	4 Oct 2007 15:54:26 -0000	1.4
--- SpeckMacDP.nc	13 Feb 2008 10:32:15 -0000	1.5
***************
*** 49,52 ****
--- 49,55 ----
          interface Sleeptime;
          interface ChannelCongestion;
+ #ifdef MAC_EVAL
+         interface MacEval;
+ #endif
      }
      uses {
***************
*** 82,87 ****
          interface GeneralIO as Led1;
          interface GeneralIO as Led2;
!         interface GeneralIO as Led3;        
! */  
  #ifdef SPECKMAC_DEBUG
          interface SerialDebug;
--- 85,91 ----
          interface GeneralIO as Led1;
          interface GeneralIO as Led2;
!         interface GeneralIO as Led3;
! */
!   
  #ifdef SPECKMAC_DEBUG
          interface SerialDebug;
***************
*** 129,146 ****
      /**************** Module Global Constants  *****************/
      enum {
! 
          BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
          PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
          PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
          TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
                  
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
          SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
!         // DEFAULT_SLEEP_TIME=1625,
          // DEFAULT_SLEEP_TIME=3250,
          // DEFAULT_SLEEP_TIME=6500,
          // DEFAULT_SLEEP_TIME=8192,
          // DEFAULT_SLEEP_TIME=16384,
!         DEFAULT_SLEEP_TIME=32768U,
          // DEFAULT_SLEEP_TIME=65535U,
          DATA_DETECT_TIME=17,
--- 133,155 ----
      /**************** Module Global Constants  *****************/
      enum {
! /*
          BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
          PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
          PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
          TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
+ */
+         BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
+         PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
+         PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
+         TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
                  
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
          SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
!         DEFAULT_SLEEP_TIME=1625,
          // DEFAULT_SLEEP_TIME=3250,
          // DEFAULT_SLEEP_TIME=6500,
          // DEFAULT_SLEEP_TIME=8192,
          // DEFAULT_SLEEP_TIME=16384,
!         // DEFAULT_SLEEP_TIME=32768U,
          // DEFAULT_SLEEP_TIME=65535U,
          DATA_DETECT_TIME=17,
***************
*** 152,157 ****
--- 161,171 ----
          // the duration of a send ACK
          ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
+         NAV_FACTOR = 4,
+ #ifndef MAC_EVAL
          MAX_SHORT_RETRY=9,
          MAX_LONG_RETRY=3,
+         ADD_NAV = 4,
+         INCREASE_BACKOFF = TRUE,
+ #endif
          TOKEN_ACK_FLAG = 64,
          TOKEN_ACK_MASK = 0x3f,
***************
*** 163,167 ****
      };
      
!     /**************** Module Global Variables  *****************/    
      /* flags */
      typedef enum {
--- 177,187 ----
      };
      
!     /**************** Module Global Variables  *****************/
! #ifdef MAC_EVAL
!     uint8_t MAX_SHORT_RETRY = 9;
!     uint8_t MAX_LONG_RETRY = 3;
!     uint8_t ADD_NAV = 4;
!     bool INCREASE_BACKOFF = TRUE;
! #endif
      /* flags */
      typedef enum {
***************
*** 222,226 ****
          setFlag(&flags, SWITCHING);
          clearFlag(&flags, RSSI_STABLE);
-         // sdDebug(10);
          checkCounter = 0;
          rssiValue = INVALID_SNR;
--- 242,245 ----
***************
*** 243,247 ****
  
      void setSleepMode() {
-         // sdDebug(20);
          clearFlag(&flags, RSSI_STABLE);
          post ReleaseAdcTask();
--- 262,265 ----
***************
*** 264,268 ****
      void setTxMode() {
          post ReleaseAdcTask();
-         // sdDebug(30);
          clearFlag(&flags, RSSI_STABLE);
          setFlag(&flags, SWITCHING);
--- 282,285 ----
***************
*** 289,312 ****
          if((shortRetryCounter) && (txBufPtr != NULL) && (isFlagSet(&flags, MESSAGE_PREPARED)) && 
             (macState == SLEEP) && (!isFlagSet(&flags, RESUME_BACKOFF)) && (!call Timer.isRunning())) {
-             // sdDebug(40);
              macState = CCA;
              checkCounter = 0;
              setRxMode();
          }
- /*        else {
-             if(txBufPtr) // sdDebug(41);
-             if(shortRetryCounter) // sdDebug(42);
-             if(isFlagSet(&flags, MESSAGE_PREPARED)) // sdDebug(43);
-             if(txBufPtr) {
-                 if(macState == SLEEP) // sdDebug(44);
-                 if(!isFlagSet(&flags, RESUME_BACKOFF)) // sdDebug(45);
-                 if(!call Timer.isRunning()) // sdDebug(46);
-             }
-         }
- */
      }
  
      uint32_t backoff(uint8_t counter) {
          uint32_t rVal = call Random.rand16() &  MIN_BACKOFF_MASK;
          return (rVal << counter) + ZERO_BACKOFF_MASK;
      }
--- 306,318 ----
          if((shortRetryCounter) && (txBufPtr != NULL) && (isFlagSet(&flags, MESSAGE_PREPARED)) && 
             (macState == SLEEP) && (!isFlagSet(&flags, RESUME_BACKOFF)) && (!call Timer.isRunning())) {
              macState = CCA;
              checkCounter = 0;
              setRxMode();
          }
      }
  
      uint32_t backoff(uint8_t counter) {
          uint32_t rVal = call Random.rand16() &  MIN_BACKOFF_MASK;
+         if(!INCREASE_BACKOFF) counter = 1;
          return (rVal << counter) + ZERO_BACKOFF_MASK;
      }
***************
*** 354,370 ****
              setFlag(&flags, MESSAGE_PREPARED);
              if(macState == SLEEP) {
-                 sdDebug(400);
              } else {
-                 sdDebug(401);
              }
              if(!call Timer.isRunning()) {
-                 sdDebug(402);
              } else {
-                 sdDebug(403);
              }
              if(!isFlagSet(&flags, RESUME_BACKOFF)) {
-                 sdDebug(404);
              } else {
-                 sdDebug(405);
              }
              if((macState == SLEEP) && (!call Timer.isRunning()) && (!isFlagSet(&flags, RESUME_BACKOFF))) {
--- 360,370 ----
***************
*** 372,380 ****
                     (getHeader(msg)->dest != AM_BROADCAST_ADDR)) {
                      call Timer.start((call Random.rand16() >> 3) & ZERO_BACKOFF_MASK);
-                     sdDebug(406);
                  }
                  else {
                      call Timer.start(backoff(longRetryCounter));
-                     sdDebug(407);
                  }
              }
--- 372,378 ----
***************
*** 422,426 ****
          message_t *m;
          error_t e = error;
-         // sdDebug(50);
          atomic {
              m = txBufPtr;
--- 420,423 ----
***************
*** 441,446 ****
              clearFlag(&flags, CANCEL_SEND);
          }
-         // sdDebug(3000 + e);
-         // sdDebug(4000 + getHeader(m)->type);
          signal MacSend.sendDone(m, e);
  #ifdef SPECKMAC_PERFORMANCE
--- 438,441 ----
***************
*** 457,461 ****
              shortRetryCounter = 1;
              if(longRetryCounter > MAX_LONG_RETRY) {
-                 // sdDebug(60);
                  signalSendDone(FAIL);
              }
--- 452,455 ----
***************
*** 469,473 ****
              shortRetryCounter = 1;
              if(longRetryCounter > MAX_LONG_RETRY) {
-                 // sdDebug(70);
                  signalSendDone(FAIL);
              } else {
--- 463,466 ----
***************
*** 488,498 ****
              restLaufzeit = call TimeDiff16.computeDelta(call Timer.getAlarm(), call Timer.getNow());
              call Timer.stop();
-             sdDebug(10);
-             sdDebug(restLaufzeit);
              if(restLaufzeit > MIN_BACKOFF_MASK << MAX_LONG_RETRY) {
                  restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
              }
-             sdDebug(11);
-             sdDebug(restLaufzeit);
              setFlag(&flags, RESUME_BACKOFF);
          }
--- 481,487 ----
***************
*** 503,508 ****
              setFlag(&flags, RESUME_BACKOFF);
              restLaufzeit = backoff(longRetryCounter);
-             sdDebug(20);
-             sdDebug(restLaufzeit);
              updateRetryCounters();
          }
--- 492,495 ----
***************
*** 566,573 ****
  
      task void StartDoneTask() {
-         // sdDebug(90);
          atomic  {
              call SampleTimer.start(localSleeptime);
              macState = SLEEP;
          }
          signal SplitControl.startDone(SUCCESS);        
--- 553,560 ----
  
      task void StartDoneTask() {
          atomic  {
              call SampleTimer.start(localSleeptime);
              macState = SLEEP;
+             sdDebug(60);
          }
          signal SplitControl.startDone(SUCCESS);        
***************
*** 579,584 ****
              macState = INIT;
              setRxMode();
-             // sdDebug(100);
          }
          return SUCCESS;
      }
--- 566,571 ----
              macState = INIT;
              setRxMode();
          }
+         sdDebug(10);
          return SUCCESS;
      }
***************
*** 586,590 ****
      task void StopDoneTask() {
          call Init.init();
-         // sdDebug(110);
          signal SplitControl.stopDone(SUCCESS);        
      }
--- 573,576 ----
***************
*** 597,606 ****
              if((macState == SLEEP) && isFlagSet(&flags, SWITCHING)) {
                  macState = STOP;
-                 // sdDebug(120);
              }
              else {
                  macState = STOP;
                  setSleepMode();
-                 // sdDebug(121);
              }
          }
--- 583,590 ----
***************
*** 635,663 ****
          if((macState == RX) || (macState == CCA)) {
              call Timer.start(DATA_DETECT_TIME);
-             // sdDebug(130);
          }
          else if(macState == RX_P) {
-             // sdDebug(131);
              if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
          }
          else if(macState == RX_ACK) {
              // if(call RssiAdcResource.isOwner()) call ChannelMonitor.start();
-             // sdDebug(132);
          }
          else if(macState == RX_ACK_P) {
          }
          else if(macState == INIT) {
-             // sdDebug(133);
              if(call RssiAdcResource.isOwner()) {
                  call ChannelMonitorControl.updateNoiseFloor();
              } else {
                  call RssiAdcResource.request();
              }
          }
          else if(macState == STOP) {
-             // sdDebug(134);
          }
          else {
-             // sdDebug(135);
          }
      }
--- 619,643 ----
          if((macState == RX) || (macState == CCA)) {
              call Timer.start(DATA_DETECT_TIME);
          }
          else if(macState == RX_P) {
              if(call RssiAdcResource.isOwner()) call ChannelMonitorData.getSnr();
          }
          else if(macState == RX_ACK) {
              // if(call RssiAdcResource.isOwner()) call ChannelMonitor.start();
          }
          else if(macState == RX_ACK_P) {
          }
          else if(macState == INIT) {
              if(call RssiAdcResource.isOwner()) {
+                 sdDebug(20);
                  call ChannelMonitorControl.updateNoiseFloor();
              } else {
+                 sdDebug(21);
                  call RssiAdcResource.request();
              }
          }
          else if(macState == STOP) {
          }
          else {
          }
      }
***************
*** 668,676 ****
              if((macState == RX) || (macState == RX_ACK) || (macState == CCA) ||
                 (macState == INIT) || (macState == STOP)) {
-                 // sdDebug(140);
                  if(macState != RX_ACK) requestAdc();
              }
              else {
-                 // sdDebug(141);
              }
          }
--- 648,654 ----
***************
*** 678,682 ****
      
      async event void RadioModes.TxModeDone() {
-         // sdDebug(150);
          atomic {
              clearFlag(&flags, SWITCHING);
--- 656,659 ----
***************
*** 684,702 ****
                  setFlag(&flags, ACTION_DETECTED);
                  if(call PacketSend.send(txBufPtr, txLen) == SUCCESS) {
-                     // sdDebug(151);
                  }
                  else {
-                     // sdDebug(152);
                  }
              }
              else if(macState == TX_ACK) {
                  if(call PacketSend.send(&ackMsg, 0) == SUCCESS) {
-                     // sdDebug(153);
                  } else {
-                     // sdDebug(154);
                  }
              }
              else {
-                 // sdDebug(155);
              }
          }
--- 661,674 ----
***************
*** 704,708 ****
  
      async event void RadioModes.SleepModeDone() {
-         // sdDebug(160);
          atomic {
              clearFlag(&flags, SWITCHING);
--- 676,679 ----
***************
*** 712,729 ****
                  if(congestionLevel > 0) congestionLevel--;
              }
-             // if(congestionLevel > 3) // sdDebug(2000 + congestionLevel);
              if(macState == SLEEP) {
-                 // sdDebug(161);
                  if(!call Timer.isRunning()) {
-                     // sdDebug(162);
                      if(isFlagSet(&flags, RESUME_BACKOFF)) {
-                         // sdDebug(164);
                          clearFlag(&flags, RESUME_BACKOFF);
                          call Timer.start(restLaufzeit);
                          restLaufzeit = 0;
-                         sdDebug(30);
                      }
                      else {
-                         // sdDebug(165);
                          checkSend();
                      }
--- 683,694 ----
***************
*** 731,735 ****
              }
              else if(macState == STOP) {
-                 // sdDebug(168);
                  post StopDoneTask();
              }
--- 696,699 ----
***************
*** 744,748 ****
              if((shortRetryCounter == 0) && (txBufPtr == NULL)) {
                  clearFlag(&flags, MESSAGE_PREPARED);
-                 // sdDebug(5000 + getHeader(msg)->type);
                  shortRetryCounter = 1;
                  longRetryCounter = 1;
--- 708,711 ----
***************
*** 757,766 ****
              }
              else {
-                 // sdDebug(171);
                  err = EBUSY;
              }
          }
          if(err == SUCCESS) {
-             sdDebug(300);
              post PrepareMsgTask();
          }
--- 720,727 ----
***************
*** 772,792 ****
          atomic {
              if(msg == txBufPtr) {
-                 // sdDebug(320);
                  setFlag(&flags, CANCEL_SEND);
                  shortRetryCounter = MAX_SHORT_RETRY + 2;
                  longRetryCounter  = MAX_LONG_RETRY + 2;
                  if(macState == SLEEP) {
-                     // sdDebug(321);
                      signalSendDone(ECANCEL);
                  }
                  else {
-                     // sdDebug(322);
                  }
-                 // sdDebug(1000 + macState);
                  err = SUCCESS;
              }
              else {
-                 // sdDebug(323);
-                 // sdDebug(1100 + macState);
              }
          }
--- 733,747 ----
***************
*** 802,806 ****
          if(macState <= CCA_ACK) {
              if(macState == CCA) {
-                 sdDebug(100);
                  computeBackoff();
  #ifdef SPECKMAC_PERFORMANCE
--- 757,760 ----
***************
*** 811,820 ****
                  macState = RX_P;
              } else {
-                 sdDebug(500);
                  macState = RX_ACK_P;
              }
          }
          else if(macState == INIT) {
-             // sdDebug(180);
              setFlag(&flags, UNHANDLED_PACKET);
          }
--- 765,772 ----
***************
*** 830,842 ****
          rxStat.repCounter = 0xff;
  #endif
-         // sdDebug(190);
          if(macState == RX_P) {
-             // sdDebug(191);
              if(error == SUCCESS) {
-                 // sdDebug(192);
                  isCnt = isControl(msg);
                  if(msgIsForMe(msg)) {
                      if(!isCnt) {
-                         // sdDebug(193);
                          if(isNewMsg(msg)) {
  #ifdef SPECKMAC_PERFORMANCE
--- 782,790 ----
***************
*** 850,857 ****
                              // message was not successfully delivered to upper layers
                              if(m != msg) {
-                                 // sdDebug(195);
                                  rememberMsg(msg);
                              } else {
-                                 // sdDebug(196);
                                  action = RX;
  #ifdef SPECKMAC_PERFORMANCE
--- 798,803 ----
***************
*** 866,870 ****
  #endif                  
                          if(needsAckRx(msg) && (action != RX)) {
-                             // sdDebug(197);
                              if(((red_mac_header_t*)payload)->repetitionCounter == 0) {
                                  action = CCA_ACK;
--- 812,815 ----
***************
*** 875,879 ****
                          }
                          else {
-                             // sdDebug(198);
                              if(action != RX) {
                                  nav = ((red_mac_header_t*)payload)->repetitionCounter *
--- 820,823 ----
***************
*** 885,894 ****
                      }
                      else {
-                         // sdDebug(199);
                          action = RX;
                      }
                  }
                  else {
-                     // sdDebug(200);
                      action = SLEEP;
                      if(!isCnt) {
--- 829,836 ----
***************
*** 900,904 ****
              }
              else {
-                 // sdDebug(201);
                  action = SLEEP;
              }
--- 842,845 ----
***************
*** 907,921 ****
              if(error == SUCCESS) {
                  if(ackIsForMe(msg)) {
-                     sdDebug(510);
                      storeStrength(msg);
                      getMetadata(txBufPtr)->ack = WAS_ACKED;
                      getMetadata(txBufPtr)->repetitions = txMacHdr->repetitionCounter;
-                     // sdDebug(203);
                      signalSendDone(SUCCESS);
-                     // sdDebug(30000 + getHeader(msg)->src);
                      action = SLEEP;
                  }
                  else {
-                     sdDebug(511);
                      updateLongRetryCounters(); // this will eventually schedule the right backoff
                      macState = SLEEP;          // so much traffic is going on -- take a nap
--- 848,858 ----
***************
*** 926,934 ****
              else {
                  if(call Timer.isRunning()) {
-                     sdDebug(512);
                      action = RX_ACK;
                  }
                  else {
-                     sdDebug(513);
                      updateLongRetryCounters();
                      action = RX;
--- 863,869 ----
***************
*** 937,941 ****
          }
          else {
-             // sdDebug(206);
              action = INIT;
          }
--- 872,875 ----
***************
*** 957,972 ****
              if(isFlagSet(&flags, RESUME_BACKOFF)) {
                  if(nav > restLaufzeit) {
!                     sdDebug(40);
!                     sdDebug(restLaufzeit);
!                     restLaufzeit += nav;
                  }
-                 sdDebug(41);
-                 sdDebug(restLaufzeit);
              }
              else {
                  setFlag(&flags, RESUME_BACKOFF);
                  restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
-                 sdDebug(42);
-                 sdDebug(restLaufzeit);
              }
              setSleepMode();
--- 891,900 ----
              if(isFlagSet(&flags, RESUME_BACKOFF)) {
                  if(nav > restLaufzeit) {
!                     if(nav > restLaufzeit) restLaufzeit += ((uint32_t)ADD_NAV*nav/NAV_FACTOR);
                  }
              }
              else {
                  setFlag(&flags, RESUME_BACKOFF);
                  restLaufzeit = call Random.rand16() & ZERO_BACKOFF_MASK;
              }
              setSleepMode();
***************
*** 976,980 ****
          }
          else {
-             // sdDebug(207);
          }
  #ifdef SPECKMAC_PERFORMANCE
--- 904,907 ----
***************
*** 1003,1007 ****
                  setRxMode();
                  call Timer.start(RX_ACK_TIMEOUT);
-                 // sdDebug(220);
                  checkCounter = 0;
              }
--- 930,933 ----
***************
*** 1011,1017 ****
              macState = RX;
              setRxMode();
!             // sdDebug(221);
! #ifdef SPECKMAC_DEBUG            
!             // sdDebug(40000U + repCounter);
  #endif
          }
--- 937,941 ----
              macState = RX;
              setRxMode();
! #ifdef SPECKMAC_DEBUG
  #endif
          }
***************
*** 1040,1044 ****
          if((macState == RX) || (macState == CCA) || (macState == CCA_ACK)) {
              if(macState == CCA) {
-                 sdDebug(101);
                  computeBackoff();
  #ifdef SPECKMAC_PERFORMANCE
--- 964,967 ----
***************
*** 1047,1051 ****
              }
              requestAdc();
-             // sdDebug(230);
              macState = RX;
              checkCounter = 0;
--- 970,973 ----
***************
*** 1056,1060 ****
      void checkOnIdle()  {
          if(macState == RX) {
-             // sdDebug(240);
              checkCounter++;
              if(checkCounter < 2) {
--- 978,981 ----
***************
*** 1069,1078 ****
              checkCounter++;
              if(checkCounter < 3) {
-                 // sdDebug(242);                
                  call Timer.start(TX_GAP_TIME >> 1);
                  requestAdc();
              }
              else {
-                 // sdDebug(243);
                  macState = TX;
                  setTxMode();
--- 990,997 ----
***************
*** 1086,1098 ****
      
      async event void Timer.fired() {
-         // sdDebug(250);
          if((macState == RX) || (macState == CCA) || (macState == CCA_ACK)) {
              if((!call RssiAdcResource.isOwner()) || (call ChannelMonitor.start() != SUCCESS)) {
                  if(call UartPhyControl.isBusy()) {
-                     // sdDebug(251);
                      checkOnBusy();
                  }
                  else {
-                     // sdDebug(252);
                      checkOnIdle();
                  }
--- 1005,1014 ----
***************
*** 1101,1105 ****
          else if(macState == RX_ACK) {
              if(needsAckTx(txBufPtr)) {
-                 // sdDebug(254);
  #ifdef SPECKMAC_PERFORMANCE
                  call Performance.macAckTimeout();
--- 1017,1020 ----
***************
*** 1108,1112 ****
              }
              else {
-                 // sdDebug(255);
                  signalSendDone(SUCCESS);
              }
--- 1023,1026 ----
***************
*** 1116,1136 ****
          else if(macState == TX_ACK) {
              setTxMode();
-             // sdDebug(10000 + getHeader(&ackMsg)->dest);
          }
          else if(macState == SLEEP) {
               if(isFlagSet(&flags, SWITCHING)) {
-                  // sdDebug(256);
                   call Timer.start(call Random.rand16() & 0x0f);
               }
               else {
                   if(isFlagSet(&flags, RESUME_BACKOFF)) {
-                      // sdDebug(261);
                       clearFlag(&flags, RESUME_BACKOFF);
                       call Timer.start(restLaufzeit);
                       restLaufzeit = 0;
-                      sdDebug(50);
                   }
                   else {
-                      // sdDebug(262);
                       checkSend();
                   }
--- 1030,1045 ----
***************
*** 1138,1149 ****
          }
          else if((macState == RX_ACK_P) || (macState == RX_P)) {
-             // sdDebug(258);
          }
          else if(macState == INIT) {
-             // sdDebug(259);
              post StartDoneTask();
          }
          else {
-             // sdDebug(260);
          }
      }
--- 1047,1056 ----
          }
          else if((macState == RX_ACK_P) || (macState == RX_P)) {
          }
          else if(macState == INIT) {
              post StartDoneTask();
+             sdDebug(50);
          }
          else {
          }
      }
***************
*** 1153,1163 ****
      async event void SampleTimer.fired() {
          call SampleTimer.start(localSleeptime);
-         // sdDebug(270);
          if((macState == SLEEP) && (!isFlagSet(&flags, SWITCHING))) {
              clearFlag(&flags, ACTION_DETECTED);
-             sdDebug(200);
              interruptBackoffTimer();
              macState = RX;
-             // sdDebug(271);
              setRxMode();
              call Timer.stop();
--- 1060,1067 ----
***************
*** 1195,1204 ****
  
      async event void ChannelMonitor.channelBusy() {
-         // sdDebug(280);
          checkOnBusy();
      }
  
      async event void ChannelMonitor.channelIdle() {
-         // sdDebug(281);
          checkOnIdle();
      }
--- 1099,1106 ----
***************
*** 1208,1216 ****
      event void ChannelMonitorControl.updateNoiseFloorDone() {
          if(macState == INIT) {
-             // sdDebug(290);
              call Timer.start(call Random.rand16() % localSleeptime);
              setSleepMode();
          } else {
-             // sdDebug(291);
          }
      }
--- 1110,1117 ----
      event void ChannelMonitorControl.updateNoiseFloorDone() {
          if(macState == INIT) {
              call Timer.start(call Random.rand16() % localSleeptime);
              setSleepMode();
+             sdDebug(40);
          } else {
          }
      }
***************
*** 1227,1242 ****
          atomic ms = macState;
          if(ms < SLEEP) {
-             // sdDebug(300);
          }
          else if(ms == INIT) {
!             // sdDebug(301);
              call ChannelMonitorControl.updateNoiseFloor();            
          }
          else {
-             // sdDebug(302);
              post ReleaseAdcTask();
          }
      }
      
      default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
  
--- 1128,1161 ----
          atomic ms = macState;
          if(ms < SLEEP) {
          }
          else if(ms == INIT) {
!             sdDebug(30);
              call ChannelMonitorControl.updateNoiseFloor();            
          }
          else {
              post ReleaseAdcTask();
          }
      }
      
+     /***** Mac Eval *******************************************/
+ #ifdef MAC_EVAL
+     async command void MacEval.setBackoffMask(uint16_t mask) {
+         atomic MIN_BACKOFF_MASK = mask;
+     }
+     async command void MacEval.increaseBackoff(bool value) {
+         atomic INCREASE_BACKOFF = value;
+     }
+     async command void MacEval.addNav(bool value) {
+         atomic ADD_NAV = value;
+     }
+     async command void MacEval.setLongRetry(uint8_t lr) {
+         atomic MAX_LONG_RETRY = lr;
+     }
+     async command void MacEval.setShortRetry(uint8_t sr) {
+         atomic MAX_SHORT_RETRY = sr;
+     }    
+ #endif
+ 
+     /***** unused events **************************/
      default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
  

Index: SpeckMacDC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/SpeckMacDC.nc,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** SpeckMacDC.nc	1 Oct 2007 17:58:07 -0000	1.2
--- SpeckMacDC.nc	13 Feb 2008 10:32:15 -0000	1.3
***************
*** 48,51 ****
--- 48,54 ----
      interface Sleeptime;
      interface ChannelCongestion;
+ #ifdef MAC_EVAL
+     interface MacEval;
+ #endif
    }
    uses {
***************
*** 112,115 ****
--- 115,123 ----
      SpeckMacDP.Led3 -> PlatformLedsC.Led3;
  */
+ 
+ #ifdef MAC_EVAL
+     MacEval = SpeckMacDP;
+ #endif
+ 
  #ifdef SPECKMAC_DEBUG
      components new SerialDebugC() as SD;

Index: RedMacP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/RedMacP.nc,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** RedMacP.nc	4 Oct 2007 15:54:26 -0000	1.15
--- RedMacP.nc	13 Feb 2008 10:32:15 -0000	1.16
***************
*** 40,43 ****
--- 40,47 ----
  #include "RedMac.h"
  
+ #ifdef DELTATIMEDEBUG
+ #include "DeltaTrace.h"
+ #endif
+ 
  module RedMacP {
      provides {
***************
*** 50,53 ****
--- 54,60 ----
          interface Teamgeist;
          interface ChannelCongestion;
+ #ifdef MAC_EVAL
+         interface MacEval;
+ #endif
      }
      uses {
***************
*** 91,95 ****
          interface Performance;
  #endif
! 
      }
  }
--- 98,104 ----
          interface Performance;
  #endif
! #ifdef DELTATIMEDEBUG
!         interface DeltaTrace;
! #endif
      }
  }
***************
*** 124,147 ****
      
  #ifdef REDMAC_PERFORMANCE
!     macTxStat_t txStat;
!     macRxStat_t rxStat;
  #endif
  
      /**************** Module Global Constants  *****************/
      enum {
! 
          BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
          PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
          PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
          TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
!                 
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
          SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
          // DEFAULT_SLEEP_TIME=1625,
!         // DEFAULT_SLEEP_TIME=3250,
!         // DEFAULT_SLEEP_TIME=6500,
          // DEFAULT_SLEEP_TIME=8192,
!         // DEFAULT_SLEEP_TIME=16384,
!         DEFAULT_SLEEP_TIME=32768U,
          // DEFAULT_SLEEP_TIME=65535U,
          DATA_DETECT_TIME=17,
--- 133,161 ----
      
  #ifdef REDMAC_PERFORMANCE
!      PfmTxMsg_t txStat;
!      PfmRxMsg_t rxStat;
  #endif
  
      /**************** Module Global Constants  *****************/
      enum {
! /*
          BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
          PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
          PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
          TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
! */
!         BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
!         PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
!         PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
!         TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
!         
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(message_header_t)*BYTE_TIME,
          SUB_FOOTER_TIME=2*BYTE_TIME, // 2 bytes crc 
          // DEFAULT_SLEEP_TIME=1625,
!         // DEFAULT_SLEEP_TIME=2048,
!         // DEFAULT_SLEEP_TIME=4096,
          // DEFAULT_SLEEP_TIME=8192,
!         DEFAULT_SLEEP_TIME=16384,
!         // DEFAULT_SLEEP_TIME=32768U,
          // DEFAULT_SLEEP_TIME=65535U,
          DATA_DETECT_TIME=17,
***************
*** 153,158 ****
          // the duration of a send ACK
          ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
!         MAX_SHORT_RETRY=9,
!         MAX_LONG_RETRY=3,
          TOKEN_ACK_FLAG = 64,
          TOKEN_ACK_MASK = 0x3f,
--- 167,177 ----
          // the duration of a send ACK
          ACK_DURATION = SUB_HEADER_TIME + SUB_FOOTER_TIME,
!         NAV_FACTOR = 4,
! #ifndef MAC_EVAL
!         MAX_SHORT_RETRY=3,
!         MAX_LONG_RETRY=7,
!         ADD_NAV = 2,
!         INCREASE_BACKOFF = TRUE,
! #endif
          TOKEN_ACK_FLAG = 64,
          TOKEN_ACK_MASK = 0x3f,
***************
*** 163,167 ****
          ZERO_BACKOFF_MASK = 0xff
      };
!     
      /**************** Module Global Variables  *****************/
      /* flags */
--- 182,195 ----
          ZERO_BACKOFF_MASK = 0xff
      };
! 
! #ifdef MAC_EVAL
!     uint8_t MAX_SHORT_RETRY = 9;
!     uint8_t MAX_LONG_RETRY = 3;
!     uint8_t ADD_NAV = 4;
!     bool INCREASE_BACKOFF = TRUE;
! #endif
! #ifdef DELTATIMEDEBUG
!     DeltaTrace_t dTrace;
! #endif    
      /**************** Module Global Variables  *****************/
      /* flags */
***************
*** 313,316 ****
--- 341,345 ----
      uint32_t backoff(uint8_t counter) {
          uint32_t rVal = call Random.rand16() &  MIN_BACKOFF_MASK;
+         if(!INCREASE_BACKOFF) counter = 1;
          return (rVal << counter) + ZERO_BACKOFF_MASK;
      }
***************
*** 540,544 ****
      
      uint32_t calcGeneratedTime(red_mac_header_t *m) {
!         return rxTime - m->time - TIME_CORRECTION;
      }
      /**************** Init ************************/
--- 569,580 ----
      
      uint32_t calcGeneratedTime(red_mac_header_t *m) {
!         uint32_t lt = rxTime - m->time - TIME_CORRECTION;
! #ifdef DELTATIMEDEBUG
!         dTrace.now = rxTime;
!         dTrace.msgTime = lt;
!         dTrace.delta = m->time;
!         call DeltaTrace.traceRx(&dTrace);
! #endif
!         return lt;
      }
      /**************** Init ************************/
***************
*** 840,843 ****
--- 876,882 ----
                              // sdDebug(194);
                              storeStrength(msg);
+ #ifdef DELTATIMEDEBUG
+                             dTrace.sender = getHeader(msg)->src;
+ #endif
                              getMetadata(msg)->time = calcGeneratedTime((red_mac_header_t*) payload);
                              getMetadata(msg)->ack = WAS_NOT_ACKED;
***************
*** 959,962 ****
--- 998,1002 ----
              macState = SLEEP;
              if(isFlagSet(&flags, RESUME_BACKOFF)) {
+                 nav = nav*(uint32_t)ADD_NAV/(uint32_t)NAV_FACTOR;
                  if(nav > restLaufzeit) restLaufzeit += nav;
              }
***************
*** 1019,1024 ****
--- 1059,1072 ----
      async event void RadioTimeStamping.transmittedSFD( uint16_t time, message_t* p_msg ) {
          if((macState == TX) && (p_msg == txBufPtr)) {
+ #ifdef DELTATIMEDEBUG
+             dTrace.now = call LocalTime32kHz.get();
+             dTrace.msgTime = getMetadata(p_msg)->time;
+             dTrace.delta = call TimeDiff32.computeDelta(dTrace.now, dTrace.msgTime);
+             txMacHdr->time = dTrace.delta;
+             call DeltaTrace.traceTx(&dTrace);
+ #else
              txMacHdr->time =
                  call TimeDiff32.computeDelta(call LocalTime32kHz.get(), getMetadata(p_msg)->time);
+ #endif
          }
      }
***************
*** 1271,1276 ****
      default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
  
!     /***** unused Radio Modes events **************************/
      
      async event void RadioModes.TimerModeDone() {}
      async event void RadioModes.SelfPollingModeDone() {}
--- 1319,1342 ----
      default async event void ChannelCongestion.congestionEvent(uint8_t level) {}
  
!     /***** Mac Eval *******************************************/
! #ifdef MAC_EVAL
!     async command void MacEval.setBackoffMask(uint16_t mask) {
!         atomic MIN_BACKOFF_MASK = mask;
!     }
!     async command void MacEval.increaseBackoff(bool value) {
!         atomic INCREASE_BACKOFF = value;
!     }
!     async command void MacEval.addNav(bool value) {
!         atomic ADD_NAV = value;
!     }
!     async command void MacEval.setLongRetry(uint8_t lr) {
!         atomic MAX_LONG_RETRY = lr;
!     }
!     async command void MacEval.setShortRetry(uint8_t sr) {
!         atomic MAX_SHORT_RETRY = sr;
!     }    
! #endif
      
+     /***** unused Radio Modes events **************************/
      async event void RadioModes.TimerModeDone() {}
      async event void RadioModes.SelfPollingModeDone() {}

Index: RedMacC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/RedMacC.nc,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** RedMacC.nc	1 Oct 2007 17:58:07 -0000	1.8
--- RedMacC.nc	13 Feb 2008 10:32:15 -0000	1.9
***************
*** 37,41 ****
  
  #ifdef REDMAC_PERFORMANCE
! #include <Performance.h>
  #endif
  
--- 37,41 ----
  
  #ifdef REDMAC_PERFORMANCE
! #include <PerformanceMsgs.h>
  #endif
  
***************
*** 48,51 ****
--- 48,54 ----
      interface Sleeptime;
      interface ChannelCongestion;
+ #ifdef MAC_EVAL
+     interface MacEval;
+ #endif
    }
    uses {
***************
*** 108,111 ****
--- 111,117 ----
      RedMacP.Led3 -> PlatformLedsC.Led3;
  */
+ #ifdef MAC_EVAL
+     MacEval = RedMacP;
+ #endif
  #ifdef REDMAC_DEBUG
      components new SerialDebugC() as SD;
***************
*** 117,120 ****
--- 123,131 ----
      RedMacP.Performance -> Perf;
  #endif
+ 
+ #ifdef DELTATIMEDEBUG
+     components DeltaTraceC;
+     RedMacP.DeltaTrace -> DeltaTraceC;
+ #endif
  }
  

Index: CsmaMacP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/tda5250/mac/CsmaMacP.nc,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** CsmaMacP.nc	1 Oct 2007 17:58:07 -0000	1.14
--- CsmaMacP.nc	13 Feb 2008 10:32:15 -0000	1.15
***************
*** 90,96 ****
  
      enum {
!         BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
!         PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
!         PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
  
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,
--- 90,104 ----
  
      enum {
!         /*
!           BYTE_TIME=21,                 // byte at 23405 kBit/s, 4b6b encoded
!           PREAMBLE_BYTE_TIME=14,        // byte at 23405 kBit/s, no coding
!           PHY_HEADER_TIME=84,           // 6 Phy Preamble at 23405 bits/s
!           TIME_CORRECTION=16,           // difference between txSFD and rxSFD: 475us
!         */
!         
!         BYTE_TIME=14,                 // byte at 35108 kBit/s, 4b6b encoded
!         PREAMBLE_BYTE_TIME=9,         // byte at 35108 kBit/s, no coding
!         PHY_HEADER_TIME=56,           // 6 Phy Preamble at 35108 bits/s
!         TIME_CORRECTION=11,           // difference between txSFD and rxSFD: to do
  
          SUB_HEADER_TIME=PHY_HEADER_TIME + sizeof(tda5250_header_t)*BYTE_TIME,



More information about the Tinyos-2-commits mailing list