X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=tos%2Flib%2Ftossim%2FUscGainInterferenceModelC.nc;h=284d2d6329067361e177844172415551f8ad53b3;hb=1e6876d1dc58d93708669a64ed5d9c058c65ef91;hp=26c280eba74c0ffbac8c47a194f35273fe37d4dd;hpb=b410ae3a294c1858497ece38de0b60b43fbfee92;p=tinyos-2.x.git diff --git a/tos/lib/tossim/UscGainInterferenceModelC.nc b/tos/lib/tossim/UscGainInterferenceModelC.nc index 26c280eb..284d2d63 100644 --- a/tos/lib/tossim/UscGainInterferenceModelC.nc +++ b/tos/lib/tossim/UscGainInterferenceModelC.nc @@ -134,18 +134,23 @@ implementation { receive_message_t* predecessor = NULL; receive_message_t* list = outstandingReceptionHead; dbg("Gain", "Handling reception event @ %s.\n", sim_time_string()); + // Scan the list for the node which precedes the one pointing + // to the received packet. while (list != NULL) { if (list->next == mine) { predecessor = list; } if (list != mine) { - if ((list->power - sim_gain_sensitivity()) < heardSignal()) { + if ((list->power - sim_gain_sensitivity()) < mine->power) { 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; } + // Remove the received packet from the oustanding list by updating + // the list pointers: A->B->C becomes A->C. If the received packet + // is the head of the queue, then update the head pointer. if (predecessor) { predecessor->next = mine->next; } @@ -155,7 +160,10 @@ implementation { else { dbgerror("Gain", "Incoming packet list structure is corrupted: entry is not the head and no entry points to it.\n"); } - + // Because the packet has been removed from the queue, it is not + // included in heardSignal(): this line tests if the Signal of the + // packet is above the threshold over the Noise of all other RF + // energy sources (local noise, other packets, etc.). if ((mine->power - sim_gain_sensitivity()) < heardSignal()) { dbg("Gain", "Lost packet from %i as its power %lf was below sensitivity threshold\n", mine->source, mine->power); mine->lost = 1;