Fix clang-tidy bugprone-argument-comment warnings

This commit is contained in:
Eduardo Almeida
2022-09-27 14:08:43 +01:00
parent 1809468c76
commit 959e9b9873
8 changed files with 238 additions and 113 deletions

View File

@@ -657,10 +657,14 @@ RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
m_lo = m_ipv4->GetNetDevice (0);
NS_ASSERT (m_lo);
// Remember lo route
RoutingTableEntry rt (/*device=*/ m_lo, /*dst=*/ Ipv4Address::GetLoopback (), /*know seqno=*/ true, /*seqno=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address::GetLoopback (), Ipv4Mask ("255.0.0.0")),
/*hops=*/ 1, /*next hop=*/ Ipv4Address::GetLoopback (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ m_lo,
/*dst=*/ Ipv4Address::GetLoopback (),
/*vSeqNo=*/ true,
/*seqNo=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address::GetLoopback (), Ipv4Mask ("255.0.0.0")),
/*hops=*/ 1,
/*nextHop=*/ Ipv4Address::GetLoopback (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
Simulator::ScheduleNow (&RoutingProtocol::Start, this);
@@ -705,8 +709,14 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i)
// Add local broadcast record to the routing table
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true, /*seqno=*/ 0, /*iface=*/ iface,
/*hops=*/ 1, /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ dev,
/*dst=*/ iface.GetBroadcast (),
/*vSeqNo=*/ true,
/*seqNo=*/ 0,
/*iface=*/ iface,
/*hops=*/ 1,
/*nextHop=*/ iface.GetBroadcast (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
if (l3->GetInterface (i)->GetArpCache ())
@@ -821,9 +831,14 @@ RoutingProtocol::NotifyAddAddress (uint32_t i, Ipv4InterfaceAddress address)
// Add local broadcast record to the routing table
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (
m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true,
/*seqno=*/ 0, /*iface=*/ iface, /*hops=*/ 1,
/*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ dev,
/*dst=*/ iface.GetBroadcast (),
/*vSeqNo=*/ true,
/*seqNo=*/ 0,
/*iface=*/ iface,
/*hops=*/ 1,
/*nextHop=*/ iface.GetBroadcast (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
}
}
@@ -880,8 +895,14 @@ RoutingProtocol::NotifyRemoveAddress (uint32_t i, Ipv4InterfaceAddress address)
// Add local broadcast record to the routing table
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*know seqno=*/ true, /*seqno=*/ 0, /*iface=*/ iface,
/*hops=*/ 1, /*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ dev,
/*dst=*/ iface.GetBroadcast (),
/*vSeqNo=*/ true,
/*seqNo=*/ 0,
/*iface=*/ iface,
/*hops=*/ 1,
/*nextHop=*/ iface.GetBroadcast (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
}
if (m_socketAddresses.empty ())
@@ -1020,9 +1041,14 @@ RoutingProtocol::SendRequest (Ipv4Address dst)
{
rreqHeader.SetUnknownSeqno (true);
Ptr<NetDevice> dev = 0;
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ dst, /*validSeqNo=*/ false, /*seqno=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (),/*hop=*/ ttl,
/*nextHop=*/ Ipv4Address (), /*lifeTime=*/ m_pathDiscoveryTime);
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ dst,
/*vSeqNo=*/ false,
/*seqNo=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (),
/*hops=*/ ttl,
/*nextHop=*/ Ipv4Address (),
/*lifetime=*/ m_pathDiscoveryTime);
// Check if TtlStart == NetDiameter
if (ttl == m_netDiameter)
{
@@ -1200,9 +1226,14 @@ RoutingProtocol::UpdateRouteToNeighbor (Ipv4Address sender, Ipv4Address receiver
if (!m_routingTable.LookupRoute (sender, toNeighbor))
{
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver));
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ sender, /*know seqno=*/ false, /*seqno=*/ 0,
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ 1, /*next hop=*/ sender, /*lifetime=*/ m_activeRouteTimeout);
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ sender,
/*vSeqNo=*/ false,
/*seqNo=*/ 0,
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ 1,
/*nextHop=*/ sender,
/*lifetime=*/ m_activeRouteTimeout);
m_routingTable.AddRoute (newEntry);
}
else
@@ -1214,9 +1245,14 @@ RoutingProtocol::UpdateRouteToNeighbor (Ipv4Address sender, Ipv4Address receiver
}
else
{
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ sender, /*know seqno=*/ false, /*seqno=*/ 0,
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ 1, /*next hop=*/ sender, /*lifetime=*/ std::max (m_activeRouteTimeout, toNeighbor.GetLifeTime ()));
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ sender,
/*vSeqNo=*/ false,
/*seqNo=*/ 0,
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ 1,
/*nextHop=*/ sender,
/*lifetime=*/ std::max (m_activeRouteTimeout, toNeighbor.GetLifeTime ()));
m_routingTable.Update (newEntry);
}
}
@@ -1272,9 +1308,14 @@ RoutingProtocol::RecvRequest (Ptr<Packet> p, Ipv4Address receiver, Ipv4Address s
if (!m_routingTable.LookupRoute (origin, toOrigin))
{
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver));
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ origin, /*validSeno=*/ true, /*seqNo=*/ rreqHeader.GetOriginSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0), /*hops=*/ hop,
/*nextHop*/ src, /*timeLife=*/ Time ((2 * m_netTraversalTime - 2 * hop * m_nodeTraversalTime)));
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ origin,
/*vSeqNo=*/ true,
/*seqNo=*/ rreqHeader.GetOriginSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ hop,
/*nextHop=*/ src,
/*lifetime=*/ Time ((2 * m_netTraversalTime - 2 * hop * m_nodeTraversalTime)));
m_routingTable.AddRoute (newEntry);
}
else
@@ -1423,8 +1464,12 @@ RoutingProtocol::SendReply (RreqHeader const & rreqHeader, RoutingTableEntry con
{
m_seqNo++;
}
RrepHeader rrepHeader ( /*prefixSize=*/ 0, /*hops=*/ 0, /*dst=*/ rreqHeader.GetDst (),
/*dstSeqNo=*/ m_seqNo, /*origin=*/ toOrigin.GetDestination (), /*lifeTime=*/ m_myRouteTimeout);
RrepHeader rrepHeader (/*prefixSize=*/ 0,
/*hopCount=*/ 0,
/*dst=*/ rreqHeader.GetDst (),
/*dstSeqNo=*/ m_seqNo,
/*origin=*/ toOrigin.GetDestination (),
/*lifetime=*/ m_myRouteTimeout);
Ptr<Packet> packet = Create<Packet> ();
SocketIpTtlTag tag;
tag.SetTtl (toOrigin.GetHop ());
@@ -1441,8 +1486,12 @@ void
RoutingProtocol::SendReplyByIntermediateNode (RoutingTableEntry & toDst, RoutingTableEntry & toOrigin, bool gratRep)
{
NS_LOG_FUNCTION (this);
RrepHeader rrepHeader (/*prefix size=*/ 0, /*hops=*/ toDst.GetHop (), /*dst=*/ toDst.GetDestination (), /*dst seqno=*/ toDst.GetSeqNo (),
/*origin=*/ toOrigin.GetDestination (), /*lifetime=*/ toDst.GetLifeTime ());
RrepHeader rrepHeader (/*prefixSize=*/ 0,
/*hopCount=*/ toDst.GetHop (),
/*dst=*/ toDst.GetDestination (),
/*dstSeqNo=*/ toDst.GetSeqNo (),
/*origin=*/ toOrigin.GetDestination (),
/*lifetime=*/ toDst.GetLifeTime ());
/* If the node we received a RREQ for is a neighbor we are
* probably facing a unidirectional link... Better request a RREP-ack
*/
@@ -1474,9 +1523,12 @@ RoutingProtocol::SendReplyByIntermediateNode (RoutingTableEntry & toDst, Routing
// Generating gratuitous RREPs
if (gratRep)
{
RrepHeader gratRepHeader (/*prefix size=*/ 0, /*hops=*/ toOrigin.GetHop (), /*dst=*/ toOrigin.GetDestination (),
/*dst seqno=*/ toOrigin.GetSeqNo (), /*origin=*/ toDst.GetDestination (),
/*lifetime=*/ toOrigin.GetLifeTime ());
RrepHeader gratRepHeader (/*prefixSize=*/ 0,
/*hopCount=*/ toOrigin.GetHop (),
/*dst=*/ toOrigin.GetDestination (),
/*dstSeqNo=*/ toOrigin.GetSeqNo (),
/*origin=*/ toDst.GetDestination (),
/*lifetime=*/ toOrigin.GetLifeTime ());
Ptr<Packet> packetToDst = Create<Packet> ();
SocketIpTtlTag gratTag;
gratTag.SetTtl (toDst.GetHop ());
@@ -1540,9 +1592,14 @@ RoutingProtocol::RecvReply (Ptr<Packet> p, Ipv4Address receiver, Ipv4Address sen
* - and the destination sequence number is the Destination Sequence Number in the RREP message.
*/
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver));
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ dst, /*validSeqNo=*/ true, /*seqno=*/ rrepHeader.GetDstSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),/*hop=*/ hop,
/*nextHop=*/ sender, /*lifeTime=*/ rrepHeader.GetLifeTime ());
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ dst,
/*vSeqNo=*/ true,
/*seqNo=*/ rrepHeader.GetDstSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ hop,
/*nextHop=*/ sender,
/*lifetime=*/ rrepHeader.GetLifeTime ());
RoutingTableEntry toDst;
if (m_routingTable.LookupRoute (dst, toDst))
{
@@ -1672,9 +1729,14 @@ RoutingProtocol::ProcessHello (RrepHeader const & rrepHeader, Ipv4Address receiv
if (!m_routingTable.LookupRoute (rrepHeader.GetDst (), toNeighbor))
{
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (receiver));
RoutingTableEntry newEntry (/*device=*/ dev, /*dst=*/ rrepHeader.GetDst (), /*validSeqNo=*/ true, /*seqno=*/ rrepHeader.GetDstSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hop=*/ 1, /*nextHop=*/ rrepHeader.GetDst (), /*lifeTime=*/ rrepHeader.GetLifeTime ());
RoutingTableEntry newEntry (/*dev=*/ dev,
/*dst=*/ rrepHeader.GetDst (),
/*vSeqNo=*/ true,
/*seqNo=*/ rrepHeader.GetDstSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ 1,
/*nextHop=*/ rrepHeader.GetDst (),
/*lifetime=*/ rrepHeader.GetLifeTime ());
m_routingTable.AddRoute (newEntry);
}
else
@@ -1852,8 +1914,12 @@ RoutingProtocol::SendHello ()
{
Ptr<Socket> socket = j->first;
Ipv4InterfaceAddress iface = j->second;
RrepHeader helloHeader (/*prefix size=*/ 0, /*hops=*/ 0, /*dst=*/ iface.GetLocal (), /*dst seqno=*/ m_seqNo,
/*origin=*/ iface.GetLocal (),/*lifetime=*/ Time (m_allowedHelloLoss * m_helloInterval));
RrepHeader helloHeader (/*prefixSize=*/ 0,
/*hopCount=*/ 0,
/*dst=*/ iface.GetLocal (),
/*dstSeqNo=*/ m_seqNo,
/*origin=*/ iface.GetLocal (),
/*lifetime=*/ Time (m_allowedHelloLoss * m_helloInterval));
Ptr<Packet> packet = Create<Packet> ();
SocketIpTtlTag tag;
tag.SetTtl (1);

View File

@@ -620,15 +620,15 @@ RoutingProtocol::RecvDsdv (Ptr<Socket> socket)
{
NS_LOG_DEBUG ("Received New Route!");
RoutingTableEntry newEntry (
/*device=*/ dev, /*dst=*/
dsdvHeader.GetDst (), /*seqno=*/
dsdvHeader.GetDstSeqno (),
/*dev=*/ dev,
/*dst=*/ dsdvHeader.GetDst (),
/*seqNo=*/ dsdvHeader.GetDstSeqno (),
/*iface=*/ m_ipv4->GetAddress (m_ipv4->GetInterfaceForAddress (receiver), 0),
/*hops=*/ dsdvHeader.GetHopCount (), /*next hop=*/
sender, /*lifetime=*/
Simulator::Now (), /*settlingTime*/
m_settlingTime, /*entries changed*/
true);
/*hops=*/ dsdvHeader.GetHopCount (),
/*nextHop=*/ sender,
/*lifetime=*/ Simulator::Now (),
/*settlingTime=*/ m_settlingTime,
/*changedEntries=*/ true);
newEntry.SetFlag (VALID);
m_routingTable.AddRoute (newEntry);
NS_LOG_DEBUG ("New Route added to both tables");
@@ -967,12 +967,12 @@ RoutingProtocol::SetIpv4 (Ptr<Ipv4> ipv4)
NS_ASSERT (m_lo);
// Remember lo route
RoutingTableEntry rt (
/*device=*/ m_lo, /*dst=*/
Ipv4Address::GetLoopback (), /*seqno=*/
0,
/*dev=*/ m_lo,
/*dst=*/ Ipv4Address::GetLoopback (),
/*seqNo=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address::GetLoopback (),Ipv4Mask ("255.0.0.0")),
/*hops=*/ 0, /*next hop=*/
Ipv4Address::GetLoopback (),
/*hops=*/ 0,
/*nextHop=*/ Ipv4Address::GetLoopback (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
rt.SetFlag (INVALID);
rt.SetEntriesChanged (false);
@@ -1002,8 +1002,13 @@ RoutingProtocol::NotifyInterfaceUp (uint32_t i)
m_socketAddresses.insert (std::make_pair (socket,iface));
// Add local broadcast record to the routing table
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (), /*seqno=*/ 0,/*iface=*/ iface,/*hops=*/ 0,
/*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ dev,
/*dst=*/ iface.GetBroadcast (),
/*seqNo=*/ 0,
/*iface=*/ iface,
/*hops=*/ 0,
/*nextHop=*/ iface.GetBroadcast (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
if (m_mainAddress == Ipv4Address ())
{
@@ -1058,8 +1063,13 @@ RoutingProtocol::NotifyAddAddress (uint32_t i,
socket->SetAllowBroadcast (true);
m_socketAddresses.insert (std::make_pair (socket,iface));
Ptr<NetDevice> dev = m_ipv4->GetNetDevice (m_ipv4->GetInterfaceForAddress (iface.GetLocal ()));
RoutingTableEntry rt (/*device=*/ dev, /*dst=*/ iface.GetBroadcast (),/*seqno=*/ 0, /*iface=*/ iface,/*hops=*/ 0,
/*next hop=*/ iface.GetBroadcast (), /*lifetime=*/ Simulator::GetMaximumSimulationTime ());
RoutingTableEntry rt (/*dev=*/ dev,
/*dst=*/ iface.GetBroadcast (),
/*seqNo=*/ 0,
/*iface=*/ iface,
/*hops=*/ 0,
/*nextHop=*/ iface.GetBroadcast (),
/*lifetime=*/ Simulator::GetMaximumSimulationTime ());
m_routingTable.AddRoute (rt);
}
}

View File

@@ -45,14 +45,14 @@ RoutingTableEntry::RoutingTableEntry (Ptr<NetDevice> dev,
uint32_t hops,
Ipv4Address nextHop,
Time lifetime,
Time SettlingTime,
Time settlingTime,
bool areChanged)
: m_seqNo (seqNo),
m_hops (hops),
m_lifeTime (lifetime),
m_iface (iface),
m_flag (VALID),
m_settlingTime (SettlingTime),
m_settlingTime (settlingTime),
m_entriesChanged (areChanged)
{
m_ipv4Route = Create<Ipv4Route> ();

View File

@@ -66,12 +66,12 @@ public:
* \param hops the number of hops
* \param nextHop the IP address of the next hop
* \param lifetime the lifetime
* \param SettlingTime the settling time
* \param settlingTime the settling time
* \param changedEntries flag for changed entries
*/
RoutingTableEntry (Ptr<NetDevice> dev = 0, Ipv4Address dst = Ipv4Address (), uint32_t seqNo = 0,
Ipv4InterfaceAddress iface = Ipv4InterfaceAddress (), uint32_t hops = 0, Ipv4Address nextHop = Ipv4Address (),
Time lifetime = Simulator::Now (), Time SettlingTime = Simulator::Now (), bool changedEntries = false);
Time lifetime = Simulator::Now (), Time settlingTime = Simulator::Now (), bool changedEntries = false);
~RoutingTableEntry ();
/**

View File

@@ -138,35 +138,42 @@ DsdvTableTestCase::DoRun ()
Ptr<NetDevice> dev;
{
dsdv::RoutingTableEntry rEntry1 (
/*device=*/ dev, /*dst=*/
Ipv4Address ("10.1.1.4"), /*seqno=*/ 2,
/*dev=*/ dev,
/*dst=*/ Ipv4Address ("10.1.1.4"),
/*seqNo=*/ 2,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address ("10.1.1.1"), Ipv4Mask ("255.255.255.0")),
/*hops=*/ 2, /*next hop=*/
Ipv4Address ("10.1.1.2"),
/*hops=*/ 2,
/*nextHop=*/ Ipv4Address ("10.1.1.2"),
/*lifetime=*/ Seconds (10));
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rEntry1),true,"add route");
dsdv::RoutingTableEntry rEntry2 (
/*device=*/ dev, /*dst=*/
Ipv4Address ("10.1.1.2"), /*seqno=*/ 4,
/*dev=*/ dev,
/*dst=*/ Ipv4Address ("10.1.1.2"),
/*seqNo=*/ 4,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address ("10.1.1.1"), Ipv4Mask ("255.255.255.0")),
/*hops=*/ 1, /*next hop=*/
Ipv4Address ("10.1.1.2"),
/*hops=*/ 1,
/*nextHop=*/ Ipv4Address ("10.1.1.2"),
/*lifetime=*/ Seconds (10));
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rEntry2),true,"add route");
dsdv::RoutingTableEntry rEntry3 (
/*device=*/ dev, /*dst=*/
Ipv4Address ("10.1.1.3"), /*seqno=*/ 4,
/*dev=*/ dev,
/*dst=*/ Ipv4Address ("10.1.1.3"),
/*seqNo=*/ 4,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address ("10.1.1.1"), Ipv4Mask ("255.255.255.0")),
/*hops=*/ 1, /*next hop=*/
Ipv4Address ("10.1.1.3"),
/*hops=*/ 1,
/*nextHop=*/ Ipv4Address ("10.1.1.3"),
/*lifetime=*/ Seconds (10));
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rEntry3),true,"add route");
dsdv::RoutingTableEntry rEntry4 (
/*device=*/ dev, /*dst=*/
Ipv4Address ("10.1.1.255"), /*seqno=*/ 0,
/*dev=*/ dev,
/*dst=*/ Ipv4Address ("10.1.1.255"),
/*seqNo=*/ 0,
/*iface=*/ Ipv4InterfaceAddress (Ipv4Address ("10.1.1.1"), Ipv4Mask ("255.255.255.0")),
/*hops=*/ 0, /*next hop=*/
Ipv4Address ("10.1.1.255"),
/*hops=*/ 0,
/*nextHop=*/ Ipv4Address ("10.1.1.255"),
/*lifetime=*/ Seconds (10));
NS_TEST_EXPECT_MSG_EQ (rtable.AddRoute (rEntry4),true,"add route");
}

