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