blob: 16fd62d5b9c0a3c099b9c8d9083f06f3c613bcb9 [file] [log] [blame]
Alexander Laneea2d5d62019-10-04 16:48:52 -05001# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
2#
dulalsaurab20855442021-05-21 20:37:03 +00003# Copyright (C) 2015-2021, The University of Memphis,
Alexander Laneea2d5d62019-10-04 16:48:52 -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
24from mininet.log import setLogLevel, info
25from minindn.wifi.minindnwifi import MinindnWifi
dulalsaurab20855442021-05-21 20:37:03 +000026from minindn.util import MiniNDNWifiCLI
Alexander Laneea2d5d62019-10-04 16:48:52 -050027from minindn.apps.app_manager import AppManager
28from minindn.apps.nfd import Nfd
29from minindn.helpers.nfdc import Nfdc
dulalsaurab578f2ec2021-06-10 20:55:26 +000030from minindn.helpers.ndnping import NDNPing
Alexander Laneea2d5d62019-10-04 16:48:52 -050031from 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")
38 ndnwifi = MinindnWifi()
39 a = ndnwifi.net["sta1"]
40 b = ndnwifi.net["sta2"]
41 # Test for model-based mobility
42 if ndnwifi.args.modelMob:
43 ndnwifi.startMobilityModel(model='GaussMarkov')
44 #Test for replay based mobility
45 if ndnwifi.args.mobility:
46 info("Running with mobility...")
47
48 p1, p2, p3, p4 = dict(), dict(), dict(), dict()
49 p1 = {'position': '40.0,30.0,0.0'}
50 p2 = {'position': '40.0,40.0,0.0'}
51 p3 = {'position': '31.0,10.0,0.0'}
52 p4 = {'position': '200.0,200.0,0.0'}
53
54 ndnwifi.net.mobility(a, 'start', time=1, **p1)
55 ndnwifi.net.mobility(b, 'start', time=2, **p2)
56 ndnwifi.net.mobility(a, 'stop', time=12, **p3)
57 ndnwifi.net.mobility(b, 'stop', time=22, **p4)
58 ndnwifi.net.stopMobility(time=23)
59 ndnwifi.startMobility(time=0, mob_rep=1, reverse=False)
60
61 ndnwifi.start()
62 info("Starting NFD")
63 sleep(2)
dulalsaurab20855442021-05-21 20:37:03 +000064 AppManager(ndnwifi, ndnwifi.net.stations, Nfd)
Alexander Laneea2d5d62019-10-04 16:48:52 -050065
66 info("Starting pingserver...")
dulalsaurab578f2ec2021-06-10 20:55:26 +000067 NDNPing.startPingServer(b, "/example")
Alex Lane1d3c0a82021-07-22 17:28:16 -050068 faceID = Nfdc.createFace(a, b.IP())
69 Nfdc.registerRoute(a, "/example", faceID)
Alexander Laneea2d5d62019-10-04 16:48:52 -050070
71 info("Starting ping...")
dulalsaurab578f2ec2021-06-10 20:55:26 +000072 NDNPing.ping(a, "/example", nPings=10)
Alexander Laneea2d5d62019-10-04 16:48:52 -050073
dulalsaurab578f2ec2021-06-10 20:55:26 +000074 sleep(10)
Alexander Laneea2d5d62019-10-04 16:48:52 -050075 # Start the CLI
76 MiniNDNWifiCLI(ndnwifi.net)
77 ndnwifi.net.stop()
78 ndnwifi.cleanUp()
79
80if __name__ == '__main__':
81 try:
82 runExperiment()
83 except Exception as e:
84 MinindnWifi.handleException()