blob: e27c74f8d5e257de88e5eb0f545d7286f9ee34c2 [file] [log] [blame]
Ashlesh Gawande6c86e302019-09-17 22:27:05 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
dulalsaurab20855442021-05-21 20:37:03 +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
dulalsaurab20855442021-05-21 20:37:03 +000025import sys
Ashlesh Gawande6c86e302019-09-17 22:27:05 -050026
27from mininet.log import setLogLevel, info
28
29from minindn.minindn import Minindn
30from minindn.util import MiniNDNCLI
31from minindn.apps.app_manager import AppManager
32from minindn.apps.nfd import Nfd
33from minindn.apps.nlsr import Nlsr
34from minindn.helpers.experiment import Experiment
35
36from nlsr_common import getParser
37
38if __name__ == '__main__':
39 setLogLevel('info')
40
41 ndn = Minindn(parser=getParser())
42 args = ndn.args
43
44 ndn.start()
45
46 nfds = AppManager(ndn, ndn.net.hosts, Nfd)
47 nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr, sync=args.sync,
48 security=args.security, faceType=args.faceType,
49 nFaces=args.faces, routingType=args.routingType)
50
51 Experiment.checkConvergence(ndn, ndn.net.hosts, args.ctime, quit=True)
52
53 firstNode = ndn.net.hosts[0]
54
55 if args.security:
56 firstNode.cmd('ndnsec-set-default /ndn/{}-site/%C1.Operator/op'.format(firstNode.name))
57
58 info('Testing advertise\n')
59 firstNode.cmd('nlsrc advertise /testPrefix')
60 time.sleep(30)
61
62 for host in ndn.net.hosts:
63 if host.name != firstNode.name:
64 if (int(host.cmd('nfdc fib | grep testPrefix | wc -l')) != 1 or
65 int(host.cmd('nlsrc status | grep testPrefix | wc -l')) != 1):
66 info('Advertise test failed\n')
67 ndn.stop()
68 sys.exit(1)
69
70 info('Testing withdraw\n')
71 firstNode.cmd('nlsrc withdraw /testPrefix')
72 time.sleep(30)
73
74 for host in ndn.net.hosts:
75 if host.name != firstNode.name:
76 if (int(host.cmd('nfdc fib | grep testPrefix | wc -l')) != 0 or
77 int(host.cmd('nlsrc status | grep testPrefix | wc -l')) != 0):
78 info('Withdraw test failed\n')
79 ndn.stop()
80 sys.exit(1)
81
82 if args.isCliEnabled:
83 MiniNDNCLI(ndn.net)
84
85 ndn.stop()