ashu | 34c3ee0 | 2015-03-25 14:41:14 -0500 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | from ndn.experiments.experiment import Experiment |
| 4 | from ndn.nlsr import Nlsr |
| 5 | |
| 6 | import time |
| 7 | |
| 8 | class FailureExperiment(Experiment): |
| 9 | |
Vince Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 10 | def __init__(self, args): |
| 11 | args["nPings"] = 300 |
| 12 | Experiment.__init__(self, args) |
ashu | 34c3ee0 | 2015-03-25 14:41:14 -0500 | [diff] [blame] | 13 | |
ashu | 34c3ee0 | 2015-03-25 14:41:14 -0500 | [diff] [blame] | 14 | 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 Lehman | 3b8bc65 | 2015-06-18 15:01:47 -0500 | [diff] [blame] | 44 | |
| 45 | Experiment.register("failure", FailureExperiment) |