Added the possibility to not calculate the full route when routing, but stop at maxhtl. Should speed up random networks (flat) quite a bit.
diff --git a/sim.py b/sim.py
--- a/sim.py
+++ b/sim.py
@@ -442,9 +442,13 @@ def checkfold(target, prev, net, probabi
if strategy == "connectsimple":
return checksimpleconnect(target, prev, net)
-def fold(net, num=100, strategy="jumphalf", maxhtl=20):
+def fold(net, num=100, strategy="jumphalf", maxhtl=20, fullroutes=True):
"""do num path foldings.
+ :param fullroutes: Calculate the full route, regardless of
+ maxhtl. Only use the HTL for deciding whether to try to fold
+ the route.
+
:return: the lengths of all used routes."""
routelengths = []
for i in range(num):
@@ -453,8 +457,16 @@ def fold(net, num=100, strategy="jumphal
target = choice(nodes)
while target == start:
target = choice(nodes)
- route = findroute(target, start, net)
+ if fullroute:
+ route = findroute(target, start, net, maxhtl=9999)
+ else:
+ route = findroute(target, start, net, maxhtl=maxhtl)
if not route:
+ # in case we break the route at maxhtl, we just add the
+ # HTL+1 to be able to do the simplistic success stats
+ # later.
+ if not fullroute:
+ routelengths.append(maxhtl+1)
continue
routelen = len(route)
routelengths.append(routelen)