 |
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>
79 unsigned short *listen_port)
84 struct addrinfo hints, *res, *ressave;
86 bzero(&hints,
sizeof(
struct addrinfo));
87 hints.ai_flags = bind_addr ? 0 : AI_PASSIVE;
88 hints.ai_family = AF_UNSPEC;
89 hints.ai_socktype = SOCK_STREAM;
92 if ((rc = getaddrinfo(bind_addr,
"0", &hints, &res)) != 0) {
93 logging(LOG_ALERT,
"getaddrinfo() failed: %s",
103 fd = socket(res->ai_family, res->ai_socktype,
107 if (bind(fd, res->ai_addr, res->ai_addrlen) == 0)
110 }
while ((res = res->ai_next) != NULL);
113 logging(LOG_ALERT,
"failed to create listen socket: %s",
117 freeaddrinfo(ressave);
121 freeaddrinfo(ressave);
130 if (listen(fd, 0) < 0) {
131 logging(LOG_ALERT,
"listen failed: %s", strerror(errno));
145 *listen_port = (
unsigned short)
port;
161 unsigned short server_data_port;
164 logging(LOG_WARNING,
"can not accept another flow, already "
173 logging(LOG_ALERT,
"could not allocate memory for flow");
185 logging(LOG_ALERT,
"could not allocate memory for read/write "
188 "for read/write blocks");
198 (
unsigned char)(byte_idx & 0xff);
206 &server_data_port)) == -1) {
207 logging(LOG_ALERT,
"could not create listen socket for "
217 logging(LOG_ALERT,
"failed to add listen socket: "
220 "file descriptors in use by this daemon");
224 DEBUG_MSG(LOG_WARNING,
"listening on %s port %u for data "
238 request->listen_data_port = (int)server_data_port;
239 request->real_listen_send_buffer_size =
241 request->real_listen_read_buffer_size =
252 struct sockaddr_storage caddr;
253 socklen_t addrlen =
sizeof(caddr);
254 unsigned real_send_buffer_size;
255 unsigned real_receive_buffer_size;
261 if (errno == EINTR || errno == EAGAIN)
263 logging(LOG_ALERT,
"accept() failed: %s", strerror(errno));
269 if (
flow->
fd >= FD_SETSIZE) {
270 logging(LOG_ALERT,
"too many file descriptors are "
271 "already in use by this daemon (FD number=%u)",
flow->
fd);
273 "file descriptors in use by this daemon");
279 logging(LOG_WARNING,
"close() failed");
282 logging(LOG_NOTICE,
"client %s connected for testing (fd=%u)",
289 real_send_buffer_size =
295 logging(LOG_WARNING,
"failed to set send buffer size of test "
296 "socket to send buffer size size of listen socket "
297 "(listen = %u, test = %u)",
301 real_receive_buffer_size =
307 logging(LOG_WARNING,
"failed to set receive buffer size "
308 "(advertised window) of test socket to receive "
309 "buffer size of listen socket (listen = %u, "
311 real_receive_buffer_size);
316 DEBUG_MSG(LOG_NOTICE,
"data socket accepted");
int get_tcp_info(struct flow *flow, struct tcp_info *info)
#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,...)
int accept_data(struct flow *flow)
int requested_read_buffer_size
Request receiver buffer, advertised window in bytes (option -W).
int set_flow_tcp_options(struct flow *flow)
void logging(int priority, const char *fmt,...)
int set_non_blocking(int fd)
#define MAX_FLOWS_DAEMON
Maximal number of parallel flows supported by one daemon instance.
int byte_counting
Enumerate bytes in payload instead of sending zeros (option -E).
char cc_alg[TCP_CA_NAME_MAX]
Set congestion control algorithm ALG on test socket (option -O).
struct flow_settings settings
void remove_flow(unsigned i)
void init_flow(struct flow *flow, int is_source)
To initialize all flows to the default value.
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.
unsigned real_listen_receive_buffer_size
Timing related routines used by Flowgrind.
unsigned real_listen_send_buffer_size
void flow_error(struct flow *flow, const char *fmt,...)
Data structures used by the Flowgrind daemon and controller.
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)
unsigned short requested_server_test_port
void add_flow_destination(struct request_add_flow_destination *request)
To set daemon flow as destination endpoint.
const char * fg_nameinfo(const struct sockaddr *sa, socklen_t salen)
void uninit_flow(struct flow *flow)
int mtcp
Set TCP_MTCP (15) on test socket (option -O).
int set_congestion_control(int fd, const char *cc_alg)
Routines for statistics and advanced traffic generation.
char bind_address[1000]
The interface address for the flow (used by daemon).
static int create_listen_socket(struct flow *flow, char *bind_addr, unsigned short *listen_port)
Debugging routines for Flowgrind controller and daemon.
Routines used by the Flowgrind daemon.
int requested_send_buffer_size
Request sender buffer in bytes (option -B).