routing: (fixes #2527) Extend PrintRoutingTable to specify the time unit for the report.

This commit is contained in:
Robert Ammon
2016-11-05 02:38:15 +01:00
parent 25c6f50908
commit bf956783aa
34 changed files with 123 additions and 112 deletions

View File

@@ -54,6 +54,10 @@ us a note on ns-developers mailing list.</p>
<h1>Changes from ns-3.26 to ns-3.27</h1>
<h2>New API:</h2>
<ul>
<li>Function <b>PrintRoutingTable</b> has been extended to add an optional Time::Units
parameter to specify the time units used on the report. The new parameter is
optional and if not specified defaults to the previous behavior (Time::S).
</li>
</ul>
<h2>Changes to existing API:</h2>
<ul>

View File

@@ -26,12 +26,11 @@ Bugs fixed
----------
- Bug 2007 - uan: Remove deprecation on SetRxThresholdDb
- Bug 2450 - LogDistancePropagationLossModel is not continuous
- Bug 2477 - DCF manager assert
- Bug 2492 - uan: Make use of RxGain attribute in UanPhyGen class
- Bug 2511 - HT Greenfield is not working
- Bug 2521 - Include ipv6-option.h in wscript
- Bug 2529 - Missing trace when Block ACK timeout is triggered or when missing MPDUs are announced by a Block ACK response
- Bug 2532 - Inconsistencies between 802.11n MCS and NSS value reported in TXVECTOR
- Bug 2527 - PrintRoutingTable extended to add an optional Time::Units parameter
- Bug 2530 - Rename aodv::SetBalckListTimeout to aodv::SetBlackListTimeout
Known issues
------------

View File

@@ -318,11 +318,11 @@ RoutingProtocol::DoDispose ()
}
void
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
*stream->GetStream () << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< "; Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< "; Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", AODV Routing table" << std::endl;
m_routingTable.Print (stream);

View File

@@ -71,8 +71,8 @@ public:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
// Handle protocol parameters
Time GetMaxQueueTime () const { return m_maxQueueTime; }
void SetMaxQueueTime (Time t);

View File

@@ -557,7 +557,7 @@ Ipv4ClickRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header,
}
void
Ipv4ClickRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv4ClickRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
}

View File

@@ -255,7 +255,7 @@ public:
virtual bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev,
UnicastForwardCallback ucb, MulticastForwardCallback mcb,
LocalDeliverCallback lcb, ErrorCallback ecb);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
virtual void NotifyInterfaceUp (uint32_t interface);
virtual void NotifyInterfaceDown (uint32_t interface);
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);

View File

@@ -229,11 +229,11 @@ RoutingProtocol::DoDispose ()
}
void
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
*stream->GetStream () << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", DSDV Routing table" << std::endl;
m_routingTable.Print (stream);

View File

@@ -68,7 +68,7 @@ public:
Ptr<Ipv4Route> RouteOutput (Ptr<Packet> p, const Ipv4Header &header, Ptr<NetDevice> oif, Socket::SocketErrno &sockerr);
bool RouteInput (Ptr<const Packet> p, const Ipv4Header &header, Ptr<const NetDevice> idev, UnicastForwardCallback ucb,
MulticastForwardCallback mcb, LocalDeliverCallback lcb, ErrorCallback ecb);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
virtual void NotifyInterfaceUp (uint32_t interface);
virtual void NotifyInterfaceDown (uint32_t interface);
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);

View File

@@ -36,59 +36,59 @@ Ipv4RoutingHelper::~Ipv4RoutingHelper ()
}
void
Ipv4RoutingHelper::PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, node, stream);
Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, node, stream, unit);
}
}
void
Ipv4RoutingHelper::PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
}
void
Ipv4RoutingHelper::PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, node, stream);
Simulator::Schedule (printTime, &Ipv4RoutingHelper::Print, node, stream, unit);
}
void
Ipv4RoutingHelper::PrintRoutingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
void
Ipv4RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
if (ipv4)
{
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
rp->PrintRoutingTable (stream, unit);
}
}
void
Ipv4RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv4RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
if (ipv4)
{
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream);
rp->PrintRoutingTable (stream, unit);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
}

View File

@@ -69,47 +69,51 @@ public:
* \brief prints the routing tables of all nodes at a particular time.
* \param printTime the time at which the routing table is supposed to be printed.
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object, for all nodes at the
* specified time; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of all nodes at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object, for all nodes at the
* specified time interval; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of a node at a particular time.
* \param printTime the time at which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
* at the specified time; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
static void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the neighbor cache of all nodes at a particular time.
@@ -190,24 +194,26 @@ private:
* \brief prints the routing tables of a node.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object;
* the output format is routing protocol-specific.
*/
static void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv4RoutingProtocol stored in the Ipv4 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
static void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the neighbor cache of a node.

View File

