blob: 9b37281c2f5ad3c5ea63a3ccfd04907facf33276 [file] [log] [blame]
Ashlesh Gawande6651a742019-01-03 18:13:06 -06001# -*- 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
24from ndn.experiments.experiment import Experiment
25from ndn.apps.nfdc import Nfdc
26
27import time
28import sys
29
30class PSyncPartial(Experiment):
31
32 def __init__(self, args):
33 Experiment.__init__(self, args)
34
35 def start(self):
36 host1 = self.net.hosts[0]
37
38 host1.cmd("export NDN_LOG=examples.PartialSyncProducerApp=INFO")
39 host1.cmd("psync-producer /sync /{} 10 1 &> producer.log &".format(host1.name))
40 time.sleep(1)
41
42 host1.cmd("export NDN_LOG=examples.PartialSyncConsumerApp=INFO:$NDN_LOG")
43 host1.cmd("psync-consumer /sync 5 &> consumer.log &")
44
45 print("Sleeping 90 seconds for convergence")
46 time.sleep(90)
47
48 consumerSubs = int(host1.cmd("cat consumer.log | grep -c Subscribing"))
49 consumerUpdates = int(host1.cmd("cat consumer.log | grep -c Update"))
50 producerPublish = int(host1.cmd("cat producer.log | grep -c Publish"))
51
52 if consumerSubs == 5 and consumerUpdates == 5 and producerPublish == 10:
53 print("PSync partial sync has successfully converged.")
54 else:
55 print("PSync partial sync convergence was not successful. Exiting...")
56 self.net.stop()
57 sys.exit(1)
58
59Experiment.register("psync-partial", PSyncPartial)