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 - 2021 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 
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;
238  int elcn;
240  int lcd;
242  int mtcp;
244  int dscp;
247 
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;
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 */
330 
332  unsigned pmtu;
334  unsigned imtu;
335 
336  int status;
337 
338  struct report* next;
339 };
340 
341 #endif /* _COMMON_H_*/
fg_tcp_info::tcpi_unacked
int tcpi_unacked
Definition: common.h:270
UNIFORM
@ UNIFORM
Uniform distribution.
Definition: common.h:138
FINAL
@ FINAL
Final report.
Definition: common.h:116
level_sol_socket
@ level_sol_socket
Definition: common.h:121
INTERVAL
@ INTERVAL
Intermediated interval report.
Definition: common.h:114
report::id
int id
Definition: common.h:287
trafgen_options::distribution
enum distribution_t distribution
The stochastic distribution to draw values from.
Definition: common.h:168
WRITE
@ WRITE
Write operation.
Definition: common.h:106
fg_tcp_info::tcpi_rttvar
int tcpi_rttvar
Definition: common.h:278
MAX_EXTRA_SOCKET_OPTIONS
#define MAX_EXTRA_SOCKET_OPTIONS
Max number of arbitrary extra socket options which may sent to the deamon.
Definition: common.h:68
flow_settings::random_seed
unsigned random_seed
Random seed to use (default: read /dev/urandom) (option -J).
Definition: common.h:223
block::request_block_size
int32_t request_block_size
Size of the response block we request.
Definition: common.h:157
report::rtt_max
double rtt_max
Maximum round-trip time.
Definition: common.h:323
fg_tcp_info::tcpi_reordering
int tcpi_reordering
Definition: common.h:276
level_ipproto_udp
@ level_ipproto_udp
Definition: common.h:126
report::rtt_sum
double rtt_sum
Accumulated round-trip time.
Definition: common.h:325
MAX_EXTRA_SOCKET_OPTION_VALUE_LENGTH
#define MAX_EXTRA_SOCKET_OPTION_VALUE_LENGTH
Ensures extra options are limited in length on both controller and deamon.
Definition: common.h:71
block::this_block_size
int32_t this_block_size
Size of our request or response block.
Definition: common.h:150
flow_settings::dscp
int dscp
DSCP value for TOS byte (option -D).
Definition: common.h:244
flow_settings::requested_read_buffer_size
int requested_read_buffer_size
Request receiver buffer, advertised window in bytes (option -W).
Definition: common.h:198
report::delay_max
double delay_max
Maximum one-way delay.
Definition: common.h:317
report::request_blocks_written
unsigned request_blocks_written
Definition: common.h:302
report::bytes_read
unsigned long long bytes_read
Definition: common.h:295
report::iat_sum
double iat_sum
Accumulated inter-arrival time.
Definition: common.h:313
fg_tcp_info::tcpi_sacked
int tcpi_sacked
Definition: common.h:271
READ
@ READ
Read operation.
Definition: common.h:108
fg_tcp_info::tcpi_fackets
int tcpi_fackets
Definition: common.h:275
DESTINATION
@ DESTINATION
Endpoint that accepts the connection.
Definition: common.h:100
flow_settings::duration
double duration[2]
Duration of flow in seconds (option -T).
Definition: common.h:190
flow_settings::cork
int cork
Sets SO_DEBUG on test socket (option -O).
Definition: common.h:232
report::delay_min
double delay_min
Minimum one-way delay.
Definition: common.h:315
PARETO
@ PARETO
Pareto distribution.
Definition: common.h:142
trafgen_options::param_two
double param_two
Second mathematical parameter of the distribution, if required.
Definition: common.h:172
flow_settings::byte_counting
int byte_counting
Enumerate bytes in payload instead of sending zeros (option -E).
Definition: common.h:229
flow_settings::cc_alg
char cc_alg[TCP_CA_NAME_MAX]
Set congestion control algorithm ALG on test socket (option -O).
Definition: common.h:236
flow_settings::response_trafgen_options
struct trafgen_options response_trafgen_options
Stochastic traffic generation settings for the response size.
Definition: common.h:251
report::next
struct report * next
Definition: common.h:338
fg_tcp_info::tcpi_backoff
int tcpi_backoff
Definition: common.h:280
flow_settings::extra_socket_options::optlen
int optlen
Definition: common.h:259
fg_tcp_info::tcpi_rtt
int tcpi_rtt
Definition: common.h:277
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
gitversion.h
report
Definition: common.h:286
flow_settings::traffic_dump
int traffic_dump
Dump traffic using libpcap (option -M).
Definition: common.h:204
distribution_t
distribution_t
Stochastic distributions for traffic generation.
Definition: common.h:130
flow_settings::ipmtudiscover
int ipmtudiscover
Set IP_MTU_DISCOVER on test socket (option -O).
Definition: common.h:246
flow_settings::extra_socket_options::optval
char optval[MAX_EXTRA_SOCKET_OPTION_VALUE_LENGTH]
Definition: common.h:260
fg_tcp_info::tcpi_retransmits
int tcpi_retransmits
Definition: common.h:274
flow_settings::maximum_block_size
int maximum_block_size
Application buffer size in bytes (option -U).
Definition: common.h:201
LOGNORMAL
@ LOGNORMAL
Log Normal distribution.
Definition: common.h:144
fg_tcp_info::tcpi_snd_mss
int tcpi_snd_mss
Definition: common.h:281
flow_settings::flow_control
int flow_control
Stop flow if it is experiencing local congestion (option -C).
Definition: common.h:226
CONSTANT
@ CONSTANT
No stochastic distribution.
Definition: common.h:132
flow_settings::flow_id
int flow_id
Flow ID maintained by controller.
Definition: common.h:186
WEIBULL
@ WEIBULL
Weibull distribution.
Definition: common.h:136
report::iat_max
double iat_max
Maximum inter-arrival time.
Definition: common.h:311
flow_settings::num_extra_socket_options
int num_extra_socket_options
Definition: common.h:262
flow_settings::pushy
int pushy
Do not iterate through select() to continue sending in case block size did not suffice to fill sendin...
Definition: common.h:213
flow_settings::nonagle
int nonagle
Disable nagle algorithm on test socket (option -O).
Definition: common.h:234
endpoint_t
endpoint_t
Flow endpoint types.
Definition: common.h:96
trafgen_options
Options for stochastic traffic generation.
Definition: common.h:166
report::bytes_written
unsigned long long bytes_written
Definition: common.h:296
flow_settings::reporting_interval
double reporting_interval
Interval to report flow on screen (option -i).
Definition: common.h:193
flow_settings::write_rate
int write_rate
The actual rate we should send.
Definition: common.h:220
SOURCE
@ SOURCE
Endpoint that opens the connection.
Definition: common.h:98
flow_settings::elcn
int elcn
Set TCP_ELCN (20) on test socket (option -O).
Definition: common.h:238
EXPONENTIAL
@ EXPONENTIAL
Exponential distribution.
Definition: common.h:140
fg_tcp_info::tcpi_ca_state
int tcpi_ca_state
Definition: common.h:282
io_t
io_t
I/O operation types.
Definition: common.h:104
report::pmtu
unsigned pmtu
Discovered Path MTU.
Definition: common.h:332
block
Flowgrind's data block layout.
Definition: common.h:148
flow_settings::delay
double delay[2]
Delay of flow in seconds (option -Y).
Definition: common.h:188
report::status
int status
Definition: common.h:336
flow_settings::lcd
int lcd
Set TCP_LCD (21) on test socket (option -O).
Definition: common.h:240
extra_socket_option_level
extra_socket_option_level
Definition: common.h:120
report::delay_sum
double delay_sum
Accumulated one-way delay.
Definition: common.h:319
level_ipproto_ip
@ level_ipproto_ip
Definition: common.h:123
report_t
report_t
Report types.
Definition: common.h:112
report::response_blocks_written
unsigned response_blocks_written
Definition: common.h:304
block::data
struct timespec data
Sending timestap for calculating delay and RTT.
Definition: common.h:160
level_ipproto_sctp
@ level_ipproto_sctp
Definition: common.h:124
level_sol_tcp
@ level_sol_tcp
Definition: common.h:122
report::type
enum report_t type
Report type - either INTERVAL or FINAL report.
Definition: common.h:291
flow_settings::shutdown
int shutdown
Shutdown socket after test flow (option -N).
Definition: common.h:215
fg_tcp_info::tcpi_lost
int tcpi_lost
Definition: common.h:272
flow_settings::extra_socket_options
Definition: common.h:256
block::data2
struct timespec data2
Used to access 64bit timespec on 32bit arch.
Definition: common.h:162
report::endpoint
enum endpoint_t endpoint
Daemon endpoint - either source or destination.
Definition: common.h:289
flow_settings::extra_socket_options::level
int level
Definition: common.h:257
report::imtu
unsigned imtu
Interface MTU.
Definition: common.h:334
fg_tcp_info::tcpi_retrans
int tcpi_retrans
Definition: common.h:273
fg_tcp_info
Definition: common.h:267
config.h
TCP_CA_NAME_MAX
#define TCP_CA_NAME_MAX
Max size of the congestion control algorithm specifier string.
Definition: common.h:75
report::end
struct timespec end
Definition: common.h:293
report::tcp_info
struct fg_tcp_info tcp_info
Definition: common.h:329
fg_tcp_info::tcpi_snd_ssthresh
int tcpi_snd_ssthresh
Definition: common.h:269
fg_tcp_info::tcpi_snd_cwnd
int tcpi_snd_cwnd
Definition: common.h:268
report::request_blocks_read
unsigned request_blocks_read
Definition: common.h:301
flow_settings::mtcp
int mtcp
Set TCP_MTCP (15) on test socket (option -O).
Definition: common.h:242
flow_settings::write_rate_str
const char * write_rate_str
Send at specified rate per second (option -R).
Definition: common.h:218
report::rtt_min
double rtt_min
Minimum round-trip time.
Definition: common.h:321
trafgen_options::param_one
double param_one
First mathemathical parameter of the distribution.
Definition: common.h:170
NORMAL
@ NORMAL
Normal distribution.
Definition: common.h:134
flow_settings::request_trafgen_options
struct trafgen_options request_trafgen_options
Stochastic traffic generation settings for the request size.
Definition: common.h:249
flow_settings::bind_address
char bind_address[1000]
The interface address for the flow (used by daemon).
Definition: common.h:183
level_ipproto_tcp
@ level_ipproto_tcp
Definition: common.h:125
report::begin
struct timespec begin
Definition: common.h:292
flow_settings::so_debug
int so_debug
Sets SO_DEBUG on test socket (option -O).
Definition: common.h:206
flow_settings::extra_socket_options::optname
int optname
Definition: common.h:258
fg_tcp_info::tcpi_rto
int tcpi_rto
Definition: common.h:279
report::iat_min
double iat_min
Minimum inter-arrival time.
Definition: common.h:309
flow_settings::requested_send_buffer_size
int requested_send_buffer_size
Request sender buffer in bytes (option -B).
Definition: common.h:196
report::response_blocks_read
unsigned response_blocks_read
Definition: common.h:303
flow_settings::route_record
int route_record
Sets ROUTE_RECORD on test socket (option -O).
Definition: common.h:208
flow_settings
Settings that describe a flow between from a endpoint's perspective.
Definition: common.h:181