Unable to access Sequence Number

160 views
Skip to first unread message

Sumukh

unread,
Mar 26, 2017, 11:56:17 AM3/26/17
to OMNeT++ Users
Hi Alfonso, 

I am working on the DSDV protocol using the INET framework and and trying  to retrieve the Sequence Number of a current node in my network, i.e. If the control is presently at Node 4, how do I get the Sequence Number of Node 4, using its IP address.
 
How do I access  the sequence number with the help of IP address of the node? Or is there any other method of retrieving the sequence number?

                    IPv4Address source = (interface80211ptr->ipv4Data()->getIPAddress());
                    recHello->setSequencenumber(sequencenumber);

I tried doing the above, but the Sequence Number is set to null which is its initialized value. Kindly help. 

Thanks in Advance.
Best Regards.

Alfonso Ariza Quintana

unread,
Mar 26, 2017, 6:46:12 PM3/26/17
to omn...@googlegroups.com

I don't have clear what do you want, you can access to the last know sequence number using the routing table, it is an attribute of the routing entries


De: omn...@googlegroups.com <omn...@googlegroups.com> en nombre de Sumukh <sumuk...@gmail.com>
Enviado: domingo, 26 de marzo de 2017 17:56:17
Para: OMNeT++ Users
Asunto: [Omnetpp-l] Unable to access Sequence Number
 
--
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.

Hazard

unread,
Mar 27, 2017, 5:18:38 AM3/27/17
to OMNeT++ Users, aari...@hotmail.com
Hi Sir,

When I receive an update from the Neighbouring node, before forwarding this update to the next node, I am trying to put in the sequence number of my node in this update packet. When I create a pointer to my Routing Table and try to access the "Sequence Number" field, it gives me Segmentation Fault error saying that the pointer is pointing to a an empty entry. 

                    IPv4Route *_CurRoute = rt->findBestMatchingRoute(source);
                    DSDVIPv4Route *CurRoute = dynamic_cast<DSDVIPv4Route *>(_CurRoute);
                    unsigned int CurSeqNum = CurRoute->getSequencenumber();

I tried doing the above but got a segmentation fault. "source" field in  "IPv4Route *_CurRoute = rt->findBestMatchingRoute(source)" is  the address of my current node. 
Message has been deleted

Hazard

unread,
Mar 28, 2017, 6:08:31 AM3/28/17
to OMNeT++ Users, aari...@hotmail.com
Hello,

Please Correct me if I  am wrong. Suppose my Routing Table at  Node 4 looks like this :


Destination        Next Hop          Metric         Seq.No

      1                       3                     2                406
      2                       5                     2                128
      3                       3                     1                564
      4                       4                     0                710
      5                       5                     1                392

When I create a pointer to the routing table(of Node 4) to find the best matching route for any particular node say for example Node 3 using the following command,

                IPv4Route *_entrada_routing = rt->findBestMatchingRoute(src);
                DSDVIPv4Route *entrada_routing = dynamic_cast<DSDVIPv4Route *>(_entrada_routing);  

then it will retrieve the details about Node 3 with the help of this pointer. In a similar way, there should be a place where Node 4 has information about itself right?(Information like Sequence Number). How do I access this Information? I know that a Node does not store Information about itself in its routing table, but there must be a place where it stores the Sequence Number information and its IP address. How do I access this Sequence Number information?In this example Sequence Number of Node 4. 

I would be really happy to know where I am going wrong in my understanding.

Thanks and Best Regards. 

Hazard

unread,
Mar 28, 2017, 8:00:16 AM3/28/17
to OMNeT++ Users, aari...@hotmail.com
Yes I checked it. But I am getting strange kind of values. When I ran the protocol in Debug mode, and put a breakpoint at: 

------------------->        DSDVIPv4Route *entrada_routing = dynamic_cast<DSDVIPv4Route *>(_entrada_routing);  

the pointer *entrada_routing was pointing to an address when the control was at this instruction. As soon as the control jumped to the next instruction, the value of *entrada_routing pointing to is changing to NULL.  In short 

If (entrada_routing  !=nullptr) {

}


