diff --git a/src/osmo-pfcp-tool/gtp_flood.c b/src/osmo-pfcp-tool/gtp_flood.c index e0d6832..4ad31b7 100644 --- a/src/osmo-pfcp-tool/gtp_flood.c +++ b/src/osmo-pfcp-tool/gtp_flood.c @@ -77,6 +77,11 @@ struct gtp_flood_worker { struct io_uring ring; pthread_t worker; + + uint64_t tx_packets; + uint64_t tx_bytes; + uint64_t rx_packets; + uint64_t rx_bytes; }; struct gtp_flood_flow { @@ -310,10 +315,11 @@ static void *gtp_flood_tx_worker_thread(void *_worker) osmo_ctx_init(__func__); - gtp_flood->tx_workers_started++; + int worker_id = gtp_flood->tx_workers_started++; gtp_flood->tx_workers_running++; - LOGP(DLGLOBAL, LOGL_INFO, "gtp flood tx worker starting (%u started, %u running)\n", + LOGP(DLGLOBAL, LOGL_INFO, "gtp flood tx worker %d starting (%u started, %u running)\n", + worker_id, gtp_flood->tx_workers_started, gtp_flood->tx_workers_running); @@ -388,14 +394,11 @@ static void *gtp_flood_tx_worker_thread(void *_worker) num_submitted_total += num_submitted; if (num_pending > 0) num_pending_total += num_pending; - //printf("\nnum_submitted=%5d/%5d num_pending=%5d/%5d tx_flows_ended=%5d/%5d\n", - // num_submitted, num_submitted_total, num_pending, num_pending_total, tx_flows_ended, tx_flows_count); } - printf("\nnum_submitted=%d,%d tx_flows_ended=%d/%d\n", - num_submitted_total, num_pending_total, tx_flows_ended, tx_flows_count); gtp_flood->tx_workers_running--; - LOGP(DLGLOBAL, LOGL_INFO, "gtp flood tx worker done (%u started, %u running)\n", + LOGP(DLGLOBAL, LOGL_INFO, "gtp flood tx worker %d done (%u started, %u running)\n", + worker_id, gtp_flood->tx_workers_started, gtp_flood->tx_workers_running); return NULL; @@ -424,6 +427,8 @@ void rx_completion(struct gtp_flood_worker *worker, struct io_uring_cqe *cqe) if (len > 0) { flow->received_udp_packets++; flow->received_udp_bytes += len; + worker->rx_packets++; + worker->rx_bytes += len; } io_uring_cqe_seen(&worker->ring, cqe); @@ -438,7 +443,7 @@ static void *gtp_flood_rx_worker_thread(void *_worker) osmo_ctx_init(__func__); - gtp_flood->rx_workers_started++; + int worker_id = gtp_flood->rx_workers_started++; gtp_flood->rx_workers_running++; LOGP(DLGLOBAL, LOGL_INFO, "gtp rx worker starting (%u started, %u running)\n", @@ -471,6 +476,42 @@ static void *gtp_flood_rx_worker_thread(void *_worker) completed++; } + /* periodically log rx stats */ + if (1) { + static time_t last_info_log = 0; + time_t now; + time_t diff_time; + now = time(NULL); + if (!last_info_log) + diff_time = 1; + else + diff_time = now - last_info_log; + /* the resolution is in seconds, output stats once per second. */ + if (diff_time > 0) { + static uint64_t last_total_packets = 0; + static uint64_t last_total_bytes = 0; + uint64_t diff_packets; + uint64_t diff_bytes; + last_info_log = now; + + diff_packets = worker->rx_packets - last_total_packets; + diff_bytes = worker->rx_bytes - last_total_bytes; + last_total_packets = worker->rx_packets; + last_total_bytes = worker->rx_bytes; + + if (diff_packets) { + LOGP(DLGLOBAL, LOGL_INFO, + "%d: rx %"PRIu64" packets %"PRIu64"Mb (%"PRIu64"Mb/s)\n", + worker_id, + worker->rx_packets, worker->rx_bytes / (1024*1024), + (diff_bytes / diff_time) / (1024*1024)); + + /* mark that something happened to not enter the wait below */ + completed++; + } + } + } + /* Nothing happened in this loop, wait for the next event */ if (!submitted && !completed) { if (io_uring_wait_cqe_timeout(&worker->ring, &cqe, &ts_1s) == 0) {