blob: d4e938075c96db621d759b6f7bd8601f486c4eb4 [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
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)