#include <sys/ioctl.h>
#include <net/if.h>
#include <inttypes.h>
+#include <ncurses.h>
#ifdef WITH_FWP
#include <frsh.h>
-#include <ncurses.h>
#include <fwp_res.h>
-#include <ul_log.h>
-#include <ul_logreg.h>
-static UL_LOG_CUST(ulogd);
-static ul_log_domain_t ulogd = {UL_LOGL_MSG, "wclient"};
-UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_wclient, ulogd);
+/* static UL_LOG_CUST(ulogd); */
+/* static ul_log_domain_t ulogd = {UL_LOGL_MSG, "wclient"}; */
+/* UL_LOGREG_SINGLE_DOMAIN_INIT_FUNCTION(init_ulogd_wclient, ulogd); */
#endif
int opt_granularity_usec = MIN_GRANULARITY;
bool opt_wait_for_queue_is_full; /* Don't gather any statistics until any queue is full */
char *opt_comment = NULL;
+bool opt_gui = false;
bool some_queue_is_full = false;
uint64_t reset_timestamp; /* [nsec] */
frsh_vres_id_t vres, vres_rcv;
uint16_t resp_port;
struct receiver receiver;
- long wc_delay; /* worst-case delay */
#endif
/* Statistics */
pthread_mutex_t mutex;
unsigned long long sent, really_sent, received;
+ long wc_delay; /* worst-case delay */
};
static struct cmsg_ipi {
}
pthread_mutex_unlock(&delay_stats_mutex);
-#ifdef WITH_FWP
- if (trans_time_usec > stream->wc_delay) {
- stream->wc_delay = trans_time_usec;
+ if (trans_time_usec > streams[msg.stream].wc_delay) {
+ streams[msg.stream].wc_delay = trans_time_usec;
}
-#endif
receivers[ac].received++;
pthread_mutex_lock(&streams[msg.stream].mutex);
static inline int
send_packet_fwp(struct stream* stream, union msg_buff* buff)
{
- int ret;
+ int ret = 0;
buff->msg.resp_port = htons(stream->resp_port);
ret = frsh_send_sync(stream->endpoint, buff, stream->packet_size);
-
return (ret == 0) ? 0 : -1;
}
#endif
struct timespec ts;
int ret;
-#ifndef WITH_FWP
- char stream_desc[100];
- stream_to_text(stream_desc, sizeof(stream_desc), stream, 0);
- printf("%s\n", stream_desc);
-#endif
+ if (!opt_gui) {
+ char stream_desc[100];
+ stream_to_text(stream_desc, sizeof(stream_desc), stream, 0);
+ printf("%s\n", stream_desc);
+ }
if (stream->bandwidth_bps == 0)
goto out;
}
#endif
-#ifdef WITH_FWP
-
WINDOW *logwin;
+#if 0
struct log_params {
ul_log_domain_t *domain;
int level;
use_window(logwin, locked_log, (void*)&p);
}
+#endif
void init_gui()
{
- initscr();
- cbreak();
- noecho();
-
- logwin = newwin(0, 0, LINES/2, 0);
- if (logwin) {
- scrollok(logwin, TRUE);
- ul_log_redir(wclient_log_fnc, 0);
+ if (opt_gui) {
+ initscr();
+ cbreak();
+ noecho();
+/* nonl(); */
+/* intrflush(stdscr, FALSE); */
+/* keypad(stdscr, TRUE); */
+
+ logwin = newwin(0, 0, LINES/2, 0);
+ if (logwin) {
+ scrollok(logwin, TRUE);
+/* ul_log_redir(wclient_log_fnc, 0); */
+ }
}
}
void end_gui()
{
- endwin();
- if (logwin) {
- ul_log_redir(NULL, 0);
+ if (opt_gui) {
+ endwin();
+ if (logwin) {
+/* ul_log_redir(NULL, 0); */
+ }
}
}
addstr(str); \
}
-void print_status(int seconds)
+void print_status_gui(int seconds)
{
int i;
char str[200], s1[20];
wnoutrefresh(stdscr);
doupdate();
}
-#else
-void init_gui() {}
-void end_gui() {}
-void print_status(int seconds)
+
+void print_status_nogui(int seconds)
{
int ac;
fprintf(stderr, "\r%3ds", seconds);
}
fflush(stderr);
}
-#endif
int main(int argc, char *argv[])
{
char opt;
- while ((opt = getopt(argc, argv, "B:b:C:c:g:I:j:o:qQ:s:T:")) != -1) {
+ while ((opt = getopt(argc, argv, "B:b:C:c:Gg:I:j:o:qQ:s:T:")) != -1) {
switch (opt) {
case 'B':
opt_def_bandwidth = atoi(optarg);
case 'c':
opt_count_sec = atoi(optarg);
break;
+ case 'G':
+ opt_gui = true;
+ break;
case 'g':
opt_granularity_usec = atoi(optarg);
if (opt_granularity_usec < MIN_GRANULARITY) {
reset_statistics();
#ifdef WITH_FWP
+ //ul_log_domain_arg2levels("6");
rc = frsh_init();
if (rc != 0) {
error(1, errno, "FWP initialization failed");
seconds = 1;
frames=0;
while (!exit_flag) {
-#ifdef WITH_FWP
- usleep(40000);
-#else
- sleep(1);
-#endif
- frames++;
- if (frames>=25) {
+ if (opt_gui) {
+ usleep(40000);
+ frames++;
+ if (frames>=25) {
+ seconds++;
+ frames = 0;
+ }
+ print_status_gui(seconds);
+ } else {
+ sleep(1);
seconds++;
- frames = 0;
+ print_status_nogui(seconds);
}
- print_status(seconds);
+
if (seconds == opt_count_sec)
stopper();
}
}
-#ifdef WITH_FWP
end_gui();
+#ifdef WITH_FWP
for (i=0; i < nr_streams; i++) {
if (streams[i].vres)
frsh_contract_cancel(streams[i].vres);
if (streams[i].vres_rcv)
frsh_contract_cancel(streams[i].vres_rcv);
}
-#else
+#endif
+
fprintf(stderr, "\nWaiting for threads to finish\n");
wait_for_all_threads_to_finish();
measure_length = end_timestamp - reset_timestamp;
save_results(argc, argv, measure_length/1000);
-#endif
return 0;
}