[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection LinkEstimatorP.nc, 1.1.2.11, 1.1.2.12

Omprakash Gnawali gnawali at users.sourceforge.net
Sun Jun 4 04:54:45 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	LinkEstimatorP.nc 
Log Message:
send the number of entries that can fit in this packet, do round robin if all the packet is too small to fit all the entries

Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/LinkEstimatorP.nc,v
retrieving revision 1.1.2.11
retrieving revision 1.1.2.12
diff -C2 -d -r1.1.2.11 -r1.1.2.12
*** LinkEstimatorP.nc	4 Jun 2006 02:44:00 -0000	1.1.2.11
--- LinkEstimatorP.nc	4 Jun 2006 11:54:42 -0000	1.1.2.12
***************
*** 162,165 ****
--- 162,169 ----
    // we send out beacon if curBeaconInterval == BEACON_INTERVAL
    uint8_t curBeaconInterval = 0;
+   // if there is not enough room in the packet to put all the neighbor table
+   // entries, in order to do round robin we need to remember which entry
+   // we sent in the last beacon
+   uint8_t prevSentIdx = 0;
  
    // get the link estimation header in the packet
***************
*** 180,200 ****
      linkest_header_t *hdr;
      linkest_footer_t *footer;
!     uint8_t i, j;
      dbg("LI", "newlen1 = %d\n", len);
      hdr = getHeader(msg);
      footer = getFooter(msg, len);
-     j = 0;
-     for (i = 0; i < NEIGHBOR_TABLE_SIZE; i++) {
-       if (NeighborTable[i].flags & VALID_ENTRY) {
- 	footer->neighborList[j].ll_addr = NeighborTable[i].ll_addr;
- 	footer->neighborList[j].inquality = NeighborTable[i].inquality;
  
  	dbg("LI", "Loaded on footer: %d %d %d\n", j, footer->neighborList[j].ll_addr,
  	    footer->neighborList[j].inquality);
- 
  	j++;
- 
        }
      }
  
      hdr->ll_addr = call SubAMPacket.address();
--- 184,211 ----
      linkest_header_t *hdr;
      linkest_footer_t *footer;
!     uint8_t i, j, k;
!     uint8_t maxEntries, newPrevSentIdx;
      dbg("LI", "newlen1 = %d\n", len);
      hdr = getHeader(msg);
      footer = getFooter(msg, len);
  
+     maxEntries = ((call SubPacket.maxPayloadLength() - len - sizeof(linkest_header_t))
+ 		  / sizeof(linkest_footer_t));
+     dbg("LI", "Max payload is: %d, maxEntries is: %d\n", call SubPacket.maxPayloadLength(), maxEntries);
+ 
+     j = 0;
+     newPrevSentIdx = 0;
+     for (i = 0; i < NEIGHBOR_TABLE_SIZE && j < maxEntries; i++) {
+       k = (prevSentIdx + i + 1) % NEIGHBOR_TABLE_SIZE;
+       if (NeighborTable[k].flags & VALID_ENTRY) {
+ 	footer->neighborList[j].ll_addr = NeighborTable[k].ll_addr;
+ 	footer->neighborList[j].inquality = NeighborTable[k].inquality;
+ 	newPrevSentIdx = k;
  	dbg("LI", "Loaded on footer: %d %d %d\n", j, footer->neighborList[j].ll_addr,
  	    footer->neighborList[j].inquality);
  	j++;
        }
      }
+     prevSentIdx = newPrevSentIdx;
  
      hdr->ll_addr = call SubAMPacket.address();



More information about the Tinyos-2-commits mailing list