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:
parent
8c4931819b
commit
866e13e0ef
3 changed files with 25 additions and 30 deletions
|
@ -15,18 +15,18 @@ def parse(name):
|
|||
help="number of nodes to create in this example",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-t",
|
||||
"--time",
|
||||
"-c",
|
||||
"--count",
|
||||
type=int,
|
||||
default=DEFAULT_TIME,
|
||||
help="example iperf run time in seconds",
|
||||
help="number of time to ping node",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.nodes < 2:
|
||||
parser.error(f"invalid min number of nodes: {args.nodes}")
|
||||
if args.time < 1:
|
||||
parser.error(f"invalid test time: {args.time}")
|
||||
if args.count < 1:
|
||||
parser.error(f"invalid ping count({args.count}), count must be greater than 0")
|
||||
|
||||
return args
|
|
@ -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__":
|
||||
|
|
|
@ -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, NodeOptions
|
||||
from core.emulator.enumerations import EventTypes, NodeTypes
|
||||
|
@ -37,14 +37,10 @@ def example(args):
|
|||
# get nodes for example run
|
||||
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")
|
||||
address = prefixes.ip4_address(first_node)
|
||||
logging.info("node %s connecting to %s", last_node.name, address)
|
||||
output = last_node.cmd(f"iperf -t {args.time} -c {address}")
|
||||
logging.info("node %s pinging %s", last_node.name, address)
|
||||
output = last_node.cmd(f"ping -c {args.count} {address}")
|
||||
logging.info(output)
|
||||
first_node.cmd("killall -9 iperf")
|
||||
|
||||
# shutdown session
|
||||
coreemu.shutdown()
|
||||
|
@ -52,12 +48,13 @@ def example(args):
|
|||
|
||||
def main():
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
args = parser.parse("wlan")
|
||||
|
||||
start = datetime.datetime.now()
|
||||
logging.info("running wlan example: nodes(%s) time(%s)", args.nodes, args.time)
|
||||
args = params.parse("wlan")
|
||||
start = time.perf_counter()
|
||||
logging.info(
|
||||
"running wlan 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__":
|
||||
|
|
Loading…
Add table
Reference in a new issue