dsdv: Update NS_LOG print format for ns3::Time
Also fixed issue in which RoutingProtocol::PrintRoutingTable () was not using the provided Time::Unit to format the routing table entry lifetimes or settling times.
This commit is contained in:
@@ -197,7 +197,7 @@ DsdvManetExample::DsdvManetExample ()
|
||||
void
|
||||
DsdvManetExample::ReceivePacket (Ptr <Socket> socket)
|
||||
{
|
||||
NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " Received one packet!");
|
||||
NS_LOG_UNCOND (Simulator::Now ().As (Time::S) << " Received one packet!");
|
||||
Ptr <Packet> packet;
|
||||
while ((packet = socket->Recv ()))
|
||||
{
|
||||
|
||||
@@ -244,7 +244,7 @@ RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit
|
||||
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
|
||||
<< ", DSDV Routing table" << std::endl;
|
||||
|
||||
m_routingTable.Print (stream);
|
||||
m_routingTable.Print (stream, unit);
|
||||
*stream->GetStream () << std::endl;
|
||||
}
|
||||
|
||||
@@ -666,8 +666,8 @@ RoutingProtocol::RecvDsdv (Ptr<Socket> socket)
|
||||
NS_LOG_DEBUG ("Received update with better sequence number and changed metric.Waiting for WST");
|
||||
Time tempSettlingtime = GetSettlingTime (dsdvHeader.GetDst ());
|
||||
advTableEntry.SetSettlingTime (tempSettlingtime);
|
||||
NS_LOG_DEBUG ("Added Settling Time:" << tempSettlingtime.GetSeconds ()
|
||||
<< "s as there is no event running for this route");
|
||||
NS_LOG_DEBUG ("Added Settling Time:" << tempSettlingtime.As (Time::S)
|
||||
<< " as there is no event running for this route");
|
||||
event = Simulator::Schedule (tempSettlingtime,&RoutingProtocol::SendTriggeredUpdate,this);
|
||||
m_advRoutingTable.AddIpv4Event (dsdvHeader.GetDst (),event);
|
||||
NS_LOG_DEBUG ("EventCreated EventUID: " << event.GetUid ());
|
||||
@@ -706,7 +706,7 @@ RoutingProtocol::RecvDsdv (Ptr<Socket> socket)
|
||||
advTableEntry.SetHop (dsdvHeader.GetHopCount ());
|
||||
Time tempSettlingtime = GetSettlingTime (dsdvHeader.GetDst ());
|
||||
advTableEntry.SetSettlingTime (tempSettlingtime);
|
||||
NS_LOG_DEBUG ("Added Settling Time," << tempSettlingtime.GetSeconds ()
|
||||
NS_LOG_DEBUG ("Added Settling Time," << tempSettlingtime.As (Time::S)
|
||||
<< " as there is no current event running for this route");
|
||||
event = Simulator::Schedule (tempSettlingtime,&RoutingProtocol::SendTriggeredUpdate,this);
|
||||
m_advRoutingTable.AddIpv4Event (dsdvHeader.GetDst (),event);
|
||||
@@ -913,7 +913,7 @@ RoutingProtocol::SendPeriodicUpdate ()
|
||||
NS_LOG_DEBUG ("Forwarding details are, Destination: " << dsdvHeader.GetDst ()
|
||||
<< ", SeqNo:" << dsdvHeader.GetDstSeqno ()
|
||||
<< ", HopCount:" << dsdvHeader.GetHopCount ()
|
||||
<< ", LifeTime: " << i->second.GetLifeTime ().GetSeconds ());
|
||||
<< ", LifeTime: " << i->second.GetLifeTime ().As (Time::S));
|
||||
}
|
||||
for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator rmItr = removedAddresses.begin (); rmItr
|
||||
!= removedAddresses.end (); ++rmItr)
|
||||
@@ -1196,11 +1196,11 @@ RoutingProtocol::GetSettlingTime (Ipv4Address address)
|
||||
}
|
||||
else
|
||||
{
|
||||
NS_LOG_DEBUG ("Route SettlingTime: " << mainrt.GetSettlingTime ().GetSeconds ()
|
||||
<< " and LifeTime:" << mainrt.GetLifeTime ().GetSeconds ());
|
||||
weightedTime = Time (m_weightedFactor * mainrt.GetSettlingTime ().GetSeconds () + (1.0 - m_weightedFactor)
|
||||
* mainrt.GetLifeTime ().GetSeconds ());
|
||||
NS_LOG_DEBUG ("Calculated weightedTime:" << weightedTime.GetSeconds ());
|
||||
NS_LOG_DEBUG ("Route SettlingTime: " << mainrt.GetSettlingTime ().As (Time::S)
|
||||
<< " and LifeTime:" << mainrt.GetLifeTime ().As (Time::S));
|
||||
weightedTime = m_weightedFactor * mainrt.GetSettlingTime () +
|
||||
(1.0 - m_weightedFactor) * mainrt.GetLifeTime ();
|
||||
NS_LOG_DEBUG ("Calculated weightedTime:" << weightedTime.As (Time::S));
|
||||
return weightedTime;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,13 +195,13 @@ RoutingTable::GetListOfDestinationWithNextHop (Ipv4Address nextHop,
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTableEntry::Print (Ptr<OutputStreamWrapper> stream) const
|
||||
RoutingTableEntry::Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit /*= Time::S*/) const
|
||||
{
|
||||
*stream->GetStream () << std::setiosflags (std::ios::fixed) << m_ipv4Route->GetDestination () << "\t\t" << m_ipv4Route->GetGateway () << "\t\t"
|
||||
<< m_iface.GetLocal () << "\t\t" << std::setiosflags (std::ios::left)
|
||||
<< std::setw (10) << m_hops << "\t" << std::setw (10) << m_seqNo << "\t"
|
||||
<< std::setprecision (3) << (Simulator::Now () - m_lifeTime).GetSeconds ()
|
||||
<< "s\t\t" << m_settlingTime.GetSeconds () << "s\n";
|
||||
<< std::setprecision (3) << (Simulator::Now () - m_lifeTime).As (unit)
|
||||
<< "\t\t" << m_settlingTime.As (unit) << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
@@ -249,13 +249,13 @@ RoutingTable::Purge (std::map<Ipv4Address, RoutingTableEntry> & removedAddresses
|
||||
}
|
||||
|
||||
void
|
||||
RoutingTable::Print (Ptr<OutputStreamWrapper> stream) const
|
||||
RoutingTable::Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit /*= Time::S*/) const
|
||||
{
|
||||
*stream->GetStream () << "\nDSDV Routing table\n" << "Destination\t\tGateway\t\tInterface\t\tHopCount\t\tSeqNum\t\tLifeTime\t\tSettlingTime\n";
|
||||
for (std::map<Ipv4Address, RoutingTableEntry>::const_iterator i = m_ipv4AddressEntry.begin (); i
|
||||
!= m_ipv4AddressEntry.end (); ++i)
|
||||
{
|
||||
i->second.Print (stream);
|
||||
i->second.Print (stream, unit);
|
||||
}
|
||||
*stream->GetStream () << "\n";
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ public:
|
||||
* \param stream the output stream
|
||||
*/
|
||||
void
|
||||
Print (Ptr<OutputStreamWrapper> stream) const;
|
||||
Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
|
||||
|
||||
private:
|
||||
// Fields
|
||||
@@ -395,7 +395,7 @@ public:
|
||||
* \param stream the output stream
|
||||
*/
|
||||
void
|
||||
Print (Ptr<OutputStreamWrapper> stream) const;
|
||||
Print (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
|
||||
/**
|
||||
* Provides the number of routes present in that nodes routing table.
|
||||
* \returns the number of routes
|
||||
|
||||
Reference in New Issue
Block a user