Dijkstra Algorithm

594 views
Skip to first unread message

adisi...@gmail.com

unread,
Jun 27, 2017, 2:00:47 AM6/27/17
to OMNeT++ Users

Hello Alfonso Sir,

I am working with the DSDV protocol with few changes to it. I am trying to compare the path(number of hops) taken by a message from a 'Src' to a 'Destination' using my DSDV protocol and the actual shortest path(lowest cost/hop count) that exits in the network to reach the Destination. I am also trying to compare if there exists a path from the "Src" to "Destination" in my Routing table and in the actual actual topology. I read in the documentation that the actual shortest path can be obtained using the inbuilt Dijkstra's Algorithm in the cTopology class. I extracted the topology like this:

cTopology *topo = new cTopology("topo");

    topo->extractByProperty("Node");


for (int i = 0; i < topo->getNumNodes(); i++) {
       if(i==10){                                                            //considering node 10 as my Destination

cTopology::Node *targetNode = topo->getNode(i);

        int numOfPaths = targetNode->getNumPaths();

       if(targetNode->getPath(numOfPaths) && rt->getRoute(i)){         //Here  I am using targetNode->getPath(numOfPaths) to check if there exists a path in the topology to the destination 10.

         cout << Route Exists;

        }

}
 topo->calculateWeightedSingleShortestPathsTo(topo->getNode(i)); //Calculate the shortest path(Number of hops to the Destination)

}

I have 2 questions Sir.

1. Is there any other method that can be used to check the existence of a path in the Network 'OR' is comparison i have done using the if statement "if (targetNode->getPath(numOfPaths) && rt->getRoute(i))" the correct way to do it?

2. I did not understand how to get the number of hops from a given "Src" to a "Destination" using "topo->calculateWeightedSingleShortestPathsTo(topo->getNode(i));". How to get the hop count value after this step Sir?

Kindly Help!!

Regards,
Advithiya.






Alfonso Ariza Quintana

unread,
Jun 27, 2017, 4:01:46 AM6/27/17
to omn...@googlegroups.com

If you are using wireless nodes you cannot use cTopo to compute the path, it is valid for wired only

 

Respect to your question, if you are using a wireless network, the answer is no and no, you cannot use targetNode->getPath or topo->calculateWeightedSingleShortestPathsTo

--
You received this message because you are subscribed to the Google Groups "OMNeT++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to omnetpp+u...@googlegroups.com.
Visit this group at https://groups.google.com/group/omnetpp.
For more options, visit https://groups.google.com/d/optout.

adisi...@gmail.com

unread,
Jun 27, 2017, 4:10:35 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
Thank you for the reply Sir.

Yes,  I am using wireless nodes in my network which are in moving. Is there any other way I can extract the topology from the network and compare it with my Routing table entries?

Regards,
Advithiya

adisi...@gmail.com

unread,
Jun 27, 2017, 4:30:31 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
To get the position of the nodes, I have to get the mobility modules of all the nodes and get their positions. And then apply the Dijkstras Algorithm on these positions. But for that, I need to get the mobility modules of the nodes from the simulator. Is there a possibility to get the mobility modules of all the nodes in my network from the simulator? Can the mobility modules be stored in a vector during the initialization stage and then later accessed to apply the Dijkstras Algorithm?

Kindly help Sir

adisi...@gmail.com

unread,
Jun 27, 2017, 5:45:56 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
I have already tried this Sir.

        cTopology topo("topo");

        topo.extractByProperty("node");

        //std::vector<IMobility *> posVect;//------------>Creates a Vector to store the Mobility Module of all the nodes and is initialized in the header file.

          for (int i = 0; i < topo.getNumNodes(); i++)

        {

            cTopology::Node *destNode = topo.getNode(i);//virtual Node *getNode(int i)------>return pointer to the ith node in the graph

            IMobility *mod;

            cModule *host = destNode->getModule();

            mod = check_and_cast<IMobility *>(host->getSubmodule("mobility"));

            posVect.push_back(mod);

        }

I have this code in my 'void DSDV_2::initialize(int stage)' method during which the initialization takes place. But later when i print the size of the 'posVect' in handleMessage() function, its empty.

adisi...@gmail.com

unread,
Jun 27, 2017, 6:02:22 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
No sir. I have defined the posVect in the header file.

std::vector<IMobility *> posVect; // initialized in the header file

adisi...@gmail.com

unread,
Jun 27, 2017, 6:14:37 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
Just an update Sir. Now the size of the posVect is 1 when i print it in the handle message function. But if my network, consists of 50 nodes, the size should be 50.

adisi...@gmail.com

unread,
Jun 27, 2017, 6:47:43 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
I changed the value of extractByProperty from 'node'  to "networkNode". Now all the modules are being strored in my vector and it says that the size of the vector is 50. How do I apply the Dijkstras algorithm on these mobility modules after retrieving their positions?

adisi...@gmail.com

unread,
Jun 27, 2017, 7:44:43 AM6/27/17
to OMNeT++ Users, aari...@hotmail.com
Thank you Sir. For example, in my network. I have a basic udpApp. The sender(host 0) is sending the msg to the destination(host 45). As you said, "If the distance is lower that a value, you can suppose that exist a link between nodes, in other case no" . This link you said,  is it between the "src and its neighbours" or between the "src and dest" nodes?  What value is this? In my network, the maxCommunicationRange is 300m. I want to first calculate, if there exists a path between the source and destination after applying the dijkstras algorithm. Then I want  to calculate the number of hops needed to reach the destination. I went through the inbuilt implementation DijkstraKshortest.cc, but I did not understand how to use it with my vector containing the mobility modules. I am a bit confused here.

