Skip to content
This repository has been archived by the owner on Sep 14, 2019. It is now read-only.

Commit

Permalink
More CPR stats.
Browse files Browse the repository at this point in the history
  • Loading branch information
mutability committed Feb 19, 2015
1 parent 46ad97d commit f6d2f3d
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 4 deletions.
4 changes: 4 additions & 0 deletions README-json.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion debian/changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 9 additions & 1 deletion net_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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,
Expand Down
16 changes: 14 additions & 2 deletions stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions stats.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down
9 changes: 9 additions & 0 deletions track.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
}
}
Expand Down

0 comments on commit f6d2f3d

Please sign in to comment.