blob: 4d52c83a925bbd9e734a7f6ea0b05306451733fc [file] [log] [blame]
matianxing1992b95d1942025-01-28 15:04:02 -06001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
3# Copyright (C) 2015-2025, 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 time import sleep
25from mininet.log import setLogLevel, info
26from minindn.wifi.minindnwifi import MinindnAdhoc
27from minindn.util import MiniNDNWifiCLI
28from minindn.apps.app_manager import AppManager
29from minindn.apps.nfd import Nfd
30from minindn.apps.gpsd import Gpsd
31# This experiment uses the topology defined in adhoc-topology.conf and
32# is intended to test whether app Gpsd can work with Mini-NDN.
33def runExperiment():
34 setLogLevel('info')
35
36 info("Starting network\n")
37 ndnwifi = MinindnAdhoc()
38 a = ndnwifi.net["sta1"]
39 b = ndnwifi.net["sta2"]
40
41 ndnwifi.start()
42
43 info("Starting gpsd\n")
44
45 AppManager(ndnwifi, ndnwifi.net.stations, Gpsd, lat=35.11908, lon=-89.93778, altitude=200, update_interval=0.2)
46
47 info("Starting NFD\n")
48 AppManager(ndnwifi, ndnwifi.net.stations, Nfd)
49
50 sleep(1)
51
52 # run cgps in the Xterm terminal to check gps info
53 for node in [a,b]:
54 node.cmd(f"xterm -T '{node.name}' -e 'cgps' &")
55
56 # Start the CLI
57 MiniNDNWifiCLI(ndnwifi.net)
58
59 # Stop the network and clean up
60 ndnwifi.stop()
61 ndnwifi.cleanUp()
62
63if __name__ == '__main__':
64 try:
65 runExperiment()
66 except Exception as e:
67 MinindnAdhoc.handleException()