Add MiniNDN utility application for PCAP logging

Change-Id: I4f8ee5b6b970c7b74e3697af4a08b72d2169dc2a
This commit is contained in:
Philipp Moll committed 2020-03-05 21:47:42 -08:00
1 parent 52223f7144
commit 55e2dd9087
3 files changed
+115 -2

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
# Copyright (C) 2015-2020, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
# This file is part of Mini-NDN.
# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
#
# Mini-NDN is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mini-NDN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mini-NDN, e.g., in COPYING.md file.
# If not, see <http://www.gnu.org/licenses/>.
from mininet.log import setLogLevel, info
from minindn.minindn import Minindn
from minindn.apps.app_manager import AppManager
from minindn.util import MiniNDNCLI
from minindn.apps.nfd import Nfd
from minindn.apps.nlsr import Nlsr
from minindn.apps.tshark import Tshark
if __name__ == '__main__':
setLogLevel('info')
Minindn.cleanUp()
Minindn.verifyDependencies()
ndn = Minindn()
ndn.start()
info('Starting tshark logging on nodes\n')
tshark = AppManager(ndn, ndn.net.hosts, Tshark, logFolder="./log/", singleLogFile=False)
info('Starting NFD on nodes\n')
nfds = AppManager(ndn, ndn.net.hosts, Nfd)
info('Starting NLSR on nodes\n')
nlsrs = AppManager(ndn, ndn.net.hosts, Nlsr)
MiniNDNCLI(ndn.net)
ndn.stop()
+2 -2
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# -*- Mode:bash; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
# Copyright (C) 2015-2019, The University of Memphis,
# Copyright (C) 2015-2020, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
@@ -191,7 +191,7 @@ function infoedit {
}
function minindn {
$install libigraph0-dev
$install libigraph0-dev tshark
sudo pip install -r requirements.txt
if [[ updated != true ]]; then
+60
View File
@@ -0,0 +1,60 @@
# -*- Mode:python; c-file-style:"gnu"; indent-tabs-mode:nil -*- */
#
# Copyright (C) 2015-2020, The University of Memphis,
# Arizona Board of Regents,
# Regents of the University of California.
#
# This file is part of Mini-NDN.
# See AUTHORS.md for a complete list of Mini-NDN authors and contributors.
#
# Mini-NDN is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Mini-NDN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Mini-NDN, e.g., in COPYING.md file.
# If not, see <http://www.gnu.org/licenses/>.
from minindn.apps.application import Application
from mininet.log import debug
class Tshark(Application):
"""
Logging utility to dump network traffic of a node to a PCAP file.
The app is based on the command line tool tshark and requires tshark to be installed on the system.
"""
def __init__(self, node, logFolder="./", singleLogFile=False):
"""
:param logFolder Folder, where PCAP files are stored.
:param singleLogFile Single PCAP file per node, or individual PCAP for each interface
"""
Application.__init__(self, node)
self.logFolder = logFolder
self.singleLogFile = singleLogFile
# Create logfile folder in case it does not exist
node.cmd('mkdir -p {}'.format(self.logFolder))
def start(self):
# Start capturing traffic with Tshark.
debug("[{0}] Starting tshark logging\n".format(self.node.name))
if self.singleLogFile:
interfaces = ["-i " + intf for intf in self.node.intfNames()]
ndnDumpOutputFile = "{}/{}-interfaces.pcap".format(self.logFolder, self.node.name)
self.node.cmd("tshark {} -w {} -q &".format(" ".join(interfaces), ndnDumpOutputFile))
else:
for intf in self.node.intfNames():
ndnDumpOutputFile = "{}/{}.pcap".format(self.logFolder, intf)
self.node.cmd("tshark -i {} -w {} -q &".format(intf, ndnDumpOutputFile))