Commit 70b0fa2c authored by Joanne Hugé's avatar Joanne Hugé

Print lost packets

parent 773ed882
......@@ -35,6 +35,7 @@ typedef struct thread_stat {
uint64_t max_interval;
int packets_received;
packet_info_t packet_info;
int lost_packets;
} thread_stat_t;
typedef struct thread_param {
......@@ -106,6 +107,7 @@ static void *packet_receiving_thread(void *p) {
uint64_t diff = 0;
cpu_set_t mask;
int64_t dist_to_interval;
int prev_packet_id = 0;
stats->min_interval = UINT64_MAX;
stats->max_interval = 0;
......@@ -134,15 +136,23 @@ static void *packet_receiving_thread(void *p) {
} else if (tsn_task == RECV_PACKET_TASK) {
int current_packet_id;
param->stats.packet_info = recv_udp_packet(enable_timestamps, enable_histograms, histograms);
clock_gettime(CLOCK_MONOTONIC, &current);
// If this is not the first received packet
if (stats->packets_received) {
diff = calcdiff_ns(current, previous);
stats->min_interval = diff < stats->min_interval ? diff : stats->min_interval;
stats->max_interval = diff > stats->max_interval ? diff : stats->max_interval;
// Check if packets were lost
current_packet_id = atoi(param->stats.packet_info.data);
param->stats.lost_packets += current_packet_id - prev_packet_id - 1;
if(enable_histograms) {
dist_to_interval = (((int64_t)diff) - param->interval) / 1000;
dist_to_interval += MAX_HIST_VAL / 2;
......@@ -157,6 +167,7 @@ static void *packet_receiving_thread(void *p) {
}
previous = current;
prev_packet_id = current_packet_id;
}
}
......@@ -217,10 +228,11 @@ int main(int argc, char *argv[]) {
if(tsn_task == RECV_PACKET_TASK) {
diff = ((int64_t)stats->max_interval) - stats->min_interval;
printf( "(%d) Jitter : %" PRIi64 " [Packet data: %s]\n",
printf( "(%d) Jitter : %" PRIi64 " [Packet data: %s] [Lost packets: %d]\n",
stats->packets_received,
diff,
stats->packet_info.data);
stats->packet_info.data,
stats->lost_packets);
if(enable_timestamps) {
printf("(%d) Enter send_udp_packet timestamp: %" PRIu64 "\n",
......
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