entrada_routing  is a NULL pointer.  But the other strange part is that it is entering the loop,                        


                if (entrada_routing != nullptr)

                            rt->deleteRoute(entrada_routing);

                      {

                            e->setDestination(src);

                            e->setNetmask(netmask);

                            e->setGateway(next);

                            e->setInterface(interface80211ptr);

                            e->setSourceType(IRoute::MANET);

                            e->setMetric(numHops);

                            e->setSequencenumber(msgsequencenumber);

                            e->setExpiryTime(simTime()+routeLifetime);

                    }

How can it enter the loop if the condition is false?Is there something wrong that I am doing?


Thanks and Regards.

Hazard

unread,
Mar 28, 2017, 7:34:39 PM3/28/17
to OMNeT++ Users, aari...@hotmail.com
Thanks for the explanation. How do I go about it? The Dynamic Cast is failing as you said and is returning a NULL pointer. To cast a base class pointer(in this case IPv4Route *_entrada_routing) to a derived class(DSDVIPv4Route *entrada_routing) pointer requires the IPv4Route base class to have a virtual member function and IPv4Route already has it. But still the dynamic cast is failing. What is the solution to this?Without this pointer, I am not able to access the contents of the routing table and hence the sequence number.

Kindly help.

Thanks and Regards.

Hazard

unread,
Mar 29, 2017, 10:42:54 AM3/29/17
to OMNeT++ Users, aari...@hotmail.com
Hi Alfonso, 

I tried doing this.

                                                                            IPv4Route *_entrada_routing = new DSDVIPv4Route;
                                                                            _entrada_routing = rt->findBestMatchingRoute(src);
                                                                            DSDVIPv4Route *entrada_routing = dynamic_cast<DSDVIPv4Route *>(_entrada_routing);

Since "_entrada_routing" is a pointer of type IPv4Route and in order for dynamic casting to be successful, Base class pointer has to point to a derived class object. So i assigned 

                                                                         "IPv4Route *_entrada_routing = new DSDVIPv4Route;"

Even though I get a NULL pointer, the DSDV protocol is running fine without errors. But I am not able to get the Sequence Number of the current node. Is there any other method/way to access the Sequence Number of the Current Node.

Thanks and Regards.

Hazard

unread,
Mar 29, 2017, 5:10:23 PM3/29/17
to OMNeT++ Users
the null pointer exception was there initially in the code of the DSDV protocol. Is there some way I can get rid of it? Because, as long as there is this exception, the previous record in the routing table would not be deleted and every time a new record will be added in the routing table. Because of this exception I am not able to access the sequence number which I need for further processing. Please advice how to proceed further.
Thanks

Alfonso Ariza Quintana

unread,
Mar 31, 2017, 4:09:46 AM3/31/17
to omn...@googlegroups.com
You can check if it is a null pointer
If (ptr == nullptr)
or
If (ptr != nullptr)

And avoid to do anything with the pointer
If (ptr != nullptr) {
}
else {
}


-----Mensaje original-----
De: omn...@googlegroups.com [mailto:omn...@googlegroups.com] En nombre de Hazard
Enviado el: miércoles, 29 de marzo de 2017 23:10
Para: OMNeT++ Users <omn...@googlegroups.com>
Asunto: Re: [Omnetpp-l] Unable to access Sequence Number

the null pointer exception was there initially in the code of the DSDV protocol. Is there some way I can get rid of it? Because, as long as there is this exception, the previous record in the routing table would not be deleted and every time a new record will be added in the routing table. Because of this exception I am not able to access the sequence number which I need for further processing. Please advice how to proceed further.
Thanks

Hazard

unread,
Apr 2, 2017, 3:19:33 PM4/2/17
to OMNeT++ Users, aari...@hotmail.com
Hi Alfonso,

          IPv4Address source = (interface80211ptr->ipv4Data()->getIPAddress());
          recHello->setSequencenumber(sequencenumber);

I tried doing this at the forwarder node. I pointed the interface pointer to the current node. Then I tried to set the sequencenumber using recHello->setSequencenumber(sequencenumber). But  "sequencenumber" is initialized to 0 in the header field. So it will return 0. 
Kindly let me know how to get the Sequence Number of the Current Node. Is there any other method by which I get the Sequence Number.

