Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Simulation.h
Go to the documentation of this file.
1
6
7#ifndef SIMULATION_H
8#define SIMULATION_H
9
10#include <iosfwd>
11#include <memory>
12#include <vector>
13
14#include "Config.h"
15#include "LoadBalancer.h"
16#include "Logger.h"
17#include "RequestGenerator.h"
18#include "Switch.h"
19
33public:
39 Simulation(const Config& config, Logger& logger);
40
42 void run();
43
48 void writeReport(std::ostream& out) const;
49
51 std::vector<const LoadBalancer*> loadBalancers() const;
52
54 const RequestGenerator& generator() const;
55
56private:
57 std::vector<LoadBalancer*> mutableLoadBalancers();
58 void writeSettings(std::ostream& out) const;
59 void writeRandomness(std::ostream& out) const;
60 void writeSnapshots(std::ostream& out, const LoadBalancer& balancer) const;
61 void writeScaleTimeline(std::ostream& out, const LoadBalancer& balancer) const;
62
63 Config config_;
64 Logger& logger_;
65 RequestGenerator generator_;
66 std::unique_ptr<LoadBalancer> single_;
67 std::unique_ptr<Switch> switch_;
68 unsigned long statusEvery_;
69 unsigned long snapshotEvery_;
70 double runSeconds_ = 0.0;
71};
72
73#endif
Declares the Config structure and the command-line and interactive input functions.
Declares the LoadBalancer class, which queues requests, dispatches them and scales its server pool.
Declares the Logger class that prints colored, mode-aware simulation events.
Declares the RequestGenerator class, the seeded source of random traffic.
Declares the Switch class (bonus), which routes requests to separate load balancers by job type.
Distributes queued requests across a dynamically sized pool of WebServer objects.
Writes simulation events to the console and, optionally, to a file.
Definition Logger.h:40
Produces random requests from a single seeded Mersenne Twister engine.
void writeReport(std::ostream &out) const
Writes the full log summary: settings, randomness, results, snapshots and scaling timeline.
std::vector< const LoadBalancer * > loadBalancers() const
Simulation(const Config &config, Logger &logger)
Builds the components described by a validated configuration.
const RequestGenerator & generator() const
void run()
Runs every clock cycle of the simulation.
Every user-adjustable setting for one simulation run.
Definition Config.h:21