Simulation¶
This module contains the simulation setup and execution.
ControlledEnvironment¶
- class cs143sim.simulation.ControlledEnvironment(controller)[source]¶
SimPy Environment with a reference to its Controller
Parameters: controller – Controller that created the Environment
Controller¶
- class cs143sim.simulation.Controller(case='cs143sim/cases/case0.txt')[source]¶
Controller that prepares, starts, and cleans up a run of the simulation
Parameters: case (str) – path to simulation input file
Variables: - env – SimPy simulation Environment
- flows (dict) – all Flows in the simulation
- hosts (dict) – all Hosts in the simulation
- links (dict) – all Links in the simulation
- routers (dict) – all Routers in the simulation
- buffer_occupancy (dict) – buffer occupancy records for each link; Links key to lists of (time, value) tuples
- flow_rate (dict) – flow rate records for each flow; Flows key to lists of (time, value) tuples
- link_rate (dict) – link rate records for each link; Links key to lists of (time, value) tuples
- packet_delay (dict) – packet delay records for each flow; Flows key to lists of (time, value) tuples
- packet_loss (dict) – packet loss records for each link; Links key to lists of (time, value) tuples
- window_size (dict) – window size records for each flow; Flows key to lists of (time, value) tuples
- make_flow(name, source, destination, amount, start_time, algorithm)[source]¶
Make a new Flow and add it to self.flows
Parameters:
- make_link(name, source, destination, rate, delay, buffer_capacity)[source]¶
Make a new Host and add it to self.hosts
Parameters:
- make_router(name, ip_address, update_time)[source]¶
Make a new Router and add it to self.routers
Parameters:
- read_case(case)[source]¶
Read input file at path case and create actors accordingly
Parameters: case (str) – path to simulation input file
- record(recorder, actor, value)[source]¶
Record the time and value in the recorder keyed by the actor
Parameters:
- record_buffer_occupancy(link, buffer_occupancy)[source]¶
Record the occupancy of a link buffer
Parameters:
- record_packet_loss(link)[source]¶
Record a packet loss
Parameters: link – Link that dropped the packet