Bug 1190 - Suppress hello if bcast was sent within the last hello interval
This commit is contained in:
@@ -147,12 +147,10 @@ RoutingProtocol::RoutingProtocol () :
|
||||
m_rerrCount (0),
|
||||
m_htimer (Timer::CANCEL_ON_DESTROY),
|
||||
m_rreqRateLimitTimer (Timer::CANCEL_ON_DESTROY),
|
||||
m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY)
|
||||
m_rerrRateLimitTimer (Timer::CANCEL_ON_DESTROY),
|
||||
m_lastBcastTime (Seconds (0))
|
||||
{
|
||||
if (EnableHello)
|
||||
{
|
||||
m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkToNextHop, this));
|
||||
}
|
||||
m_nb.SetCallback (MakeCallback (&RoutingProtocol::SendRerrWhenBreaksLinkToNextHop, this));
|
||||
}
|
||||
|
||||
TypeId
|
||||
@@ -334,6 +332,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header,
|
||||
NS_LOG_FUNCTION (this << header << (oif ? oif->GetIfIndex () : 0));
|
||||
if (!p)
|
||||
{
|
||||
NS_LOG_DEBUG("Packet is == 0");
|
||||
return LoopbackRoute (header, oif); // later
|
||||
}
|
||||
if (m_socketAddresses.empty ())
|
||||
@@ -368,6 +367,7 @@ RoutingProtocol::RouteOutput (Ptr<Packet> p, const Ipv4Header &header,
|
||||
// routed to loopback, received from loopback and passed to RouteInput (see below)
|
||||
uint32_t iif = (oif ? m_ipv4->GetInterfaceForDevice (oif) : -1);
|
||||
DeferredRouteOutputTag tag (iif);
|
||||
NS_LOG_DEBUG ("Valid Route not found");
|
||||
if (!p->PeekPacketTag (tag))
|
||||
{
|
||||
p->AddPacketTag (tag);
|
||||
@@ -903,19 +903,18 @@ RoutingProtocol::SendRequest (Ipv4Address dst)
|
||||
destination = iface.GetBroadcast ();
|
||||
}
|
||||
NS_LOG_DEBUG ("Send RREQ with id " << rreqHeader.GetId () << " to socket");
|
||||
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
|
||||
m_lastBcastTime = Simulator::Now ();
|
||||
Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination);
|
||||
}
|
||||
ScheduleRreqRetry (dst);
|
||||
if (EnableHello)
|
||||
{
|
||||
if (!m_htimer.IsRunning ())
|
||||
{
|
||||
m_htimer.Cancel ();
|
||||
m_htimer.Schedule (HelloInterval - Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
RoutingProtocol::SendTo (Ptr<Socket> socket, Ptr<Packet> packet, Ipv4Address destination)
|
||||
{
|
||||
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
|
||||
|
||||
}
|
||||
void
|
||||
RoutingProtocol::ScheduleRreqRetry (Ipv4Address dst)
|
||||
{
|
||||
@@ -1101,7 +1100,32 @@ RoutingProtocol::RecvRequest (Ptr<Packet> p, Ipv4Address receiver, Ipv4Address s
|
||||
toOrigin.SetLifeTime (std::max (Time (2 * NetTraversalTime - 2 * hop * NodeTraversalTime),
|
||||
toOrigin.GetLifeTime ()));
|
||||
m_routingTable.Update (toOrigin);
|
||||
//m_nb.Update (src, Time (AllowedHelloLoss * HelloInterval));
|
||||
}
|
||||
|
||||
|
||||
RoutingTableEntry toNeighbor;
|
||||
if (!m_routingTable.LookupRoute (src, toNeighbor))
|
||||
{
|
||||
NS_LOG_DEBUG ("Neighbor:" << src << " not found in routing table. Creating an entry");
|
||||
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver));
|
||||
RoutingTableEntry newEntry (dev, src, false, rreqHeader.GetOriginSeqno (),
|
||||
m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
|
||||
1, src, ActiveRouteTimeout);
|
||||
m_routingTable.AddRoute (newEntry);
|
||||
}
|
||||
else
|
||||
{
|
||||
toNeighbor.SetLifeTime (ActiveRouteTimeout);
|
||||
toNeighbor.SetValidSeqNo (false);
|
||||
toNeighbor.SetSeqNo (rreqHeader.GetOriginSeqno ());
|
||||
toNeighbor.SetFlag (VALID);
|
||||
toNeighbor.SetOutputDevice (m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver)));
|
||||
toNeighbor.SetInterface (m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0));
|
||||
m_routingTable.Update (toNeighbor);
|
||||
}
|
||||
m_nb.Update (src, Time (AllowedHelloLoss * HelloInterval));
|
||||
|
||||
NS_LOG_LOGIC (receiver << " receive RREQ with hop count " << static_cast<uint32_t>(rreqHeader.GetHopCount ())
|
||||
<< " ID " << rreqHeader.GetId ()
|
||||
<< " to destination " << rreqHeader.GetDst ());
|
||||
@@ -1170,16 +1194,9 @@ RoutingProtocol::RecvRequest (Ptr<Packet> p, Ipv4Address receiver, Ipv4Address s
|
||||
{
|
||||
destination = iface.GetBroadcast ();
|
||||
}
|
||||
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
|
||||
}
|
||||
m_lastBcastTime = Simulator::Now ();
|
||||
Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination);
|
||||
|
||||
if (EnableHello)
|
||||
{
|
||||
if (!m_htimer.IsRunning ())
|
||||
{
|
||||
m_htimer.Cancel ();
|
||||
m_htimer.Schedule (HelloInterval - Time (0.1 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1539,10 +1556,20 @@ void
|
||||
RoutingProtocol::HelloTimerExpire ()
|
||||
{
|
||||
NS_LOG_FUNCTION (this);
|
||||
SendHello ();
|
||||
Time offset = Time (Seconds (0));
|
||||
if (m_lastBcastTime > Time (Seconds (0)))
|
||||
{
|
||||
offset = Simulator::Now () - m_lastBcastTime;
|
||||
NS_LOG_DEBUG ("Hello deferred due to last bcast at:" << m_lastBcastTime);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendHello ();
|
||||
}
|
||||
m_htimer.Cancel ();
|
||||
Time t = Time (0.01 * MilliSeconds (m_uniformRandomVariable->GetInteger (0, 100)));
|
||||
m_htimer.Schedule (HelloInterval - t);
|
||||
Time diff = HelloInterval - offset;
|
||||
m_htimer.Schedule (std::max (Time (Seconds (0)), diff));
|
||||
m_lastBcastTime = Time (Seconds (0));
|
||||
}
|
||||
|
||||
void
|
||||
@@ -1598,7 +1625,8 @@ RoutingProtocol::SendHello ()
|
||||
{
|
||||
destination = iface.GetBroadcast ();
|
||||
}
|
||||
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
|
||||
Time jitter = Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10)));
|
||||
Simulator::Schedule (jitter, &RoutingProtocol::SendTo, this , socket, packet, destination);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1757,7 +1785,7 @@ RoutingProtocol::SendRerrMessage (Ptr<Packet> packet, std::vector<Ipv4Address> p
|
||||
Ptr<Socket> socket = FindSocketWithInterfaceAddress (toPrecursor.GetInterface ());
|
||||
NS_ASSERT (socket);
|
||||
NS_LOG_LOGIC ("one precursor => unicast RERR to " << toPrecursor.GetDestination () << " from " << toPrecursor.GetInterface ().GetLocal ());
|
||||
socket->SendTo (packet, 0, InetSocketAddress (precursors.front (), AODV_PORT));
|
||||
Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, precursors.front ());
|
||||
m_rerrCount++;
|
||||
}
|
||||
return;
|
||||
@@ -1790,8 +1818,7 @@ RoutingProtocol::SendRerrMessage (Ptr<Packet> packet, std::vector<Ipv4Address> p
|
||||
{
|
||||
destination = i->GetBroadcast ();
|
||||
}
|
||||
socket->SendTo (packet, 0, InetSocketAddress (destination, AODV_PORT));
|
||||
m_rerrCount++;
|
||||
Simulator::Schedule (Time (MilliSeconds (m_uniformRandomVariable->GetInteger (0, 10))), &RoutingProtocol::SendTo, this, socket, packet, destination);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,6 +248,8 @@ private:
|
||||
void SendRerrWhenNoRouteToForward (Ipv4Address dst, uint32_t dstSeqNo, Ipv4Address origin);
|
||||
//\}
|
||||
|
||||
void SendTo (Ptr<Socket> socket, Ptr<Packet> packet, Ipv4Address destination);
|
||||
|
||||
/// Hello timer
|
||||
Timer m_htimer;
|
||||
/// Schedule next send of hello message
|
||||
@@ -269,6 +271,8 @@ private:
|
||||
|
||||
/// Provides uniform random variables.
|
||||
Ptr<UniformRandomVariable> m_uniformRandomVariable;
|
||||
/// Keep track of the last bcast time
|
||||
Time m_lastBcastTime;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -161,10 +161,10 @@ ChainRegressionTest::CreateDevices ()
|
||||
internetStack.Install (*m_nodes);
|
||||
streamsUsed += internetStack.AssignStreams (*m_nodes, streamsUsed);
|
||||
// InternetStack uses m_size more streams
|
||||
NS_TEST_ASSERT_MSG_EQ (streamsUsed, (devices.GetN () * 6) + m_size, "Stream assignment mismatch");
|
||||
NS_TEST_ASSERT_MSG_EQ (streamsUsed, (devices.GetN () * 8) + m_size, "Stream assignment mismatch");
|
||||
streamsUsed += aodv.AssignStreams (*m_nodes, streamsUsed);
|
||||
// AODV uses m_size more streams
|
||||
NS_TEST_ASSERT_MSG_EQ (streamsUsed, ((devices.GetN () * 6) + (2*m_size)), "Stream assignment mismatch");
|
||||
NS_TEST_ASSERT_MSG_EQ (streamsUsed, ((devices.GetN () * 8) + (2*m_size)), "Stream assignment mismatch");
|
||||
|
||||
Ipv4AddressHelper address;
|
||||
address.SetBase ("10.1.1.0", "255.255.255.0");
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user