Ashlesh Gawande | 6c86e30 | 2019-09-17 22:27:05 -0500 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame^] | 3 | # Copyright (C) 2015-2021, The University of Memphis, |
Ashlesh Gawande | 6c86e30 | 2019-09-17 22:27:05 -0500 | [diff] [blame] | 4 | # 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 | |
| 24 | import time |
| 25 | |
| 26 | from mininet.log import setLogLevel, info |
| 27 | |
| 28 | from minindn.minindn import Minindn |
| 29 | from minindn.util import MiniNDNCLI |
| 30 | from minindn.apps.app_manager import AppManager |
| 31 | from minindn.apps.nfd import Nfd |
| 32 | from minindn.apps.nlsr import Nlsr |
| 33 | from minindn.helpers.experiment import Experiment |
| 34 | from minindn.helpers.nfdc import Nfdc |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame^] | 35 | from minindn.helpers.ndnping import NDNPing |
Ashlesh Gawande | 6c86e30 | 2019-09-17 22:27:05 -0500 | [diff] [blame] | 36 | |
| 37 | from nlsr_common import getParser |
| 38 | |
| 39 | def 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]: |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame^] | 66 | NDNPing.ping(mcn, nodeToPing, nPings=PING_COLLECTION_TIME_AFTER_RECOVERY) |
Ashlesh Gawande | 6c86e30 | 2019-09-17 22:27:05 -0500 | [diff] [blame] | 67 | |
| 68 | time.sleep(PING_COLLECTION_TIME_AFTER_RECOVERY) |
| 69 | |
| 70 | Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True) |
| 71 | |
| 72 | if __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() |