How to use AODV hello packet to discover the neighbor

2,074 views
Skip to first unread message

PATEL RAJANKUMAR

unread,
Jan 28, 2014, 2:19:59 AM1/28/14
to ns-3-...@googlegroups.com
Hi,

Anyone know or have a code to discover the neighbor from module AODV.


Konstantinos

unread,
Jan 28, 2014, 3:58:19 AM1/28/14
to ns-3-...@googlegroups.com
Are you looking for example code to implement your own HELLO packets or how to enable HELLO packets in AODV?

AODV has implemented HELLO packets and the code is in /src/aodv/model
You can start looking into those files. It is not a single file you can take but parts on different files.

Regards,
K.

PATEL RAJANKUMAR

unread,
Jan 29, 2014, 3:14:47 AM1/29/14
to ns-3-...@googlegroups.com
sir i am looking example code how to implement hello packet with example if possible.
i referred two neighbor .cc and .h files of aodv model from src.


--
You received this message because you are subscribed to the Google Groups "ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ns-3-users+...@googlegroups.com.
To post to this group, send email to ns-3-...@googlegroups.com.
Visit this group at http://groups.google.com/group/ns-3-users.
For more options, visit https://groups.google.com/groups/opt_out.



--
Regards,
Rajan Patel
Dept. of Computer Engg.,
Sankalchand Patel College of Engg., Visnagar

Tommaso Pecorella

unread,
Jan 29, 2014, 3:32:56 AM1/29/14
to ns-3-...@googlegroups.com
Hi,

as Kostantinos said, AODV already implements HELLO messages. It might be a bit complex to crawl the code, but it's all there.

I'd kindly ask you to state your problem in a better way. I know english might not be your mother language, but if we don't understand your problem and what's your goal, we can t give you any help.

Cheers,

T.

PATEL RAJANKUMAR

unread,
Jan 29, 2014, 4:40:23 AM1/29/14
to ns-3-...@googlegroups.com
sir you just read content of mail, it clearly mention that the node discovery of neighbor nodes using hello packet is available in src. i gone through that but not able to know that how to use the code. so have any example so that i can simulate and able to find neighbor nodes. 

Konstantinos

unread,
Jan 29, 2014, 5:42:07 AM1/29/14
to ns-3-...@googlegroups.com
The code you mention, belongs to the AODV module and implements the Neighbor class used in AODV. This class can be seen as an entry to the list of neighbors.
It is not possible to use part of the code as it is, only to simulate the neighbor discovery.

Some basic steps you have to do to implement a neighbor discovery mechanism are:

- You define your own class (like AODV) or simply a struct (like OLSR) to identify a Neighbor and its properties (e.g. IP address).
- Have a list/vector of that class/struct to store them, this will be your neighbor list.
- Send/Receive HELLO messages and update the list containing the properties you want to store. These messages are broadcast, so no routing is actually needed. Therefore, you can implement the neighbor discovery mechanism even as an application. Create a UDP socket and send HELLO messages, whilst listening to that socket you can receive HELLO messages from others and update your neighbor list. 

Konstantinos Katsaros

unread,
Jan 29, 2014, 12:50:30 PM1/29/14
to PATEL RAJANKUMAR, ns-3-...@googlegroups.com
Hi,

Please send your queries to the ns-3-users mailing list as well. 

To alter the HELLO packet in AODV you have to modify the RREP message header, or define an additional header to add before the RREP

In  /src/aodv/model/aodv-routing-protocol.cc you have the actual send of the HELLO

void

RoutingProtocol::SendHello ()

