removed usage of iperf in examples, to remove need of another dependency, renamed parser module examples used to avoid conflict with std library module

This commit is contained in:
Blake Harnden 2020-02-04 09:48:37 -08:00
parent 8c4931819b
commit 866e13e0ef
3 changed files with 25 additions and 30 deletions

View file

@ -1,7 +1,7 @@
import datetime
import logging
import parser
import time
import params
from core.emulator.coreemu import CoreEmu
from core.emulator.emudata import IpPrefixes
from core.emulator.enumerations import EventTypes, NodeTypes
@ -33,14 +33,10 @@ def example(args):
# get nodes to run example
first_node = session.get_node(2)
last_node = session.get_node(args.nodes + 1)
logging.info("starting iperf server on node: %s", first_node.name)
first_node.cmd("iperf -s -D")
first_node_address = prefixes.ip4_address(first_node)
logging.info("node %s connecting to %s", last_node.name, first_node_address)
output = last_node.cmd(f"iperf -t {args.time} -c {first_node_address}")
logging.info("node %s pinging %s", last_node.name, first_node_address)
output = last_node.cmd(f"ping -c {args.count} {first_node_address}")
logging.info(output)
first_node.cmd("killall -9 iperf")
# shutdown session
coreemu.shutdown()
@ -48,11 +44,13 @@ def example(args):
def main():
logging.basicConfig(level=logging.INFO)
args = parser.parse("switch")
start = datetime.datetime.now()
logging.info("running switch example: nodes(%s) time(%s)", args.nodes, args.time)
args = params.parse("switch")
start = time.perf_counter()
logging.info(
"running switch example: nodes(%s) ping count(%s)", args.nodes, args.count
)
example(args)
logging.info("elapsed time: %s", datetime.datetime.now() - start)
logging.info("elapsed time: %s", time.perf_counter() - start)
if __name__ == "__main__":