On Aug 16, 2007, at 2:20 AM, Marek Jawurek wrote:
Hi everyone,
I tried to understand how Tossim 2.x determines whether a node
receives
a packet and therefore tried to understand the code in
tos/lib/tossim/CpmModelC.nc. I need to understand it in order to
compare
our theoretical assumptions and models to the "reality" in Tossim.
I think I do understand the code in general but I have some questions
regarding the meaning of certain variables and the way some things are
accomplished. I realize that Hyungjune Lee, Philip Levis are the
authors
of CpmModel nevertheless the discussion might be of interest to more
people.
I was primarily interested in how a message sent by a node A is
received
by another node B and what might happen to it on the way.
First I will describe what I think happens, then I will pose my
questions:
The method
command void Model.putOnAirTo(int dest, message_t* msg, bool ack,
sim_time_t endTime, double power, double reversePower) is used by a
node
to send packets over the air. putOnAirTo itself calls sim_put_gain for
every node, for which a link gain has been defined via python oder
the C
++ interface.
sim_put_gain creates a reception event via
enqueue_receive_event(prevNode, endTime, msg, receive, power,
reversePower);
enqueue_receive_event does the following:
1. Check whether the receiving node is off
2. Check whether the power of the message in question, reduced by the
link gain is still loud enough in relation to the noise of all other
messages received at the respective node and the calculated CPM value.
3. Check whether the receiving node is already receiving a message
if either of 1/2/3 is true the current message is marked as lost.
Then, independently of 1/2/3, all messages received so far are
marked as
lost if the current message drowns their signal strength.
In the end (of enqueue_receive_event) the message is inserted on
top of
the list of received messages and a reception event is generated and
inserted for this message and the receiving node. Note that this is
again done independently of the message being lost or not.
In the end,the simulator calls the sim_gain_receive_handle method with
the previously generated reception event as argument.
sim_gain_receive_handle removes the corresponding message from the
list
of received messages, checks again whether the message could have been
understood through the noise of CPM and other incoming messages and
marks it as lost if it cannot.
Finally if the message has not been marked as lost it is handed up to
the next network layer via "signal Model.receive(mine->msg)" and the
message memory is freed.
This all sounds right to me. Note that one inaccuracy in the
simulation is that it only samples noise at the beginning and end of
the packet; if the packet is longer than two CPM samples (2ms), then
the model doesn't automatically sample the middle millisecond.
Ok, when I started to write this mail I had 3 questions that I could
answer myself, so here is the remaining one:
In sim_gain_receive_handle every message strength is again checked
against the noise generated by all other messages because the message
has to be loud and clear through all the time it takes to receive it.
But is this necessary if the handled message is already marked as
lost ?
I guess that you could skip the check if it is already lost.
Phil
_______________________________________________
Tinyos-help mailing list
[email protected]
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help