adisi...@gmail.com

unread,
Aug 22, 2017, 6:49:27 PM8/22/17
to OMNeT++ Users, aari...@hotmail.com
Dear Alfonso Sir,

Greetings!

I have written a simple module for Statistic Collection in my DSDV protocol and added it in my network. This simple module does some statistic collection and the code for statistic collection is written in the finish() function of my simple module. There is no code in the handleMessage() function. I tried to schedule this simple module to start the statistic collection process after 50s i.e when the simulation ends and the finish() function of my simple module is called, this should  collect the statistics of the network starting from the starting from the 50th second until the end of the simulation till the 200th second. I checked the manual but did not figure out how to schedule the a simple module. Kindly help Sir!!

Regards,
Advithiya

serap bakioglu

unread,
Dec 4, 2018, 4:06:27 AM12/4/18
to OMNeT++ Users
Dear Alfonso;

I run some examples related to rip, ospf,eigrp and is-is.

Basically, I want to show the shortest paths between nıdes and some performance metrics like throughput, end-to-end, packet delivery ratio.

What way do you suggest me?

Thank you and best regards,
Serap

27 Haziran 2017 Salı 11:01:46 UTC+3 tarihinde Alfonso Ariza Quintana yazdı:

Alfonso Ariza Quintana

unread,
Dec 6, 2018, 4:40:32 AM12/6/18
to serap bakioglu, OMNeT++ Users
If you use a udp source, you can record de end to end delay and pdr, the number of hops, i do not know i the routing protocol records it

Enviado desde mi Honor


-------- Mensaje original --------
Asunto: Re: [Omnetpp-l] Dijkstra Algorithm
De: serap bakioglu
Para: OMNeT++ Users
CC:

Ana Lopes

unread,
May 16, 2019, 1:04:42 PM5/16/19
to OMNeT++ Users
Hi,

Do you know the net file .cc where I can get that info that you are talking about?

Thanks in advance
To unsubscribe from this group and stop receiving emails from it, send an email to omn...@googlegroups.com.

Alfonso Ariza Quintana

unread,
May 17, 2019, 4:21:54 AM5/17/19
to omn...@googlegroups.com
Can you specify a bit more?
I don't know what do you want.

De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de Ana Lopes <arm....@campus.fct.unl.pt>
Enviado: jueves, 16 de mayo de 2019 19:04
Para: OMNeT++ Users

Ana Lopes

unread,
May 17, 2019, 10:12:27 AM5/17/19
to OMNeT++ Users
Hi, sorry

What I wanted to know is where the routing protocol is implemented on 802.11. Like what is the file where the packet forwarding is made.

Thank you

Alfonso Ariza Quintana

unread,
May 17, 2019, 10:50:03 AM5/17/19
to omn...@googlegroups.com
Quite vague, you can implement the routing and forwarding in the link layer or in the network layer, if it is in the network layer, it is the ipv4.cc code that has the routing tables and forwarding, the routing protocol sets the routing tables of the ip protocol and it is this protocol that does the forwarding.
The different routing protocols (AODV, DYMO, OLSR ... ) have internal routing tables that they maintain synchronized with the routing table of ip protocol.

Enviado: viernes, 17 de mayo de 2019 16:12

serap bakioglu

unread,
May 17, 2019, 11:29:19 AM5/17/19
to omn...@googlegroups.com
What about shortest paths? How can we see the paths?

17 May 2019 Cum 17:50 tarihinde Alfonso Ariza Quintana <aari...@hotmail.com> şunu yazdı:
You received this message because you are subscribed to a topic in the Google Groups "OMNeT++ Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/omnetpp/HuU8zzrbeAg/unsubscribe.
To unsubscribe from this group and all its topics, send an email to omnetpp+u...@googlegroups.com.

Alfonso Ariza Quintana

unread,
May 17, 2019, 11:36:38 AM5/17/19
to omn...@googlegroups.com
With AODV, DYMO or batman, you cannot if you don't modify the code, the nodes only maintains the next hop. You can access from your code, to the routing table over every node using the class L3Addressresolver and iterate over the different routing tables of the nodes and to obtain the complete path

De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de serap bakioglu <serapb...@gmail.com>
Enviado: viernes, 17 de mayo de 2019 17:28
Para: omn...@googlegroups.com

serap bakioglu

unread,
May 18, 2019, 5:22:56 AM5/18/19
to omn...@googlegroups.com
Well, thanks for your reply. For RIP, OSPF, EIGRP and IS-IS, is it possible to see shortest paths?
When I looked each router's routing table, I am very confused.

Alfonso Ariza Quintana <aari...@hotmail.com>, 17 May 2019 Cum, 18:36 tarihinde şunu yazdı:

Alfonso Ariza Quintana

unread,
May 19, 2019, 7:43:19 AM5/19/19
to omn...@googlegroups.com

With RIP no, with OSPF, the protocol can see the route, but I don't know if the actual code allows to show it. The easier to obtain a route, with independency of the protocol, is iterate over the routing tables of the nodes, you can use L3AddressReolver to extract the routing table of the different nodes and extract the complete route.



Enviado: sábado, 18 de mayo de 2019 11:22

serap bakioglu

unread,
May 24, 2019, 3:05:56 AM5/24/19
to omn...@googlegroups.com
Is there any example for understanding how to use  L3AddressReolver?

Alfonso Ariza Quintana <aari...@hotmail.com>, 19 May 2019 Paz, 14:43 tarihinde şunu yazdı:
Reply all
Reply to author
Forward
0 new messages