[Tinyos-devel] DisseminationEngineImplP.nc , sendObject function

Marcin Szczodrak marcin at ieee.org
Mon May 4 16:59:38 PDT 2009


Hi All,

I was working on the Drip protocol and found something that may be a bug.
In tinyos-2.1.0/tos/lib/net/drip/DisseminationEngineImplP.nc  ,
function sendObject sends empty messages with sequence number equal to
DISSEMINATION_SEQNO_UNKNOWN, as result
of Trickle's Timer being fired. However, these messages have been not
initialized for dissemination by the application, and I guess they
should not be disseminated. They simply waste energy. The problematic
lines are the 149-152 , of the original version of code pasted below.
I would like suggest to change them as in the modified version of the
pasted code in lines 149-155. This will avoid sending empty messages.

-Marcin

// ORIGINAL
130   void sendObject( uint16_t key ) {
131     void* object;
132     uint8_t objectSize = 0;
133
134     dissemination_message_t* dMsg =
135       (dissemination_message_t*) call AMSend.getPayload(
&m_buf,sizeof(dissemination_message_t) );
136     if (dMsg != NULL) {
137       m_bufBusy = TRUE;
138
139       dMsg->key = key;
140       dMsg->seqno = call DisseminationCache.requestSeqno[ key ]();
141
142       if ( dMsg->seqno != DISSEMINATION_SEQNO_UNKNOWN ) {
143         object = call DisseminationCache.requestData[ key ]( &objectSize );
144         if ((objectSize + sizeof(dissemination_message_t)) >
145             call AMSend.maxPayloadLength()) {
146           objectSize = call AMSend.maxPayloadLength() -
sizeof(dissemination_message_t);
147         }
148         memcpy( dMsg->data, object, objectSize );
149       }
150       call AMSend.send( AM_BROADCAST_ADDR,
151                         &m_buf, sizeof( dissemination_message_t )
+ objectSize );
152     }
153   }


// MODIFIED
130   void sendObject( uint16_t key ) {
131     void* object;
132     uint8_t objectSize = 0;
133
134     dissemination_message_t* dMsg =
135       (dissemination_message_t*) call AMSend.getPayload( &m_buf,
sizeof(dissemination_message_t) );
136     if (dMsg != NULL) {
137       m_bufBusy = TRUE;
138
139       dMsg->key = key;
140       dMsg->seqno = call DisseminationCache.requestSeqno[ key ]();
141
142       if ( dMsg->seqno != DISSEMINATION_SEQNO_UNKNOWN ) {
143         object = call DisseminationCache.requestData[ key ]( &objectSize );
144         if ((objectSize + sizeof(dissemination_message_t)) >
145             call AMSend.maxPayloadLength()) {
146           objectSize = call AMSend.maxPayloadLength() -
sizeof(dissemination_message_t);
147         }
148         memcpy( dMsg->data, object, objectSize );
149
150         call AMSend.send( AM_BROADCAST_ADDR,
151                           &m_buf, sizeof( dissemination_message_t)
+ objectSize );
152       } else {
153         m_bufBusy = FALSE;
154       }
155     }
156   }



---------------------------------------------------------------------------------------------
Marcin Szczodrak
Ph.D. Student in Department of Computer Science
The Graduate Center
City University of New York
URL: http://web.cs.gc.cuny.edu/~mszczodrak/
----------------------------------------------------------------------------------------------


More information about the Tinyos-devel mailing list