 |
Flowgrind
Advanced TCP traffic generator
|
Go to the documentation of this file.
40 #include <sys/types.h>
41 #include <sys/socket.h>
42 #include <sys/param.h>
43 #include <sys/select.h>
44 #include <netinet/in.h>
45 #include <arpa/inet.h>
78 const int read_buffer_size_req,
int *read_buffer_size,
79 const int send_buffer_size_req,
int *send_buffer_size)
82 struct addrinfo hints, *res, *ressave;
85 bzero(&hints,
sizeof(
struct addrinfo));
86 hints.ai_family = AF_UNSPEC;
87 hints.ai_socktype = SOCK_STREAM;
89 snprintf(service,
sizeof(service),
"%u",
port);
91 if ((n = getaddrinfo(server_name, service, &hints, &res)) != 0) {
100 fd = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
106 if (fd >= FD_SETSIZE) {
107 logging(LOG_ALERT,
"too many file descriptors are"
108 "already in use by this daemon");
110 "file descriptors in use by this daemon");
112 freeaddrinfo(ressave);
116 if (send_buffer_size)
118 if (read_buffer_size)
123 }
while ((res = res->ai_next) != NULL);
127 "\"%s:%d\": %s", server_name,
port, strerror(errno));
128 freeaddrinfo(ressave);
133 *saptr = malloc(res->ai_addrlen);
135 crit(
"malloc(): failed");
136 memcpy(*saptr, res->ai_addr, res->ai_addrlen);
137 *lenp = res->ai_addrlen;
140 freeaddrinfo(ressave);
157 if (rc == -1 && errno != EINPROGRESS) {
160 err(
"failed to connect flow %u",
flow->
id);
179 #ifdef HAVE_SO_TCP_CONGESTION
180 socklen_t opt_len = 0;
185 logging(LOG_WARNING,
"can not accept another flow, already "
188 "Can not accept another flow, already "
195 logging(LOG_ALERT,
"could not allocate memory for flow");
209 logging(LOG_ALERT,
"could not allocate memory for read/write "
228 logging(LOG_ALERT,
"could not create data socket: %s",
242 #ifdef HAVE_SO_TCP_CONGESTION
243 opt_len =
sizeof(
request->cc_alg);
244 if (getsockopt(
flow->
fd, IPPROTO_TCP, TCP_CONGESTION,
245 request->cc_alg, &opt_len) == -1) {
#define DEBUG_MSG(LVL, MSG,...)
Print debug message to standard error.
Packet capture support for the Flowgrind daemon.
size_t fg_list_size(struct linked_list *const list)
Returns the number of elements in the list.
void request_error(struct request *request, const char *fmt,...)
#define crit(...)
To report an critical error w/ the corresponding system error message.
int requested_read_buffer_size
Request receiver buffer, advertised window in bytes (option -W).
char destination_host[256]
static int name2socket(struct flow *flow, char *server_name, unsigned port, struct sockaddr **saptr, socklen_t *lenp, const int read_buffer_size_req, int *read_buffer_size, const int send_buffer_size_req, int *send_buffer_size)
int set_flow_tcp_options(struct flow *flow)
void logging(int priority, const char *fmt,...)
Error-reporting routines used by Flowgrind.
#define MAX_FLOWS_DAEMON
Maximal number of parallel flows supported by one daemon instance.
struct flow_source_settings source_settings
int byte_counting
Enumerate bytes in payload instead of sending zeros (option -E).
struct flow_settings settings
void init_flow(struct flow *flow, int is_source)
To initialize all flows to the default value.
#define err(...)
To report an error w/ the corresponding system error message.
void remove_flow(unsigned i)
int maximum_block_size
Application buffer size in bytes (option -U).
void fg_pcap_go(struct flow *flow)
Start a tcpdump to capture traffic of the provided flow.
int flow_id
Flow ID maintained by controller.
Routines used to manipulate socket parameters for Flowgrind.
Timing related routines used by Flowgrind.
void flow_error(struct flow *flow, const char *fmt,...)
int add_flow_source(struct request_add_flow_source *request)
To set daemon flow as source endpoint.
int fg_list_push_back(struct linked_list *const list, void *const data)
Inserts a new element at the end of the list.
int set_window_size_directed(int fd, int window, int direction)
int do_connect(struct flow *flow)
Establishes a connection of a flow.
int get_tcp_info(struct flow *flow, struct tcp_info *info)
void uninit_flow(struct flow *flow)
Routines for statistics and advanced traffic generation.
Debugging routines for Flowgrind controller and daemon.
int requested_send_buffer_size
Request sender buffer in bytes (option -B).