@@ -36,59 +36,59 @@ Ipv6RoutingHelper::~Ipv6RoutingHelper ()
}
void
Ipv6RoutingHelper::PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream);
Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
}
}
void
Ipv6RoutingHelper::PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
for (uint32_t i = 0; i < NodeList::GetNNodes (); i++)
{
Ptr<Node> node = NodeList::GetNode (i);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
}
void
Ipv6RoutingHelper::PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream);
Simulator::Schedule (printTime, &Ipv6RoutingHelper::Print, node, stream, unit);
}
void
Ipv6RoutingHelper::PrintRoutingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::PrintRoutingTableEvery (Time printInterval,Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
void
Ipv6RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
if (ipv6)
{
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
rp->PrintRoutingTable (stream, unit);
}
}
void
Ipv6RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
Ipv6RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit)
{
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
if (ipv6)
{
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream);
rp->PrintRoutingTable (stream, unit);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream, unit);
}
}

View File

@@ -70,47 +70,51 @@ public:
* \brief prints the routing tables of all nodes at a particular time.
* \param printTime the time at which the routing table is supposed to be printed.
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
* specified time; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream);;
static void PrintRoutingTableAllAt (Time printTime, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of all nodes at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for all nodes at the
* specified time interval; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableAllEvery (Time printInterval, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of a node at a particular time.
* \param printTime the time at which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* at the specified time; the output format is routing protocol-specific.
*/
static void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableAt (Time printTime, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
static void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintRoutingTableEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S);
/**
* \brief prints the neighbor cache of all nodes at a particular time.
@@ -191,24 +195,26 @@ private:
* \brief prints the routing tables of a node.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object;
* the output format is routing protocol-specific.
*/
static void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit);
/**
* \brief prints the routing tables of a node at regular intervals specified by user.
* \param printInterval the time interval for which the routing table is supposed to be printed.
* \param node The node ptr for which we need the routing table to be printed
* \param stream The output stream object to use
* \param unit The time unit to be used in the report
*
* This method calls the PrintRoutingTable() method of the
* Ipv6RoutingProtocol stored in the Ipv6 object, for the selected node
* at the specified interval; the output format is routing protocol-specific.
*/
static void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream);
static void PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream, Time::Unit unit);
/**
* \brief prints the neighbor cache of a node.

View File

@@ -398,14 +398,14 @@ Ipv4GlobalRouting::DoDispose (void)
// Formatted like output of "route -n" command
void
Ipv4GlobalRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv4GlobalRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Ipv4GlobalRouting table" << std::endl;
if (GetNRoutes () > 0)

View File

@@ -98,7 +98,7 @@ public:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
/**
* \brief Add a host route to the global routing table.

View File

@@ -70,18 +70,18 @@ Ipv4ListRouting::DoDispose (void)
}
void
Ipv4ListRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv4ListRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
*stream->GetStream () << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Ipv4ListRouting table" << std::endl;
for (Ipv4RoutingProtocolList::const_iterator i = m_routingProtocols.begin ();
i != m_routingProtocols.end (); i++)
{
*stream->GetStream () << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
(*i).second->PrintRoutingTable (stream);
(*i).second->PrintRoutingTable (stream, unit);
}
}

View File

@@ -22,6 +22,7 @@
#include <list>
#include "ns3/ipv4-routing-protocol.h"
#include "ns3/simulator.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -88,7 +89,7 @@ public:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
protected:
virtual void DoDispose (void);

View File

@@ -26,6 +26,7 @@
#include "ns3/ipv4-interface-address.h"
#include "ipv4.h"
#include "ns3/output-stream-wrapper.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -165,9 +166,11 @@ public:
/**
* \brief Print the Routing Table entries
*
* \param stream the ostream the Routing table is printed to
* \param stream The ostream the Routing table is printed to
* \param unit The time unit to be used in the report
*/
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const = 0;
};
} // namespace ns3

View File

@@ -690,14 +690,14 @@ Ipv4StaticRouting::SetIpv4 (Ptr<Ipv4> ipv4)
}
// Formatted like output of "route -n" command
void
Ipv4StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv4StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Ipv4StaticRouting table" << std::endl;
if (GetNRoutes () > 0)

View File

@@ -85,7 +85,7 @@ public:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
/**
* \brief Add a network route to the static routing table.

View File

@@ -210,19 +210,19 @@ void Ipv6ListRouting::NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6A
}
void
Ipv6ListRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv6ListRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this);
*stream->GetStream () << "Node: " << m_ipv6->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Ipv6ListRouting table" << std::endl;
for (Ipv6RoutingProtocolList::const_iterator i = m_routingProtocols.begin ();
i != m_routingProtocols.end (); i++)
{
*stream->GetStream () << " Priority: " << (*i).first << " Protocol: " << (*i).second->GetInstanceTypeId () << std::endl;
(*i).second->PrintRoutingTable (stream);
(*i).second->PrintRoutingTable (stream, unit);
}
}

View File

@@ -98,13 +98,7 @@ public:
virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void SetIpv6 (Ptr<Ipv6> ipv6);
/**
* \brief Print the Routing Table entries
*
* \param stream the ostream the Routing table is printed to
*/
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
protected:
/**

View File

@@ -30,6 +30,7 @@
#include "ipv6-interface-address.h"
#include "ipv6.h"
#include "ns3/output-stream-wrapper.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -191,9 +192,11 @@ public:
/**
* \brief Print the Routing Table entries
*
* \param stream the ostream the Routing table is printed to
* \param stream The ostream the Routing table is printed to
* \param unit The time unit to be used in the report
*/
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const = 0;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const = 0;
};
} // namespace ns3

