Commit ad077ce2 authored by Joanne Hugé's avatar Joanne Hugé

Remove JSON formatting for histograms

parent 08bfdac7
......@@ -129,7 +129,7 @@ static void *packet_sending_thread(void *p) {
clock_gettime(CLOCK_MONOTONIC, &measures_start);
if(thread_params.start_ts)
if (thread_params.start_ts)
next = uint_to_ts(thread_params.start_ts);
else
clock_gettime(CLOCK_REALTIME, &next);
......@@ -283,18 +283,15 @@ int main(int argc, char *argv[]) {
usleep(main_params.refresh_rate);
if (main_params.verbose) {
// RTT stats printing
if (tsn_task == RTT_TASK) {
// N_CYCLES, RTT min / avg / max
printf("%9" PRIu64 ": RTT: %4d %4d %4d\n", nb_cycles, rtt_stats.min_rtt,
rtt_stats.avg_rtt, rtt_stats.max_rtt);
printf("\033[%dA", 1);
// Packet send stats printing
// Packet send stats printing
} else {
// N_CYCLES, error queue, measured send interval min / avg / max
printf("%9" PRIu64 ": [%4d, %4d], I (10us): %3d %3d %3d", nb_cycles,
(int)egress_stats.invalid_parameter,
......@@ -356,7 +353,7 @@ static void do_tsn_task(char *data, uint64_t next_txtime) {
}
}
/* Print histograms in .json format
/* Print histogram
*/
static void print_histograms() {
uint64_t duration;
......@@ -372,19 +369,6 @@ static void print_histograms() {
interval = thread_params.interval / 1000;
printf(
"{\"measure_sets\": [{"
"\"measure_type\": \"%s\","
"\"props_names\": [\"%s\"],"
"\"units\": [\"us\"],"
"\"props_type\": \"histogram\","
"\"metadata\": {\"i\": \"%dus\", \"duration\": \"%dh%d\", "
"\"etf_offset\": \"%dus\"},"
"\"props\": [[",
(tsn_task == SEND_PACKET_TASK) ? "packet_send_timestamps" : "packet_rtt",
(tsn_task == SEND_PACKET_TASK) ? "kernel_space" : "rtt", interval,
duration_hour, duration_minutes, thread_params.etf_offset);
if (tsn_task == SEND_PACKET_TASK) {
histogram = kernel_latency_hist;
max_hist_val = histogram_max(histogram, MAX_KERNEL_LATENCY - 1);
......@@ -393,9 +377,15 @@ static void print_histograms() {
max_hist_val = histogram_max(histogram, MAX_RTT - 1);
}
for (int j = 0; j < max_hist_val; j++)
printf("%" PRIi64 "%s", histogram[j], (j + 1 < max_hist_val ? ", " : ""));
printf("]]}]}\n");
printf(
"Duration: %dh%d\n"
"High kernel latencies: %" PRIu64 "\n"
"Invalid parameters: %" PRIu64 "\n"
"Missed deadlines: %" PRIu64 "\n",
duration_hour, duration_minutes, egress_stats.high_kernel_latency,
egress_stats.invalid_parameter, egress_stats.missed_deadline);
for (int j = 0; j < max_hist_val; j++) printf("%" PRIi64 "\n", histogram[j]);
}
static void sighand(int sig_num) {
......@@ -407,7 +397,6 @@ static void sighand(int sig_num) {
/* Process bash options
*/
static void process_options(int argc, char *argv[]) {
for (;;) {
int c = getopt(argc, argv, "a:bc:d:e:ghi:l:p:q:r:s:tvT");
......
......@@ -25,10 +25,10 @@
#include <unistd.h>
#include "common.h"
#include "gpio.h"
#include "recv_packet.h"
#include "send_packet.h"
#include "tracer.h"
#include "gpio.h"
// Structs
......@@ -117,13 +117,11 @@ static void *emit_signal_thread(void *p) {
pthread_mutex_lock(&emit_signal_mutex);
for (;;) {
pthread_cond_wait(&emit_signal_ts_received, &emit_signal_mutex);
clock_nanosleep(CLOCK_TAI, TIMER_ABSTIME, &emit_signal_next, NULL);
toggle_gpio(49);
printf("Toggled GPIO\n");
}
pthread_mutex_unlock(&emit_signal_mutex);
......@@ -144,7 +142,8 @@ static void *tsn_thread(void *p) {
CPU_ZERO(&mask);
CPU_SET(thread_params.affinity_cpu, &mask);
if (sched_setaffinity(0, sizeof(mask), &mask))
error(EXIT_FAILURE, errno, "Could not set CPU affinity to CPU %d\n", thread_params.affinity_cpu);
error(EXIT_FAILURE, errno, "Could not set CPU affinity to CPU %d\n",
thread_params.affinity_cpu);
}
clock_gettime(CLOCK_MONOTONIC, &measures_start);
......@@ -171,7 +170,7 @@ static void *tsn_thread(void *p) {
// Emit signal
if (thread_params.emit_signal) {
uint64_t emit_signal_t = *((uint64_t *) ingress_stats.data);
uint64_t emit_signal_t = *((uint64_t *)ingress_stats.data);
pthread_mutex_lock(&emit_signal_mutex);
emit_signal_next = uint_to_ts(emit_signal_t);
......@@ -222,8 +221,7 @@ static void *tsn_thread(void *p) {
return NULL;
}
static void create_thread(void * (*thread_function)(void *)) {
static void create_thread(void *(*thread_function)(void *)) {
pthread_t thread;
pthread_attr_t attr;
struct sched_param param;
......@@ -257,7 +255,6 @@ static void create_thread(void * (*thread_function)(void *)) {
// Create the real time thread
if (pthread_create(&thread, &attr, thread_function, NULL))
error(EXIT_FAILURE, errno, "Couldn't create packet receiving thread");
}
/* Main thread:
......@@ -265,7 +262,6 @@ static void create_thread(void * (*thread_function)(void *)) {
* - Handles the IO and creates real time threads
*/
int main(int argc, char *argv[]) {
// Initial values
ingress_stats.min_interval = INT_MAX;
ingress_stats.avg_interval = 0;
......@@ -318,7 +314,7 @@ int main(int argc, char *argv[]) {
if (tsn_task == RTT_TASK)
init_udp_send(&egress_params, &egress_stats, 0, 0, NULL);
if(thread_params.emit_signal) {
if (thread_params.emit_signal) {
pthread_mutex_init(&emit_signal_mutex, NULL);
pthread_cond_init(&emit_signal_ts_received, NULL);
......@@ -378,47 +374,29 @@ static void print_histograms() {
interval = thread_params.interval / 1000;
if (enable_timestamps) {
printf(
"{\"measure_sets\": [{"
"\"measure_type\": \"packet_recv_timestamps\","
"\"props_names\": [\"kernel_space\"],"
"\"units\": [\"us\"],"
"\"props_type\": \"histogram\","
"\"metadata\": {\"i\": \"%dus\", \"duration\": \"%dh%d\","
"\"lost_packets\": \"%d\"},"
"\"props\": [[",
interval, duration_hour, duration_minutes,
((int)ingress_stats.high_jitter));
max_jitter = histogram_max(jitter_hist, MAX_JITTER - 1);
min_jitter = histogram_min(jitter_hist, MAX_JITTER - 1);
if (enable_timestamps) {
max_latency = histogram_max(kernel_latency_hist, MAX_KERNEL_LATENCY - 1);
printf(
"Duration: %dh%d\n"
"Lost packets: %" PRIu64 "\n",
duration_hour, duration_minutes, ingress_stats.high_jitter);
for (int j = 0; j < max_latency; j++)
printf("%" PRIi64 "%s", kernel_latency_hist[j],
(j + 1 < max_latency ? ", " : ""));
printf("]]");
printf("%" PRIi64 "\n", kernel_latency_hist[j]);
}
max_jitter = histogram_max(jitter_hist, MAX_JITTER - 1);
min_jitter = histogram_min(jitter_hist, MAX_JITTER - 1);
printf("%s", enable_timestamps ? "}, {" : "{\"measure_sets\": [{");
printf(
"\"measure_type\": \"packet_jitter\","
"\"props_names\": [\"jitter\"],"
"\"units\": [\"us\"],"
"\"props_type\": \"histogram\","
"\"middle\": \"%d\","
"\"metadata\": {\"i\": \"%dus\", \"duration\": \"%dh%d\","
"\"lost_packets\": \"%d\"},"
"\"props\": [[",
MAX_JITTER / 2 - min_jitter, interval, duration_hour, duration_minutes,
((int)ingress_stats.high_jitter));
"Middle: %d\n"
"Lost packets\": %" PRIu64 "\n",
MAX_JITTER / 2 - min_jitter, duration_hour, duration_minutes,
ingress_stats.high_jitter);
for (int j = min_jitter; j < max_jitter; j++)
printf("%" PRIi64 "%s", jitter_hist[j], (j + 1 < max_jitter ? ", " : ""));
printf("]]}]}\n");
printf("%" PRIi64 "\n", jitter_hist[j]);
}
static void sighand(int sig_num) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment