[Tinyos-devel] Tossim - node receives packet althought sending other
Philip Levis
pal at cs.stanford.edu
Wed Jun 17 12:11:12 PDT 2009
On Feb 12, 2009, at 8:05 AM, Lumir Honus wrote:
> I'm sending a patch, I think it fix the problem. Node is now not able
> to receive packet while sending.
> I don't know whether is possible to send attachments directly to
> mailing list, so I dump patch also here.
>
> -----------------------------------------
>
> *** /opt/tinyos-2.1.0/tos/lib/tossim/CpmModelC.nc 2009-02-12
> 16:54:15.000000000 +0100
> --- Desktop/cvstos/tinyos-2.x/tos/lib/tossim/CpmModelC.nc 2007-09-04
> 19:19:22.000000000 +0200
> ***************
> *** 50,56 ****
> message_t* outgoing; // If I'm sending, this is my outgoing packet
> bool requestAck;
> bool receiving = 0; // Whether or not I think I'm receiving a
> packet
> - bool sending = 0; // Whether or not I think I'm sending a
> packet
> struct receive_message;
> typedef struct receive_message receive_message_t;
>
> --- 50,55 ----
> ***************
> *** 72,78 ****
> receive_message_t* allocate_receive_message();
> void free_receive_message(receive_message_t* msg);
> sim_event_t* allocate_receive_event(sim_time_t t,
> receive_message_t* m);
> - sim_event_t* allocate_sending_finished_event(sim_time_t endTime);
>
> bool shouldReceive(double SNR);
> bool checkReceive(receive_message_t* msg);
> --- 71,76 ----
> ***************
> *** 383,391 ****
> if (!sim_mote_is_on(sim_node())) {
> dbg("CpmModelC", "Lost packet from %i due to %i being off\n",
> source, sim_node());
> rcv->lost = 1;
> - }else if (sending){
> - dbg("CpmModelC", "Node can not receive it sends another
> packet.\n");
> - rcv->lost = 1;
> }
> else if (!shouldReceive(power - noiseStr)) {
> dbg("CpmModelC,SNRLoss", "Lost packet from %i to %i due to SNR
> being too low (%i)\n", source, sim_node(), (int)(power - noiseStr));
> --- 381,386 ----
> ***************
> *** 414,424 ****
> sim_queue_insert(evt);
>
> }
> -
> - // Node finished sending packet
> - void sim_sending_finished_handle(sim_event_t* evt) {
> - sending = 0;
> - }
>
> void sim_gain_put(int dest, message_t* msg, sim_time_t endTime,
> bool receive, double power, double reversePower) {
> int prevNode = sim_node();
> --- 409,414 ----
> ***************
> *** 430,443 ****
>
> command void Model.putOnAirTo(int dest, message_t* msg, bool ack,
> sim_time_t endTime, double power, double reversePower) {
> gain_entry_t* neighborEntry = sim_gain_first(sim_node());
> - sim_event_t* evt;
> requestAck = ack;
> outgoing = msg;
> - // Node is busy until does not send the whole packet
> - evt = allocate_sending_finished_event(endTime);
> - sim_queue_insert(evt);
> - sending = 1;
> -
> dbg("CpmModelC", "Node %i transmitting to %i, finishes at
> %llu.\n", sim_node(), dest, endTime);
>
> while (neighborEntry != NULL) {
> --- 420,427 ----
> ***************
> *** 464,479 ****
> return evt;
> }
>
> - sim_event_t* allocate_sending_finished_event(sim_time_t endTime)
> - {
> - sim_event_t* evt = (sim_event_t*)malloc(sizeof(sim_event_t));
> - evt->mote = sim_node();
> - evt->time = endTime;
> - evt->handle = sim_sending_finished_handle;
> - evt->cleanup = sim_queue_cleanup_event;
> - return evt;
> - }
> -
> receive_message_t* allocate_receive_message() {
> return (receive_message_t*)malloc(sizeof(receive_message_t));
> }
> --- 448,453 ----
Sorry it took so long, but this bug has now been fixed in the tree.
It turns out correctly catching all the cases was a little more
complex than the above patch. There is no longer a case where a node
can receive a packet while transmitting.
Phil
More information about the Tinyos-devel
mailing list