Flowgrind
Advanced TCP traffic generator
trafgen.h File Reference

Routines used by the Flowgrind daemon for advanced traffic generation. More...

#include "config.h"

Go to the source code of this file.

Functions

double next_interpacket_gap (struct flow *)
 
int next_request_block_size (struct flow *)
 
int next_response_block_size (struct flow *)
 

Detailed Description

Routines used by the Flowgrind daemon for advanced traffic generation.

Definition in file trafgen.h.

Function Documentation

◆ next_interpacket_gap()

double next_interpacket_gap ( struct flow )

Definition at line 173 of file trafgen.c.

173  {
174 
175  double gap = 0.0;
176  if (flow->settings.write_rate)
178  else
179  gap = calculate(flow,
183  );
184 
185  if (gap)
186  DEBUG_MSG(LOG_NOTICE, "calculated next interpacket gap %.6fs "
187  "for flow %d", gap, flow->id);
188 
189  return gap;
190 }

◆ next_request_block_size()

int next_request_block_size ( struct flow )

Definition at line 107 of file trafgen.c.

108 {
109  int bs = 0;
110  int i = 0;
111  /* recalculate values to match prequisits, but at most 10 times */
112  while (( bs < MIN_BLOCK_SIZE || bs > flow->settings.maximum_block_size) && i < MAX_RUNS_PER_DISTRIBUTION) {
113 
114  bs = round(calculate(
115  flow,
119  ));
120  i++;
121  }
122 
123  /* sanity checks */
124  if (i >= MAX_RUNS_PER_DISTRIBUTION && bs < MIN_BLOCK_SIZE) {
125  bs = MIN_BLOCK_SIZE;
126  DEBUG_MSG(LOG_WARNING, "applied minimal request size limit %d "
127  "for flow %d", bs, flow->id);
128  }
129 
132  DEBUG_MSG(LOG_WARNING, "applied maximal request size limit %d "
133  "for flow %d", bs, flow->id);
134 
135  }
136 
137  DEBUG_MSG(LOG_NOTICE, "calculated request size %d for flow %d after %d "
138  "runs", bs, flow->id, i);
139 
140  return bs;
141 }

◆ next_response_block_size()

int next_response_block_size ( struct flow )

Definition at line 143 of file trafgen.c.

144 {
145  int bs = round(calculate(
146  flow,
150  ));
151 
152  /* sanity checks */
153  if (bs && bs < MIN_BLOCK_SIZE) {
154  bs = MIN_BLOCK_SIZE;
155  DEBUG_MSG(LOG_WARNING, "applied minimal response size limit "
156  "%d for flow %d", bs, flow->id);
157  }
158  if (bs > flow->settings.maximum_block_size) {
160  DEBUG_MSG(LOG_WARNING, "applied maximal response size limit "
161  "%d for flow %d", bs, flow->id);
162 
163  }
164 
165  if (bs)
166  DEBUG_MSG(LOG_NOTICE, "calculated response size %d for flow "
167  "%d", bs, flow->id);
168 
169  return bs;
170 
171 }
DEBUG_MSG
#define DEBUG_MSG(LVL, MSG,...)
Print debug message to standard error.
Definition: debug.h:49
trafgen_options::distribution
enum distribution_t distribution
The stochastic distribution to draw values from.
Definition: common.h:168
flow
Definition: daemon.h:73
trafgen_options::param_two
double param_two
Second mathematical parameter of the distribution, if required.
Definition: common.h:172
flow_settings::response_trafgen_options
struct trafgen_options response_trafgen_options
Stochastic traffic generation settings for the response size.
Definition: common.h:251
flow::settings
struct flow_settings settings
Definition: daemon.h:83
flow_settings::interpacket_gap_trafgen_options
struct trafgen_options interpacket_gap_trafgen_options
Stochastic traffic generation settings for the interpacket gap.
Definition: common.h:253
MAX_RUNS_PER_DISTRIBUTION
#define MAX_RUNS_PER_DISTRIBUTION
Definition: trafgen.c:48
flow_settings::maximum_block_size
int maximum_block_size
Application buffer size in bytes (option -U).
Definition: common.h:201
MIN_BLOCK_SIZE
#define MIN_BLOCK_SIZE
Minium block (message) size we can send.
Definition: common.h:79
flow_settings::write_rate
int write_rate
The actual rate we should send.
Definition: common.h:220
flow::id
int id
Definition: daemon.h:75
calculate
static double calculate(struct flow *flow, enum distribution_t type, double param_one, double param_two)
Definition: trafgen.c:50
trafgen_options::param_one
double param_one
First mathemathical parameter of the distribution.
Definition: common.h:170
flow_settings::request_trafgen_options
struct trafgen_options request_trafgen_options
Stochastic traffic generation settings for the request size.
Definition: common.h:249