diff --git a/README-json.md b/README-json.md index 5ef383525..b6599aa58 100644 --- a/README-json.md +++ b/README-json.md @@ -104,12 +104,16 @@ Each period has the following subkeys: * reader: milliseconds spent reading sample data over USB from a SDR dongle * background: milliseconds spent doing network I/O, processing received network messages, and periodic tasks. * cpr: statistics about Compact Position Report message decoding. Has subkeys: + * surface: total number of surface CPR messages received + * airborne: total number of airborne CPR messages received * global_ok: global positions successfuly derived * global_bad: global positions that were rejected because they were inconsistent * global_range: global positions that were rejected because they exceeded the receiver max range * global_speed: global positions that were rejected because they failed the inter-position speed check * global_skipped: global position attempts skipped because we did not have the right data (e.g. even/odd messages crossed a zone boundary) * local_ok: local (relative) positions successfully found + * local_aircraft_relative: local positions found relative to a previous aircraft position + * local_receiver_relative: local positions found relative to the receiver position * local_skipped: local (relative) positions not used because we did not have the right data * local_range: local positions not used because they exceeded the receiver max range or fell into the ambiguous part of the receiver range * local_speed: local positions not used because they failed the inter-position speed check diff --git a/debian/changelog b/debian/changelog index b140dd51e..5fc26bf07 100644 --- a/debian/changelog +++ b/debian/changelog @@ -44,7 +44,7 @@ dump1090-mutability (1.14) UNRELEASED; urgency=medium garbage). * Fix stats timestamp output during the period shortly after restart. * Include timezone in timestamps shown with --stats - * Add stats for CPR speed/range filtering. + * Add various stats for CPR position-decoding details. * Webmap: * Fix webmap history loading when no history is present. diff --git a/net_io.c b/net_io.c index 1ac91febe..c282da7b4 100644 --- a/net_io.c +++ b/net_io.c @@ -880,12 +880,16 @@ static char * appendStatsJson(char *p, uint64_t background_cpu_millis = (uint64_t)st->background_cpu.tv_sec*1000UL + st->background_cpu.tv_nsec/1000000UL; p += snprintf(p, end-p, - ",\"cpr\":{\"global_ok\":%u" + ",\"cpr\":{\"surface\":%u" + ",\"airborne\":%u" + "\"global_ok\":%u" ",\"global_bad\":%u" ",\"global_range\":%u" ",\"global_speed\":%u" ",\"global_skipped\":%u" ",\"local_ok\":%u" + ",\"local_aircraft_relative\":%u" + ",\"local_receiver_relative\":%u" ",\"local_skipped\":%u" ",\"local_range\":%u" ",\"local_speed\":%u" @@ -894,12 +898,16 @@ static char * appendStatsJson(char *p, ",\"tracks\":{\"all\":%u" ",\"single_message\":%u}" ",\"messages\":%u}", + st->cpr_surface, + st->cpr_airborne, st->cpr_global_ok, st->cpr_global_bad, st->cpr_global_range_checks, st->cpr_global_speed_checks, st->cpr_global_skipped, st->cpr_local_ok, + st->cpr_local_aircraft_relative, + st->cpr_local_receiver_relative, st->cpr_local_skipped, st->cpr_local_range_checks, st->cpr_local_speed_checks, diff --git a/stats.c b/stats.c index 6f2c70d72..13e1b0c4a 100644 --- a/stats.c +++ b/stats.c @@ -122,22 +122,30 @@ void display_stats(struct stats *st) { printf("%u total usable messages\n", st->messages_total); - printf("%u global CPR attempts with valid positions\n" + printf("%u surface position messages received\n" + "%u airborne position messages received\n" + "%u global CPR attempts with valid positions\n" "%u global CPR attempts with bad data\n" " %u global CPR attempts that failed the range check\n" " %u global CPR attempts that failed the speed check\n" "%u global CPR attempts with insufficient data\n" "%u local CPR attempts with valid positions\n" - "%u local CPR attempts with insufficient data\n" + " %u aircraft-relative positions\n" + " %u receiver-relative positions\n" + "%u local CPR attempts that did not produce useful positions\n" " %u local CPR attempts that failed the range check\n" " %u local CPR attempts that failed the speed check\n" "%u CPR messages that look like transponder failures filtered\n", + st->cpr_surface, + st->cpr_airborne, st->cpr_global_ok, st->cpr_global_bad, st->cpr_global_range_checks, st->cpr_global_speed_checks, st->cpr_global_skipped, st->cpr_local_ok, + st->cpr_local_aircraft_relative, + st->cpr_local_receiver_relative, st->cpr_local_skipped, st->cpr_local_range_checks, st->cpr_local_speed_checks, @@ -233,12 +241,16 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t target->http_requests = st1->http_requests + st2->http_requests; // CPR decoding: + target->cpr_surface = st1->cpr_surface + st2->cpr_surface; + target->cpr_airborne = st1->cpr_airborne + st2->cpr_airborne; target->cpr_global_ok = st1->cpr_global_ok + st2->cpr_global_ok; target->cpr_global_bad = st1->cpr_global_bad + st2->cpr_global_bad; target->cpr_global_skipped = st1->cpr_global_skipped + st2->cpr_global_skipped; target->cpr_global_range_checks = st1->cpr_global_range_checks + st2->cpr_global_range_checks; target->cpr_global_speed_checks = st1->cpr_global_speed_checks + st2->cpr_global_speed_checks; target->cpr_local_ok = st1->cpr_local_ok + st2->cpr_local_ok; + target->cpr_local_aircraft_relative = st1->cpr_local_aircraft_relative + st2->cpr_local_aircraft_relative; + target->cpr_local_receiver_relative = st1->cpr_local_receiver_relative + st2->cpr_local_receiver_relative; target->cpr_local_skipped = st1->cpr_local_skipped + st2->cpr_local_skipped; target->cpr_local_range_checks = st1->cpr_local_range_checks + st2->cpr_local_range_checks; target->cpr_local_speed_checks = st1->cpr_local_speed_checks + st2->cpr_local_speed_checks; diff --git a/stats.h b/stats.h index d855b2492..7c9cd7d2f 100644 --- a/stats.h +++ b/stats.h @@ -99,6 +99,8 @@ struct stats { uint32_t http_requests; // CPR decoding: + unsigned int cpr_surface; + unsigned int cpr_airborne; unsigned int cpr_global_ok; unsigned int cpr_global_bad; unsigned int cpr_global_skipped; @@ -108,6 +110,8 @@ struct stats { unsigned int cpr_local_skipped; unsigned int cpr_local_range_checks; unsigned int cpr_local_speed_checks; + unsigned int cpr_local_aircraft_relative; + unsigned int cpr_local_receiver_relative; unsigned int cpr_filtered; // aircraft: diff --git a/track.c b/track.c index f1d66d6a1..8a8b8499c 100644 --- a/track.c +++ b/track.c @@ -326,6 +326,11 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm, uint64_t double new_lat = 0, new_lon = 0; unsigned new_nuc = 0; + if (mm->bFlags & MODES_ACFLAGS_AOG) + ++Modes.stats_current.cpr_surface; + else + ++Modes.stats_current.cpr_airborne; + if (mm->bFlags & MODES_ACFLAGS_AOG) { // Surface: 25 seconds if >25kt or speed unknown, 50 seconds otherwise @@ -390,6 +395,10 @@ static void updatePosition(struct aircraft *a, struct modesMessage *mm, uint64_t Modes.stats_current.cpr_local_skipped++; } else { Modes.stats_current.cpr_local_ok++; + if (a->bFlags & MODES_ACFLAGS_LATLON_REL_OK) + Modes.stats_current.cpr_local_aircraft_relative++; + else + Modes.stats_current.cpr_local_receiver_relative++; mm->bFlags |= MODES_ACFLAGS_REL_CPR_USED; } }