Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 1 | # -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | # |
dulalsaurab | 2085544 | 2021-05-21 20:37:03 +0000 | [diff] [blame] | 3 | # Copyright (C) 2015-2021, The University of Memphis, |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 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 | |
| 24 | from mininet.log import setLogLevel, info |
| 25 | from minindn.wifi.minindnwifi import MinindnWifi |
dulalsaurab | 2085544 | 2021-05-21 20:37:03 +0000 | [diff] [blame] | 26 | from minindn.util import MiniNDNWifiCLI |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 27 | from minindn.apps.app_manager import AppManager |
| 28 | from minindn.apps.nfd import Nfd |
| 29 | from minindn.helpers.nfdc import Nfdc |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame] | 30 | from minindn.helpers.ndnping import NDNPing |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 31 | from 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. |
| 34 | def 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) |
dulalsaurab | 2085544 | 2021-05-21 20:37:03 +0000 | [diff] [blame] | 64 | AppManager(ndnwifi, ndnwifi.net.stations, Nfd) |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 65 | |
| 66 | info("Starting pingserver...") |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame] | 67 | NDNPing.startPingServer(b, "/example") |
Alex Lane | 1d3c0a8 | 2021-07-22 17:28:16 -0500 | [diff] [blame^] | 68 | faceID = Nfdc.createFace(a, b.IP()) |
| 69 | Nfdc.registerRoute(a, "/example", faceID) |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 70 | |
| 71 | info("Starting ping...") |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame] | 72 | NDNPing.ping(a, "/example", nPings=10) |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 73 | |
dulalsaurab | 578f2ec | 2021-06-10 20:55:26 +0000 | [diff] [blame] | 74 | sleep(10) |
Alexander Lane | ea2d5d6 | 2019-10-04 16:48:52 -0500 | [diff] [blame] | 75 | # Start the CLI |
| 76 | MiniNDNWifiCLI(ndnwifi.net) |
| 77 | ndnwifi.net.stop() |
| 78 | ndnwifi.cleanUp() |
| 79 | |
| 80 | if __name__ == '__main__': |
| 81 | try: |
| 82 | runExperiment() |
| 83 | except Exception as e: |
| 84 | MinindnWifi.handleException() |