From 79982e8cf4a44ec9ccbd5e52fdcfbc5c87614396 Mon Sep 17 00:00:00 2001 From: Tommaso Pecorella Date: Fri, 6 Nov 2015 23:09:19 +0100 Subject: [PATCH] Print node ID and time when printing routing tables --- RELEASE_NOTES | 15 +++++++++------ src/aodv/model/aodv-routing-protocol.cc | 7 ++++++- src/dsdv/model/dsdv-routing-protocol.cc | 7 ++++++- src/internet/model/ipv4-global-routing.cc | 8 ++++++++ src/internet/model/ipv4-list-routing.cc | 6 +++--- src/internet/model/ipv4-static-routing.cc | 7 +++++++ src/internet/model/ipv6-list-routing.cc | 6 +++--- src/internet/model/ipv6-static-routing.cc | 6 ++++-- src/internet/model/ripng.cc | 6 ++++-- .../model/ipv4-nix-vector-routing.cc | 7 +++++++ src/olsr/model/olsr-routing-protocol.cc | 18 ++++++++++++++++-- 11 files changed, 73 insertions(+), 20 deletions(-) diff --git a/RELEASE_NOTES b/RELEASE_NOTES index e6fcf5c73..6c71a31bd 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -22,12 +22,15 @@ To be determined. New user-visible features ------------------------- -(internet) The native TCP implementation has been refactored, for the following -improvements: 1) congestion control has been aligned with the Linux -architecture, to facilitate easier coding of new congestion control algorithms -or porting implementations from the Linux kernel, 2) Fast Retransmit and Fast -recovery algorithms, compliant to RFCs, are shared by all TCP variants, unlike -previous releases. 3) TCP Hybla and TCP HighSpeed have been added. +- (internet) The native TCP implementation has been refactored, for the following + improvements: 1) congestion control has been aligned with the Linux + architecture, to facilitate easier coding of new congestion control algorithms + or porting implementations from the Linux kernel, 2) Fast Retransmit and Fast + recovery algorithms, compliant to RFCs, are shared by all TCP variants, unlike + previous releases. 3) TCP Hybla and TCP HighSpeed have been added. +- (general) The PrintRoutingTable* functions now print the following informations + each time they are called: 1) the node ID, 2) the global time, 3) the local time + 4) the routing protocol type Bugs fixed ---------- diff --git a/src/aodv/model/aodv-routing-protocol.cc b/src/aodv/model/aodv-routing-protocol.cc index 59086d39a..e0514292f 100644 --- a/src/aodv/model/aodv-routing-protocol.cc +++ b/src/aodv/model/aodv-routing-protocol.cc @@ -298,8 +298,13 @@ RoutingProtocol::DoDispose () void RoutingProtocol::PrintRoutingTable (Ptr stream) const { - *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () << " Time: " << Simulator::Now ().GetSeconds () << "s "; + *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () + << "; Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", AODV Routing table" << std::endl; + m_routingTable.Print (stream); + *stream->GetStream () << std::endl; } int64_t diff --git a/src/dsdv/model/dsdv-routing-protocol.cc b/src/dsdv/model/dsdv-routing-protocol.cc index e2a27e89b..b20ecc239 100644 --- a/src/dsdv/model/dsdv-routing-protocol.cc +++ b/src/dsdv/model/dsdv-routing-protocol.cc @@ -231,8 +231,13 @@ RoutingProtocol::DoDispose () void RoutingProtocol::PrintRoutingTable (Ptr stream) const { - *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () << " Time: " << Simulator::Now ().GetSeconds () << "s "; + *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", DSDV Routing table" << std::endl; + m_routingTable.Print (stream); + *stream->GetStream () << std::endl; } void diff --git a/src/internet/model/ipv4-global-routing.cc b/src/internet/model/ipv4-global-routing.cc index a5fc2dfb7..cbc8e42ed 100644 --- a/src/internet/model/ipv4-global-routing.cc +++ b/src/internet/model/ipv4-global-routing.cc @@ -27,6 +27,7 @@ #include "ns3/ipv4-route.h" #include "ns3/ipv4-routing-table-entry.h" #include "ns3/boolean.h" +#include "ns3/node.h" #include "ipv4-global-routing.h" #include "global-route-manager.h" @@ -401,6 +402,12 @@ Ipv4GlobalRouting::PrintRoutingTable (Ptr stream) const { NS_LOG_FUNCTION (this << stream); std::ostream* os = stream->GetStream (); + + *os << "Node: " << m_ipv4->GetObject ()->GetId () + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", Ipv4GlobalRouting table" << std::endl; + if (GetNRoutes () > 0) { *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; @@ -441,6 +448,7 @@ Ipv4GlobalRouting::PrintRoutingTable (Ptr stream) const *os << std::endl; } } + *os << std::endl; } Ptr diff --git a/src/internet/model/ipv4-list-routing.cc b/src/internet/model/ipv4-list-routing.cc index 945d32724..1dd14fb20 100644 --- a/src/internet/model/ipv4-list-routing.cc +++ b/src/internet/model/ipv4-list-routing.cc @@ -74,15 +74,15 @@ Ipv4ListRouting::PrintRoutingTable (Ptr stream) const { NS_LOG_FUNCTION (this << stream); *stream->GetStream () << "Node: " << m_ipv4->GetObject ()->GetId () - << " Time: " << Simulator::Now ().GetSeconds () << "s " - << "Ipv4ListRouting table" << std::endl; + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", 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); } - *stream->GetStream () << std::endl; } void diff --git a/src/internet/model/ipv4-static-routing.cc b/src/internet/model/ipv4-static-routing.cc index 76d0fb70a..6220c2f9d 100644 --- a/src/internet/model/ipv4-static-routing.cc +++ b/src/internet/model/ipv4-static-routing.cc @@ -712,6 +712,12 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const { NS_LOG_FUNCTION (this << stream); std::ostream* os = stream->GetStream (); + + *os << "Node: " << m_ipv4->GetObject ()->GetId () + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", Ipv4StaticRouting table" << std::endl; + if (GetNRoutes () > 0) { *os << "Destination Gateway Genmask Flags Metric Ref Use Iface" << std::endl; @@ -751,6 +757,7 @@ Ipv4StaticRouting::PrintRoutingTable (Ptr stream) const *os << std::endl; } } + *os << std::endl; } Ipv4Address Ipv4StaticRouting::SourceAddressSelection (uint32_t interfaceIdx, Ipv4Address dest) diff --git a/src/internet/model/ipv6-list-routing.cc b/src/internet/model/ipv6-list-routing.cc index 4a4e55b03..aefccaf61 100644 --- a/src/internet/model/ipv6-list-routing.cc +++ b/src/internet/model/ipv6-list-routing.cc @@ -277,15 +277,15 @@ Ipv6ListRouting::PrintRoutingTable (Ptr stream) const NS_LOG_FUNCTION (this); *stream->GetStream () << "Node: " << m_ipv6->GetObject ()->GetId () - << " Time: " << Simulator::Now ().GetSeconds () << "s " - << "Ipv6ListRouting table" << std::endl; + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", 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); } - *stream->GetStream () << std::endl; } void diff --git a/src/internet/model/ipv6-static-routing.cc b/src/internet/model/ipv6-static-routing.cc index 4e0594298..ba7261753 100644 --- a/src/internet/model/ipv6-static-routing.cc +++ b/src/internet/model/ipv6-static-routing.cc @@ -85,8 +85,9 @@ Ipv6StaticRouting::PrintRoutingTable (Ptr stream) const std::ostream* os = stream->GetStream (); *os << "Node: " << m_ipv6->GetObject ()->GetId () - << " Time: " << Simulator::Now ().GetSeconds () << "s " - << "Ipv6StaticRouting table" << std::endl; + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", Ipv6StaticRouting table" << std::endl; if (GetNRoutes () > 0) { @@ -125,6 +126,7 @@ Ipv6StaticRouting::PrintRoutingTable (Ptr stream) const *os << std::endl; } } + *os << std::endl; } void Ipv6StaticRouting::AddHostRouteTo (Ipv6Address dst, Ipv6Address nextHop, uint32_t interface, Ipv6Address prefixToUse, uint32_t metric) diff --git a/src/internet/model/ripng.cc b/src/internet/model/ripng.cc index 4710c545c..915cc80f5 100644 --- a/src/internet/model/ripng.cc +++ b/src/internet/model/ripng.cc @@ -488,8 +488,9 @@ void RipNg::PrintRoutingTable (Ptr stream) const std::ostream* os = stream->GetStream (); *os << "Node: " << m_ipv6->GetObject ()->GetId () - << " Time: " << Simulator::Now ().GetSeconds () << "s " - << "Ipv6 RIPng table" << std::endl; + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", IPv6 RIPng table" << std::endl; if (!m_routes.empty ()) { @@ -534,6 +535,7 @@ void RipNg::PrintRoutingTable (Ptr stream) const } } } + *os << std::endl; } void RipNg::DoDispose () diff --git a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc index fe54c794c..062cfe87e 100644 --- a/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc +++ b/src/nix-vector-routing/model/ipv4-nix-vector-routing.cc @@ -677,6 +677,12 @@ Ipv4NixVectorRouting::PrintRoutingTable (Ptr stream) const CheckCacheStateAndFlush (); std::ostream* os = stream->GetStream (); + + *os << "Node: " << m_ipv4->GetObject ()->GetId () + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", Nix Routing" << std::endl; + *os << "NixCache:" << std::endl; if (m_nixCache.size () > 0) { @@ -714,6 +720,7 @@ Ipv4NixVectorRouting::PrintRoutingTable (Ptr stream) const *os << std::endl; } } + *os << std::endl; } // virtual functions from Ipv4RoutingProtocol diff --git a/src/olsr/model/olsr-routing-protocol.cc b/src/olsr/model/olsr-routing-protocol.cc index 9648d1858..5cf67da19 100644 --- a/src/olsr/model/olsr-routing-protocol.cc +++ b/src/olsr/model/olsr-routing-protocol.cc @@ -254,6 +254,12 @@ void RoutingProtocol::PrintRoutingTable (Ptr stream) const { std::ostream* os = stream->GetStream (); + + *os << "Node: " << m_ipv4->GetObject ()->GetId () + << ", Time: " << Now().As (Time::S) + << ", Local time: " << GetObject ()->GetLocalTime ().As (Time::S) + << ", OLSR Routing table" << std::endl; + *os << "Destination\t\tNextHop\t\tInterface\tDistance\n"; for (std::map::const_iterator iter = m_table.begin (); @@ -272,9 +278,17 @@ RoutingProtocol::PrintRoutingTable (Ptr stream) const *os << iter->second.distance << "\t"; *os << "\n"; } + // Also print the HNA routing table - *os << " HNA Routing Table:\n"; - m_hnaRoutingTable->PrintRoutingTable (stream); + if (m_hnaRoutingTable->GetNRoutes () > 0) + { + *os << " HNA Routing Table: "; + m_hnaRoutingTable->PrintRoutingTable (stream); + } + else + { + *os << " HNA Routing Table: empty" << std::endl; + } } void RoutingProtocol::DoInitialize ()