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);
}