Add failNode and recoverNode methods to Experiment class
refs: #3085
Change-Id: Ib99edc1c7a201f16c993aa0e0c4791c2eea15a35
diff --git a/ndn/experiments/experiment.py b/ndn/experiments/experiment.py
index bf08c7f..d6d5df7 100644
--- a/ndn/experiments/experiment.py
+++ b/ndn/experiments/experiment.py
@@ -94,6 +94,17 @@
if host.name != other.name:
self.ping(host, other, self.nPings)
+ def failNode(self, host):
+ print("Bringing %s down" % host.name)
+ host.nfd.stop()
+
+ def recoverNode(self, host):
+ print("Bringing %s up" % host.name)
+ host.nfd.start()
+ host.nlsr.start()
+ host.nfd.setStrategy("/ndn/edu", self.strategy)
+ host.cmd("ndnpingserver /ndn/edu/" + str(host) + " > ping-server &")
+
@staticmethod
def register(name, experimentClass):
ExperimentManager.register(name, experimentClass)
diff --git a/ndn/experiments/failure_experiment.py b/ndn/experiments/failure_experiment.py
index 3f34789..8bca445 100644
--- a/ndn/experiments/failure_experiment.py
+++ b/ndn/experiments/failure_experiment.py
@@ -44,8 +44,7 @@
# Bring down CSU
for host in self.net.hosts:
if host.name == "csu":
- print("Bringing CSU down")
- host.nfd.stop()
+ self.failNode(host)
break
# CSU is down for 2 minutes
@@ -54,11 +53,7 @@
# Bring CSU back up
for host in self.net.hosts:
if host.name == "csu":
- print("Bringing CSU up")
- host.nfd.start()
- host.nlsr.start()
- host.nfd.setStrategy("/ndn/edu", self.strategy)
- host.cmd("ndnpingserver /ndn/edu/" + str(host) + " > ping-server &")
+ self.recoverNode(host)
for other in self.net.hosts:
if host.name != other.name:
diff --git a/ndn/experiments/multiple_failure_experiment.py b/ndn/experiments/multiple_failure_experiment.py
index 1736f9a..bea9a78 100644
--- a/ndn/experiments/multiple_failure_experiment.py
+++ b/ndn/experiments/multiple_failure_experiment.py
@@ -43,17 +43,6 @@
Experiment.__init__(self, args)
- def failNode(self, host):
- print("Bringing %s down" % host.name)
- host.nfd.stop()
-
- def recoverNode(self, host):
- print("Bringing %s up" % host.name)
- host.nfd.start()
- host.nlsr.start()
- host.nfd.setStrategy("/ndn/edu", self.strategy)
- host.cmd("ndnpingserver /ndn/edu/" + str(host) + " > ping-server &")
-
def run(self):
self.startPings()