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