On Mar 29, 2007, at 2:03 AM, Salvo Fiduccia wrote:


But the "heardSignal()" operates on the "outstandingReceptionHead" list, and I don't understand what are the lines that remove the packet from this list.

Thanks for your attention.
Here's the code snippet:

 void sim_gain_receive_handle(sim_event_t* evt) {
    receive_message_t* mine = (receive_message_t*)evt->data;
    receive_message_t* predecessor = NULL;
    receive_message_t* list = outstandingReceptionHead;
dbg("Gain", "Handling reception event @ %s.\n", sim_time_string ());
    while (list != NULL) {
      if (list->next == mine) {
        predecessor = list;
      }
      if (list != mine) {
        //is the following "if" always true?
====>        if ((list->power - sim_gain_sensitivity()) < heardSignal()) {
          dbg("Gain", "Lost packet from %i as I concurrently received a
packet stronger than %lf\n", list->source, list- >power);
          list->lost = 1;
        }
      }
      list = list->next;
    }
    ........

outstandingReceptionHead is the head of a singly-linked list of packets that the node is currently hearing. The above lines of code find the node in the list that precedes the packet in question (predecessor). If there is no preceding node, then it must be the head of the list. The next lines of code remove it from the list:

    if (predecessor) {
      predecessor->next = mine->next;
    }
    else if (mine == outstandingReceptionHead) { // must be head
      outstandingReceptionHead = mine->next;
    }

These lines occur before the test you originally mentioned.

I'll check in some comments to explain this.

Phil
_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to