Thanks and Regards.  

Hazard

unread,
Apr 2, 2017, 3:52:25 PM4/2/17
to OMNeT++ Users, aari...@hotmail.com
How do I emit the signal?Because till now I have never come across this and have been working with the Sequence Number part. I have been trying to achieve this for quite sometime now but without any success. Like there is a way to find out the IP address of the current node using this "interface80211ptr->ipv4Data()->getIPAddress()" instruction, there must be a way to access the fields of the current node right?A node should store info about itself somewhere.

Thanks and Regards.

Hazard

unread,
Apr 4, 2017, 5:15:12 AM4/4/17
to OMNeT++ Users, aari...@hotmail.com
Thank you sir. I humbly appreciate your help. I will try the L3Resolver to access the Routing Table.

Thanks and Regards.

Hazard

unread,
Apr 5, 2017, 9:38:31 AM4/5/17
to OMNeT++ Users, aari...@hotmail.com
Hi Alfonso Sir,

I could access my Interface table using the L3Resolver. However, when I tried accessing the Routing Table using the L3Resolver using the following code, It did not display anything. 

                      cModule *hostFrwdr = getContainingNode(this)
                      IIPv4RoutingTable *frwdrRt = L3AddressResolver().findIPv4RoutingTableOf(hostFrwdr);
                       cout << "Routing Table of the Current Node is: " << frwdrRt->printRoutingTable() << endl;

I tried using the "printRoutingTable()" to debug and check if it works. But It returns an error. How do I access my Routing Table? How can I Iterate through my routing table and access the entries in it?

Thanks and Regards.

Hazard

unread,
Apr 7, 2017, 8:30:16 AM4/7/17
to OMNeT++ Users, aari...@hotmail.com
Hi Alfonso Sir,

Thank you for your patience and help sir. Now I am able to Iterate through my routing table and obtain the IP address stored in the routing table. I can even access the Sequence Number corresponding to the IP address. However when I tried accessing the position thats stored in my Routing Table, its returning me (0, 0, 0).  I Debugged my program, to check if the value which is being set in the routing table with this instruction "e->setPosition(pos);" is setting the values as it should. 
My setPosition function looks like this. 

                                virtual Coord setPosition(const Coord& pos) {return pos;}

Its not able to set the value in the routing table.

However "Hello->setPosition(pos);" , Coord ThisPos = recHello->getPosition(); "recHello->setPosition(ThisPos);" works. But  "e->setPosition(pos);" fails and hence when I retrieve the position which is stored in my routing table, I get  (0, 0, 0). Why is it that it fails when it tries to set the position in the routing table? Kindly help Sir. 

Thanks and Regards

Hazard

unread,
Apr 7, 2017, 9:02:07 AM4/7/17
to OMNeT++ Users, aari...@hotmail.com
Hello Sir, 

Apologizes!!!!!I figured out that the "setPosition" method was not written properly. I changed my method to this : virtual void setPosition(const Coord& pos){this->pos = pos;}. I am able to retrieve the values now. 
I Humbly appreciate your help.
Thank you Sir. 

Hazard

unread,
Apr 24, 2017, 5:13:01 AM4/24/17
to OMNeT++ Users, aari...@hotmail.com
Hello Alfonso Sir,

Greetings!!!!!!!!!!!!!!!!!!!!!!

I have written a function to check if the co-ordinates saved in my Routing Table are with a specific Communication Range. I have used a Scheduler and my function checks the validity of the collected co-ordinates at this Scheduled instant. For instant, I have scheduled my Function to check the validity starting at 30 seconds, and after every 1 second(i.e 31s, 32s, 33s...), my Function prints the co-ordinates saved in my Routing Table and checks if they are valid or not. I am calling my Function from the Handle Message function after checking whether the event I created is a "self-messge"(Basically a Scheduler). I want to plot a graph to check the percentage of valid nodes as the routing period elapses. So I tried using the "Scalar and Vector" recording which is inbuilt in Omnet. But I am not able to see the values of my Function and I am not able to plot them. However, the output of my Function is being printed in the console but I am not able to get them in the recorded Scalar and Vector values. Kindly suggest how to plot the values of my Function using the Scalars and Vectors concept.

