[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection
TreeRoutingInspect.nc, NONE, 1.1.2.1 TreeRoutingEngineP.nc,
1.1.2.7, 1.1.2.8
Rodrigo Fonseca
rfonseca76 at users.sourceforge.net
Sat Jun 10 12:24:24 PDT 2006
Update of /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv27270
Modified Files:
Tag: tinyos-2_0_devel-BRANCH
TreeRoutingEngineP.nc
Added Files:
Tag: tinyos-2_0_devel-BRANCH
TreeRoutingInspect.nc
Log Message:
Added interface TreeRoutingInspect for mostly debugging purposes: clients can get information about the parent, the depth (hopcount), and the quality metric of the path to the root.
--- NEW FILE: TreeRoutingInspect.nc ---
/* $Id: TreeRoutingInspect.nc,v 1.1.2.1 2006/06/10 19:24:22 rfonseca76 Exp $ */
/*
* "Copyright (c) 2005 The Regents of the University of California.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose, without fee, and without written agreement is
* hereby granted, provided that the above copyright notice, the following
* two paragraphs and the author appear in all copies of this software.
*
* IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
* DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
* OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
* CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
* AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
* ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
*
*/
/*
* @author Rodrigo Fonseca
* @date $Date: 2006/06/10 19:24:22 $
* @see Net2-WG
*/
interface TreeRoutingInspect {
/* Get the parent of the node in the tree.
* The pointer is allocated by the caller.
* If the parent is invalid, return FAIL.
* The caller MUST NOT use the value in parent if the return is not SUCCESS
*/
command error_t getParent(am_addr_t* parent);
/* Get the depth (hopcount) of the node in the tree.
* The pointer is allocated by the caller.
* If the parent is invalid, return FAIL (no info).
* The caller MUST NOT use the value in parent if the return is not SUCCESS
*/
command error_t getHopcount(uint8_t* hopcount);
/* Get the path quality metric for the current path to the root through the
* current parent.
* The pointer is allocated by the caller.
* If the parent is invalid, return FAIL (no info).
* The caller MUST NOT use the value in parent if the return is not SUCCESS
*/
command error_t getMetric(uint16_t* metric);
}
Index: TreeRoutingEngineP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeRoutingEngineP.nc,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -C2 -d -r1.1.2.7 -r1.1.2.8
*** TreeRoutingEngineP.nc 2 Jun 2006 02:10:19 -0000 1.1.2.7
--- TreeRoutingEngineP.nc 10 Jun 2006 19:24:22 -0000 1.1.2.8
***************
*** 38,41 ****
--- 38,42 ----
interface UnicastNameFreeRouting as Routing;
interface RootControl;
+ interface TreeRoutingInspect;
interface StdControl;
interface Init;
***************
*** 183,206 ****
entry = &routingTable[i];
! // Avoid bad entries and 1-hop loops
if (entry->info.parent == INVALID_ADDR || entry->info.parent == my_ll_addr) {
! dbg("TreeRouting,LITest", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: NO ROUTE]\n", i, entry->neighbor, entry->info.parent, entry->info.hopcount);
! continue;
! }
!
linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
! dbg("TreeRouting,LITest", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: %d]\n", i, entry->neighbor, entry->info.parent, entry->info.hopcount, linkMetric);
! dbg_clear("TreeRouting,LITest", " metric: %hu.\n", linkMetric);
! pathMetric =linkMetric + entry->info.metric;
//for current parent
if (entry->neighbor == routeInfo.parent) {
currentMetric = pathMetric;
! dbg("TreeRouting", " already parent.\n");
continue;
}
if (!passLinkMetricThreshold(linkMetric)) {
! dbg("TreeRouting", " did not pass threshold.\n");
! continue;
! }
if (pathMetric < minMetric) {
--- 184,207 ----
entry = &routingTable[i];
! // Avoid bad entries and 1-hop loops
if (entry->info.parent == INVALID_ADDR || entry->info.parent == my_ll_addr) {
! dbg("TreeRouting", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: NO ROUTE]\n", i, entry->neighbor, entry->info.parent, entry->info.hopcount);
! continue;
! }
!
linkMetric = evaluateMetric(call LinkEstimator.getLinkQuality(entry->neighbor));
! dbg("TreeRouting", "routingTable[%d]: neighbor: [id: %d parent: %d hopcount: %d metric: %d]\n", i, entry->neighbor, entry->info.parent, entry->info.hopcount, linkMetric);
! dbg_clear("TreeRouting", " metric: %hu.\n", linkMetric);
! pathMetric = linkMetric + entry->info.metric;
//for current parent
if (entry->neighbor == routeInfo.parent) {
currentMetric = pathMetric;
! dbg("TreeRouting", " already parent.\n");
continue;
}
if (!passLinkMetricThreshold(linkMetric)) {
! dbg("TreeRouting", " did not pass threshold.\n");
! continue;
! }
if (pathMetric < minMetric) {
***************
*** 236,239 ****
--- 237,242 ----
}
+ /* Inspection interface implementations */
+
/* send a beacon advertising this node's routeInfo */
***************
*** 244,249 ****
return;
}
! beaconMsg->parent = routeInfo.parent;
! beaconMsg->hopcount = routeInfo.hopcount;
if (state_is_root || routeInfo.parent == INVALID_ADDR) {
--- 247,252 ----
return;
}
! beaconMsg->parent = routeInfo.parent;
! beaconMsg->hopcount = routeInfo.hopcount;
if (state_is_root || routeInfo.parent == INVALID_ADDR) {
***************
*** 254,258 ****
}
! dbg("TreeRouting,LITest", "%s parent: %d hopcount: %d metric: %d\n",
__FUNCTION__,
beaconMsg->parent,
--- 257,261 ----
}
! dbg("TreeRouting", "%s parent: %d hopcount: %d metric: %d\n",
__FUNCTION__,
beaconMsg->parent,
***************
*** 296,311 ****
beacon_msg_t* rcvBeacon;
! // Received a beacon, but it's not from us.
! if (len != sizeof(beacon_msg_t)) {
! dbg("LITest", "%s, received beacon of size %hhu, expected %i\n", __FUNCTION__, len, (int)sizeof(beacon_msg_t));
!
! return msg;
! }
!
//need to get the am_addr_t of the source
from = call LinkSrcPacket.getSrc(msg);
rcvBeacon = (beacon_msg_t*)payload;
! dbg("TreeRouting,LITest","%s from: %d [ parent: %d hopcount: %d metric: %d]\n",
__FUNCTION__, from,
rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
--- 299,314 ----
beacon_msg_t* rcvBeacon;
! // Received a beacon, but it's not from us.
! if (len != sizeof(beacon_msg_t)) {
! dbg("LITest", "%s, received beacon of size %hhu, expected %i\n", __FUNCTION__, len, (int)sizeof(beacon_msg_t));
!
! return msg;
! }
!
//need to get the am_addr_t of the source
from = call LinkSrcPacket.getSrc(msg);
rcvBeacon = (beacon_msg_t*)payload;
! dbg("TreeRouting","%s from: %d [ parent: %d hopcount: %d metric: %d]\n",
__FUNCTION__, from,
rcvBeacon->parent, rcvBeacon->hopcount, rcvBeacon->metric);
***************
*** 345,349 ****
return (routeInfo.parent != INVALID_ADDR);
}
!
/* RootControl interface */
/** sets the current node as a root, if not already a root */
--- 348,378 ----
return (routeInfo.parent != INVALID_ADDR);
}
!
! /* TreeRoutingInspect interface */
! command error_t TreeRoutingInspect.getParent(am_addr_t* parent) {
! if (parent == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *parent = routeInfo.parent;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getHopcount(uint8_t* hopcount) {
! if (hopcount == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *hopcount= routeInfo.hopcount;
! return SUCCESS;
! }
! command error_t TreeRoutingInspect.getMetric(uint16_t* metric) {
! if (metric == NULL)
! return FAIL;
! if (routeInfo.parent == INVALID_ADDR)
! return FAIL;
! *metric = routeInfo.metric;
! return SUCCESS;
! }
!
/* RootControl interface */
/** sets the current node as a root, if not already a root */
More information about the Tinyos-2-commits
mailing list