blob: bae70c12e5c48dcd92ad4cc98233584e8daab92c [file] [log] [blame]
ashu34c3ee02015-03-25 14:41:14 -05001#!/usr/bin/python
2
3from ndn.experiments.experiment import Experiment
4from ndn.nlsr import Nlsr
5
6import time
7
8class FailureExperiment(Experiment):
9
Vince Lehman3b8bc652015-06-18 15:01:47 -050010 def __init__(self, args):
11 args["nPings"] = 300
12 Experiment.__init__(self, args)
ashu34c3ee02015-03-25 14:41:14 -050013
ashu34c3ee02015-03-25 14:41:14 -050014 self.PING_COLLECTION_TIME_BEFORE_FAILURE = 60
15 self.PING_COLLECTION_TIME_AFTER_RECOVERY = 90
16
17 def run(self):
18 self.startPings()
19
20 # After the pings are scheduled, collect pings for 1 minute
21 time.sleep(self.PING_COLLECTION_TIME_BEFORE_FAILURE)
22
23 # Bring down CSU
24 for host in self.net.hosts:
25 if host.name == "csu":
26 print("Bringing CSU down")
27 host.nfd.stop()
28 break
29
30 # CSU is down for 2 minutes
31 time.sleep(120)
32
33 # Bring CSU back up
34 for host in self.net.hosts:
35 if host.name == "csu":
36 print("Bringing CSU up")
37 host.nfd.start()
38 host.nlsr.start()
39 host.nfd.setStrategy("/ndn/edu", self.strategy)
40 host.cmd("ndnpingserver /ndn/edu/" + str(host) + " > ping-server &")
41
42 # Collect pings for more seconds after CSU is up
43 time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY)
Vince Lehman3b8bc652015-06-18 15:01:47 -050044
45Experiment.register("failure", FailureExperiment)