[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection
LinkEstimatorP.nc, 1.1.2.10, 1.1.2.11
Omprakash Gnawali
gnawali at users.sourceforge.net
Sat Jun 3 19:44:02 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv11498
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
LinkEstimatorP.nc
Log Message:
use flags instead of num entries for the header, if pkt generated by the link estimator no need to feed that to the upper app aka router
Index: LinkEstimatorP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/LinkEstimatorP.nc,v
retrieving revision 1.1.2.10
retrieving revision 1.1.2.11
diff -C2 -d -r1.1.2.10 -r1.1.2.11
*** LinkEstimatorP.nc 2 Jun 2006 02:10:19 -0000 1.1.2.10
--- LinkEstimatorP.nc 4 Jun 2006 02:44:00 -0000 1.1.2.11
***************
*** 59,76 ****
// Timer that determines how often beacons should be
// sent and link estimate updated
! #define LINKEST_TIMER 4096
!
- // Flags for the neighbor table entry
- enum {
- VALID_ENTRY = 0x1,
- // A link becomes mature after
- // TABLEUPDATE_INTERVAL*LINKEST_TIMER
- MATURE_ENTRY = 0x2,
- // Flag to indicate that this link has received the
- // first sequence number
- INIT_ENTRY = 0x4
- };
enum {
// If inbound link quality is above this threshold
--- 59,66 ----
// Timer that determines how often beacons should be
// sent and link estimate updated
! #define LINKEST_TIMER_RATE 4096
+ // configure the link estimator and some constants
enum {
// If inbound link quality is above this threshold
***************
*** 97,100 ****
--- 87,102 ----
};
+ // Flags for the neighbor table entry
+ enum {
+ VALID_ENTRY = 0x1,
+ // A link becomes mature after
+ // TABLEUPDATE_INTERVAL*LINKEST_TIMER_RATE
+ MATURE_ENTRY = 0x2,
+ // Flag to indicate that this link has received the
+ // first sequence number
+ INIT_ENTRY = 0x4
+ };
+
+
// neighbor table
typedef struct neighbor_table_entry {
***************
*** 122,125 ****
--- 124,138 ----
} linkest_footer_t;
+ // Masks for the flag field in the link estimation header
+ enum {
+ // use last two bits to keep track of
+ // how many footer entries there are
+ NUM_ENTRIES_FLAG = 0x3,
+ // set to 1 if linkestimator originated the
+ // beacon because upper layer did not send
+ // messages frequently enough
+ SELF_BEACON_FLAG = 0x4
+ };
+
// link estimator header added to
// every message passing thru' the link estimator
***************
*** 127,131 ****
nx_am_addr_t ll_addr;
nx_uint8_t seq;
! nx_uint8_t num_entries;
} linkest_header_t;
--- 140,148 ----
nx_am_addr_t ll_addr;
nx_uint8_t seq;
! // Bits Purpose
! // 1,0 Number of footer entries
! // 2 Was this packet generated by the link estimator?
! // 3..7 Not used yet
! nx_uint8_t flags;
} linkest_header_t;
***************
*** 183,187 ****
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);
--- 200,205 ----
hdr->ll_addr = call SubAMPacket.address();
hdr->seq = linkEstSeq++;
! hdr->flags = 0;
! hdr->flags |= (NUM_ENTRIES_FLAG & j);
newlen = sizeof(linkest_header_t) + len + j*sizeof(linkest_footer_t);
dbg("LI", "newlen2 = %d\n", newlen);
***************
*** 378,382 ****
}
! // initialize the neighbor talbe in the very beginning
void initNeighborTable() {
uint8_t i;
--- 396,400 ----
}
! // initialize the neighbor table in the very beginning
void initNeighborTable() {
uint8_t i;
***************
*** 388,392 ****
command error_t StdControl.start() {
! call Timer.startPeriodic(LINKEST_TIMER);
return SUCCESS;
}
--- 406,411 ----
command error_t StdControl.start() {
! dbg("LI", "Link estimator start\n");
! call Timer.startPeriodic(LINKEST_TIMER_RATE);
return SUCCESS;
}
***************
*** 412,418 ****
--- 431,440 ----
task void sendLinkEstBeacon() {
uint8_t newlen;
+ linkest_header_t *hdr;
if (!beaconBusy) {
newlen = addLinkEstHeaderAndFooter(&linkEstPkt, 0);
+ hdr = getHeader(&linkEstPkt);
+ hdr->flags |= SELF_BEACON_FLAG;
dbg("LI", "Sending seq because noone sent: %d\n", linkEstSeq);
print_packet(&linkEstPkt, newlen);
***************
*** 592,595 ****
--- 614,618 ----
uint8_t len) {
uint8_t nidx;
+ uint8_t num_entries;
dbg("LI", "LI receiving packet, buf addr: %x\n", payload);
***************
*** 601,604 ****
--- 624,628 ----
dbg("LI", "Got seq: %d from link: %d\n", hdr->seq, hdr->ll_addr);
+ num_entries = hdr->flags & NUM_ENTRIES_FLAG;
print_neighbor_table();
***************
*** 640,652 ****
}
! if ((nidx != INVALID_RVAL) && (hdr->num_entries > 0)) {
! dbg("LI", "Number of footer entries: %d\n", hdr->num_entries);
footer = (linkest_footer_t*) ((uint8_t *)call SubPacket.getPayload(msg, NULL)
+ call SubPacket.payloadLength(msg)
! - hdr->num_entries*sizeof(linkest_footer_t));
{
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);
--- 664,676 ----
}
! if ((nidx != INVALID_RVAL) && (num_entries > 0)) {
! dbg("LI", "Number of footer entries: %d\n", num_entries);
footer = (linkest_footer_t*) ((uint8_t *)call SubPacket.getPayload(msg, NULL)
+ call SubPacket.payloadLength(msg)
! - num_entries*sizeof(linkest_footer_t));
{
uint8_t i, my_ll_addr;
my_ll_addr = call SubAMPacket.address();
! for (i = 0; i < num_entries; i++) {
dbg("LI", "%d %d %d\n", i, footer->neighborList[i].ll_addr,
footer->neighborList[i].inquality);
***************
*** 660,665 ****
--- 684,698 ----
print_neighbor_table();
+ // if SELF_BEACON_FLAG is on, we do not need to signal the upper
+ // layer because the beacon was originated by the link estimator
+ if (hdr->flags & SELF_BEACON_FLAG) {
+ dbg("LI", "No need to signal the router, SELF_BEACON_FLAG on\n");
+ return msg;
+ } else {
+ dbg("LI", "It was a router beacon SELF_BEACON_FLAG is off\n");
+ }
}
+
return signal Receive.receive(msg,
call Packet.getPayload(msg, NULL),
***************
*** 686,690 ****
return call SubPacket.payloadLength(msg)
- sizeof(linkest_header_t)
! - sizeof(linkest_footer_t)*hdr->num_entries;
}
--- 719,723 ----
return call SubPacket.payloadLength(msg)
- sizeof(linkest_header_t)
! - sizeof(linkest_footer_t)*(NUM_ENTRIES_FLAG & hdr->flags);
}
***************
*** 697,701 ****
len
+ sizeof(linkest_header_t)
! + sizeof(linkest_footer_t)*hdr->num_entries);
}
--- 730,734 ----
len
+ sizeof(linkest_header_t)
! + sizeof(linkest_footer_t)*(NUM_ENTRIES_FLAG & hdr->flags));
}
***************
*** 710,714 ****
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);
--- 743,747 ----
hdr = getHeader(msg);
if (len != NULL) {
! *len = *len - sizeof(linkest_header_t) - sizeof(linkest_footer_t)*(NUM_ENTRIES_FLAG & hdr->flags);
}
return payload + sizeof(linkest_header_t);
More information about the Tinyos-2-commits
mailing list