Merge pull request #25 from logos-co/Issue-#20

Adds simulation command line arguments(Issue-#20)
This commit is contained in:
Daimakaimura 2023-01-04 09:26:18 +00:00 committed by GitHub
commit 2d5d4ed2f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 14 deletions

View File

@ -23,6 +23,10 @@ If you want to run it with default arguments, if you are in the root of this rep
There are arguments that can be modified:
- _same_toml_configuration_: boolean. Default: **true**. If **true**, the some `.toml` file will be applied to every Waku node. If **false*, every node will use its own `.toml` file.
- _topology_file_: string. Default: **waku_test_topology_small.json**. If defines the network topology that will be created.
- _simulation_time_: int. Default: **300**. Specifies the simulation time in seconds.
- _message_rate_: int. Default: **25**. Specifies the message rate in packets per second.
- _min_packet_size_: int. Default: **1**. Specifies the minimum size of the packet in bytes.
- _max_packet_size_: int. Default: **1024**. Specifies the maximum size of the packet in bytes.
Example modifying arguments:

View File

@ -31,4 +31,8 @@ def run(args):
# waku.get_waku_peers(waku_topology.keys()[1])
# Setup WSL & Start the Simulation
wsl_service = wsl.set_up_wsl(waku_services)
simulation_time = args.simulation_time
message_rate = args.message_rate
min_packet_size = args.min_packet_size
max_packet_size = args.max_packet_size
wsl_service = wsl.set_up_wsl(waku_services, simulation_time, message_rate, min_packet_size, max_packet_size)

View File

@ -3,13 +3,41 @@ system_variables = import_module("github.com/logos-co/wakurtosis/src/system_vari
def apply_default_to_input_args(input_args):
same_config = system_variables.SAME_TOML_CONFIGURATION
topology_file = system_variables.DEFAULT_TOPOLOGY_FILE
same_config = system_variables.SAME_TOML_CONFIGURATION
if hasattr(input_args, system_variables.SAME_TOML_CONFIGURATION_NAME):
same_config = input_args.same_toml_configuration
topology_file = system_variables.DEFAULT_TOPOLOGY_FILE
if hasattr(input_args, system_variables.TOPOLOGY_FILE_NAME):
topology_file = input_args.topology
return struct(same_toml_configuration=same_config, topology_file=topology_file)
simulation_time = system_variables.SIMULATION_TIME
if hasattr(input_args, "simulation_time"):
simulation_time = int(input_args.simulation_time)
print("Got simulation time: %ds." %simulation_time)
else:
print("Got default simulation time: %ds." %simulation_time)
message_rate = system_variables.MESSAGE_RATE
if hasattr(input_args, "message_rate"):
message_rate = int(input_args.message_rate)
print("Got message rate: %d pps" %message_rate)
else:
print("Got default message rate: %d packets per second" %message_rate)
min_packet_size = system_variables.MIN_PACKET_SIZE
if hasattr(input_args, "min_packet_size"):
min_packet_size = int(input_args.min_packet_size)
print("Got min. packet size of: %d bytes" %min_packet_size)
else:
print("Got default min. packet size of: %d bytes" %min_packet_size)
max_packet_size = system_variables.MAX_PACKET_SIZE
if hasattr(input_args, "max_packet_size"):
max_packet_size = int(input_args.max_packet_size)
print("Got max. packet size of: %d bytes" %max_packet_size)
else:
print("Got default max. packet size of: %d bytes" %max_packet_size)
return struct(same_toml_configuration=same_config, topology_file=topology_file, simulation_time=simulation_time, message_rate=message_rate, min_packet_size=min_packet_size, max_packet_size=max_packet_size)

View File

@ -56,3 +56,10 @@ DEFAULT_TOPOLOGY_FILE = "waku_test_topology_small.json"
NUMBER_TEST_MESSAGES = 50
DELAY_BETWEEN_TEST_MESSAGE = "0.5"
# Default Simulation Parameters
SIMULATION_TIME = 300
MESSAGE_RATE = 25
MIN_PACKET_SIZE = 1
MAX_PACKET_SIZE = 1024

View File

@ -4,9 +4,9 @@ system_variables = import_module("github.com/logos-co/wakurtosis/src/system_vari
# Module Imports
files = import_module(system_variables.FILE_HELPERS_MODULE)
def create_wsl_config():
def create_wsl_config(simulation_time=300, message_rate=50, min_packet_size=1, max_packet_size=1024):
template_data = None
template_data = {"simulation_time": simulation_time, "message_rate" : message_rate, "min_packet_size" : min_packet_size, "max_packet_size" : max_packet_size}
# Traffic simulation parameters
wsl_yml_template = """
@ -19,14 +19,14 @@ def create_wsl_config():
prng_seed : 0
# Simulation time in seconds
simulation_time : 1000
simulation_time : {{.simulation_time}}
# Message rate in messages per second
msg_rate : 10
msg_rate : {{.message_rate}}
# Packet size in bytes
min_packet_size : 2
max_packet_size : 1024
min_packet_size : {{.min_packet_size}}
max_packet_size : {{.max_packet_size}}
"""
artifact_id = render_templates(
@ -61,10 +61,10 @@ def create_wsl_targets(services):
return artifact_id
def set_up_wsl(services):
def set_up_wsl(services, simulation_time, message_rate, min_packet_size, max_packet_size):
# Generate simulation config
wsl_config = create_wsl_config()
wsl_config = create_wsl_config(simulation_time, message_rate, min_packet_size, max_packet_size)
# Create targets.json
wsl_targets = create_wsl_targets(services)