[Tinyos-devel] CTP data overwritten problem in LinkEstimatorP

Omprakash Gnawali gnawali at usc.edu
Sun Sep 23 19:57:16 PDT 2007


CtpRoutingEngineP calls Beaconsend to get a pointer to the location in
the packet where it can put the routing header:

beaconMsg = call BeaconSend.getPayload(&beaconMsgBuffer, call BeaconSend.maxPayloadLength());

beaconMsg->options = 0;
...

eval = call BeaconSend.send(AM_BROADCAST_ADDR, &beaconMsgBuffer, ...)


The link estimator implementation of getPayload:

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

  // application payload pointer is just past the link estimation header
  command void* Packet.getPayload(message_t* msg, uint8_t len) {
    linkest_header_t *hdr = getHeader(msg);
    uint8_t footerLen = (hdr->flags & NUM_ENTRIES_FLAG) * sizeof(linkest_header_t);
==>    void* payload = call SubPacket.getPayload(msg, len + footerLen);
    if (payload != NULL) {
==>      payload += sizeof(linkest_header_t);
    }
    return payload;
  }


If you look at the two lines marked with arrows, you will notice that
the link estimator gets the payload from the AM packet and allocates
the room for linkest_header_t (payload += sizeof(linkest_header_t)
before returning the payload.

Later when the link estimator needs to put its own header in the
packet, it uses the allocated space:

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


- om_p

> 
> In CtpRoutingEngineP, some ctp_routing_header_t info was put at the
> beginning  of data field(line 391 in CtpRoutingEngineP.nc).
> And then use the BeaconSend interface which is provided by
> LinkEstimatorP(line 139 in CtpP.nc) to send the Beacon message.
> But in LinkEstimatorP, some linkest_header_t info was added at the beginning
> of datafield( line 140 in LinkEstimatorP.nc).
> So, I think the ctp_routing_header_t data was overwritten, right?
> 
> -- 
> Best Regards,
> SANG JUNJUN
> 
> ------=_Part_48702_17417039.1190599373351
> Content-Type: text/html; charset=ISO-8859-1
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> <div>In CtpRoutingEngineP, some ctp_routing_header_t&nbsp;info was put at the
 * beginning&nbsp; of data field(line 391 in CtpRoutingEngineP.nc).</div>
> <div>And then use the BeaconSend interface&nbsp;which is provided by LinkEsti
 *matorP(line 139 in CtpP.nc)&nbsp;to send the Beacon message.</div>
> <div>But in LinkEstimatorP, some linkest_header_t info was added at the begin
 *ning of datafield( line 140 in LinkEstimatorP.nc).<br clear="all">So, I think
 * the ctp_routing_header_t&nbsp;data was overwritten, right?</div>
> <div><br>-- <br>Best Regards,<br>SANG JUNJUN </div>
> 
> ------=_Part_48702_17417039.1190599373351--
> 
> --===============0621624184==
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> _______________________________________________
> Tinyos-devel mailing list
> Tinyos-devel at Millennium.Berkeley.EDU
> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-devel
> 
> --===============0621624184==--


More information about the Tinyos-devel mailing list