 |
Flowgrind
Advanced TCP traffic generator
|
Routines used by Flowgrind to setup the source for a test flow.
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 "debug.h"
#include "fg_error.h"
#include "fg_math.h"
#include "fg_socket.h"
#include "fg_time.h"
#include "fg_log.h"
#include "fg_pcap.h"
Go to the source code of this file.
|
int | add_flow_source (struct request_add_flow_source *request) |
| To set daemon flow as source endpoint. More...
|
|
int | do_connect (struct flow *flow) |
| Establishes a connection of a flow. More...
|
|
int | get_tcp_info (struct flow *flow, struct tcp_info *info) |
|
void | init_flow (struct flow *flow, int is_source) |
| To initialize all flows to the default value. More...
|
|
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) |
|
void | remove_flow (unsigned i) |
|
void | uninit_flow (struct flow *flow) |
|
Routines used by Flowgrind to setup the source for a test flow.
Definition in file source.c.
◆ add_flow_source()
To set daemon flow as source endpoint.
To set the flow options and settings as source endpoint. Depending upon the late connection option the data connection is established to connect the destination daemon listening port address with source daemon.
- Parameters
-
[in,out] | request | Contain the test option and parameter for daemon source endpoint |
Definition at line 177 of file source.c.
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) {
◆ do_connect()
int do_connect |
( |
struct flow * |
flow | ) |
|
Establishes a connection of a flow.
Establishes a connection to the destination daemon listening port, and marks the flow as connected.
- Parameters
-
[in,out] | flow | Flow to connect. |
Definition at line 153 of file source.c.
157 if (rc == -1 && errno != EINPROGRESS) {
160 err(
"failed to connect flow %u",
flow->
id);
◆ 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));
◆ name2socket()
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 |
|
) |
| |
|
static |
- Bug:
- : currently we use portable select() API, which is limited by the number of bits in an fd_set
Definition at line 76 of file source.c.
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);
◆ 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,...)
#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,...)
double rtt_sum
Accumulated round-trip time.
@ 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.
struct flow_source_settings source_settings
int byte_counting
Enumerate bytes in payload instead of sending zeros (option -E).
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
#define err(...)
To report an error w/ the corresponding system error message.
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.
@ SOURCE
Endpoint that opens the connection.
unsigned request_blocks_read
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.
int do_connect(struct flow *flow)
Establishes a connection of a flow.
void uninit_flow(struct flow *flow)
double iat_sum
Accumulated interarrival time.
int requested_send_buffer_size
Request sender buffer in bytes (option -B).
struct flow::statistics statistics[2]