Flowgrind
Advanced TCP traffic generator
common.h
Go to the documentation of this file.
1 
6 /*
7  * Copyright (C) 2013-2014 Alexander Zimmermann <alexander.zimmermann@netapp.com>
8  * Copyright (C) 2010-2013 Christian Samsel <christian.samsel@rwth-aachen.de>
9  * Copyright (C) 2009 Tim Kosse <tim.kosse@gmx.de>
10  * Copyright (C) 2007-2008 Daniel Schaffrath <daniel.schaffrath@mac.com>
11  *
12  * This file is part of Flowgrind.
13  *
14  * Flowgrind is free software: you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation, either version 3 of the License, or
17  * (at your option) any later version.
18  *
19  * Flowgrind is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with Flowgrind. If not, see <http://www.gnu.org/licenses/>.
26  *
27  */
28 
29 #ifndef _COMMON_H_
30 #define _COMMON_H_
31 
32 #ifdef HAVE_CONFIG_H
33 #include "config.h"
34 #endif /* HAVE_CONFIG_H */
35 
36 #include <sys/time.h>
37 #include <time.h>
38 #include <stdint.h>
39 
40 #include "gitversion.h"
41 
42 #ifdef GITVERSION
43 
44 #define FLOWGRIND_VERSION GITVERSION
45 #elif defined PACKAGE_VERSION
46 #define FLOWGRIND_VERSION PACKAGE_VERSION
47 #else /* GITVERSION */
48 #define FLOWGRIND_VERSION "(n/a)"
49 #endif /* GITVERSION */
50 
52 #define FLOWGRIND_API_VERSION 3
53 
55 #define DEFAULT_LISTEN_PORT 5999
56 
58 #define MAX_FLOWS_CONTROLLER 2048
59 
65 #define MAX_FLOWS_DAEMON FD_SETSIZE >> 1
66 
68 #define MAX_EXTRA_SOCKET_OPTIONS 10
69 
71 #define MAX_EXTRA_SOCKET_OPTION_VALUE_LENGTH 100
72 
73 #ifndef TCP_CA_NAME_MAX
74 
75 #define TCP_CA_NAME_MAX 16
76 #endif /* TCP_CA_NAME_MAX */
77 
79 #define MIN_BLOCK_SIZE (signed) sizeof (struct block)
80 
82 #define FLOWGRIND_COPYRIGHT "Copyright (C) 2007 - 2014 Flowgrind authors."
83 
85 #define FLOWGRIND_COPYING \
86  "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.\n" \
87  "This is free software: you are free to change and redistribute it.\n" \
88  "There is NO WARRANTY, to the extent permitted by law."
89 
91 #define FLOWGRIND_AUTHORS \
92  "Written by Arnd Hannemann, Tim Kosse, Christian Samsel, Daniel Schaffrath\n" \
93  "and Alexander Zimmermann."
94 
96 enum endpoint_t {
98  SOURCE = 0,
101 };
102 
104 enum io_t {
106  WRITE = 0,
109 };
110 
112 enum report_t {
114  INTERVAL = 0,
117 };
118 
119 /* XXX add a brief description doxygen. */
127 };
128 
132  CONSTANT = 0,
145 };
146 
148 struct block {
151 
158 
160  struct timespec data;
162  struct timespec data2;
163 };
164 
168  enum distribution_t distribution;
170  double param_one;
172  double param_two;
173 
174 };
175 
183  char bind_address[1000];
184 
186  int flow_id;
188  double delay[2];
190  double duration[2];
191 
194 
199 
202 
206  int so_debug;
213  int pushy;
215  int shutdown;
216 
218  const char *write_rate_str;
221 
223  unsigned random_seed;
224 
227 
230 
232  int cork;
234  int nonagle;
236  char cc_alg[TCP_CA_NAME_MAX];
238  int elcn;
240  int lcd;
242  int mtcp;
244  int dscp;
247 
249  struct trafgen_options request_trafgen_options;
251  struct trafgen_options response_trafgen_options;
253  struct trafgen_options interpacket_gap_trafgen_options;
254 
255  /* XXX add a brief description doxygen + is this obsolete? */
257  int level;
258  int optname;
259  int optlen;
263 };
264 
265 /* Flowgrinds view on the tcp_info struct for
266  * serialization / deserialization */
267 struct fg_tcp_info {
277  int tcpi_rtt;
279  int tcpi_rto;
283 };
284 
285 /* Report (measurement sample) of a flow */
286 struct report {
287  int id;
289  enum endpoint_t endpoint;
291  enum report_t type;
292  struct timespec begin;
293  struct timespec end;
294 #ifdef HAVE_UNSIGNED_LONG_LONG_INT
295  unsigned long long bytes_read;
296  unsigned long long bytes_written;
297 #else /* HAVE_UNSIGNED_LONG_LONG_INT */
298  long bytes_read;
299  long bytes_written;
300 #endif /* HAVE_UNSIGNED_LONG_LONG_INT */
305 
306  /* TODO Create an array for IAT / RTT and delay */
307 
309  double iat_min;
311  double iat_max;
313  double iat_sum;
315  double delay_min;
317  double delay_max;
319  double delay_sum;
321  double rtt_min;
323  double rtt_max;
325  double rtt_sum;
326 
327  /* on the Daemon this is filled from the os specific
328  * tcp_info struct */
329  struct fg_tcp_info tcp_info;
330 
332  unsigned pmtu;
334  unsigned imtu;
335 
336  int status;
337 
338  struct report* next;
339 };
340 
341 #endif /* _COMMON_H_*/
double delay_sum
Accumulated one-way delay.
Definition: common.h:319
int maximum_block_size
Application buffer size in bytes (option -U).
Definition: common.h:201
int32_t this_block_size
Size of our request or response block.
Definition: common.h:150
int mtcp
Set TCP_MTCP (15) on test socket (option -O).
Definition: common.h:242
Options for stochastic traffic generation.
Definition: common.h:166
int num_extra_socket_options
Definition: common.h:262
int lcd
Set TCP_LCD (21) on test socket (option -O).
Definition: common.h:240
#define MAX_EXTRA_SOCKET_OPTIONS
Max number of arbitrary extra socket options which may sent to the deamon.
Definition: common.h:68
int requested_send_buffer_size
Request sender buffer in bytes (option -B).
Definition: common.h:196
double iat_sum
Accumulated inter-arrival time.
Definition: common.h:313
int tcpi_rttvar
Definition: common.h:278
#define MAX_EXTRA_SOCKET_OPTION_VALUE_LENGTH
Ensures extra options are limited in length on both controller and deamon.
Definition: common.h:71
int write_rate
The actual rate we should send.
Definition: common.h:220
struct report * next
Definition: common.h:338
double rtt_sum
Accumulated round-trip time.
Definition: common.h:325
int tcpi_snd_mss
Definition: common.h:281
#define TCP_CA_NAME_MAX
Max size of the congestion control algorithm specifier string.
Definition: common.h:75
struct timespec data2
Used to access 64bit timespec on 32bit arch.
Definition: common.h:162
double rtt_min
Minimum round-trip time.
Definition: common.h:321
int id
Definition: common.h:287
unsigned request_blocks_read
Definition: common.h:301
double iat_min
Minimum inter-arrival time.
Definition: common.h:309
int tcpi_unacked
Definition: common.h:270
int tcpi_retransmits
Definition: common.h:274
Definition: common.h:286
int tcpi_fackets
Definition: common.h:275
io_t
I/O operation types.
Definition: common.h:104
unsigned response_blocks_written
Definition: common.h:304
int32_t request_block_size
Size of the response block we request.
Definition: common.h:157
int cork
Sets SO_DEBUG on test socket (option -O).
Definition: common.h:232
unsigned pmtu
Discovered Path MTU.
Definition: common.h:332
int tcpi_rto
Definition: common.h:279
double param_two
Second mathematical parameter of the distribution, if required.
Definition: common.h:172
int ipmtudiscover
Set IP_MTU_DISCOVER on test socket (option -O).
Definition: common.h:246
Endpoint that accepts the connection.
Definition: common.h:100
Log Normal distribution.
Definition: common.h:144
unsigned imtu
Interface MTU.
Definition: common.h:334
struct timespec data
Sending timestap for calculating delay and RTT.
Definition: common.h:160
int status
Definition: common.h:336
int pushy
Do not iterate through select() to continue sending in case block size did not suffice to fill sendin...
Definition: common.h:213
double rtt_max
Maximum round-trip time.
Definition: common.h:323
endpoint_t
Flow endpoint types.
Definition: common.h:96
int tcpi_snd_cwnd
Definition: common.h:268
int dscp
DSCP value for TOS byte (option -D).
Definition: common.h:244
Endpoint that opens the connection.
Definition: common.h:98
Uniform distribution.
Definition: common.h:138
int requested_read_buffer_size
Request receiver buffer, advertised window in bytes (option -W).
Definition: common.h:198
unsigned request_blocks_written
Definition: common.h:302
Exponential distribution.
Definition: common.h:140
int route_record
Sets ROUTE_RECORD on test socket (option -O).
Definition: common.h:208
Flowgrind&#39;s data block layout.
Definition: common.h:148
unsigned response_blocks_read
Definition: common.h:303
double delay_min
Minimum one-way delay.
Definition: common.h:315
int tcpi_snd_ssthresh
Definition: common.h:269
report_t
Report types.
Definition: common.h:112
int tcpi_ca_state
Definition: common.h:282
int tcpi_retrans
Definition: common.h:273
unsigned random_seed
Random seed to use (default: read /dev/urandom) (option -J).
Definition: common.h:223
Normal distribution.
Definition: common.h:134
unsigned long long bytes_written
Definition: common.h:296
const char * write_rate_str
Send at specified rate per second (option -R).
Definition: common.h:218
int elcn
Set TCP_ELCN (20) on test socket (option -O).
Definition: common.h:238
distribution_t
Stochastic distributions for traffic generation.
Definition: common.h:130
Final report.
Definition: common.h:116
Weibull distribution.
Definition: common.h:136
double iat_max
Maximum inter-arrival time.
Definition: common.h:311
int traffic_dump
Dump traffic using libpcap (option -M).
Definition: common.h:204
double delay_max
Maximum one-way delay.
Definition: common.h:317
Read operation.
Definition: common.h:108
int so_debug
Sets SO_DEBUG on test socket (option -O).
Definition: common.h:206
unsigned long long bytes_read
Definition: common.h:295
Write operation.
Definition: common.h:106
int tcpi_lost
Definition: common.h:272
int flow_id
Flow ID maintained by controller.
Definition: common.h:186
No stochastic distribution.
Definition: common.h:132
int flow_control
Stop flow if it is experiencing local congestion (option -C).
Definition: common.h:226
int byte_counting
Enumerate bytes in payload instead of sending zeros (option -E).
Definition: common.h:229
double param_one
First mathemathical parameter of the distribution.
Definition: common.h:170
int tcpi_reordering
Definition: common.h:276
extra_socket_option_level
Definition: common.h:120
int nonagle
Disable nagle algorithm on test socket (option -O).
Definition: common.h:234
int shutdown
Shutdown socket after test flow (option -N).
Definition: common.h:215
Pareto distribution.
Definition: common.h:142
int tcpi_backoff
Definition: common.h:280
Settings that describe a flow between from a endpoint&#39;s perspective.
Definition: common.h:181
int tcpi_sacked
Definition: common.h:271
int tcpi_rtt
Definition: common.h:277
double reporting_interval
Interval to report flow on screen (option -i).
Definition: common.h:193
Intermediated interval report.
Definition: common.h:114