[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection
LinkEstimatorP.nc, 1.1.2.4, 1.1.2.5
Omprakash Gnawali
gnawali at users.sourceforge.net
Wed May 17 18:27:02 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv7946
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
LinkEstimatorP.nc
Log Message:
use num entry flag, put neighbor est on the footer
Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/LinkEstimatorP.nc,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -C2 -d -r1.1.2.4 -r1.1.2.5
*** LinkEstimatorP.nc 2 May 2006 01:37:10 -0000 1.1.2.4
--- LinkEstimatorP.nc 18 May 2006 01:27:00 -0000 1.1.2.5
***************
*** 59,62 ****
--- 59,66 ----
enum {
VALID_ENTRY = 0x1,
+ NEW_ENTRY = 0x2
+ };
+
+ enum {
EVICT_QUALITY_THRESHOLD = 0x20,
MAX_AGE = 6,
***************
*** 86,94 ****
typedef nx_struct neighbor_stat_entry {
nx_am_addr_t ll_addr;
! nx_int8_t inquality;
} neighbor_stat_entry_t;
typedef nx_struct linkest_footer {
- nx_uint16_t num_entries;
neighbor_stat_entry_t neighborList[1];
} linkest_footer_t;
--- 90,97 ----
typedef nx_struct neighbor_stat_entry {
nx_am_addr_t ll_addr;
! nx_uint8_t inquality;
} neighbor_stat_entry_t;
typedef nx_struct linkest_footer {
neighbor_stat_entry_t neighborList[1];
} linkest_footer_t;
***************
*** 99,103 ****
nx_am_addr_t ll_addr;
nx_uint8_t seq;
! nx_uint8_t linkest_footer_offset;
} linkest_header_t;
--- 102,106 ----
nx_am_addr_t ll_addr;
nx_uint8_t seq;
! nx_uint8_t num_entries;
} linkest_header_t;
***************
*** 121,129 ****
uint8_t i, j;
dbg("LI", "newlen1 = %d\n", len);
- newlen = len + sizeof(linkest_header_t) + sizeof(linkest_footer_t);
- call Packet.setPayloadLength(msg, newlen);
hdr = getHeader(msg);
footer = getFooter(msg, len);
- footer->num_entries = 0;
j = 0;
for (i = 0; i < NEIGHBOR_TABLE_SIZE; i++) {
--- 124,129 ----
***************
*** 135,139 ****
footer->neighborList[j].inquality);
! j = ++footer->num_entries;
}
--- 135,139 ----
footer->neighborList[j].inquality);
! j++;
}
***************
*** 142,151 ****
hdr->ll_addr = call SubAMPacket.address();
hdr->seq = linkEstSeq++;
! hdr->linkest_footer_offset = sizeof(linkest_header_t) + len;
dbg("LI", "newlen2 = %d\n", newlen);
- if (j > 0) {
- newlen += j * sizeof(neighbor_stat_entry_t);
- }
- dbg("LI", "newlen3 = %d\n", newlen);
return newlen;
}
--- 142,148 ----
hdr->ll_addr = call SubAMPacket.address();
hdr->seq = linkEstSeq++;
! hdr->num_entries = j;
! newlen = sizeof(linkest_header_t) + len + j*sizeof(linkest_footer_t);
dbg("LI", "newlen2 = %d\n", newlen);
return newlen;
}
***************
*** 295,299 ****
command error_t Init.init() {
- uint8_t i;
dbg("LI", "Link estimator init\n");
initNeighborTable();
--- 292,295 ----
***************
*** 364,368 ****
command uint8_t LinkEstimator.getForwardQuality(uint16_t neighbor) {
uint8_t idx;
- uint16_t q;
idx = findIdx(neighbor);
if (idx == INVALID_RVAL) {
--- 360,363 ----
***************
*** 382,385 ****
--- 377,389 ----
newlen = addLinkEstHeaderAndFooter(msg, len);
dbg("LI", "Sending seq: %d\n", linkEstSeq);
+ {
+ uint8_t ii;
+ uint8_t* b;
+ b = (uint8_t *)call SubPacket.getPayload(msg, NULL);
+ for(ii=0; ii<newlen; ii++)
+ dbg_clear("LI", "%x ", (uint8_t *)b[ii]);
+ }
+ dbg_clear("LI", "\n");
+
return call AMSend.send(addr, msg, newlen);
}
***************
*** 405,408 ****
--- 409,427 ----
uint8_t len) {
uint8_t nidx;
+
+
+
+ dbg("LI", "LI receiving packet, buf addr: %x\n", payload);
+ {
+ uint8_t ii;
+ uint8_t* b;
+ // b = (uint8_t *)call SubPacket.getPayload(msg, NULL);
+ b = (uint8_t *)msg->data;
+ for(ii=0; ii<call SubPacket.payloadLength(msg); ii++)
+ dbg_clear("LI", "%x ", (uint8_t *)b[ii]);
+ }
+ dbg_clear("LI", "\n");
+
+
if (call SubAMPacket.destination(msg) == AM_BROADCAST_ADDR) {
linkest_header_t* hdr = getHeader(msg);
***************
*** 430,447 ****
}
! if (hdr->linkest_footer_offset > 0) {
! dbg("LI", "There is a linkest footer in this packet: %d\n", hdr->linkest_footer_offset);
! footer = (linkest_footer_t*) (hdr->linkest_footer_offset +
! (uint8_t *)call SubPacket.getPayload(msg, NULL));
! dbg("LI", "Number of footer entries: %d\n", footer->num_entries);
{
uint8_t i, my_ll_addr;
my_ll_addr = call SubAMPacket.address();
! for (i = 0; i < footer->num_entries; i++) {
dbg("LI", "%d %d %d\n", i, footer->neighborList[i].ll_addr,
footer->neighborList[i].inquality);
if (footer->neighborList[i].ll_addr == my_ll_addr) {
updateReverseQuality(hdr->ll_addr, footer->neighborList[i].inquality);
}
--- 449,470 ----
}
! if (hdr->num_entries > 0) {
! dbg("LI", "There is a linkest footer in this packet\n");
! dbg("LI", "size of linkestfooter %d\n", sizeof(linkest_footer_t));
! footer = (linkest_footer_t*) ((uint8_t *)call SubPacket.getPayload(msg, NULL)
! + call SubPacket.payloadLength(msg)
! - hdr->num_entries*sizeof(linkest_footer_t));
!
! dbg("LI", "Number of footer entries: %d\n", hdr->num_entries);
{
uint8_t i, my_ll_addr;
my_ll_addr = call SubAMPacket.address();
! for (i = 0; i < hdr->num_entries; i++) {
dbg("LI", "%d %d %d\n", i, footer->neighborList[i].ll_addr,
footer->neighborList[i].inquality);
if (footer->neighborList[i].ll_addr == my_ll_addr) {
+ dbg("LI", "Found my reverse link to %d\n", hdr->ll_addr);
updateReverseQuality(hdr->ll_addr, footer->neighborList[i].inquality);
}
***************
*** 450,453 ****
--- 473,477 ----
}
+ print_neighbor_table();
}
***************
*** 471,479 ****
command uint8_t Packet.payloadLength(message_t* msg) {
! return call SubPacket.payloadLength(msg) - sizeof(linkest_header_t);
}
command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
! call SubPacket.setPayloadLength(msg, len + sizeof(linkest_header_t));
}
--- 495,512 ----
command uint8_t Packet.payloadLength(message_t* msg) {
! linkest_header_t *hdr;
! hdr = getHeader(msg);
! return call SubPacket.payloadLength(msg)
! - sizeof(linkest_header_t)
! - sizeof(linkest_footer_t)*hdr->num_entries;
}
command void Packet.setPayloadLength(message_t* msg, uint8_t len) {
! linkest_header_t *hdr;
! hdr = getHeader(msg);
! call SubPacket.setPayloadLength(msg,
! len
! + sizeof(linkest_header_t)
! + sizeof(linkest_footer_t)*hdr->num_entries);
}
***************
*** 484,489 ****
command void* Packet.getPayload(message_t* msg, uint8_t* len) {
uint8_t* payload = call SubPacket.getPayload(msg, len);
if (len != NULL) {
! *len -= sizeof(linkest_header_t);
}
return payload + sizeof(linkest_header_t);
--- 517,524 ----
command void* Packet.getPayload(message_t* msg, uint8_t* len) {
uint8_t* payload = call SubPacket.getPayload(msg, len);
+ linkest_header_t *hdr;
+ hdr = getHeader(msg);
if (len != NULL) {
! *len = *len - sizeof(linkest_header_t) - sizeof(linkest_footer_t)*hdr->num_entries;
}
return payload + sizeof(linkest_header_t);
More information about the Tinyos-2-commits
mailing list