diff --git a/demod_2000.c b/demod_2000.c index e433138..0c59958 100644 --- a/demod_2000.c +++ b/demod_2000.c @@ -346,7 +346,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { useModesMessage(&mm); j += MODEAC_MSG_SAMPLES; - Modes.stats_current.ModeAC++; + Modes.stats_current.demod_modeac++; continue; } } @@ -398,7 +398,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { dumpRawMessage("Too high level in samples between 10 and 15", msg, m, j); continue; } - Modes.stats_current.valid_preamble++; + Modes.stats_current.demod_preambles++; } else { @@ -407,7 +407,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { // Make a copy of the Payload, and phase correct the copy memcpy(aux, &pPreamble[-1], sizeof(aux)); applyPhaseCorrection(&aux[1]); - Modes.stats_current.out_of_phase++; pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES]; // TODO ... apply other kind of corrections } @@ -475,7 +474,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { msglen = MODES_SHORT_MSG_BITS; msg[0] ^= theErrs; errorsTy = 0; errors = errors56; // revert to the number of errors prior to bit 56 - Modes.stats_current.DF_Len_Corrected++; } else if (i < MODES_LONG_MSG_BITS) { msglen = MODES_SHORT_MSG_BITS; @@ -517,7 +515,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { if (validDFbits & thisDFbit) { // Yep, more likely, so update the main message msg[0] = theByte; - Modes.stats_current.DF_Type_Corrected++; errors--; // decrease the error count so we attempt to use the modified DF. } } @@ -538,37 +535,26 @@ void demodulate2000(uint16_t *m, uint32_t mlen) { if ( (msglen) && ((2 * snr) > (int) (MODES_MSG_SQUELCH_DB * 10)) && (errors <= MODES_MSG_ENCODER_ERRS) ) { + int result; + // Set initial mm structure details mm.timestampMsg = Modes.timestampBlk + (j*6); mm.signalLevel = (365.0*60 + sigLevel + noiseLevel) * (365.0*60 + sigLevel + noiseLevel) / MAX_POWER / 60 / 60; - mm.phase_corrected = use_correction; // Decode the received message - message_ok = (decodeModesMessage(&mm, msg) >= 0); + result = decodeModesMessage(&mm, msg); + if (result < 0) { + message_ok = 0; + if (result == -1) + Modes.stats_current.demod_rejected_unknown_icao++; + else + Modes.stats_current.demod_rejected_bad++; + } else { + message_ok = 1; + Modes.stats_current.demod_accepted[mm.correctedbits]++; + } // Update statistics - if (Modes.stats) { - struct demod_stats *dstats = (use_correction ? &Modes.stats_current.demod_phasecorrected : &Modes.stats_current.demod); - - switch (errors) { - case 0: dstats->demodulated0++; break; - case 1: dstats->demodulated1++; break; - case 2: dstats->demodulated2++; break; - default: dstats->demodulated3++; break; - } - - if (!message_ok) { - dstats->badcrc++; - } else if (mm.correctedbits == 0) { - dstats->goodcrc++; - dstats->goodcrc_byphase[0]++; - } else { - dstats->badcrc++; - dstats->fixed++; - if (mm.correctedbits <= MODES_MAX_BITERRORS) - dstats->bit_fix[mm.correctedbits-1] += 1; - } - } // Output debug mode info if needed if (use_correction) { diff --git a/demod_2400.c b/demod_2400.c index 1a73df8..0a493a3 100644 --- a/demod_2400.c +++ b/demod_2400.c @@ -259,7 +259,6 @@ void demodulate2400(uint16_t *m, uint32_t mlen) { preamble[16] >= high || preamble[17] >= high || preamble[18] >= high) { - ++Modes.stats_current.preamble_not_quiet; continue; } @@ -270,16 +269,14 @@ void demodulate2400(uint16_t *m, uint32_t mlen) { // Crosscorrelate against the first few bits to find a likely phase offset initial_phase = best_phase(&preamble[19]); if (initial_phase < 0) { - ++Modes.stats_current.preamble_no_correlation; continue; // nothing satisfactory } - Modes.stats_current.preamble_phase[initial_phase%MODES_MAX_PHASE_STATS]++; first_phase = last_phase = initial_phase; // try only the phase we think it is } - Modes.stats_current.valid_preamble++; - bestmsg = NULL; bestscore = -1; bestphase = -1; + Modes.stats_current.demod_preambles++; + bestmsg = NULL; bestscore = -2; bestphase = -1; for (try_phase = first_phase; try_phase <= last_phase; ++try_phase) { uint16_t *pPtr; int phase, i, score, bytelen; @@ -407,8 +404,11 @@ void demodulate2400(uint16_t *m, uint32_t mlen) { } // Do we have a candidate? - if (!bestmsg) { - Modes.stats_current.demod.badcrc++; + if (bestscore < 0) { + if (bestscore == -1) + Modes.stats_current.demod_rejected_unknown_icao++; + else + Modes.stats_current.demod_rejected_bad++; continue; // nope. } @@ -442,22 +442,20 @@ void demodulate2400(uint16_t *m, uint32_t mlen) { } // Decode the received message - if (decodeModesMessage(&mm, bestmsg) < 0) - continue; - - // Update statistics - if (Modes.stats) { - if (mm.correctedbits == 0) { - Modes.stats_current.demod.goodcrc++; - Modes.stats_current.demod.goodcrc_byphase[bestphase%MODES_MAX_PHASE_STATS]++; + { + int result = decodeModesMessage(&mm, bestmsg); + if (result < 0) { + if (result == -1) + Modes.stats_current.demod_rejected_unknown_icao++; + else + Modes.stats_current.demod_rejected_bad++; + continue; } else { - Modes.stats_current.demod.badcrc++; - Modes.stats_current.demod.fixed++; - if (mm.correctedbits) - Modes.stats_current.demod.bit_fix[mm.correctedbits-1]++; + Modes.stats_current.demod_accepted[mm.correctedbits]++; } } + // Skip over the message: // (we actually skip to 8 bits before the end of the message, // because we can often decode two messages that *almost* collide, diff --git a/dump1090.h b/dump1090.h index c949f14..f757a1b 100644 --- a/dump1090.h +++ b/dump1090.h @@ -398,13 +398,11 @@ struct modesMessage { int msgtype; // Downlink format # uint32_t crc; // Message CRC int correctedbits; // No. of bits corrected - char corrected[MODES_MAX_BITERRORS]; // corrected bit positions - uint32_t addr; // ICAO Address from bytes 1 2 and 3 - int phase_corrected; // True if phase correction was applied + uint32_t addr; // Address Announced uint64_t timestampMsg; // Timestamp of the message int remote; // If set this message is from a remote station double signalLevel; // RSSI, in the range [0..1], as a fraction of full-scale power - int score; + int score; // Scoring from scoreModesMessage, if used // DF 11, DF 17 int ca; // Responder capabilities diff --git a/mode_s.c b/mode_s.c index 042dfe1..f6c3d91 100644 --- a/mode_s.c +++ b/mode_s.c @@ -312,7 +312,8 @@ static int correct_aa_field(uint32_t *addr, struct errorinfo *ei) // 1000: DF20/21 with a CRC-derived address matching a known aircraft // 500: DF20/21 with a CRC-derived address matching a known aircraft (bottom 16 bits only - overlay control in use) -// -1: bad message +// -1: message might be valid, but we couldn't validate the CRC against a known ICAO +// -2: bad message or unrepairable CRC error int scoreModesMessage(unsigned char *msg, int validbits) { @@ -321,13 +322,13 @@ int scoreModesMessage(unsigned char *msg, int validbits) struct errorinfo *ei; if (validbits < 56) - return -1; + return -2; msgtype = msg[0] >> 3; // Downlink Format msgbits = modesMessageLenByType(msgtype); if (validbits < msgbits) - return -1; + return -2; crc = modesChecksum(msg, msgbits); @@ -346,7 +347,7 @@ int scoreModesMessage(unsigned char *msg, int validbits) ei = modesChecksumDiagnose(crc, msgbits); if (!ei) - return -1; // can't correct errors + return -2; // can't correct errors // fix any errors in the address field correct_aa_field(&addr, ei); @@ -368,7 +369,7 @@ int scoreModesMessage(unsigned char *msg, int validbits) case 18: // Extended squitter/non-transponder ei = modesChecksumDiagnose(crc, msgbits); if (!ei) - return -1; // can't correct errors + return -2; // can't correct errors // fix any errors in the address field addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]); @@ -391,11 +392,11 @@ int scoreModesMessage(unsigned char *msg, int validbits) return 500; // Data/Parity #endif - return -1; + return -2; default: // unknown message type - return -1; + return -2; } } @@ -410,7 +411,10 @@ static void decodeExtendedSquitter(struct modesMessage *mm); static void decodeCommB(struct modesMessage *mm); static char *ais_charset = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?"; -// return 0 if all OK, -1 if the message was rejected +// return 0 if all OK +// -1: message might be valid, but we couldn't validate the CRC against a known ICAO +// -2: bad message or unrepairable CRC error + int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) { // Work on our local copy @@ -435,8 +439,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) // We can't tell if the CRC is correct or not as we don't know the correct address. // Accept the message if it appears to be from a previously-seen aircraft if (!icaoFilterTest(mm->crc)) { - //fprintf(stderr, "reject: AP doesn't match known ICAO\n"); - return -1; + return -1; } mm->addr = mm->crc; break; @@ -453,8 +456,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) int addr; struct errorinfo *ei = modesChecksumDiagnose(mm->crc & 0xffff80, mm->msgbits); if (!ei) { - //fprintf(stderr, "reject: DF11 uncorrectable CRC error\n"); - return -1; // couldn't fix it + return -2; // couldn't fix it } mm->correctedbits = ei->errors; modesChecksumFix(msg, ei); @@ -464,7 +466,6 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) // match an existing aircraft. addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]); if (!icaoFilterTest(addr)) { - //fprintf(stderr, "reject: DF11 CRC error, repaired address doesn't match known ICAO\n"); return -1; } } @@ -482,8 +483,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) ei = modesChecksumDiagnose(mm->crc, mm->msgbits); if (!ei) { - //fprintf(stderr, "reject: DF17/18 uncorrectable CRC error\n"); - return -1; // couldn't fix it + return -2; // couldn't fix it } addr1 = (msg[1] << 16) | (msg[2] << 8) | (msg[3]); @@ -494,7 +494,6 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) // we are conservative here: only accept corrected messages that // match an existing aircraft. if (addr1 != addr2 && !icaoFilterTest(addr2)) { - //fprintf(stderr, "reject: DF17/18 CRC corrected address, repaired address doesn't match known ICAO\n"); return -1; } @@ -528,12 +527,11 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg) } #endif - //fprintf(stderr, "reject: DF20/21 address doesn't match known ICAO\n"); return -1; // no good default: // All other message types, we don't know how to handle their CRCs, give up - return -1; + return -2; } // decode the bulk of the message diff --git a/net_io.c b/net_io.c index a1ed88a..ca6bb18 100644 --- a/net_io.c +++ b/net_io.c @@ -579,13 +579,21 @@ int decodeBinMessage(struct client *c, char *p) { } if (msgLen == MODEAC_MSG_BYTES) { // ModeA or ModeC + Modes.stats_current.remote_received_modeac++; decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1])); } else { - if (decodeModesMessage(&mm, msg) < 0) { - Modes.stats_current.remote_rejected++; + int result; + + Modes.stats_current.remote_received_modes++; + result = decodeModesMessage(&mm, msg); + if (result < 0) { + if (result == -1) + Modes.stats_current.remote_rejected_unknown_icao++; + else + Modes.stats_current.remote_rejected_bad++; return 0; } else { - Modes.stats_current.remote_accepted++; + Modes.stats_current.remote_accepted[mm.correctedbits]++; } } @@ -684,13 +692,21 @@ int decodeHexMessage(struct client *c, char *hex) { } if (l == (MODEAC_MSG_BYTES * 2)) { // ModeA or ModeC + Modes.stats_current.remote_received_modeac++; decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1])); } else { // Assume ModeS - if (decodeModesMessage(&mm, msg) < 0) { - Modes.stats_current.remote_rejected++; + int result; + + Modes.stats_current.remote_received_modes++; + result = decodeModesMessage(&mm, msg); + if (result < 0) { + if (result == -1) + Modes.stats_current.remote_rejected_unknown_icao++; + else + Modes.stats_current.remote_rejected_bad++; return 0; } else { - Modes.stats_current.remote_accepted++; + Modes.stats_current.remote_accepted[mm.correctedbits]++; } } diff --git a/stats.c b/stats.c index e5a915b..14db764 100644 --- a/stats.c +++ b/stats.c @@ -49,25 +49,6 @@ #include "dump1090.h" -static void display_demod_stats(const char *prefix, struct demod_stats *dstats) { - int j; - - printf("%d %sdemodulated with 0 errors\n", dstats->demodulated0, prefix); - printf("%d %sdemodulated with 1 error\n", dstats->demodulated1, prefix); - printf("%d %sdemodulated with 2 errors\n", dstats->demodulated2, prefix); - printf("%d %sdemodulated with > 2 errors\n", dstats->demodulated3, prefix); - printf("%d %swith good crc\n", dstats->goodcrc, prefix); - for (j = 0; j < MODES_MAX_PHASE_STATS; ++j) - if (dstats->goodcrc_byphase[j] > 0) - printf(" %d %swith phase offset %d\n", dstats->goodcrc_byphase[j], prefix, j); - printf("%d %swith bad crc\n", dstats->badcrc, prefix); - printf("%d %serrors corrected\n", dstats->fixed, prefix); - - for (j = 0; j < Modes.nfix_crc; j++) { - printf(" %d %swith %d bit %s\n", dstats->bit_fix[j], prefix, j+1, (j==0)?"error":"errors"); - } -} - void display_stats(struct stats *st) { int j; struct tm tm_start, tm_end; @@ -84,64 +65,63 @@ void display_stats(struct stats *st) { printf("Statistics: %s - %s\n", tb_start, tb_end); - if (!Modes.net_only) { - printf("%d sample blocks processed\n", st->blocks_processed); - printf("%d sample blocks dropped\n", st->blocks_dropped); + if (!Modes.net_only) { + printf("Local receiver:\n"); + printf(" %u sample blocks processed\n", st->blocks_processed); + printf(" %u sample blocks dropped\n", st->blocks_dropped); if (st->blocks_processed > 0) { long cpu_millis = (long)st->cputime.tv_sec*1000L + st->cputime.tv_nsec/1000000L; long sample_millis = (long) ((uint64_t)st->blocks_processed * MODES_ASYNC_BUF_SAMPLES / (Modes.oversample ? 2400 : 2000)); - printf("%ld ms CPU time used to process %ld ms samples, %.1f%% load\n", + printf(" %ld ms CPU time used to process %ld ms samples, %.1f%% load\n", cpu_millis, sample_millis, 100.0 * cpu_millis / sample_millis); } - printf("%d ModeA/C detected\n", st->ModeAC); - printf("%d Mode-S preambles with poor correlation\n", st->preamble_no_correlation); - printf("%d Mode-S preambles with noise in the quiet period\n", st->preamble_not_quiet); - printf("%d valid Mode-S preambles\n", st->valid_preamble); - for (j = 0; j < MODES_MAX_PHASE_STATS; ++j) - if (st->preamble_phase[j] > 0) - printf(" %d with phase offset %d\n", st->preamble_phase[j], j); - printf("%d DF-?? fields corrected for length\n", st->DF_Len_Corrected); - printf("%d DF-?? fields corrected for type\n", st->DF_Type_Corrected); - - display_demod_stats("", &st->demod); - if (Modes.phase_enhance) { - printf("%d phase enhancement attempts\n", st->out_of_phase); - display_demod_stats("phase enhanced ", &st->demod_phasecorrected); - } + printf(" %u Mode A/C messages received\n", st->demod_modeac); + printf(" %u Mode-S message preambles received\n", st->demod_preambles); + printf(" %u with bad message format or invalid CRC\n", st->demod_rejected_bad); + printf(" %u with unrecognized ICAO address\n", st->demod_rejected_unknown_icao); + printf(" %u accepted with correct CRC\n", st->demod_accepted[0]); + for (j = 1; j <= Modes.nfix_crc; ++j) + printf(" %u accepted with %d-bit error repaired\n", st->demod_accepted[j], j); if (st->noise_power_count) { - printf("%.1f dBFS noise floor\n", + printf(" %.1f dBFS noise floor\n", 10 * log10(st->noise_power_sum / st->noise_power_count)); } if (st->signal_power_count) { - printf("%.1f dBFS mean signal power\n", + printf(" %.1f dBFS mean signal power\n", 10 * log10(st->signal_power_sum / st->signal_power_count)); } - printf("%.1f dBFS peak signal power\n", + printf(" %.1f dBFS peak signal power\n", 10 * log10(st->peak_signal_power)); - printf("%u messages with signal power above -3dBFS\n", + printf(" %u messages with signal power above -3dBFS\n", st->strong_signal_count); } - printf("%d remote messages accepted\n" - "%d remote messages rejected\n", - st->remote_accepted, - st->remote_rejected); + if (Modes.net) { + printf("Messages from network clients:\n"); + printf(" %u Mode A/C messages received\n", st->remote_received_modeac); + printf(" %u Mode S messages received\n", st->remote_received_modes); + printf(" %u with bad message format or invalid CRC\n", st->remote_rejected_bad); + printf(" %u with unrecognized ICAO address\n", st->remote_rejected_unknown_icao); + printf(" %u accepted with correct CRC\n", st->remote_accepted[0]); + for (j = 1; j <= Modes.nfix_crc; ++j) + printf(" %u accepted with %d-bit error repaired\n", st->remote_accepted[j], j); + } - printf("%d total usable messages\n", + printf("%u total usable messages\n", st->messages_total); - printf("%d global CPR attempts with valid positions\n" - "%d global CPR attempts with bad data\n" - "%d global CPR attempts with insufficient data\n" - "%d local CPR attempts with valid positions\n" - "%d local CPR attempts with insufficient data\n" - "%d CPR messages that look like transponder failures filtered\n", + printf("%u global CPR attempts with valid positions\n" + "%u global CPR attempts with bad data\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 CPR messages that look like transponder failures filtered\n", st->cpr_global_ok, st->cpr_global_bad, st->cpr_global_skipped, @@ -149,6 +129,9 @@ void display_stats(struct stats *st) { st->cpr_local_skipped, st->cpr_filtered); + if (Modes.net && Modes.net_http_port) + printf("%d HTTP requests\n", st->http_requests); + fflush(stdout); } @@ -157,26 +140,6 @@ void reset_stats(struct stats *st) { *st = st_zero; } -static void add_demod_stats(const struct demod_stats *st1, const struct demod_stats *st2, struct demod_stats *target) -{ - int i; - - target->demodulated0 = st1->demodulated0 + st2->demodulated0; - target->demodulated1 = st1->demodulated1 + st2->demodulated1; - target->demodulated2 = st1->demodulated2 + st2->demodulated2; - target->demodulated3 = st1->demodulated3 + st2->demodulated3; - target->goodcrc = st1->goodcrc + st2->goodcrc; - - for (i = 0; i < MODES_MAX_PHASE_STATS; ++i) - target->goodcrc_byphase[i] = st1->goodcrc_byphase[i] + st2->goodcrc_byphase[i]; - - target->badcrc = st1->badcrc + st2->badcrc; - target->fixed = st1->fixed + st2->fixed; - - for (i = 0; i < MODES_MAX_BITERRORS; ++i) - target->bit_fix[i] = st1->bit_fix[i] + st2->bit_fix[i]; -} - void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target) { int i; @@ -191,21 +154,12 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t target->end = st1->end > st2->end ? st1->end : st2->end; - target->preamble_no_correlation = st1->preamble_no_correlation + st2->preamble_no_correlation; - target->preamble_not_quiet = st1->preamble_not_quiet + st2->preamble_not_quiet; - target->valid_preamble = st1->valid_preamble + st2->valid_preamble; - for (i = 0; i < MODES_MAX_PHASE_STATS; ++i) - target->preamble_phase[i] = st1->preamble_phase[i] + st2->preamble_phase[i]; - - add_demod_stats(&st1->demod, &st2->demod, &target->demod); - add_demod_stats(&st1->demod_phasecorrected, &st2->demod_phasecorrected, &target->demod_phasecorrected); - - target->http_requests = st1->http_requests + st2->http_requests; - target->out_of_phase = st1->out_of_phase + st2->out_of_phase; - - target->DF_Len_Corrected = st1->DF_Len_Corrected + st2->DF_Len_Corrected; - target->DF_Type_Corrected = st1->DF_Type_Corrected + st2->DF_Type_Corrected; - target->ModeAC = st1->ModeAC + st2->ModeAC; + target->demod_preambles = st1->demod_preambles + st2->demod_preambles; + target->demod_rejected_bad = st1->demod_rejected_bad + st2->demod_rejected_bad; + target->demod_rejected_unknown_icao = st1->demod_rejected_unknown_icao + st2->demod_rejected_unknown_icao; + for (i = 0; i < MODES_MAX_BITERRORS+1; ++i) + target->demod_accepted[i] = st1->demod_accepted[i] + st2->demod_accepted[i]; + target->demod_modeac = st1->demod_modeac + st2->demod_modeac; target->blocks_processed = st1->blocks_processed + st2->blocks_processed; target->blocks_dropped = st1->blocks_dropped + st2->blocks_dropped; @@ -214,14 +168,7 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t target->cputime.tv_nsec = st1->cputime.tv_nsec + st2->cputime.tv_nsec; target->cputime.tv_sec += target->cputime.tv_nsec / 1000000000L; target->cputime.tv_nsec %= 1000000000L; - - // remote messages: - target->remote_accepted = st1->remote_accepted + st2->remote_accepted; - target->remote_rejected = st1->remote_rejected + st2->remote_rejected; - - // total messages: - target->messages_total = st1->messages_total + st2->messages_total; - + // noise floor: target->noise_power_sum = st1->noise_power_sum + st2->noise_power_sum; target->noise_power_count = st1->noise_power_count + st2->noise_power_count; @@ -239,6 +186,20 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t // strong signals target->strong_signal_count = st1->strong_signal_count + st2->strong_signal_count; + // remote messages: + target->remote_received_modeac = st1->remote_received_modeac + st2->remote_received_modeac; + target->remote_received_modes = st1->remote_received_modeac + st2->remote_received_modes; + target->remote_rejected_bad = st1->remote_rejected_bad + st2->remote_rejected_bad; + target->remote_rejected_unknown_icao = st1->remote_rejected_unknown_icao + st2->remote_rejected_unknown_icao; + for (i = 0; i < MODES_MAX_BITERRORS+1; ++i) + target->remote_accepted[i] = st1->remote_accepted[i] + st2->remote_accepted[i]; + + // total messages: + target->messages_total = st1->messages_total + st2->messages_total; + + // network: + target->http_requests = st1->http_requests + st2->http_requests; + // CPR decoding: target->cpr_global_ok = st1->cpr_global_ok + st2->cpr_global_ok; target->cpr_global_bad = st1->cpr_global_bad + st2->cpr_global_bad; diff --git a/stats.h b/stats.h index 4f19391..3cd1061 100644 --- a/stats.h +++ b/stats.h @@ -50,45 +50,22 @@ #ifndef DUMP1090_STATS_H #define DUMP1090_STATS_H -// Common stats for non-phase-corrected vs phase-corrected cases -struct demod_stats { - unsigned int demodulated0; - unsigned int demodulated1; - unsigned int demodulated2; - unsigned int demodulated3; - unsigned int goodcrc; - unsigned int goodcrc_byphase[MODES_MAX_PHASE_STATS]; - unsigned int badcrc; - unsigned int fixed; - - // Histogram of fixed bit errors: index 0 for single bit erros, - // index 1 for double bit errors etc. - unsigned int bit_fix[MODES_MAX_BITERRORS]; -}; - struct stats { time_t start; time_t end; - // Statistics - unsigned int preamble_no_correlation; - unsigned int preamble_not_quiet; - unsigned int valid_preamble; - unsigned int preamble_phase[MODES_MAX_PHASE_STATS]; + // Mode S demodulator counts: + uint32_t demod_preambles; + uint32_t demod_rejected_bad; + uint32_t demod_rejected_unknown_icao; + uint32_t demod_accepted[MODES_MAX_BITERRORS+1]; - struct demod_stats demod; - struct demod_stats demod_phasecorrected; - - unsigned int http_requests; - unsigned int out_of_phase; - - unsigned int DF_Len_Corrected; - unsigned int DF_Type_Corrected; - unsigned int ModeAC; - - unsigned int blocks_processed; - unsigned int blocks_dropped; + // Mode A/C demodulator counts: + uint32_t demod_modeac; + // timing: + uint32_t blocks_processed; + uint32_t blocks_dropped; struct timespec cputime; // noise floor: @@ -106,11 +83,17 @@ struct stats { uint32_t strong_signal_count; // remote messages: - unsigned int remote_accepted; - unsigned int remote_rejected; + uint32_t remote_received_modeac; + uint32_t remote_received_modes; + uint32_t remote_rejected_bad; + uint32_t remote_rejected_unknown_icao; + uint32_t remote_accepted[MODES_MAX_BITERRORS+1]; // total messages: - unsigned int messages_total; + uint32_t messages_total; + + // network: + uint32_t http_requests; // CPR decoding: unsigned int cpr_global_ok;