Hi Rasheed,

Segmentation fault is usually due to memory access violation. A common
example is as follows.

int x[10];
x[20] = 0;

where you create an array x with 10 slots, but try to access 20th slot of
x.

Hope this will help.

Best Regards,

Teerawat Issariyakul
http://www.ns2ultimate.com/
http://www.facebook.com/pages/Teerawat-Issariyakul/358240861417
http://twitter.com/T_Bear
http://www.t-issariyakul.blogspot.com
http://www.ece.ubc.ca/~teerawat

On 4/12/2010, "Èļ¼ÀÎ  ¶ó½¬µå[RASHEED HUSSAIN]
rasheed1...@gmail.com"
<=?EUC-KR?B?yMS8vMDOICC2872steVbUkFTSEVFRCBIVVNTQUlOXQ==?=
rasheed1...@gmail.com> wrote:

>
>Dear NS2 Users
>I am facing a very serious problem regarding modification to AODV protocol.
>I have customized AODV Protocol to work as VANET Beaconing Protocol
>according to DSRC Standard.
>I also having implemented the duplicity mechansim where each node on
>receiving a beacon, stores it for certain time to check for duplicity,
>because i want the beacons to travel for multihops.
>i have divided the road into regions and there is a linked list for every
>region which stores the hashes of certain values taken from every beacon.
>i have implemented all this, and when i run my tcl script, it gives
>segmentation fault.
>
>basically i get the segmentation fault after adding the following code (This
>whole code is included in aodv.cc and aodv is no more a routing protocol. it
>is just a VANET Beaconing protocol now which i optimized for my
>simulations).
>
>aodv/aodv.cc
>recev_beacon()
>{
>...
>...
>.....
>receive the beacon and calculate the hash from some values
>////////// Now Save the Beacons
>
> if (xx<=x && x<(xx+200))
>   {
>     bool flag=obj.search(hash2);
>     if (flag==TRUE)
>       {
>     cout<<"Already exists in the linked list"<<endl;
>       }
>     else
>       {
>           obj.add(hash2, 1);
>       //ofstream list1;//for saving hash values
>       //list1.open("linkedlist1.dat", ios::app);
>       //list1<<hash2<<endl;
>       }
>    } // end of if
> else if (x>=xx && (xx<=x && x<(xx+400)))
>   {
>   obj.add(hash2, 2);
>ofstream list2;//for saving hash values
> list2.open("linkedlist2.dat", ios::app);
> list2<<hash2<<endl;
>   }
> else if (x>=xx && (xx<=x && x<(xx+600)))
>   {
>   obj.add(hash2, 3);
>   }
> else if (x>=xx && (xx<=x && x<(xx+1000)))
>   {
>   obj.add(hash2, 4);
>   }
>
>the linked list implemented is given below
>//++++++++++++++++++++++++++++++++++++
>// Defining Linked Lists
>//++++++++++++++++++++++++++++++++++++
>struct list1{
>unsigned int  bid;list1  *link;
>};
>
>struct list2{
>unsigned int  bid;list2  *link;
>};
>
>
>struct list3{
>unsigned int  bid;list3  *link;
>};
>
>struct list4{
>unsigned int  bid;list4  *link;
>};
>
>class list{
>private:
>int i;
>  list1  *cur1,*temp1,*start1;
>  list2  *cur2,*temp2,*start2;
>  list3  *cur3,*temp3,*start3;
>  list4  *cur4,*temp4,*start4;
>
>public:
>
>list()
>{
>start1=NULL;
>start2=NULL;
>start3=NULL;
>start4=NULL;
>}
>
>void add(unsigned int hashval, int listno)
>{
>//cout<<"Enter the list number to add element to";cin>>i;
>// check for list no.
> if (listno==1)
> {
>
>   if(start1==NULL)
>   {
>     start1=new list1;
>     cur1=start1;
>     cur1->bid=hashval;
>     cur1->link=NULL;
>   }
>   else
>   {
>    cur1->link=new list1;
>    cur1=cur1->link;
>    cur1->bid=hashval;
>    cur1->link=NULL;
>   }
>
>  }
> else if (listno==2)
>   {
>    if(start2==NULL)
>     {
>     start2=new list2;
>     cur2=start2;
>     cur2->bid=hashval;
>     cur2->link=NULL;
>     }
>   else
>    {
>    cur2->link=new list2;
>    cur2=cur2->link;
>    cur2->bid=hashval;
>    cur2->link=NULL;
>    }
>   }
>else if (listno==3)
>   {
>    if(start3==NULL)
>     {
>     start3=new list3;
>     cur3=start3;
>     cur3->bid=hashval;
>     cur3->link=NULL;
>     }
>   else
>    {
>    cur3->link=new list3;
>    cur3=cur3->link;
>    cur3->bid=hashval;
>    cur3->link=NULL;
>    }
>   }
>else if (listno==4)
>   {
>    if(start4==NULL)
>     {
>     start4=new list4;
>     cur4=start4;
>     cur4->bid=hashval;
>     cur4->link=NULL;
>     }
>   else
>    {
>    cur4->link=new list4;
>    cur4=cur4->link;
>    cur4->bid=hashval;
>    cur4->link=NULL;
>    }
>   }
>}
>  ////////////////// searching method
>  bool search(unsigned int hashval)
>  {
>    bool b;
> cur1=start1;
>     while (cur1->link!=NULL)
>       {
>     if(cur1->bid==hashval)
>       b=TRUE;
>     else
>       b=FALSE;
>     cur1=cur1->link;
>    }
> return b;
>  }
>
>I will be looking for some help as soon as possible.
>THanks to all concerned in advance!!
>
>
>Rasheed
>

Reply via email to