Thanks and Regards.    
Message has been deleted

Hazard

unread,
May 16, 2017, 1:34:58 PM5/16/17
to OMNeT++ Users, aari...@hotmail.com

Hello Sir,


I have written a method which collects these values and stores them. and later this method is called through a scheduler after every second to check these values. I have managed to get these values. However, I am trying to schedule this event for only 10 Nodes from a total of 30 nodes in my network. I am trying to do this with the help of the ini file. For example, in the ini file, I have set


**.host[5-15].manetrouting.myevent = true.


In the DSDV.cc file, in the initialize stage, I read this boolean value and schedule an event like this:


if(par ("myevent").boolvalue())

{

myEvent = new cMessage("myEvent"); 

simtime_t eventTime = par ("eventTime")

scheduleAt(simTime()+eventTimemyEvent);

}


However, when I check the GUI during simulation, myEvent has been scheduled for all the 30 nodes. I want this event("myEvent") to be scheduled for only 10 nodes. What am I doing wrong here?


Thanks and Regards.


  

On Monday, May 15, 2017 at 12:58 PM UTC+2, Hazard wrote: 


Hello Alfonso Sir,
Thank you. I have set the Vector recording and now its able to record the values in a Vector file.  

Is it possible to get the "time" a node sent its previous "DSDV_Hello message" and the position(coordinates) it was at that particular instant when it made the previous DSDV Hello message announcement?  I checked the cEvent Class to see if there is any method to get the previous events in the event set. But I did not find any which serves my purpose. All the nodes in my network have to check these 2 values(last announcement of the DSDV Hello Message and its postion) and they check this after a particular time interval(with the help of a scheduler). Can you please suggest how to get these 2 values? 

Thanks and Regards.

Hazard

unread,
May 16, 2017, 2:10:37 PM5/16/17
to OMNeT++ Users, aari...@hotmail.com
Hello Sir,

I solved this too. There was a problem in the way I was reading the parameter from the ini file. I solved it. Thank you.

Regards
Message has been deleted
Message has been deleted
Message has been deleted
Message has been deleted

Hazard

unread,
May 27, 2017, 6:16:21 AM5/27/17
to OMNeT++ Users, aari...@hotmail.com
Hello Sir, 
Thank you for the reply. The checks are already in the default code, but since I am trying to optimize the DSDV protocol, I added some new checks. The problem is that, the number of Hello messages created in very large in number and for just 50 nodes, its taking a lot of time to simulate(when the simulation time = 300s). I have 2 questions:

First, I recognized that as the simulation time passes by, there are 3-4 entries in my Routing Table for each node. Which means the old entries are not getting deleted. I check the source code for the method "findBestMatchingRoute(const IPv4Address& dest)" and "deleteRoute(IPv4Route *entry)" in the "IPv4RoutingTable.cc" file, but its strange that the old routes are not getting deleted. How do I delete routes explicitly 'OR' should I delete these routes explictly(the 'deleteRoute' method should do this, but seeing the results seems like its not doing it)? 

Second, in the "addRoute(IPv4Route *entry)" method there is a call to "internalAddRoute(entry)" . The description of the "internalAddRoute(entry)" says that "The 'routes' vector may contain multiple routes with the same destination/netmask.
 Routes are stored in descending netmask length and ascending administrative_distance/metric order, so the first matching is the best one." This means, the route with the "best metric" is selected as the the "Best Route" even if the 'sequence number' is an old one and invalid(since there is more than one entry per destination). This creates an inconsistency in the whole protocol, since the old information will be propagating through the network because of which the nodes will be exchanging invalid information. I have attached a screenshot of the 'Routing Table' of a random node in my network. How do I solve this Sir? Kindly advice!! 

Thanks and Regards.


I don’t understand, all the conditions that are in the check are already in the default code,

 

