blackwidow package

Submodules

blackwidow.blackwidow module

class blackwidow.blackwidow.BlackWidow(settings={})[source]

Bases: object

Runs simulation based on settings.

Generalizes Python’s print to adapt to custom settings, and direct different types of messages to different outputs including files, or functions that dynamically generate graphs.

Parameters:

settings : dict

Contains settings to initialize the printer. Values include:
real_time : bool

Whether to graph in real time or write to files.

show_verbose : bool

Whether to print statements labelled verbose.

log_file : str

Name of file to write to. This is the prefix for all data types written to files. See documentation for write for more information.

data_dir : str

Directory where the data is stored.

static_routing : bool

Whether to use static routing.

routing_packet_size : int

Size of routing packets.

tcp_alg : str

Which TCP algorithm to use. Must be ‘Reno’, ‘Fast’, or ‘Tahoe’.

Methods

run(file_name) Runs the overall simulation based on settings specified when the BlackWidow object is constructed.
print_verbose(msg) Handles a verbose message based on specified settings.
record(data, data_type) Records data based on specified settings.
Examples  
   
>>> from blackwidow import BlackWidow
 
>>> settings = {'filename': 'case0.json' ... }
 
>>> bw = BlackWidow(settings)
 
>>> bw.run()
 
print_verbose(msg)[source]

Handles a verbose message based on specified settings.

Parameters:

msg : str

Message to show.

record(data, data_type)[source]

Records data based on specified settings.

Parameters:

data : str

Data point to record/plot.

data_type : str

Type of data, will be used as a file extension.

Notes

Standard data types:
link.drop - “Time in ms”, “Number of drops” link.sent - “Time in ms”, “Number of packets sent” flow.window - “Time in ms”, “Window size” flow.sent - “Time in ms”, “Mega bits” flow.delay - “Time in ms”, “Delay in ms”
run(file_name)[source]

Runs the overall simulation based on settings specified when the BlackWidow object is constructed.

Parameters:

file_name : string

Name of config file containing network.

Returns:

sim_time : float

The amount of time taken for the network to finish running.

run_network(network)[source]

Runs the overall simulation based on settings specified when the BlackWidow object is constructed.

Parameters:

network : Network

The network to run.

Returns:

sim_time : float

The amount of time taken for the network to finish running.

write()[source]

Writes data to files.

This function writes each type of data to a file. The files are dependent on the extensions used to save data and the log_file file. Files are created as:

[log_file].[data_type].csv

Files are created in the data_dir directory in CSV format.