[Tinyos-2-commits] CVS: tinyos-2.x/tos/lib/net/collection LinkEstimatorDummyP.nc, NONE, 1.1.2.1 TreeRouting.notes, 1.1.2.1, 1.1.2.2

Rodrigo Fonseca rfonseca76 at users.sourceforge.net
Tue May 16 15:52:27 PDT 2006


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

Modified Files:
      Tag: tinyos-2_0_devel-BRANCH
	TreeRouting.notes 
Added Files:
      Tag: tinyos-2_0_devel-BRANCH
	LinkEstimatorDummyP.nc 
Log Message:
Added dummy link estimator module just for testing the tree building.


--- NEW FILE: LinkEstimatorDummyP.nc ---
/* $Id: LinkEstimatorDummyP.nc,v 1.1.2.1 2006/05/16 22:52:25 rfonseca76 Exp $ */
/*
 * "Copyright (c) 2006 University of Southern 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 SOUTHERN 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 SOUTHERN CALIFORNIA HAS BEEN
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * THE UNIVERSITY OF SOUTHERN 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
 * SOUTHERN CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
 * SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS."
 *
 */

/*
 @ author Omprakash Gnawali
 @ Created: April 24, 2006
 */


#include "Timer.h"

module LinkEstimatorDummyP {
  provides {
    interface AMSend as Send;
    interface Receive;
    interface LinkEstimator;
    interface Init;
    interface Packet;
    interface LinkSrcPacket;
  }

  uses {
    interface AMSend;
    interface AMPacket as SubAMPacket;
    interface Packet as SubPacket;
    interface Receive as SubReceive;
    interface Timer<TMilli>;
  }
}

implementation {

  // link estimator header added to
  // every message passing thru' the link estimator
  typedef nx_struct linkest_header {
    nx_am_addr_t ll_addr;
  } linkest_header_t;

  linkest_header_t* getHeader(message_t* m) {
    return (linkest_header_t*)call SubPacket.getPayload(m, NULL);
  }


  uint8_t addLinkEstHeaderAndFooter(message_t *msg, uint8_t len) {
    uint8_t newlen;
    linkest_header_t *hdr;
    dbg("LI", "newlen1 = %d\n", len);
    newlen = len + sizeof(linkest_header_t);
    call Packet.setPayloadLength(msg, newlen);
    hdr = getHeader(msg);

    hdr->ll_addr = call SubAMPacket.address();
    dbg("LI", "newlen2 = %d\n", newlen);
    return newlen;
  }

  command error_t Init.init() {
    return SUCCESS;
  }

  event void Timer.fired() { }

  // EETX (Extra Expected number of Transmission)
  // EETX = ETX - 1
  // computeEETX returns EETX*10

  command uint8_t LinkEstimator.getLinkQuality(uint16_t neighbor) {
    return 2;
  }

  command uint8_t LinkEstimator.getReverseQuality(uint16_t neighbor) {
    return 1;
  }

  command uint8_t LinkEstimator.getForwardQuality(uint16_t neighbor) {
    return 1;
  }

  command am_addr_t LinkSrcPacket.getSrc(message_t* msg) {
    linkest_header_t* hdr = getHeader(msg);
    return hdr->ll_addr;
  }

  command error_t Send.send(am_addr_t addr, message_t* msg, uint8_t len) {
    uint8_t newlen;
    newlen = addLinkEstHeaderAndFooter(msg, len);
    return call AMSend.send(addr, msg, newlen);
  }

  event void AMSend.sendDone(message_t* msg, error_t error ) {
    return signal Send.sendDone(msg, error);
  }

  command uint8_t Send.cancel(message_t* msg) {
    return call AMSend.cancel(msg);
  }

  command uint8_t Send.maxPayloadLength() {
    return call Packet.maxPayloadLength();
  }

  command void* Send.getPayload(message_t* msg) {
    return call Packet.getPayload(msg, NULL);
  }

  event message_t* SubReceive.receive(message_t* msg,
				      void* payload,
				      uint8_t len) {
    if (call SubAMPacket.destination(msg) == AM_BROADCAST_ADDR) {
      linkest_header_t* hdr = getHeader(msg);
      dbg("LI", "Got pkt from link: %d\n", hdr->ll_addr);
    }
    
    return signal Receive.receive(msg,
				  call Packet.getPayload(msg, NULL),
				  call Packet.payloadLength(msg));
  }

  command void* Receive.getPayload(message_t* msg, uint8_t* len) {
    return call Packet.getPayload(msg, len);
  }

  command uint8_t Receive.payloadLength(message_t* msg) {
    return call Packet.payloadLength(msg);
  }

  command void Packet.clear(message_t* msg) {
    call SubPacket.clear(msg);
  }

  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));
  }

  command uint8_t Packet.maxPayloadLength() {
    return call SubPacket.maxPayloadLength() - sizeof(linkest_header_t);
  }

  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);
  }

}


Index: TreeRouting.notes
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/lib/net/collection/Attic/TreeRouting.notes,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -C2 -d -r1.1.2.1 -r1.1.2.2
*** TreeRouting.notes	15 May 2006 16:52:41 -0000	1.1.2.1
--- TreeRouting.notes	16 May 2006 22:52:25 -0000	1.1.2.2
***************
*** 2,5 ****
--- 2,10 ----
  Rodrigo Fonseca
  
+ The RoutingTable is a table with information about *routing* information of neighbors: their hopcount, quality, etc. It is used to periodically choose the best route, and to find backup routes.
+ 
+ It is strictly a subset of the LinkEstimator table, meaning that no node that is not in the link estimator table is in the routing table. However, not all neighbors will be here. The policy for managing this table is a generalization of the regular tree routing: we keep the K best paths to *a* root.
+ 
+ 
  Timer has period P jittered with +- P/2
  



More information about the Tinyos-2-commits mailing list