if (_entrada_routing == nullptr

                    || (_entrada_routing != nullptr && _entrada_routing->getNetmask() != IPv4Address::ALLONES_ADDRESS)

                    || (entrada_routing != nullptr && (msgsequencenumber>(entrada_routing->getSequencenumber()) || (msgsequencenumber == (entrada_routing->getSequencenumber()) && numHops < (entrada_routing->getMetric())))))

 

Also, you need to check the condition of equal number of sequence



On Wednesday, May 17, 2017 at 7:04 PM UTC+2, Hazard wrote:

Apologizes Sir.                        

Here is what I am doing. Before the entrada_routing I add one more if condition to check the freshness of details about the IP address contained in the "next" field of the received Hello message.

 if(src!=next){
                    if (_FrwdRoute==nullptr || (_FrwdRoute != nullptr && _FrwdRoute->getNetmask() != IPv4Address::ALLONES_ADDRESS)
                            || (FrwdRoute != nullptr &&  (seqNumFrwd>(FrwdRoute->getSequencenumber()))))
                  {      
                         if (FrwdRoute != nullptr)
                            rt->deleteRoute(FrwdRoute);

                        {

                            IPv4Address netmask = IPv4Address::ALLONES_ADDRESS; // IPv4Address(par("netmask").stringValue());
                            DSDVIPv4Route *f = new DSDVIPv4Route();

                            f->setDestination(next);
                            f->setNetmask(netmask);
                            f->setGateway(source);
                            f->setInterface(interface80211ptr);
                            f->setSourceType(IRoute::MANET);
                            f->setMetric(1);
                            rt->addRoute(f);
                        }

#ifdef      NOforwardHello
                       DSDV_HelloMessage neighbourHello = new DSDV_HelloMessage("neighbourHello");

                        IPv4ControlInfo *controlInfoForNeighbour = new IPv4ControlInfo();
                        controlInfoForNeighbour->setDestAddr(IPv4Address(255, 255, 255, 255)); //let's try the limited broadcast 255.255.255.255 but multicast goes from 224.0.0.0 to 239.255.255.255
                        controlInfoForNeighbour->setSrcAddr(source); //let's try the limited broadcast
                        controlInfoForNeighbour->setProtocol(IP_PROT_MANET);
                        controlInfoForNeighbour->setInterfaceId(interface80211ptr->getInterfaceId());

                        neighbourHello->setControlInfo(controlInfoForNeighbour);

            neighbourHello -> setSrcIPAddress(next); → neighbours IP address

           neighbourHello -> setSequencenumber(sequencenumber);

           neighbourHello -> setNextIPAddress(source); → current nodes IP address

           neighbourHello -> setHopdistance(1);

           sendDelayed(neighbourHello, waitTime, "ipOut");



after this check, the entrada_routing pointer check the information about the "src" field in the received Hello message. I hope this will make it clear what I am trying to do.


Thanks and Regards.

Multiple Routes.png

Hazard

unread,
Jun 28, 2017, 2:45:44 AM6/28/17
to OMNeT++ Users, aari...@hotmail.com
Hi Alfonso Sir,
Thank you for your valuable input. I am able to delete all the invalid entries in my Routing Table. I have a question regarding Priority Queuing. I am trying to implement priority queuing at the IP layer in the DSDV protocol. I would like to prioritize the DSDV Hello messages over any other data messages. That is, when the DSDV module receives any message, If the message is a Hello message then it should be given the first priority over data messages. I got a brief idea of how priority queuing is done through your answers in these following posts : 
 
https://groups.google.com/forum/#!searchin/omnetpp/priority$20queue%7Csort:relevance/omnetpp/2ZvlFCIacgY/XHOKr9FmlgwJ
 
https://groups.google.com/forum/#!searchin/omnetpp/priority$20queueing%7Csort:relevance/omnetpp/XT2XsmsQ5Hc/L3p6LhLgDAsJ

But the concept is still not clear. How do I implement this priority queuing at the IP layer when a msg is received? Shoud I use a classifier? If yes then kindly suggest which is the best one for this purpose.

Regards
Reply all
Reply to author
Forward
0 new messages