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 | |
| 10 | def __init__(self, net, nodes, convergenceTime, strategy): |
| 11 | |
| 12 | Experiment.__init__(self, net, nodes, convergenceTime, 300, strategy) |
| 13 | self.PING_COLLECTION_TIME_BEFORE_FAILURE = 60 |
| 14 | self.PING_COLLECTION_TIME_AFTER_RECOVERY = 90 |
| 15 | |
| 16 | def run(self): |
| 17 | self.startPings() |
| 18 | |
| 19 | # After the pings are scheduled, collect pings for 1 minute |
| 20 | time.sleep(self.PING_COLLECTION_TIME_BEFORE_FAILURE) |
| 21 | |
| 22 | # Bring down CSU |
| 23 | for host in self.net.hosts: |
| 24 | if host.name == "csu": |
| 25 | print("Bringing CSU down") |
| 26 | host.nfd.stop() |
| 27 | break |
| 28 | |
| 29 | # CSU is down for 2 minutes |
| 30 | time.sleep(120) |
| 31 | |
| 32 | # Bring CSU back up |
| 33 | for host in self.net.hosts: |
| 34 | if host.name == "csu": |
| 35 | print("Bringing CSU up") |
| 36 | host.nfd.start() |
| 37 | host.nlsr.start() |
| 38 | host.nfd.setStrategy("/ndn/edu", self.strategy) |
| 39 | host.cmd("ndnpingserver /ndn/edu/" + str(host) + " > ping-server &") |
| 40 | |
| 41 | # Collect pings for more seconds after CSU is up |
| 42 | time.sleep(self.PING_COLLECTION_TIME_AFTER_RECOVERY) |