Cade Royal CSCE 412 Project 3
Loading...
Searching...
No Matches
Functions | Variables
main.cpp File Reference

Main file for testing the LoadBalancer class. More...

#include "LoadBalancer.h"
#include <iostream>
#include <chrono>
#include <thread>
#include <string>
#include <mutex>
Include dependency graph for main.cpp:

Functions

std::string makeRandomIP ()
 Generates a random IP address in the form of a string.
 
int main (int argc, char *argv[])
 Main function that starts the LoadBalancer and simulates sending requests.
 

Variables

std::mutex coutMutex_
 

Detailed Description

Main file for testing the LoadBalancer class.

This file initializes a LoadBalancer instance with a specified number of web servers and simulates sending requests over a number of cycles.

Function Documentation

◆ main()

int main ( int  argc,
char *  argv[] 
)

Main function that starts the LoadBalancer and simulates sending requests.

The program accepts two command-line arguments:

  • -s: Specifies the number of web servers to initialize.
  • -c: Specifies the number of cycles to run the simulation for.

The LoadBalancer processes requests over a number of cycles, periodically evaluating the number of active web servers based on the queue size and request load.

Parameters
argcNumber of command-line arguments.
argvArray of command-line argument strings.
Returns
int Program exit status.

◆ makeRandomIP()

std::string makeRandomIP ( )

Generates a random IP address in the form of a string.

The IP address consists of four random integers between 0 and 255.

Returns
A string representing the random IP address.

Variable Documentation

◆ coutMutex_

std::mutex coutMutex_