Ashlesh Gawande | 6c86e30 | 2019-09-17 22:27:05 -0500 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
| 3 | # Copyright (C) 2015-2019, The University of Memphis, |
| 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 | import sys |
| 26 | |
| 27 | from mininet.log import setLogLevel, info |
| 28 | from mininet.topo import Topo |
| 29 | |
| 30 | from minindn.minindn import Minindn |
| 31 | from minindn.apps.app_manager import AppManager |
| 32 | from minindn.apps.nfd import Nfd |
| 33 | from minindn.apps.nlsr import Nlsr |
| 34 | |
| 35 | from nlsr_common import getParser |
| 36 | |
| 37 | if __name__ == '__main__': |
| 38 | setLogLevel('info') |
| 39 | |
| 40 | topo = Topo() |
| 41 | h1 = topo.addHost('h1') |
| 42 | h2 = topo.addHost('h2') |
| 43 | topo.addLink(h1, h2, delay='10ms') |
| 44 | |
| 45 | ndn = Minindn(parser=getParser(), topo=topo) |
| 46 | args = ndn.args |
| 47 | |
| 48 | ndn.start() |
| 49 | |
| 50 | nfds = AppManager(ndn, ndn.net.hosts, Nfd) |
| 51 | nlsrs = AppManager(ndn, [], Nlsr) |
| 52 | |
| 53 | host1 = ndn.net.hosts[0] |
| 54 | nlsrs.startOnNode(host1, security=args.security, faceType=args.faceType, |
| 55 | nFaces=args.faces, routingType=args.routingType) |
| 56 | |
| 57 | |
| 58 | expectedTotalCount = 500 |
| 59 | for i in range(0, expectedTotalCount): |
| 60 | host1.cmd('nlsrc advertise /long/name/to/exceed/max/packet/size/host1/{}'.format(i)) |
| 61 | |
| 62 | time.sleep(60) |
| 63 | |
| 64 | host2 = ndn.net.hosts[1] |
| 65 | nlsrs.startOnNode(host2, security=args.security, faceType=args.faceType, |
| 66 | nFaces=args.faces, routingType=args.routingType) |
| 67 | |
| 68 | time.sleep(60) |
| 69 | |
| 70 | advertiseCount = int(host2.cmd('nfdc fib | grep host1 | wc -l')) |
| 71 | info(advertiseCount) |
| 72 | if advertiseCount == expectedTotalCount: |
| 73 | info('\nSuccessfully advertised {} prefixes\n'.format(expectedTotalCount)) |
| 74 | else: |
| 75 | info('\nAdvertising {} prefixes failed. Exiting...\n'.format(expectedTotalCount)) |
| 76 | ndn.stop() |
| 77 | sys.exit(1) |
| 78 | |
| 79 | ndn.stop() |