Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Loading...
Searching...
No Matches
Config.h
Go to the documentation of this file.
1
6
7#ifndef CONFIG_H
8#define CONFIG_H
9
10#include <cstdint>
11#include <iosfwd>
12#include <string>
13#include <vector>
14
21struct Config {
22 unsigned int servers = 20;
23 unsigned long cycles = 100000;
24 unsigned int minTask = 10;
25 unsigned int maxTask = 100;
26 double arrivalRate = 0.45;
27 double waveAmplitude = 0.6;
28 unsigned long wavePeriod = 0;
29 bool autoWavePeriod = true;
30 double streamingShare = 0.35;
31 unsigned int queuePerServer = 100;
32 double upperFactor = 80.0;
33 double lowerFactor = 50.0;
34 unsigned int cooldown = 10;
35 unsigned int minServers = 1;
36 unsigned int maxServers = 100;
37 std::size_t maxQueue = 0;
38 std::uint32_t seed = 412;
39 std::vector<std::string> blockedRanges{"45.0.0.0/8", "103.0.0.0/8"};
40 bool verbose = false;
41 bool color = true;
42 bool useSwitch = false;
43 bool interactive = false;
44 bool showHelp = false;
45 unsigned long statusEvery = 0;
46 std::string logPath;
47};
48
61bool parseArguments(int argc, char* argv[], Config& config, std::string& error);
62
69void promptForSettings(Config& config, std::istream& in, std::ostream& out);
70
77bool validateConfig(const Config& config, std::string& error);
78
84void printUsage(std::ostream& out, const std::string& program);
85
86#endif
void promptForSettings(Config &config, std::istream &in, std::ostream &out)
Asks the user for the main settings, keeping the current value when the answer is blank.
Definition Config.cpp:201
bool validateConfig(const Config &config, std::string &error)
Checks that the settings are consistent.
Definition Config.cpp:214
void printUsage(std::ostream &out, const std::string &program)
Prints the list of command-line options.
Definition Config.cpp:61
bool parseArguments(int argc, char *argv[], Config &config, std::string &error)
Reads command-line options into a Config.
Definition Config.cpp:95
Every user-adjustable setting for one simulation run.
Definition Config.h:21
unsigned int queuePerServer
Initial queue size = servers x queuePerServer.
Definition Config.h:31
double arrivalRate
Average new requests per cycle.
Definition Config.h:26
std::string logPath
File for the run summary (and events in verbose mode).
Definition Config.h:46
double lowerFactor
Scale down when queue < lowerFactor x servers.
Definition Config.h:33
unsigned int servers
Initial number of web servers.
Definition Config.h:22
bool useSwitch
Bonus: route P and S jobs to two load balancers.
Definition Config.h:42
unsigned long cycles
Clock cycles to simulate.
Definition Config.h:23
unsigned int maxTask
Longest task time, in cycles.
Definition Config.h:25
bool verbose
Print every event instead of only status lines.
Definition Config.h:40
double waveAmplitude
Traffic wave size, 0 (steady) to 1.
Definition Config.h:27
double streamingShare
Fraction of requests that are streaming ('S') jobs.
Definition Config.h:30
std::uint32_t seed
Random seed (logged so a run can be repeated).
Definition Config.h:38
unsigned int cooldown
Cycles between scaling checks.
Definition Config.h:34
unsigned long statusEvery
Cycles between status lines; 0 chooses automatically.
Definition Config.h:45
std::size_t maxQueue
Queue capacity; 0 means unlimited.
Definition Config.h:37
unsigned int minServers
Lower bound on active servers.
Definition Config.h:35
bool color
Use ANSI colors on a terminal.
Definition Config.h:41
unsigned long wavePeriod
Cycles per traffic wave; 0 disables the wave.
Definition Config.h:28
unsigned int minTask
Shortest task time, in cycles.
Definition Config.h:24
bool showHelp
Print usage and exit.
Definition Config.h:44
double upperFactor
Scale up when queue > upperFactor x servers.
Definition Config.h:32
std::vector< std::string > blockedRanges
Firewall CIDR ranges.
Definition Config.h:39
bool interactive
Ask for the main settings on standard input.
Definition Config.h:43
bool autoWavePeriod
Use cycles / 4 (four busy/quiet waves) unless –wave-period is given.
Definition Config.h:29
unsigned int maxServers
Upper bound on live servers.
Definition Config.h:36