{

  NS_LOG_FUNCTION (this);

  /* Broadcast a RREP with TTL = 1 with the RREP message fields set as follows:

   *   Destination IP Address         The node's IP address.

   *   Destination Sequence Number    The node's latest sequence number.

   *   Hop Count                      0

   *   Lifetime                       AllowedHelloLoss * HelloInterval

   */

.


The HELLO is in principle a RREP message with 0 hop. 
So, either add the two fields in the RREP header (/src/aodv/model/aodv-packet.h/cc) or define your own header with these two fields.

All the messages generated from AODV (like RREP, RREQ etc) are handled in RecvAodv method and if it is identified to be a HELLO the ProcessHello is called

  // If RREP is Hello message

  if (dst == rrepHeader.GetOrigin ())

    {

      ProcessHello (rrepHeader, receiver);

      return;

    }


I do not think that it is difficult to add more fields in the header. You only need to be careful in the Serialize and Deserialize methods and to calculate the size of the header properly. A guideline on how to create your own header (or update an existing) can be found here http://www.nsnam.org/support/faq/miscellaneous/#adding-data-to-an-existing-packet



-- 
Konstantinos Katsaros

On Wednesday, 29 January 2014 at 17:28, PATEL RAJANKUMAR wrote:

tks sir for your valuable suggestions.

But sir i want to modify the AODV hello packet i.e. suppose, i want
to add two more header fields of Hello packet say: random number and
load of node. After that i will simulate the aodv and to use/display
the new added field for those nodes who will be received the modified
hello packet.

Regards,
Rajan Patel


On 1/29/14, Konstantinos <dinos.k...@gmail.com> wrote:
The code you mention, belongs to the AODV module and implements the
Neighbor class used in AODV. This class can be seen as an entry to the list

of neighbors.
It is not possible to use part of the code as it is, only to simulate the
neighbor discovery.

Some basic steps you have to do to implement a neighbor discovery mechanism

are:

- You define your own class (like AODV) or simply a struct (like OLSR) to
identify a Neighbor and its properties (e.g. IP address).
- Have a list/vector of that class/struct to store them, this will be your
neighbor list.
- Send/Receive HELLO messages and update the list containing the properties

you want to store. These messages are broadcast, so no routing is actually
needed. Therefore, you can implement the neighbor discovery mechanism even
as an application. Create a UDP socket and send HELLO messages, whilst
listening to that socket you can receive HELLO messages from others and
update your neighbor list.


On Wednesday, January 29, 2014 9:40:23 AM UTC, PATEL RAJANKUMAR wrote:

sir you just read content of mail, it clearly mention that the node
discovery of neighbor nodes using hello packet is available in src. i gone

through that but not able to know that how to use the code. so have any
example so that i can simulate and able to find neighbor nodes.


On Wed, Jan 29, 2014 at 2:02 PM, Tommaso Pecorella
<tomm...@gmail.com<javascript:>
wrote:

email to ns-3-users+...@googlegroups.com <javascript:>.
To post to this group, send email to
ns-3-...@googlegroups.com<javascript:>

--
You received this message because you are subscribed to the Google Groups
"ns-3-users" group.
To unsubscribe from this group and stop receiving emails from it, send an
To post to this group, send email to ns-3-...@googlegroups.com.

Samvel

unread,
Apr 29, 2015, 5:31:23 AM4/29/15
to ns-3-...@googlegroups.com
     Greetings, Guys! I'm also learning routing mechanisms in ns3 looking at ns-3 and i'm trying to realize simplified scheme of it in one .cc file. So, for now i got how to send broadcast message and it work well, but still i cant process it receiving.

Ptr<Socket>  socket;

Ipv4InterfaceAddress iface;
 
Ipv4Address destination;
 
Ptr<Packet> packet;
Изменить
uint16_t i
;

 
for (uint16_t j = 0; j<ClusterHeadsCount; j++)
 
{
 i
= ClusterHeads[j];
 iface
= Ipv4InterfaceAddress(AllInterfaces.GetAddress(i,0),"255.255.255.0");
 destination
= iface.GetBroadcast();
 ns3
::PacketMetadata::Enable();
 packet
= Create<Packet> (16);
 socket
= Socket::CreateSocket (AllNodes.Get(i),//GetObject<Node> (),
                                                             
UdpSocketFactory::GetTypeId ());
 socket
->BindToNetDevice (AllDevices.Get(i));
 socket
->SetAllowBroadcast (true);
 
SendTo(socket,packet,destination);
}


I have 50 wireless nodes, some of them randomly becomes Cluster Heads, after they should tell that to all their neighbors, and so on. So how to catch that broadcast hello message, i tried to use socket->Recv() and even socket->RecvFrom(adr), but still hopeless, can someone advice me in witch way should i go. 

 bool u;
 for (uint16_t j =0; j<NodesCount; j++)
 {
    u = false;
    for (uint16_t k=0; k<ClusterHeadsCount; k++)
     if (j==ClusterHeads[k])
         u = true;
    if (!u) 
     {
socket = Socket::CreateSocket (AllNodes.Get(i),//GetObject<Node> (),
                                                             
UdpSocketFactory::GetTypeId ());
 socket
->BindToNetDevice (AllDevices.Get(i));
 packet = socket->Recv();   // here is my problem :(
 std::cout << "packet catched : " << packet << std::endl;
      } 

 }

Respectfully, Samvel.

среда, 29 января 2014 г., 18:42:07 UTC+8 пользователь Konstantinos написал:

Tommaso Pecorella

unread,
Apr 29, 2015, 1:06:50 PM4/29/15
to ns-3-...@googlegroups.com
Hi,

as the wise man said: Make it simpler. Simpler. Not THAT simple.

Don't try to get the shortest path, it may seems to be simpler, but it's the one leading to issues.
Learn how to install an application that sends and receive packets in the nodes and install it in the nodes. Doing it all in a single .cc is possible, but it's definitely harder and more complex.

Follow the tutorial and use the Application concepts.

Have fun,

T.
Reply all
Reply to author
Forward
0 new messages