setdelay not working as expected

52 views
Skip to first unread message

Adi Saravanan

unread,
Mar 29, 2020, 5:05:48 AM3/29/20
to ns-3-users
i have modified aodv and have used a setdelay function on a timer which doesnt seem to work. i'm not sure if its because another function is using the timer as well, but i set the timer with a delay of 0 seconds. but i am unable to call the function by using setdelay. the code is AODV-routing-protocol.cc in ns-3.29 which i have edited. i would be really grateful if someone could point out what im doing wrong.

void
 RoutingProtocol::sendDiag (Ipv4Address dst)
 {
   RoutingTableEntry toDst;
   m_routingTable.LookupRoute(dst,toDst);
   NS_LOG_FUNCTION (this << toDst.GetDestination ());
   Ipv4InterfaceAddress iface;
   Ipv4Address src;
   for (std::map<Ptr<Socket>, Ipv4InterfaceAddress>::const_iterator j =
          m_socketAddresses.begin (); j != m_socketAddresses.end (); ++j)
        {
        Ipv4InterfaceAddress iface = j->second;
        if(IsMyOwnAddress (iface.GetLocal()))
                src=iface.GetLocal();
        }      
   diagHeader diaghdr (  /*dst=*/dst , /*origin=*/ src,/*next hop*/toDst.GetNextHop ());
   Ptr<Packet> packet = Create<Packet> ();
   packet->AddHeader (diaghdr);
   TypeHeader tHeader (AODVTYPE_DIAG);
   packet->AddHeader (tHeader);
   RoutingTableEntry toNext;
   Ipv4Address neighbor=toDst.GetNextHop ();
   m_routingTable.LookupRoute(neighbor,toNext);
   m_diagTimer.SetFunction (&RoutingProtocol::DiagExpire, this);
   m_diagTimer.SetArguments (toNext.GetDestination (), m_blackListTimeout*10);
   m_diagTimer.SetDelay (Seconds(0)/*MilliSeconds(m_nextHopWait*2)*/);

   Ptr<Socket> socket = FindSocketWithInterfaceAddress (toDst.GetInterface ());
   NS_ASSERT (socket);
   socket->SendTo (packet, 0, InetSocketAddress (toDst.GetNextHop (), AODV_PORT));
   ///std::cout<<src<<" Sending diag "<<dst<<"\n";
 }

void
 RoutingProtocol::DiagExpire (Ipv4Address neighbor, Time blacklistTimeout)
 {
   NS_LOG_FUNCTION (this);
   std::cout<<"malicious \n";
   m_routingTable.MarkLinkAsUnidirectional (neighbor, blacklistTimeout);
  
 }

Saurabh Kumar

unread,
Apr 1, 2020, 3:23:47 AM4/1/20
to ns-3-users
hello sir,
do you have any code of AODV with node in it?
please share, i am not able to do it in NS3..
or you can send any tutorial for that..
please help..

Adi Saravanan

unread,
Apr 1, 2020, 5:15:04 AM4/1/20
to ns-3-users
do you mean simulation code, it so i have attached a file
aodvtest.cc

Adi Saravanan

unread,
Apr 1, 2020, 5:49:37 AM4/1/20
to ns-3-users
i have also used the schedule after setdelay to see if it works, but it doesnt


Saurabh Kumar

unread,
Apr 1, 2020, 6:39:41 AM4/1/20
to ns-3-...@googlegroups.com
yes.. its not working.


On Wed, Apr 1, 2020 at 3:19 PM Adi Saravanan <adisara...@gmail.com> wrote:
i have also used the schedule after setdelay to see if it works, but it doesnt


--
Posting to this group should follow these guidelines https://www.nsnam.org/wiki/Ns-3-users-guidelines-for-posting
---
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 view this discussion on the web visit https://groups.google.com/d/msgid/ns-3-users/d6d26fcc-cfb5-4e04-a3c9-0999b5a773b8%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages