Bug 2103 - Ipv[4,6]RoutingHelper::PrintRoutingTableAll[At,Every] hangs if a node doesn't have IP

This commit is contained in:
Tommaso Pecorella
2015-04-19 21:39:32 +02:00
parent dda924a53a
commit e0165db56c
3 changed files with 113 additions and 88 deletions

View File

@@ -45,6 +45,7 @@ Bugs fixed
- Bug 2087 - Waf fails to build ns-3 if the path contains accented characters
- Bug 2090 - (rip-ng) Routes may be added twice on interface activation
- Bug 2093 - MultiModelSpectrumChannel::GetDevice only works for 0-th index
- Bug 2103 - Ipv[4,6]RoutingHelper::PrintRoutingTableAll[At,Every] hangs if a node doesn't have IP
Known issues
------------

View File

@@ -71,19 +71,25 @@ void
Ipv4RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
if (ipv4)
{
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
}
}
void
Ipv4RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
Ptr<Ipv4> ipv4 = node->GetObject<Ipv4> ();
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream);
if (ipv4)
{
Ptr<Ipv4RoutingProtocol> rp = ipv4->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintEvery, printInterval, node, stream);
}
}
void
@@ -121,27 +127,30 @@ Ipv4RoutingHelper::PrintNeighborCacheEvery (Time printInterval,Ptr<Node> node, P
void
Ipv4RoutingHelper::PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
if (ipv4)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
arpCache->PrintArpCache (stream);
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
{
arpCache->PrintArpCache (stream);
}
}
}
}
@@ -149,30 +158,33 @@ Ipv4RoutingHelper::PrintArpCache (Ptr<Node> node, Ptr<OutputStreamWrapper> strea
void
Ipv4RoutingHelper::PrintArpCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv4L3Protocol> ipv4 = node->GetObject<Ipv4L3Protocol> ();
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
if (ipv4)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
std::ostream* os = stream->GetStream ();
*os << "ARP Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
arpCache->PrintArpCache (stream);
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
for (uint32_t i=0; i<ipv4->GetNInterfaces(); i++)
{
Ptr<ArpCache> arpCache = ipv4->GetInterface (i)->GetArpCache ();
if (arpCache)
{
arpCache->PrintArpCache (stream);
}
}
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, printInterval, node, stream);
}
Simulator::Schedule (printInterval, &Ipv4RoutingHelper::PrintArpCacheEvery, printInterval, node, stream);
}
} // namespace ns3

View File

@@ -71,19 +71,25 @@ void
Ipv6RoutingHelper::Print (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
if (ipv6)
{
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
}
}
void
Ipv6RoutingHelper::PrintEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
Ptr<Ipv6> ipv6 = node->GetObject<Ipv6> ();
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream);
if (ipv6)
{
Ptr<Ipv6RoutingProtocol> rp = ipv6->GetRoutingProtocol ();
NS_ASSERT (rp);
rp->PrintRoutingTable (stream);
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintEvery, printInterval, node, stream);
}
}
void
@@ -121,27 +127,30 @@ Ipv6RoutingHelper::PrintNeighborCacheEvery (Time printInterval,Ptr<Node> node, P
void
Ipv6RoutingHelper::PrintNdiscCache (Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> ();
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
if (ipv6)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
ndiscCache->PrintNdiscCache (stream);
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
{
ndiscCache->PrintNdiscCache (stream);
}
}
}
}
@@ -149,30 +158,33 @@ Ipv6RoutingHelper::PrintNdiscCache (Ptr<Node> node, Ptr<OutputStreamWrapper> str
void
Ipv6RoutingHelper::PrintNdiscCacheEvery (Time printInterval, Ptr<Node> node, Ptr<OutputStreamWrapper> stream)
{
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
Ptr<Ipv6L3Protocol> ipv6 = node->GetObject<Ipv6L3Protocol> ();
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
if (ipv6)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
std::ostream* os = stream->GetStream ();
*os << "NDISC Cache of node ";
std::string found = Names::FindName (node);
if (Names::FindName (node) != "")
{
ndiscCache->PrintNdiscCache (stream);
*os << found;
}
else
{
*os << static_cast<int> (node->GetId ());
}
*os << " at time " << Simulator::Now ().GetSeconds () << "\n";
for (uint32_t i=0; i<ipv6->GetNInterfaces(); i++)
{
Ptr<NdiscCache> ndiscCache = ipv6->GetInterface (i)->GetNdiscCache ();
if (ndiscCache)
{
ndiscCache->PrintNdiscCache (stream);
}
}
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, printInterval, node, stream);
}
Simulator::Schedule (printInterval, &Ipv6RoutingHelper::PrintNdiscCacheEvery, printInterval, node, stream);
}
} // namespace ns3