 |
Flowgrind
Advanced TCP traffic generator
|
Routines used to setup a Flowgrind destination for a test.
More...
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <strings.h>
#include <signal.h>
#include <string.h>
#include <fcntl.h>
#include <math.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/select.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <unistd.h>
#include <sys/wait.h>
#include <errno.h>
#include <time.h>
#include <syslog.h>
#include <sys/time.h>
#include <netdb.h>
#include <pthread.h>
#include <float.h>
#include "common.h"
#include "debug.h"
#include "fg_socket.h"
#include "fg_time.h"
#include "fg_math.h"
#include "fg_log.h"
#include "daemon.h"
#include "fg_pcap.h"
Go to the source code of this file.
Routines used to setup a Flowgrind destination for a test.
Definition in file destination.c.
◆ accept_data()
int accept_data |
( |
struct flow * |
flow | ) |
|
- Bug:
- : currently we use portable select() API, which is limited by the number of bits in an fd_set
Definition at line 250 of file destination.c.
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");
◆ add_flow_destination()
To set daemon flow as destination endpoint.
To set the flow options and settings as destination endpoint. Listening port created and send back to the controller in the same request structure
- Parameters
-
[in,out] | request | contain the test option and parameter for destination source endpoint |
- Bug:
- : currently we use portable select() API, which is limited by the number of bits in an fd_set
Definition at line 158 of file destination.c.
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 =
◆ create_listen_socket()
static int create_listen_socket |
( |
struct flow * |
flow, |
|
|
char * |
bind_addr, |
|
|
unsigned short * |
listen_port |
|
) |
| |
|
static |
Definition at line 78 of file destination.c.
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;
◆ get_tcp_info()
int get_tcp_info |
( |
struct flow * |
flow, |
|
|
struct tcp_info * |
info |
|
) |
| |
◆ init_flow()
void init_flow |
( |
struct flow * |
flow, |
|
|
int |
is_source |
|
) |
| |
To initialize all flows to the default value.
The daemon maintain all its data in its flow
statistics data structure. These data are initialize to the default value or zero value according to their metrics details.
- Parameters
-
[in,out] | flow | flow structure maintained by a daemon |
[in] | is_source | to determine flow endpoint i.e. source or destination |
Definition at line 896 of file daemon.c.
898 memset(
flow, 0,
sizeof(
struct flow));
◆ remove_flow()
void remove_flow |
( |
unsigned |
i | ) |
|
◆ uninit_flow()
void uninit_flow |
( |
struct flow * |
flow | ) |
|
Definition at line 165 of file daemon.c.
177 logging(LOG_WARNING,
"failed to cancel dump thread: %s",
183 logging(LOG_WARNING,
"failed to join dump thread: %s",
#define DEBUG_MSG(LVL, MSG,...)
Print debug message to standard error.
unsigned response_blocks_read
@ INTERVAL
Intermediated interval report.
double delay_sum
Accumulated one-way delay.
unsigned current_read_block_size
double iat_min
Minimum interarrival time.
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 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,...)
double rtt_sum
Accumulated round-trip time.
int set_non_blocking(int fd)
@ DESTINATION
Endpoint that accepts the connection.
double delay_max
Maximum one-way delay.
#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).
double delay_min
Minimum one-way delay.
struct flow_settings settings
void init_flow(struct flow *flow, int is_source)
To initialize all flows to the default value.
unsigned long long bytes_written
double rtt_max
Maximum round-trip time.
int traffic_dump
Dump traffic using libpcap (option -M).
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.
unsigned response_blocks_written
int flow_id
Flow ID maintained by controller.
unsigned current_write_block_size
#define MIN_BLOCK_SIZE
Minium block (message) size we can send.
unsigned real_listen_receive_buffer_size
@ SOURCE
Endpoint that opens the connection.
unsigned request_blocks_read
unsigned real_listen_send_buffer_size
void flow_error(struct flow *flow, const char *fmt,...)
#define free_all(...)
To free() an arbitrary number of variables.
void free_math_functions(struct flow *flow)
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 long long bytes_read
unsigned request_blocks_written
double iat_max
Maximum interarrival time.
double rtt_min
Minimum round-trip time.
unsigned short requested_server_test_port
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)
double iat_sum
Accumulated interarrival time.
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)
int requested_send_buffer_size
Request sender buffer in bytes (option -B).
struct flow::statistics statistics[2]