Routing fixes in ns3: consider point-to-point patterns when figuring out nexthop...
authorClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Mon, 23 May 2011 15:40:07 +0000 (17:40 +0200)
committerClaudio-Daniel Freire <claudio-daniel.freire@inria.fr>
Mon, 23 May 2011 15:40:07 +0000 (17:40 +0200)
  192.168.2.2/32 -> iface 10
  192.168.3.0/24 -> 192.168.2.2

src/nepi/testbeds/ns3/execute.py
src/nepi/testbeds/ns3/factories_metadata_v3_9_RC3.py

index 8b1d6b3..ab34f25 100644 (file)
@@ -124,6 +124,8 @@ class TestbedController(testbed_impl.TestbedController):
                 # graceful shutdown of locally-implemented objects
                 element.Cleanup()
             element = None
+        sys.stdout.flush()
+        sys.stderr.flush()
 
     def _simulator_run(self, condition):
         # Run simulation
index 0980ea0..febb5c4 100644 (file)
@@ -475,20 +475,40 @@ def configure_node(testbed_instance, guid):
             ifindex = -1
             # TODO: HACKISH way of getting the ifindex... improve this
             nifaces = ipv4.GetNInterfaces()
-            for ifidx in range(nifaces):
+            for ifidx in xrange(nifaces):
                 iface = ipv4.GetInterface(ifidx)
                 naddress = iface.GetNAddresses()
-                for addridx in range(naddress):
+                for addridx in xrange(naddress):
                     ifaddr = iface.GetAddress(addridx)
                     ifmask = ifaddr.GetMask()
                     ifindex = ipv4.GetInterfaceForPrefix(nexthop_address, ifmask)
                     if ifindex == ifidx:
                         break
+            if ifindex < 0:
+                # Check previous ptp routes
+                for chaindest, chainprefix, chainhop in routes:
+                    if chaindest == nexthop and chainprefix == 32:
+                        chainhop_address = ns3.Ipv4Address(chainhop)
+                        for ifidx in xrange(nifaces):
+                            iface = ipv4.GetInterface(ifidx)
+                            naddress = iface.GetNAddresses()
+                            for addridx in xrange(naddress):
+                                ifaddr = iface.GetAddress(addridx)
+                                ifmask = ifaddr.GetMask()
+                                ifindex = ipv4.GetInterfaceForPrefix(chainhop_address, ifmask)
+                                if ifindex == ifidx:
+                                    break
+            if ifindex < 0:
+                raise RuntimeError, "Cannot associate interface for routing entry:" \
+                    "%s/%s -> %s. At node %s" % (destination, netprefix, nexthop, guid)
             _add_static_route(ns3, static_routing, 
                 address, netprefix, nexthop_address, ifindex)
         else:
             mask = ns3.Ipv4Mask("/%d" % netprefix) 
             ifindex = ipv4.GetInterfaceForPrefix(address, mask)
+            if ifindex < 0:
+                raise RuntimeError, "Cannot associate interface for routing entry:" \
+                    "%s/%s -> %s. At node %s" % (destination, netprefix, nexthop, guid)
             _add_static_route_if(ns3, static_routing, 
                 address, netprefix, nexthop_address, ifindex)