7#ifndef REQUESTGENERATOR_H
8#define REQUESTGENERATOR_H
79 std::vector<Request>
makeInitialBatch(std::size_t count,
unsigned long cycle);
91 std::vector<Request>
arrivalsFor(
unsigned long cycle);
103 double rateAt(
unsigned long cycle)
const;
112 std::uint32_t
seed()
const;
115 const std::vector<Request>&
samples()
const;
118 std::string randomIp();
119 void record(
const Request& request);
123 std::mt19937 engine_;
124 std::uniform_int_distribution<unsigned int> taskCycles_;
125 std::uniform_int_distribution<unsigned int> octet_;
126 std::uniform_int_distribution<unsigned int> firstOctet_;
127 std::uniform_int_distribution<unsigned int> hostOctet_;
128 std::bernoulli_distribution streaming_;
129 std::poisson_distribution<unsigned int> arrivals_;
131 std::vector<Request> samples_;
132 unsigned long nextId_ = 1;
Defines the Request structure and its JobType that flow through the load balancer.
RequestGenerator(const GeneratorSettings &settings, std::uint32_t seed)
Creates a generator.
Request makeRequest(unsigned long cycle)
Creates one random request.
const std::vector< Request > & samples() const
const GeneratorStats & stats() const
std::vector< Request > makeInitialBatch(std::size_t count, unsigned long cycle)
Creates the initial queue contents.
const GeneratorSettings & settings() const
std::vector< Request > arrivalsFor(unsigned long cycle)
Creates the random arrivals for one clock cycle.
double rateAt(unsigned long cycle) const
Returns the mean arrival rate at a given cycle.
std::uint32_t seed() const
Tunable parameters for random request generation.
unsigned int minTaskCycles
Shortest possible task, in clock cycles.
double waveAmplitude
Traffic wave size: the rate swings between (1 - a) and (1 + a) x arrivalRate.
unsigned long wavePeriod
Cycles in one busy-to-quiet traffic wave; 0 disables the wave.
double arrivalRate
Average new requests per clock cycle (Poisson mean).
double streamingShare
Probability that a request is a streaming ('S') job.
unsigned int maxTaskCycles
Longest possible task, in clock cycles.
Running statistics that show the randomness of generated traffic.
static constexpr std::size_t kArrivalBins
Arrival-count buckets: 0, 1, 2, 3, 4+.
unsigned long streaming
Generated requests with JobType::Streaming.
unsigned int minTaskSeen
Shortest task actually generated.
std::array< unsigned long, kTaskBins > taskHistogram
Task lengths split into equal-width bins.
unsigned long initial
Requests generated for the initial queue.
unsigned int maxTaskSeen
Longest task actually generated.
std::array< unsigned long, kArrivalBins > arrivalHistogram
Cycles with 0, 1, 2, 3 and 4+ arrivals.
static constexpr std::size_t kTaskBins
Number of task-length histogram bins.
unsigned long maxArrivalsInCycle
Largest burst generated in a single cycle.
unsigned long processing
Generated requests with JobType::Processing.
unsigned long total
Requests generated, including the initial queue.
unsigned long long taskCycleSum
Sum of all task lengths, for the mean.
A single web request waiting for, or receiving, service.