View File

@@ -215,26 +215,31 @@ public:
/**
* Construct a DsrMaintainBuffEntry with the given parameters
*
* \param pa packet
* \param us our IPv4 address
* \param n next hop IPv4 address
* \param s IPv4 address of the source
* \param packet packet
* \param ourAddress our IPv4 address
* \param nextHop next hop IPv4 address
* \param src IPv4 address of the source
* \param dst IPv4 address of the destination
* \param ackId ACK ID
* \param segs number of segments left
* \param exp expiration time
* \param segsLeft number of segments left
* \param expire expiration time
*/
DsrMaintainBuffEntry (Ptr<const Packet> pa = 0, Ipv4Address us = Ipv4Address (),
Ipv4Address n = Ipv4Address (), Ipv4Address s = Ipv4Address (), Ipv4Address dst = Ipv4Address (),
uint16_t ackId = 0, uint8_t segs = 0, Time exp = Simulator::Now ())
: m_packet (pa),
m_ourAdd (us),
m_nextHop (n),
m_src (s),
DsrMaintainBuffEntry (Ptr<const Packet> packet = nullptr,
Ipv4Address ourAddress = Ipv4Address (),
Ipv4Address nextHop = Ipv4Address (),
Ipv4Address src = Ipv4Address (),
Ipv4Address dst = Ipv4Address (),
uint16_t ackId = 0,
uint8_t segsLeft = 0,
Time expire = Simulator::Now ())
: m_packet (packet),
m_ourAdd (ourAddress),
m_nextHop (nextHop),
m_src (src),
m_dst (dst),
m_ackId (ackId),
m_segsLeft (segs),
m_expire (exp + Simulator::Now ())
m_segsLeft (segsLeft),
m_expire (expire + Simulator::Now ())
{
}

