[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/tossim CpmModelC.nc, 1.4, 1.5 TossimActiveMessageP.nc, 1.5, 1.6 sim_csma.h, 1.4, 1.5

Phil Levis scipio at users.sourceforge.net
Thu May 17 15:04:02 PDT 2007


Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/tossim
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv8649

Modified Files:
	CpmModelC.nc TossimActiveMessageP.nc sim_csma.h 
Log Message:
Fixed CpmModelP to correctly lose packets caused by subsequent transmissions.

Adjust constants in CSMA to reflect the current CC2420 stack.




Index: CpmModelC.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tossim/CpmModelC.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** CpmModelC.nc	21 Apr 2007 07:02:50 -0000	1.4
--- CpmModelC.nc	17 May 2007 22:03:59 -0000	1.5
***************
*** 249,260 ****
        dbgerror("CpmModelC", "Incoming packet list structure is corrupted: entry is not the head and no entry points to it.\n");
      }
!     
      if (!checkReceive(mine)) {
!       dbg("CpmModelC", "Lost packet as SNR was too low.\n");
        mine->lost = 1;
      }
-     
      if (!mine->lost) {
!       dbg_clear("CpmModelC", "  -signaling reception, ");
        signal Model.receive(mine->msg);
        if (mine->ack) {
--- 249,259 ----
        dbgerror("CpmModelC", "Incoming packet list structure is corrupted: entry is not the head and no entry points to it.\n");
      }
!     dbg("CpmModelC,SNRLoss", "Packet from %i to %i\n", (int)mine->source, (int)sim_node());
      if (!checkReceive(mine)) {
!       dbg("CpmModelC,SNRLoss", " - lost packet from as SNR was too low.\n");
        mine->lost = 1;
      }
      if (!mine->lost) {
!       dbg_clear("CpmModelC,SNRLoss", "  -signaling reception\n");
        signal Model.receive(mine->msg);
        if (mine->ack) {
***************
*** 274,278 ****
      else {
        receiving = 0;
!       dbg_clear("CpmModelC", "  -packet was lost.\n");
      }
      free(mine);
--- 273,277 ----
      else {
        receiving = 0;
!       dbg_clear("CpmModelC,SNRLoss", "  -packet was lost.\n");
      }
      free(mine);
***************
*** 283,286 ****
--- 282,286 ----
    void enqueue_receive_event(int source, sim_time_t endTime, message_t* msg, bool receive, double power) {
      sim_event_t* evt;
+     receive_message_t* list;
      receive_message_t* rcv = allocate_receive_message();
      double noiseStr = packetNoise(rcv);
***************
*** 303,318 ****
      }
      else if (!shouldReceive(power - noiseStr)) {
        rcv->lost = 1;
      }
      else if (receiving) {
        rcv->lost = 1;
      }
      else {
        receiving = 1;
-       rcv->next = outstandingReceptionHead;
-       outstandingReceptionHead = rcv;
-       evt = allocate_receive_event(endTime, rcv);
-       sim_queue_insert(evt);
      }
    }
    
--- 303,331 ----
      }
      else if (!shouldReceive(power - noiseStr)) {
+       dbg("CpmModelC,SNRLoss", "Lost packet from %i to %i due to SNR being too low (%i)\n", source, sim_node(), (int)(power - noiseStr));
        rcv->lost = 1;
      }
      else if (receiving) {
+       dbg("CpmModelC,SNRLoss", "Lost packet from %i due to %i being mid-reception\n", source, sim_node());
        rcv->lost = 1;
      }
      else {
        receiving = 1;
      }
+ 
+     list = outstandingReceptionHead;
+     while (list != NULL) {
+       if (!shouldReceive(list->power - rcv->power)) {
+ 	dbg("Gain,SNRLoss", "Going to lose packet from %i with signal %lf as am receiving a packet from %i with signal %lf\n", list->source, list->power, source, rcv->power);
+ 	list->lost = 1;
+       }
+       list = list->next;
+     }
+     
+     rcv->next = outstandingReceptionHead;
+     outstandingReceptionHead = rcv;
+     evt = allocate_receive_event(endTime, rcv);
+     sim_queue_insert(evt);
+ 
    }
    

Index: TossimActiveMessageP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tossim/TossimActiveMessageP.nc,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** TossimActiveMessageP.nc	11 Apr 2007 01:29:44 -0000	1.5
--- TossimActiveMessageP.nc	17 May 2007 22:03:59 -0000	1.6
***************
*** 126,130 ****
      tossim_header_t* header = getHeader(msg);
      if (header->dest == call amAddress()) {
!       dbg("Acks", "addressed to me so ack it,");
        return TRUE;
      }
--- 126,130 ----
      tossim_header_t* header = getHeader(msg);
      if (header->dest == call amAddress()) {
!       dbg("Acks", "Received packet addressed to me so ack it\n");
        return TRUE;
      }

Index: sim_csma.h
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/tossim/sim_csma.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** sim_csma.h	12 Dec 2006 18:23:35 -0000	1.4
--- sim_csma.h	17 May 2007 22:03:59 -0000	1.5
***************
*** 36,40 ****
  
  #ifndef SIM_CSMA_INIT_HIGH
! #define SIM_CSMA_INIT_HIGH 400
  #endif 
  
--- 36,40 ----
  
  #ifndef SIM_CSMA_INIT_HIGH
! #define SIM_CSMA_INIT_HIGH 640
  #endif 
  
***************
*** 72,81 ****
  
  #ifndef SIM_CSMA_MIN_FREE_SAMPLES
! #define SIM_CSMA_MIN_FREE_SAMPLES 2
  #endif
  
  // 500 us ~= 32 symbols
  #ifndef SIM_CSMA_RXTX_DELAY 
! #define SIM_CSMA_RXTX_DELAY 32
  #endif
  
--- 72,81 ----
  
  #ifndef SIM_CSMA_MIN_FREE_SAMPLES
! #define SIM_CSMA_MIN_FREE_SAMPLES 1
  #endif
  
  // 500 us ~= 32 symbols
  #ifndef SIM_CSMA_RXTX_DELAY 
! #define SIM_CSMA_RXTX_DELAY 11
  #endif
  



More information about the Tinyos-2-commits mailing list