blob: de5918e1d76b4528648381b01102427412935839 [file] [log] [blame]
matianxing19921f07a832024-09-25 12:32:38 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
matianxing1992b95d1942025-01-28 15:04:02 -06003# Copyright (C) 2015-2025, The University of Memphis,
matianxing19921f07a832024-09-25 12:32:38 -05004# 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
matianxing1992b95d1942025-01-28 15:04:02 -060024from time import sleep
matianxing19921f07a832024-09-25 12:32:38 -050025from 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.helpers.nfdc import Nfdc
31from minindn.helpers.ndnping import NDNPing
matianxing1992b95d1942025-01-28 15:04:02 -060032
33# This experiment uses the topology defined in adhoc-topology.conf and is intended to be a basic
matianxing19921f07a832024-09-25 12:32:38 -050034# test case where we see if two nodes can send interests to each other.
35def runExperiment():
36 setLogLevel('info')
37
38 info("Starting network\n")
39 ndnwifi = MinindnAdhoc()
40 a = ndnwifi.net["sta1"]
41 b = ndnwifi.net["sta2"]
42
43 ndnwifi.start()
44
45
46 info("Starting NFD\n")
47 AppManager(ndnwifi, ndnwifi.net.stations, Nfd)
48
49 info("Starting pingserver...\n")
50 NDNPing.startPingServer(b, "/example")
51
52 # multicast face for wireless communication
53 multicastFaceId = Nfdc.getFaceId(a, "[01:00:5e:00:17:aa]", None, "ether", 6363)
54 # print(multicastFaceId)
55 Nfdc.registerRoute(a, "/example", multicastFaceId, 100)
56
57 info("Starting ping...\n")
58 NDNPing.ping(a, "/example", nPings=10)
59
60 sleep(10)
61
62 # Start the CLI
63 MiniNDNWifiCLI(ndnwifi.net)
matianxing1992b95d1942025-01-28 15:04:02 -060064 ndnwifi.stop()
matianxing19921f07a832024-09-25 12:32:38 -050065 ndnwifi.cleanUp()
66
67if __name__ == '__main__':
68 try:
69 runExperiment()
70 except Exception as e:
71 MinindnAdhoc.handleException()