blob: e995c509d166f9b2a73abb677eae78f5f014571e [file] [log] [blame]
Ashlesh Gawande27b5e1b2018-08-06 17:47:15 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
3# Copyright (C) 2015-2018, 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
24from ndn.experiments.experiment import Experiment
25from ndn.apps.nlsr import Nlsr, NlsrConfigGenerator
26
27from mininet.log import info
28
29import time
30
31class NlsrDelayedStartExperiment(Experiment):
32
33 def __init__(self, args):
34 Experiment.__init__(self, args)
35
36 def setup(self):
37 pass
38
39 def run(self):
40 pass
41
42 def startNlsr(self, checkConvergence = True):
43 # NLSR Security
44 if self.options.nlsrSecurity is True:
45 Nlsr.createKeysAndCertificates(self.net, self.options.workDir)
46
47 i = 1
48 # NLSR initialization
49 info('Starting NLSR on nodes\n')
50 for host in self.net.hosts:
51 host.nlsr = Nlsr(host, self.options)
52 host.nlsr.start()
53
54 # Wait 1/2 minute between starting NLSRs
55 # Wait 1 hour before starting last NLSR
56 if i == len(self.net.hosts) - 1:
57 info('Sleeping 1 hour before starting last NLSR')
58 time.sleep(3600)
59 else:
60 time.sleep(30)
61 i += 1
62
63 if checkConvergence:
64 self.checkConvergence()
65
66Experiment.register("nlsr-delayed-start", NlsrDelayedStartExperiment)