Respected Sir,

Thanks a lot for replying. It really means a lot to me.

I was indeed overwriting some memory in the code, which I have fixed.
So for the time being got rid of segmentation fault.

But the main problem still persists.

I have attached the code snippet in the file 'details.txt'. Please
take a look whenever convenient for you.
Here  nodes 1 and 2 send data to the leader node 3 which takes average
of 2 packets and sends this to base station.

Now the code runs in an infinite loop because 3 keeps on getting data,
calculates correct average and sends to base station. But the base
station isnt receiving any data. How do I make it receive ? The event
should be triggered on its own isnt it?

Or if you can suggest some other way of doing the same thing ?

I hope to hear again from you.I am sure your pointers will help me
progress further.

Thanking you in advance.

Regards,
Kiraneet


On 11/26/09, Paul Johnson <[email protected]> wrote:
> Kiraneet,
>
> As stated before, tinyos-1.x hasn't been in development for a few years,
> so it's unlikely that many people on the list are going to be able to
> give you much support.  Please include at least the important code
> segments that you modified/created, otherwise, I can only guess in the
> dark about the problem.
>
> If TOSSIM is segfaulting, then it's very likely that you have some
> memory corruption issues.  (unless there were some issues in TOSSIM for 1.x)
>
> -Paul
>
> Kiraneet sharma wrote:
>> Hello everyone...
>>
>> I had asked this query earlier but since I got no reply yet..I am
>> trying to explain the problem in detail.If someone could help me I
>> would be really grateful.
>>
>> I am trying to simulate data aggregation in tinyos-1.x
>>
>> I have 6 nodes:
>> 1 and 2 send their data to their leader i.e. node 3..similarly 4 and 5
>> send data to node 6..
>> after about collecting three readings nodes 3 and 6 calculate the
>> average and send the aggregated data to base station i.e. node 0.
>>
>>
>> This thing is done entirely in simulation and works well for ONE time
>> only.
>> After that nodes 3 and 6 continue to correctly calculate the average
>> and send data to base station,however it is never received.
>>
>> The thing is that when I am trying to implement the same logic without
>> any average calculation then it works fine.
>>
>> To implement this entire logic I have added a few statements in
>> receive and send in AMStandard.
>>
>> So is it possible that multiple sends are done consecutively and so
>> packet collision occurs, causing the packets to be dropped and not
>> being received by base station?
>>
>> At times the program terminates with a segmentation fault ?
>> Any pointers where should I do this averaging thing ? Where does the
>> problem lie?
>>
>> Thanks a lot in advance..
>>
>> Hope to hear from you..
>>
>> Best regards,
>> Kiraneet
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> Tinyos-help mailing list
>> [email protected]
>> https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help
>
Within AMStandard.nc which is located in opt/tinyos-1.x/tos/system/


  command result_t SendMsg.send[uint8_t id](uint16_t addr, uint8_t length, 
TOS_MsgPtr data) {
    if (!state) {
        ...
      }

      if (!(post sendTask())) {
        ...
        }
      else 
        {
        /*This I have added*/
        /*If the packet is being sent to leader node 3, then insert required 
data
        this is according to my appln needs, so am just writing here mydata
        for better understanding*/

     if(addr==3)
        {
                if(packets_recv3<2)
                {

                packets_send3++;

                /*Depending on odd or even packets different data is to be 
sent*/
              switch(packets_send3%2)
                        {
                        case 0: data->data[0]=mydata1;
                                        data->data[1]=mydata2;
                                        printf("Data populated 1 case\n");
                                        break;

                      case 1:   data->data[0]=mydata3;
                                        data->data[1]=mydata4;
                                        printf("Data populated 2 case\n");
                                        break;

                      default:    break;

                        }
                }
                else
                packets_send3=0;
                
        }
        /*If packet is for base station then put the average calculated in data 
packets*/
        else if(addr==0)
        {
        data->data[0]=avg3_x;
        data->data[1]=avg3_y;
        avg3_x=0;
        avg3_y=0;
        }
//This is the same as in original file
        buffer = data;
        data->length = length;
        data->addr = addr;
        data->type = id;
        buffer->group = TOS_AM_GROUP;
        
      }
      return SUCCESS;
    }
...

  TOS_MsgPtr received(TOS_MsgPtr packet)  __attribute__ ((C, spontaneous)) {
        ...
 if (packet->crc == 1 && // Uncomment this line to check crcs
        packet->group == TOS_AM_GROUP &&
        (packet->addr == TOS_BCAST_ADDR ||
         packet->addr == addr))      
      {
/*These 3 lines are added here in the same form as it is in IntToRfmM.nc*/
        struct TOS_Msg data_avg3;
        IntMsg *message = (IntMsg *)data_avg3.data;
        message->src = TOS_LOCAL_ADDRESS;

/*If packet is received by leader node 3*/
if(packet->addr==3) 
{
/*No of packets received is less than 2 we shall just add the values and store
and if this counter becomes 2 then calculate average
so aggregating only 2 packets here*/
if(packets_recv3<2)
        {
        packets_recv3++;
        avg3_x+=packet->data[0];
        avg3_y+=packet->data[1];
        }

if(packets_recv3==2)
        {
        avg3_x/=2;
        avg3_y/=2;

//send to base station
      
      packets_recv3=0;
        packets_send3=0;
        
        call SendMsg.send[4](0,sizeof(IntMsg),&data_avg3); 

        }
}

/*Now if instead of above code I write 
if(packet->addr==3)
call SendMsg.send[4](0,8,packet); 
then it is working perfectly fine
i.e. whatever packets 1 and 2 send are received correctly by 3
and forwarded to 0 and again correctly received by base station.
*/
      
else
{
// base station does it's processing
...
}



_______________________________________________
Tinyos-help mailing list
[email protected]
https://www.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help

Reply via email to