removed old examples, updated examples api to denote they are python script examples
This commit is contained in:
parent
319c10aa34
commit
41f7f46988
12 changed files with 1 additions and 1342 deletions
41
daemon/examples/python/switch_inject.py
Normal file
41
daemon/examples/python/switch_inject.py
Normal file
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/python
|
||||
#
|
||||
# run iperf to measure the effective throughput between two nodes when
|
||||
# n nodes are connected to a virtual wlan; run test for testsec
|
||||
# and repeat for minnodes <= n <= maxnodes with a step size of
|
||||
# nodestep
|
||||
from builtins import range
|
||||
|
||||
from core.emulator.emudata import IpPrefixes
|
||||
from core.emulator.enumerations import EventTypes, NodeTypes
|
||||
from core.utils import load_logging_config
|
||||
|
||||
load_logging_config()
|
||||
|
||||
|
||||
def example(nodes):
|
||||
# ip generator for example
|
||||
prefixes = IpPrefixes("10.83.0.0/16")
|
||||
|
||||
# create emulator instance for creating sessions and utility methods
|
||||
coreemu = globals()["coreemu"]
|
||||
session = coreemu.create_session()
|
||||
|
||||
# must be in configuration state for nodes to start, when using "node_add" below
|
||||
session.set_state(EventTypes.CONFIGURATION_STATE)
|
||||
|
||||
# create switch network node
|
||||
switch = session.add_node(_type=NodeTypes.SWITCH)
|
||||
|
||||
# create nodes
|
||||
for _ in range(nodes):
|
||||
node = session.add_node()
|
||||
interface = prefixes.create_interface(node)
|
||||
session.add_link(node.id, switch.id, interface_one=interface)
|
||||
|
||||
# instantiate session
|
||||
session.instantiate()
|
||||
|
||||
|
||||
if __name__ in {"__main__", "__builtin__"}:
|
||||
example(2)
|
Loading…
Add table
Add a link
Reference in a new issue