blob: 4fe7deee041b911d3fe4678a12d9a2337677f8f9 [file] [log] [blame]
Ashlesh Gawande6a075c22017-08-03 15:15:49 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
3# Copyright (C) 2015-2017, 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 sys
25import time
26from ndn.experiments.experiment import Experiment
27
28class PrefixPropogationExperiment(Experiment):
29
30 def __init__(self, args):
31 Experiment.__init__(self, args)
32
33 def setup(self):
34 self.checkConvergence()
35
36 def run(self):
37 firstNode = self.net.hosts[0]
38
39 if self.nlsrSecurity:
40 firstNode.cmd("ndnsec-set-default /ndn/{}-site/%C1.Operator/op".format(firstNode.name))
41
42 print("Testing advertise")
43 firstNode.cmd("nlsrc advertise /testPrefix")
44 time.sleep(30)
45
46 for host in self.net.hosts:
47 if host.name != firstNode.name:
48 if (int(host.cmd("nfdc fib | grep testPrefix | wc -l")) != 1 or
49 int(host.cmd("nlsrc status | grep testPrefix | wc -l")) != 1):
50 print("Advertise test failed")
51 self.net.stop()
52 sys.exit(1)
53
54 print("Testing withdraw")
55 firstNode.cmd("nlsrc withdraw /testPrefix")
56 time.sleep(30)
57
58 for host in self.net.hosts:
59 if host.name != firstNode.name:
60 if (int(host.cmd("nfdc fib | grep testPrefix | wc -l")) != 0 or
61 int(host.cmd("nlsrc status | grep testPrefix | wc -l")) != 0):
62 print("Withdraw test failed")
63 self.net.stop()
64 sys.exit(1)
65
66Experiment.register("prefix-propogation", PrefixPropogationExperiment)