View File

@@ -684,8 +684,9 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
bool addRoute = false;
if (numberAddress > 0)
{
DsrRouteCacheEntry toSource (/*IP_VECTOR=*/ m_finalRoute, /*dst=*/
dst, /*expire time=*/ ActiveRouteTimeout);
DsrRouteCacheEntry toSource (/*ip=*/ m_finalRoute,
/*dst=*/ dst,
/*exp=*/ ActiveRouteTimeout);
if (dsr->IsLinkCache ())
{
addRoute = dsr->AddRoute_Link (m_finalRoute, ipv4Address);
@@ -789,7 +790,9 @@ uint8_t DsrOptionRreq::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
NS_LOG_DEBUG ("This is the route save in route cache");
PrintVector (saveRoute);
DsrRouteCacheEntry toSource (/*IP_VECTOR=*/ saveRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
DsrRouteCacheEntry toSource (/*ip=*/ saveRoute,
/*dst=*/ dst,
/*exp=*/ ActiveRouteTimeout);
NS_ASSERT (saveRoute.front () == ipv4Address);
// Add the route entry in the route cache
if (dsr->IsLinkCache ())
@@ -1036,7 +1039,9 @@ uint8_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
* The route looks like:
* \\ "srcAddress" + "intermediate node address" + "targetAddress"
*/
DsrRouteCacheEntry toDestination (/*IP_VECTOR=*/ nodeList, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
DsrRouteCacheEntry toDestination (/*ip=*/ nodeList,
/*dst=*/ dst,
/*exp=*/ ActiveRouteTimeout);
NS_ASSERT (nodeList.front () == ipv4Address);
bool addRoute = false;
if (dsr->IsLinkCache ())
@@ -1103,7 +1108,9 @@ uint8_t DsrOptionRrep::Process (Ptr<Packet> packet, Ptr<Packet> dsrP, Ipv4Addres
{
Ipv4Address dst = cutRoute.back ();
NS_LOG_DEBUG ("The route destination after cut " << dst);
DsrRouteCacheEntry toDestination (/*IP_VECTOR=*/ cutRoute, /*dst=*/ dst, /*expire time=*/ ActiveRouteTimeout);
DsrRouteCacheEntry toDestination (/*ip=*/ cutRoute,
/*dst=*/ dst,
/*exp=*/ ActiveRouteTimeout);
NS_ASSERT (cutRoute.front () == ipv4Address);
bool addRoute = false;
if (dsr->IsLinkCache ())

View File

@@ -973,9 +973,14 @@ void DsrRouting::CheckSendBuffer ()
cleanP->AddHeader (dsrRoutingHeader);
Ptr<const Packet> mtP = cleanP->Copy ();
// Put the data packet in the maintenance queue for data packet retransmission
DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
/*source=*/ m_mainAddress, /*destination=*/ destination, /*ackId=*/ 0,
/*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
DsrMaintainBuffEntry newEntry (/*packet=*/ mtP,
/*ourAddress=*/ m_mainAddress,
/*nextHop=*/ nextHop,
/*src=*/ m_mainAddress,
/*dst=*/ destination,
/*ackId=*/ 0,
/*segsLeft=*/ nodeList.size () - 2,
/*expire=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
if (result)
{
@@ -1213,9 +1218,14 @@ DsrRouting::PacketNewRoute (Ptr<Packet> packet,
Ptr<const Packet> mtP = cleanP->Copy ();
SetRoute (nextHop, m_mainAddress);
// Put the data packet in the maintenance queue for data packet retransmission
DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*Ipv4Address=*/ m_mainAddress, /*nextHop=*/ nextHop,
/*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
/*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
DsrMaintainBuffEntry newEntry (/*packet=*/ mtP,
/*ourAddress=*/ m_mainAddress,
/*nextHop=*/ nextHop,
/*src=*/ source,
/*dst=*/ destination,
/*ackId=*/ 0,
/*segsLeft=*/ nodeList.size () - 2,
/*expire=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
if (result)
@@ -1503,9 +1513,14 @@ DsrRouting::Send (Ptr<Packet> packet,
Ptr<const Packet> mtP = cleanP->Copy ();
NS_LOG_DEBUG ("maintain packet size " << cleanP->GetSize ());
// Put the data packet in the maintenance queue for data packet retransmission
DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
/*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
/*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
DsrMaintainBuffEntry newEntry (/*packet=*/ mtP,
/*ourAddress=*/ m_mainAddress,
/*nextHop=*/ nextHop,
/*src=*/ source,
/*dst=*/ destination,
/*ackId=*/ 0,
/*segsLeft=*/ nodeList.size () - 2,
/*expire=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
if (result)
{
@@ -1791,9 +1806,14 @@ DsrRouting::SendPacketFromBuffer (DsrOptionSRHeader const &sourceRoute, Ipv4Addr
Ptr<const Packet> mtP = p->Copy ();
// Put the data packet in the maintenance queue for data packet retransmission
DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
/*source=*/ source, /*destination=*/ destination, /*ackId=*/ 0,
/*SegsLeft=*/ nodeList.size () - 2, /*expire time=*/ m_maxMaintainTime);
DsrMaintainBuffEntry newEntry (/*packet=*/ mtP,
/*ourAddress=*/ m_mainAddress,
/*nextHop=*/ nextHop,
/*src=*/ source,
/*dst=*/ destination,
/*ackId=*/ 0,
/*segsLeft=*/ nodeList.size () - 2,
/*expire=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry); // Enqueue the packet the the maintenance buffer
if (result)
@@ -2040,9 +2060,14 @@ DsrRouting::CallCancelPacketTimer (uint16_t ackId, Ipv4Header const& ipv4Header,
* The reason is ack header doesn't have the original packet copy
*/
Ptr<Packet> mainP = Create<Packet> ();
DsrMaintainBuffEntry newEntry (/*Packet=*/ mainP, /*ourAddress=*/ sender, /*nextHop=*/ receiver,
/*source=*/ realSrc, /*destination=*/ realDst, /*ackId=*/ ackId,
/*SegsLeft=*/ 0, /*expire time=*/ Simulator::Now ());
DsrMaintainBuffEntry newEntry (/*packet=*/ mainP,
/*ourAddress=*/ sender,
/*nextHop=*/ receiver,
/*src=*/ realSrc,
/*dst=*/ realDst,
/*ackId=*/ ackId,
/*segsLeft=*/ 0,
/*expire=*/ Simulator::Now ());
CancelNetworkPacketTimer (newEntry); // Only need to cancel network packet timer
}
@@ -2687,9 +2712,14 @@ DsrRouting::ForwardPacket (Ptr<const Packet> packet,
Ptr<const Packet> mtP = p->Copy ();
DsrMaintainBuffEntry newEntry (/*Packet=*/ mtP, /*ourAddress=*/ m_mainAddress, /*nextHop=*/ nextHop,
/*source=*/ source, /*destination=*/ targetAddress, /*ackId=*/ m_ackId,
/*SegsLeft=*/ sourceRoute.GetSegmentsLeft (), /*expire time=*/ m_maxMaintainTime);
DsrMaintainBuffEntry newEntry (/*packet=*/ mtP,
/*ourAddress=*/ m_mainAddress,
/*nextHop=*/ nextHop,
/*src=*/ source,
/*dst=*/ targetAddress,
/*ackId=*/ m_ackId,
/*segsLeft=*/ sourceRoute.GetSegmentsLeft (),
/*expire=*/ m_maxMaintainTime);
bool result = m_maintainBuffer.Enqueue (newEntry);
if (result)