View File

@@ -79,14 +79,14 @@ void Ipv6StaticRouting::SetIpv6 (Ptr<Ipv6> ipv6)
// Formatted like output of "route -n" command
void
Ipv6StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv6StaticRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv6->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Ipv6StaticRouting table" << std::endl;
if (GetNRoutes () > 0)

View File

@@ -237,13 +237,7 @@ public:
virtual void NotifyAddRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void SetIpv6 (Ptr<Ipv6> ipv6);
/**
* \brief Print the Routing Table entries
*
* \param stream the ostream the Routing table is printed to
*/
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
protected:
/**

View File

@@ -482,15 +482,15 @@ void Rip::SetIpv4 (Ptr<Ipv4> ipv4)
}
}
void Rip::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
void Rip::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", IPv4 RIP table" << std::endl;
if (!m_routes.empty ())

View File

@@ -194,7 +194,7 @@ public:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
/**
* Split Horizon strategy type. See \RFC{2453}.

View File

@@ -466,15 +466,15 @@ void RipNg::SetIpv6 (Ptr<Ipv6> ipv6)
}
}
void RipNg::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
void RipNg::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
NS_LOG_FUNCTION (this << stream);
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv6->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", IPv6 RIPng table" << std::endl;
if (!m_routes.empty ())

View File

@@ -199,7 +199,7 @@ public:
virtual void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop,
uint32_t interface, Ipv6Address prefixToUse = Ipv6Address::GetZero ());
virtual void SetIpv6 (Ptr<Ipv6> ipv6);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
/**
* Split Horizon strategy type. See \RFC{2080}.

View File

@@ -34,7 +34,7 @@ public:
void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) {}
void SetIpv4 (Ptr<Ipv4> ipv4) {}
void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {}
void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const {}
};
class Ipv4BRouting : public Ipv4RoutingProtocol {
@@ -48,7 +48,7 @@ public:
void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address) {}
void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address) {}
void SetIpv4 (Ptr<Ipv4> ipv4) {}
void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {}
void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const {}
};
class Ipv4ListRoutingNegativeTestCase : public TestCase

View File

@@ -38,7 +38,7 @@ public:
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {};
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const {};
};
class Ipv6BRouting : public Ipv6RoutingProtocol {
@@ -55,7 +55,7 @@ public:
GetZero ()) {}
void NotifyRemoveRoute (Ipv6Address dst, Ipv6Prefix mask, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse) {}
void SetIpv6 (Ptr<Ipv6> ipv6) {}
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const {};
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const {};
};
class Ipv6ListRoutingNegativeTestCase : public TestCase

View File

@@ -696,7 +696,7 @@ Ipv4NixVectorRouting::RouteInput (Ptr<const Packet> p, const Ipv4Header &header,
}
void
Ipv4NixVectorRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
Ipv4NixVectorRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
CheckCacheStateAndFlush ();
@@ -704,8 +704,8 @@ Ipv4NixVectorRouting::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", Nix Routing" << std::endl;
*os << "NixCache:" << std::endl;

View File

@@ -31,6 +31,7 @@
#include "ns3/ipv4-route.h"
#include "ns3/nix-vector.h"
#include "ns3/bridge-net-device.h"
#include "ns3/nstime.h"
namespace ns3 {
@@ -158,8 +159,8 @@ private:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
/*
* Flushes routing caches if required.
*/

View File

@@ -251,13 +251,13 @@ void RoutingProtocol::DoDispose ()
}
void
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit) const
{
std::ostream* os = stream->GetStream ();
*os << "Node: " << m_ipv4->GetObject<Node> ()->GetId ()
<< ", Time: " << Now ().As (Time::S)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (Time::S)
<< ", Time: " << Now ().As (unit)
<< ", Local time: " << GetObject<Node> ()->GetLocalTime ().As (unit)
<< ", OLSR Routing table" << std::endl;
*os << "Destination\t\tNextHop\t\tInterface\tDistance\n";
@@ -283,7 +283,7 @@ RoutingProtocol::PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const
if (m_hnaRoutingTable->GetNRoutes () > 0)
{
*os << " HNA Routing Table: ";
m_hnaRoutingTable->PrintRoutingTable (stream);
m_hnaRoutingTable->PrintRoutingTable (stream, unit);
}
else
{

View File

@@ -310,7 +310,7 @@ private:
virtual void NotifyAddAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void NotifyRemoveAddress (uint32_t interface, Ipv4InterfaceAddress address);
virtual void SetIpv4 (Ptr<Ipv4> ipv4);
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream) const;
virtual void PrintRoutingTable (Ptr<OutputStreamWrapper> stream, Time::Unit unit = Time::S) const;
void DoDispose ();