--- a/examples/ipv6/icmpv6-redirect.cc Mon Aug 12 22:51:37 2013 -0700
+++ b/examples/ipv6/icmpv6-redirect.cc Tue Aug 13 17:56:25 2013 +0200
@@ -53,60 +53,6 @@
NS_LOG_COMPONENT_DEFINE ("Icmpv6RedirectExample");
-/**
- * \class StackHelper
- * \brief Helper to set or get some IPv6 information about nodes.
- */
-class StackHelper
-{
-public:
- /**
- * \brief Print the routing table.
- * \param n the node
- */
- inline void PrintRoutingTable (Ptr<Node>& n)
- {
- Ptr<Ipv6StaticRouting> routing = 0;
- Ipv6StaticRoutingHelper routingHelper;
- Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
- uint32_t nbRoutes = 0;
- Ipv6RoutingTableEntry route;
-
- routing = routingHelper.GetStaticRouting (ipv6);
-
- std::cout << "Routing table of " << n << " : " << std::endl;
- std::cout << "Destination\t\t\t\t" << "Gateway\t\t\t\t\t" << "Interface\t" << "Prefix to use" << std::endl;
-
- nbRoutes = routing->GetNRoutes ();
- for(uint32_t i = 0; i < nbRoutes; i++)
- {
- route = routing->GetRoute (i);
- std::cout << route.GetDest () << "\t"
- << route.GetGateway () << "\t"
- << route.GetInterface () << "\t"
- << route.GetPrefixToUse () << "\t"
- << std::endl;
- }
- }
-
- /**
- * \brief Add an host route.
- * \param n node
- * \param dst destination address
- * \param nextHop next hop for destination
- * \param interface output interface
- */
- inline void AddHostRouteTo (Ptr<Node>& n, Ipv6Address dst, Ipv6Address nextHop, uint32_t interface)
- {
- Ptr<Ipv6StaticRouting> routing = 0;
- Ipv6StaticRoutingHelper routingHelper;
- Ptr<Ipv6> ipv6 = n->GetObject<Ipv6> ();
-
- routing = routingHelper.GetStaticRouting (ipv6);
- routing->AddHostRouteTo (dst, nextHop, interface);
- }
-};
-
int main (int argc, char **argv)
{
#if 0
@@ -131,8 +77,6 @@
NodeContainer net2 (r2, sta2);
NodeContainer all (sta1, r1, r2, sta2);
- StackHelper stackHelper;
-
InternetStackHelper internetv6;
internetv6.Install (all);
@@ -157,10 +101,15 @@
iic2.SetForwarding (0, true);
iic2.SetDefaultRouteInAllNodes (0);
- stackHelper.AddHostRouteTo (r1, iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1));
+ Ipv6StaticRoutingHelper routingHelper;
- Simulator::Schedule (Seconds (0.0), &StackHelper::PrintRoutingTable, &stackHelper, r1);
- Simulator::Schedule (Seconds (3.0), &StackHelper::PrintRoutingTable, &stackHelper, sta1);
+ // manually inject a static route to the second router.
+ Ptr<Ipv6StaticRouting> routing = routingHelper.GetStaticRouting (r1->GetObject<Ipv6> ());
+ routing->AddHostRouteTo (iic2.GetAddress (1, 1), iic1.GetAddress (2, 0), iic1.GetInterfaceIndex (1));
+
+ Ptr<OutputStreamWrapper> routingStream = Create<OutputStreamWrapper> (&std::cout);
+ routingHelper.PrintRoutingTableAt (Seconds (0.0), r1, routingStream);
+ routingHelper.PrintRoutingTableAt (Seconds (3.0), sta1, routingStream);
NS_LOG_INFO ("Create Applications.");
uint32_t packetSize = 1024;