blob: decb58608e52b634e47af6e9d86aa2470635a166 [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 mcnFailure(ndn, nfds, nlsrs, args):
40 Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
41 if args.nPings != 0:
42 Experiment.setupPing(ndn.net.hosts, Nfdc.STRATEGY_BEST_ROUTE)
43 pingedDict = Experiment.startPctPings(ndn.net, args.nPings, args.pctTraffic)
44
45 PING_COLLECTION_TIME_BEFORE_FAILURE = 60
46 PING_COLLECTION_TIME_AFTER_RECOVERY = 120
47
48 time.sleep(PING_COLLECTION_TIME_BEFORE_FAILURE)
49
50 mcn = max(ndn.net.hosts, key=lambda host: len(host.intfNames()))
51
52 info('Bringing down node {}\n'.format(mcn.name))
53 nlsrs[mcn.name].stop()
54 nfds[mcn.name].stop()
55
56 time.sleep(args.ctime)
57
58 info('Bringing up node {}\n'.format(mcn.name))
59 nfds[mcn.name].start()
60 nlsrs[mcn.name].start()
61
62 # Restart pings
63 if args.nPings != 0:
64 Experiment.setupPing([mcn], Nfdc.STRATEGY_BEST_ROUTE)
65 for nodeToPing in pingedDict[mcn]:
dulalsaurab578f2ec2021-06-10 20:55:26 +000066 NDNPing.ping(mcn, nodeToPing, nPings=PING_COLLECTION_TIME_AFTER_RECOVERY)
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050067
68 time.sleep(PING_COLLECTION_TIME_AFTER_RECOVERY)
69
70 Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
71
72if __name__ == '__main__':
73 setLogLevel('info')
74
75 ndn = Minindn(parser=getParser())
76 args = ndn.args
77
78 ndn.start()
79
80 nfds = AppManager(ndn, ndn.net.hosts, Nfd)
81 nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
82 security=args.security, faceType=args.faceType,
83 nFaces=args.faces, routingType=args.routingType)
84
85 mcnFailure(ndn, nfds, nlsrs, args)
86
87 if args.isCliEnabled:
88 MiniNDNCLI(ndn.net)
89
90 ndn.stop()