diff --git a/src/dsdv/examples/dsdv-manet.cc b/src/dsdv/examples/dsdv-manet.cc index 19fcb9e20..c8baffebe 100644 --- a/src/dsdv/examples/dsdv-manet.cc +++ b/src/dsdv/examples/dsdv-manet.cc @@ -197,7 +197,7 @@ DsdvManetExample::DsdvManetExample () void DsdvManetExample::ReceivePacket (Ptr socket) { - NS_LOG_UNCOND (Simulator::Now ().GetSeconds () << " Received one packet!"); + NS_LOG_UNCOND (Simulator::Now ().As (Time::S) << " Received one packet!"); Ptr packet; while ((packet = socket->Recv ())) { diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index f88a9ff55..ea468f080 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -244,7 +244,7 @@ RoutingProtocol::PrintRoutingTable (Ptr stream, Time::Unit << ", Local time: " << GetObject ()->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) 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) 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::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; } } diff --git a/src/dsdv/model/dsdv-rtable.cc b/src/dsdv/model/dsdv-rtable.cc index 31436c24d..48d8ea172 100644 --- a/src/dsdv/model/dsdv-rtable.cc +++ b/src/dsdv/model/dsdv-rtable.cc @@ -195,13 +195,13 @@ RoutingTable::GetListOfDestinationWithNextHop (Ipv4Address nextHop, } void -RoutingTableEntry::Print (Ptr stream) const +RoutingTableEntry::Print (Ptr 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 & removedAddresses } void -RoutingTable::Print (Ptr stream) const +RoutingTable::Print (Ptr 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::const_iterator i = m_ipv4AddressEntry.begin (); i != m_ipv4AddressEntry.end (); ++i) { - i->second.Print (stream); + i->second.Print (stream, unit); } *stream->GetStream () << "\n"; } diff --git a/src/dsdv/model/dsdv-rtable.h b/src/dsdv/model/dsdv-rtable.h index 21a367469..26ba7d4e4 100644 --- a/src/dsdv/model/dsdv-rtable.h +++ b/src/dsdv/model/dsdv-rtable.h @@ -278,7 +278,7 @@ public: * \param stream the output stream */ void - Print (Ptr stream) const; + Print (Ptr stream, Time::Unit unit = Time::S) const; private: // Fields @@ -395,7 +395,7 @@ public: * \param stream the output stream */ void - Print (Ptr stream) const; + Print (Ptr stream, Time::Unit unit = Time::S) const; /** * Provides the number of routes present in that nodes routing table. * \returns the number of routes