Dear Msrehmani, I am trying to run the code you have proviede in this link,
but it gives error: common/node.cc: In member function ‘void Node::addNeighbor(Node*)’: common/node.cc:267:9: error: invalid use of member (did you forget the ‘&’ ?) make: *** [common/node.o] Error 1 Can you please help me in compiling this code? One more thing, If I want to forward packet to all the neighbour nodes in aodv, then how it can be done? Can you give any hint regarding the same? Regards, Ranjana [ns] [NS-ANS] Re: Finding the neighbour nodes of a mobile nodeMubashir Rehmani mshrehmani at gmail.com Tue Sep 20 02:47:56 PDT 2011 * Previous message: [ns] Finding the neighbour nodes of a mobile node * Next message: [ns] [NS-ANS] Re: Finding the neighbour nodes of a mobile node * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] ________________________________ Hi, You can use the following methods to discover neighbors: 1. Use Hello Packets for *neighbor* discovery. 2. Use Communication range for neighbour discovery. 3. Use Nodes Positions for *neighbor* discovery. So, it totally depends upon you, how you discover your neighbours. But i would suggest you to use Hello Packets to discover neighbors. What you have to do is simple: Just start sending hello messages by using hello packets (if you dont know this, please ask) or just search ns2 mailing list by my name and hello packets, InshaAllah you will find the way to enable hello packets. Once each and every node is able to send hello packets then each node that receive the hello packet of other node is supposed to be the neighbor of other node. In this way, you would find the number of neighbors of each node. In simple, a node that receives the hello packet of other node is the neighbor of that node. So, there is a function of recvHello() in aodv.cc and you have to write a line of code in recvhello() that each node when receive this packet should make a entry in node.cc (inneighbor table) that i am neighbor node of this node. Node.cc ======== Add this code void Node::addNeighbor(Node * neighbor) { int flag=0; neighbor_list_node* my_neighbor_list; my_neighbor_list=neighbor_list_; //cout <<"MMMMM"<<my_neighbor_list-> nodeid<<endl; //return; while(my_neighbor_list) { if(my_neighbor_list->nodeid == neighbor->nodeid()) { flag = 1; break; } else { my_neighbor_list=my_neighbor_list->next; } } //cout<<"MMM "<<my_neighbor_list->nodeid<<endl; if(flag == 1) { //neighbour already exist do nothing } else { neighbor_list_node* nlistItem = (neighbor_list_node *)malloc(sizeof(neighbor_list_node)); nlistItem->nodeid = neighbor->nodeid(); nlistItem->next = neighbor_list_; neighbor_list_=nlistItem; } } AODV.cc ====== Add these lines in AODV::recvHello(Packet *p) {} function Node* sender_node = Node::get_node_by_address(rp->rp_dst); Node* receiver_node = Node::get_node_by_address(index); sender_node->addNeighbor(receiver_node); receiver_node->addNeighbor(sender_node); ====================================================== Now let me expalin you what i have done. In recvHello funciton whenever a node receives a Hello packet it create two objects of node, sending node and receiving node and then add them in the neighborl list. Secondly in void Node::addNeighbor(Node * neighbor) {}, first a doulbe entry is checked and if found, it won't add the neighbor, else it add the neighbor. After that you can easily get access to any node's neighbor list by creating its object and calling its neighbor list. Node* m_node = Node::get_node_by_address( this->addr()); neighbor_list_node* my_mobile_neighbor_list; my_mobile_neighbor_list = m_node->neighbor_list_; while(my_mobile_neighbor_list) { cout<<"## Mubashir Neighbor ID :"<<my_mobile_neighbor_list->nodeid<<endl; my_mobile_neighbor_list=my_mobile_neighbor_list->next; } cout<<"node id : " <<put here node id<<" Mubashir Neighbor list contains ID :"<<my_mobile_neighbor_list-> nodeid<<endl; Regards Mubashir Husain Rehmani Lip6/UPMC - Sorbonnes Universités, Paris, France On 20 September 2011 11:42, Divya G <divyagalla at gmail.com> wrote: >>Hello Sir..!! >>Can you please help in writing a code for finding all the neighbor nodes of >a mobile node in a wireless scenario. >>Thanks & Regards, >Divya. > -- Mubashir Husain Rehmani ________________________________ * Previous message: [ns] Finding the neighbour nodes of a mobile node * Next message: [ns] [NS-ANS] Re: Finding the neighbour nodes of a mobile node * Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] ________________________________ More information about the Ns-users mailing list