blob: 0833ff11ad9d4983edecb091e40cfb5e3a083b36 [file] [log] [blame]
Ashlesh Gawande6c86e302019-09-17 22:27:05 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
dulalsaurab578f2ec2021-06-10 20:55:26 +00003# Copyright (C) 2015-2021, The University of Memphis,
Ashlesh Gawande6c86e302019-09-17 22:27:05 -05004# Arizona Board of Regents,
5# Regents of the University of California.
6#
7# This file is part of Mini-NDN.
8# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
9#
10# Mini-NDN is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# Mini-NDN is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with Mini-NDN, e.g., in COPYING.md file.
22# If not, see <http://www.gnu.org/licenses/>.
23
24import time
25
26from mininet.log import setLogLevel, info
27
28from minindn.minindn import Minindn
29from minindn.util import MiniNDNCLI
30from minindn.apps.app_manager import AppManager
31from minindn.apps.nfd import Nfd
32from minindn.apps.nlsr import Nlsr
33from minindn.helpers.experiment import Experiment
34from minindn.helpers.nfdc import Nfdc
dulalsaurab578f2ec2021-06-10 20:55:26 +000035from minindn.helpers.ndnping import NDNPing
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050036
37from nlsr_common import getParser
38
39def multipleFailure(ndn, nfds, nlsrs, args):
40
41 Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
42 Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE)
43
44 PING_COLLECTION_TIME_BEFORE_FAILURE = 60
45 FAILURE_INTERVAL = 60
46 RECOVERY_INTERVAL = 60
47
dulalsaurab578f2ec2021-06-10 20:55:26 +000048 # Number of pings required to make it through the full experiment
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050049 nInitialPings = (PING_COLLECTION_TIME_BEFORE_FAILURE +
50 len(ndn.net.hosts) * (FAILURE_INTERVAL + RECOVERY_INTERVAL))
51 print('Scheduling with {} initial pings'.format(nInitialPings))
52
53 pingedDict = Experiment.startPctPings(ndn.net, nInitialPings, args.pctTraffic)
54 time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE)
55
56 nNodesRemainingToFail = len(ndn.net.hosts)
57
58 for host in ndn.net.hosts:
59 # Fail the node
60 info('Bringing down node {}\n'.format(host.name))
61 nlsrs[host.name].stop()
62 nfds[host.name].stop()
63
64 # Stay in failure state for FAILURE_INTERVAL seconds
65 time.sleep(FAILURE_INTERVAL)
66
67 # Bring the node back up
68 start_time = time.time()
69 info('Bringing up node {}\n'.format(host.name))
70 nfds[host.name].start()
71 nlsrs[host.name].start()
72 Experiment.setupPing([host], Nfdc.STRATEGY_BEST_ROUTE)
73
74 recovery_time = int(time.time() - start_time)
75
76 # Number of pings required to reach the end of the test
77 nNodesRemainingToFail -= 1
78 nPings = ((RECOVERY_INTERVAL - recovery_time) +
79 nNodesRemainingToFail * (FAILURE_INTERVAL + RECOVERY_INTERVAL))
80
81 info('Scheduling with {} remaining pings\n'.format(nPings))
82
83 # Restart pings
84 for nodeToPing in pingedDict[host]:
dulalsaurab578f2ec2021-06-10 20:55:26 +000085 NDNPing.ping(host, nodeToPing, nPings=nPings)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050086
87 time.sleep(RECOVERY_INTERVAL - recovery_time)
88
dulalsaurab578f2ec2021-06-10 20:55:26 +000089 Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050090
91if __name__ == '__main__':
92 setLogLevel('info')
93
94 ndn = Minindn(parser=getParser())
95 args = ndn.args
96
97 ndn.start()
98
99 nfds = AppManager(ndn, ndn.net.hosts, Nfd)
100 nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
101 security=args.security, faceType=args.faceType,
102 nFaces=args.faces, routingType=args.routingType)
103
104 multipleFailure(ndn, nfds, nlsrs, args)
105
106 if args.isCliEnabled:
107 MiniNDNCLI(ndn.net)
108
109 ndn.stop()