Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Simulation Class Reference

Owns one complete run: the generator, the load balancer(s) and the clock. More...

#include <Simulation.h>

Public Member Functions

 Simulation (const Config &config, Logger &logger)
 Builds the components described by a validated configuration.
void run ()
 Runs every clock cycle of the simulation.
void writeReport (std::ostream &out) const
 Writes the full log summary: settings, randomness, results, snapshots and scaling timeline.
std::vector< const LoadBalancer * > loadBalancers () const
const RequestGenerator & generator () const

Detailed Description

Owns one complete run: the generator, the load balancer(s) and the clock.

In normal mode the simulation drives a single LoadBalancer. In switch mode (bonus) it drives a Switch whose two load balancers split the initial servers in proportion to the expected job mix.

run() fills the initial queue with servers x queuePerServer requests, dispatches at time 0, then advances the clock one cycle at a time, printing a status line every Config::statusEvery cycles. writeReport() produces the log summary required for the assignment.

Definition at line 32 of file Simulation.h.

Constructor & Destructor Documentation

◆ Simulation()

Simulation::Simulation ( const Config & config,
Logger & logger )

Builds the components described by a validated configuration.

Parameters
configSettings for the run.
loggerDestination for events and status lines.

Definition at line 79 of file Simulation.cpp.

Member Function Documentation

◆ run()

void Simulation::run ( )

Runs every clock cycle of the simulation.

Definition at line 103 of file Simulation.cpp.

◆ writeReport()

void Simulation::writeReport ( std::ostream & out) const

Writes the full log summary: settings, randomness, results, snapshots and scaling timeline.

Parameters
outStream to write to.

Definition at line 288 of file Simulation.cpp.

◆ loadBalancers()

std::vector< const LoadBalancer * > Simulation::loadBalancers ( ) const
Returns
The load balancers being simulated (one, or two in switch mode).

Definition at line 147 of file Simulation.cpp.

◆ generator()

const RequestGenerator & Simulation::generator ( ) const
Returns
The request generator.

Definition at line 161 of file Simulation.cpp.


The documentation for this class was generated from the following files: