diff --git a/README-json.md b/README-json.md index 89f73f6..0ff189e 100644 --- a/README-json.md +++ b/README-json.md @@ -109,4 +109,9 @@ Each period has the following subkeys: * local_ok: local (relative) positions successfully found * local_skipped: local (relative) positions not used because we did not have the right data (e.g. position was ambiguous given the receiver range) * filtered: number of CPR messages ignored because they matched one of the heuristics for faulty transponder output + * tracks: statistics on aircraft tracks. Each track represents a unique aircraft and persists for up to 5 minutes after the last message + from the aircraft is heard. If messages from the same aircraft are subsequently heard after the 5 minute period, this will be counted + as a new track. + * all: total tracks created + * single_message: tracks consisting of only a single message. These are usually due to message decoding errors that produce a bad aircraft address. * messages: total number of messages accepted by dump1090 from any source diff --git a/net_io.c b/net_io.c index 7ecbab2..8f9821b 100644 --- a/net_io.c +++ b/net_io.c @@ -887,6 +887,8 @@ static char * appendStatsJson(char *p, ",\"local_skipped\":%u" ",\"filtered\":%u}" ",\"cpu\":{\"demod\":%llu,\"reader\":%llu,\"background\":%llu}" + ",\"tracks\":{\"all\":%u" + ",\"single_message\":%u}" ",\"messages\":%u}", st->cpr_global_ok, st->cpr_global_bad, @@ -897,6 +899,8 @@ static char * appendStatsJson(char *p, (unsigned long long)demod_cpu_millis, (unsigned long long)reader_cpu_millis, (unsigned long long)background_cpu_millis, + st->unique_aircraft, + st->single_message_aircraft, st->messages_total); } diff --git a/stats.c b/stats.c index 59e0eff..2c69592 100644 --- a/stats.c +++ b/stats.c @@ -132,6 +132,9 @@ void display_stats(struct stats *st) { st->cpr_local_skipped, st->cpr_filtered); + printf("%u unique aircraft tracks\n", st->unique_aircraft); + printf("%u aircraft tracks where only one message was seen\n", st->single_message_aircraft); + if (Modes.net && Modes.net_http_port) printf("%d HTTP requests\n", st->http_requests); @@ -150,6 +153,7 @@ void display_stats(struct stats *st) { (unsigned long long) background_cpu_millis); } + fflush(stdout); } @@ -224,5 +228,9 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t target->cpr_local_ok = st1->cpr_local_ok + st2->cpr_local_ok; target->cpr_local_skipped = st1->cpr_local_skipped + st2->cpr_local_skipped; target->cpr_filtered = st1->cpr_filtered + st2->cpr_filtered; + + // aircraft + target->unique_aircraft = st1->unique_aircraft + st2->unique_aircraft; + target->single_message_aircraft = st1->single_message_aircraft + st2->single_message_aircraft; } diff --git a/stats.h b/stats.h index c878594..22d4845 100644 --- a/stats.h +++ b/stats.h @@ -105,6 +105,12 @@ struct stats { unsigned int cpr_local_ok; unsigned int cpr_local_skipped; unsigned int cpr_filtered; + + // aircraft: + // total "new" aircraft (i.e. not seen in the last 30 or 300s) + unsigned int unique_aircraft; + // we saw only a single message + unsigned int single_message_aircraft; }; void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target); diff --git a/track.c b/track.c index 593dc0c..4cd504a 100644 --- a/track.c +++ b/track.c @@ -84,6 +84,8 @@ struct aircraft *trackCreateAircraft(struct modesMessage *mm) { // Copy the first message so we can emit it later when a second message arrives. a->first_message = *mm; + Modes.stats_current.unique_aircraft++; + return (a); } @@ -490,6 +492,11 @@ static void trackRemoveStaleAircraft(time_t now) while(a) { if ((now - a->seen) > TRACK_AIRCRAFT_TTL || (a->messages == 1 && (now - a->seen) > TRACK_AIRCRAFT_ONEHIT_TTL)) { + // Count aircraft where we saw only one message before reaping them. + // These are likely to be due to messages with bad addresses. + if (a->messages == 1) + Modes.stats_current.single_message_aircraft++; + // Remove the element from the linked list, with care // if we are removing the first element if (!prev) {