Stats overhaul.
This commit is contained in:
parent
6672d92d9e
commit
a59077a370
44
demod_2000.c
44
demod_2000.c
|
@ -346,7 +346,7 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
|
||||||
useModesMessage(&mm);
|
useModesMessage(&mm);
|
||||||
|
|
||||||
j += MODEAC_MSG_SAMPLES;
|
j += MODEAC_MSG_SAMPLES;
|
||||||
Modes.stats_current.ModeAC++;
|
Modes.stats_current.demod_modeac++;
|
||||||
continue;
|
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);
|
dumpRawMessage("Too high level in samples between 10 and 15", msg, m, j);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Modes.stats_current.valid_preamble++;
|
Modes.stats_current.demod_preambles++;
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
@ -407,7 +407,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
|
||||||
// Make a copy of the Payload, and phase correct the copy
|
// Make a copy of the Payload, and phase correct the copy
|
||||||
memcpy(aux, &pPreamble[-1], sizeof(aux));
|
memcpy(aux, &pPreamble[-1], sizeof(aux));
|
||||||
applyPhaseCorrection(&aux[1]);
|
applyPhaseCorrection(&aux[1]);
|
||||||
Modes.stats_current.out_of_phase++;
|
|
||||||
pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES];
|
pPayload = &aux[1 + MODES_PREAMBLE_SAMPLES];
|
||||||
// TODO ... apply other kind of corrections
|
// TODO ... apply other kind of corrections
|
||||||
}
|
}
|
||||||
|
@ -475,7 +474,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
|
||||||
msglen = MODES_SHORT_MSG_BITS;
|
msglen = MODES_SHORT_MSG_BITS;
|
||||||
msg[0] ^= theErrs; errorsTy = 0;
|
msg[0] ^= theErrs; errorsTy = 0;
|
||||||
errors = errors56; // revert to the number of errors prior to bit 56
|
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) {
|
} else if (i < MODES_LONG_MSG_BITS) {
|
||||||
msglen = MODES_SHORT_MSG_BITS;
|
msglen = MODES_SHORT_MSG_BITS;
|
||||||
|
@ -517,7 +515,6 @@ void demodulate2000(uint16_t *m, uint32_t mlen) {
|
||||||
if (validDFbits & thisDFbit) {
|
if (validDFbits & thisDFbit) {
|
||||||
// Yep, more likely, so update the main message
|
// Yep, more likely, so update the main message
|
||||||
msg[0] = theByte;
|
msg[0] = theByte;
|
||||||
Modes.stats_current.DF_Type_Corrected++;
|
|
||||||
errors--; // decrease the error count so we attempt to use the modified DF.
|
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)
|
if ( (msglen)
|
||||||
&& ((2 * snr) > (int) (MODES_MSG_SQUELCH_DB * 10))
|
&& ((2 * snr) > (int) (MODES_MSG_SQUELCH_DB * 10))
|
||||||
&& (errors <= MODES_MSG_ENCODER_ERRS) ) {
|
&& (errors <= MODES_MSG_ENCODER_ERRS) ) {
|
||||||
|
int result;
|
||||||
|
|
||||||
// Set initial mm structure details
|
// Set initial mm structure details
|
||||||
mm.timestampMsg = Modes.timestampBlk + (j*6);
|
mm.timestampMsg = Modes.timestampBlk + (j*6);
|
||||||
mm.signalLevel = (365.0*60 + sigLevel + noiseLevel) * (365.0*60 + sigLevel + noiseLevel) / MAX_POWER / 60 / 60;
|
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
|
// 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
|
// 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
|
// Output debug mode info if needed
|
||||||
if (use_correction) {
|
if (use_correction) {
|
||||||
|
|
36
demod_2400.c
36
demod_2400.c
|
@ -259,7 +259,6 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
|
||||||
preamble[16] >= high ||
|
preamble[16] >= high ||
|
||||||
preamble[17] >= high ||
|
preamble[17] >= high ||
|
||||||
preamble[18] >= high) {
|
preamble[18] >= high) {
|
||||||
++Modes.stats_current.preamble_not_quiet;
|
|
||||||
continue;
|
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
|
// Crosscorrelate against the first few bits to find a likely phase offset
|
||||||
initial_phase = best_phase(&preamble[19]);
|
initial_phase = best_phase(&preamble[19]);
|
||||||
if (initial_phase < 0) {
|
if (initial_phase < 0) {
|
||||||
++Modes.stats_current.preamble_no_correlation;
|
|
||||||
continue; // nothing satisfactory
|
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
|
first_phase = last_phase = initial_phase; // try only the phase we think it is
|
||||||
}
|
}
|
||||||
|
|
||||||
Modes.stats_current.valid_preamble++;
|
Modes.stats_current.demod_preambles++;
|
||||||
bestmsg = NULL; bestscore = -1; bestphase = -1;
|
bestmsg = NULL; bestscore = -2; bestphase = -1;
|
||||||
for (try_phase = first_phase; try_phase <= last_phase; ++try_phase) {
|
for (try_phase = first_phase; try_phase <= last_phase; ++try_phase) {
|
||||||
uint16_t *pPtr;
|
uint16_t *pPtr;
|
||||||
int phase, i, score, bytelen;
|
int phase, i, score, bytelen;
|
||||||
|
@ -407,8 +404,11 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do we have a candidate?
|
// Do we have a candidate?
|
||||||
if (!bestmsg) {
|
if (bestscore < 0) {
|
||||||
Modes.stats_current.demod.badcrc++;
|
if (bestscore == -1)
|
||||||
|
Modes.stats_current.demod_rejected_unknown_icao++;
|
||||||
|
else
|
||||||
|
Modes.stats_current.demod_rejected_bad++;
|
||||||
continue; // nope.
|
continue; // nope.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -442,22 +442,20 @@ void demodulate2400(uint16_t *m, uint32_t mlen) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode the received message
|
// Decode the received message
|
||||||
if (decodeModesMessage(&mm, bestmsg) < 0)
|
{
|
||||||
continue;
|
int result = decodeModesMessage(&mm, bestmsg);
|
||||||
|
if (result < 0) {
|
||||||
// Update statistics
|
if (result == -1)
|
||||||
if (Modes.stats) {
|
Modes.stats_current.demod_rejected_unknown_icao++;
|
||||||
if (mm.correctedbits == 0) {
|
else
|
||||||
Modes.stats_current.demod.goodcrc++;
|
Modes.stats_current.demod_rejected_bad++;
|
||||||
Modes.stats_current.demod.goodcrc_byphase[bestphase%MODES_MAX_PHASE_STATS]++;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
Modes.stats_current.demod.badcrc++;
|
Modes.stats_current.demod_accepted[mm.correctedbits]++;
|
||||||
Modes.stats_current.demod.fixed++;
|
|
||||||
if (mm.correctedbits)
|
|
||||||
Modes.stats_current.demod.bit_fix[mm.correctedbits-1]++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Skip over the message:
|
// Skip over the message:
|
||||||
// (we actually skip to 8 bits before the end of the message,
|
// (we actually skip to 8 bits before the end of the message,
|
||||||
// because we can often decode two messages that *almost* collide,
|
// because we can often decode two messages that *almost* collide,
|
||||||
|
|
|
@ -398,13 +398,11 @@ struct modesMessage {
|
||||||
int msgtype; // Downlink format #
|
int msgtype; // Downlink format #
|
||||||
uint32_t crc; // Message CRC
|
uint32_t crc; // Message CRC
|
||||||
int correctedbits; // No. of bits corrected
|
int correctedbits; // No. of bits corrected
|
||||||
char corrected[MODES_MAX_BITERRORS]; // corrected bit positions
|
uint32_t addr; // Address Announced
|
||||||
uint32_t addr; // ICAO Address from bytes 1 2 and 3
|
|
||||||
int phase_corrected; // True if phase correction was applied
|
|
||||||
uint64_t timestampMsg; // Timestamp of the message
|
uint64_t timestampMsg; // Timestamp of the message
|
||||||
int remote; // If set this message is from a remote station
|
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
|
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
|
// DF 11, DF 17
|
||||||
int ca; // Responder capabilities
|
int ca; // Responder capabilities
|
||||||
|
|
34
mode_s.c
34
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
|
// 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)
|
// 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)
|
int scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
{
|
{
|
||||||
|
@ -321,13 +322,13 @@ int scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
struct errorinfo *ei;
|
struct errorinfo *ei;
|
||||||
|
|
||||||
if (validbits < 56)
|
if (validbits < 56)
|
||||||
return -1;
|
return -2;
|
||||||
|
|
||||||
msgtype = msg[0] >> 3; // Downlink Format
|
msgtype = msg[0] >> 3; // Downlink Format
|
||||||
msgbits = modesMessageLenByType(msgtype);
|
msgbits = modesMessageLenByType(msgtype);
|
||||||
|
|
||||||
if (validbits < msgbits)
|
if (validbits < msgbits)
|
||||||
return -1;
|
return -2;
|
||||||
|
|
||||||
crc = modesChecksum(msg, msgbits);
|
crc = modesChecksum(msg, msgbits);
|
||||||
|
|
||||||
|
@ -346,7 +347,7 @@ int scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
|
|
||||||
ei = modesChecksumDiagnose(crc, msgbits);
|
ei = modesChecksumDiagnose(crc, msgbits);
|
||||||
if (!ei)
|
if (!ei)
|
||||||
return -1; // can't correct errors
|
return -2; // can't correct errors
|
||||||
|
|
||||||
// fix any errors in the address field
|
// fix any errors in the address field
|
||||||
correct_aa_field(&addr, ei);
|
correct_aa_field(&addr, ei);
|
||||||
|
@ -368,7 +369,7 @@ int scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
case 18: // Extended squitter/non-transponder
|
case 18: // Extended squitter/non-transponder
|
||||||
ei = modesChecksumDiagnose(crc, msgbits);
|
ei = modesChecksumDiagnose(crc, msgbits);
|
||||||
if (!ei)
|
if (!ei)
|
||||||
return -1; // can't correct errors
|
return -2; // can't correct errors
|
||||||
|
|
||||||
// fix any errors in the address field
|
// fix any errors in the address field
|
||||||
addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
||||||
|
@ -391,11 +392,11 @@ int scoreModesMessage(unsigned char *msg, int validbits)
|
||||||
return 500; // Data/Parity
|
return 500; // Data/Parity
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return -1;
|
return -2;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// unknown message type
|
// unknown message type
|
||||||
return -1;
|
return -2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -410,7 +411,10 @@ static void decodeExtendedSquitter(struct modesMessage *mm);
|
||||||
static void decodeCommB(struct modesMessage *mm);
|
static void decodeCommB(struct modesMessage *mm);
|
||||||
static char *ais_charset = "@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_ !\"#$%&'()*+,-./0123456789:;<=>?";
|
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)
|
int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
{
|
{
|
||||||
// Work on our local copy
|
// 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.
|
// 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
|
// Accept the message if it appears to be from a previously-seen aircraft
|
||||||
if (!icaoFilterTest(mm->crc)) {
|
if (!icaoFilterTest(mm->crc)) {
|
||||||
//fprintf(stderr, "reject: AP doesn't match known ICAO\n");
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
mm->addr = mm->crc;
|
mm->addr = mm->crc;
|
||||||
break;
|
break;
|
||||||
|
@ -453,8 +456,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
int addr;
|
int addr;
|
||||||
struct errorinfo *ei = modesChecksumDiagnose(mm->crc & 0xffff80, mm->msgbits);
|
struct errorinfo *ei = modesChecksumDiagnose(mm->crc & 0xffff80, mm->msgbits);
|
||||||
if (!ei) {
|
if (!ei) {
|
||||||
//fprintf(stderr, "reject: DF11 uncorrectable CRC error\n");
|
return -2; // couldn't fix it
|
||||||
return -1; // couldn't fix it
|
|
||||||
}
|
}
|
||||||
mm->correctedbits = ei->errors;
|
mm->correctedbits = ei->errors;
|
||||||
modesChecksumFix(msg, ei);
|
modesChecksumFix(msg, ei);
|
||||||
|
@ -464,7 +466,6 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
// match an existing aircraft.
|
// match an existing aircraft.
|
||||||
addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
addr = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
||||||
if (!icaoFilterTest(addr)) {
|
if (!icaoFilterTest(addr)) {
|
||||||
//fprintf(stderr, "reject: DF11 CRC error, repaired address doesn't match known ICAO\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -482,8 +483,7 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
|
|
||||||
ei = modesChecksumDiagnose(mm->crc, mm->msgbits);
|
ei = modesChecksumDiagnose(mm->crc, mm->msgbits);
|
||||||
if (!ei) {
|
if (!ei) {
|
||||||
//fprintf(stderr, "reject: DF17/18 uncorrectable CRC error\n");
|
return -2; // couldn't fix it
|
||||||
return -1; // couldn't fix it
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addr1 = (msg[1] << 16) | (msg[2] << 8) | (msg[3]);
|
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
|
// we are conservative here: only accept corrected messages that
|
||||||
// match an existing aircraft.
|
// match an existing aircraft.
|
||||||
if (addr1 != addr2 && !icaoFilterTest(addr2)) {
|
if (addr1 != addr2 && !icaoFilterTest(addr2)) {
|
||||||
//fprintf(stderr, "reject: DF17/18 CRC corrected address, repaired address doesn't match known ICAO\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,12 +527,11 @@ int decodeModesMessage(struct modesMessage *mm, unsigned char *msg)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//fprintf(stderr, "reject: DF20/21 address doesn't match known ICAO\n");
|
|
||||||
return -1; // no good
|
return -1; // no good
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// All other message types, we don't know how to handle their CRCs, give up
|
// 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
|
// decode the bulk of the message
|
||||||
|
|
28
net_io.c
28
net_io.c
|
@ -579,13 +579,21 @@ int decodeBinMessage(struct client *c, char *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msgLen == MODEAC_MSG_BYTES) { // ModeA or ModeC
|
if (msgLen == MODEAC_MSG_BYTES) { // ModeA or ModeC
|
||||||
|
Modes.stats_current.remote_received_modeac++;
|
||||||
decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1]));
|
decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1]));
|
||||||
} else {
|
} else {
|
||||||
if (decodeModesMessage(&mm, msg) < 0) {
|
int result;
|
||||||
Modes.stats_current.remote_rejected++;
|
|
||||||
|
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;
|
return 0;
|
||||||
} else {
|
} 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
|
if (l == (MODEAC_MSG_BYTES * 2)) { // ModeA or ModeC
|
||||||
|
Modes.stats_current.remote_received_modeac++;
|
||||||
decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1]));
|
decodeModeAMessage(&mm, ((msg[0] << 8) | msg[1]));
|
||||||
} else { // Assume ModeS
|
} else { // Assume ModeS
|
||||||
if (decodeModesMessage(&mm, msg) < 0) {
|
int result;
|
||||||
Modes.stats_current.remote_rejected++;
|
|
||||||
|
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;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
Modes.stats_current.remote_accepted++;
|
Modes.stats_current.remote_accepted[mm.correctedbits]++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
149
stats.c
149
stats.c
|
@ -49,25 +49,6 @@
|
||||||
|
|
||||||
#include "dump1090.h"
|
#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) {
|
void display_stats(struct stats *st) {
|
||||||
int j;
|
int j;
|
||||||
struct tm tm_start, tm_end;
|
struct tm tm_start, tm_end;
|
||||||
|
@ -85,63 +66,62 @@ void display_stats(struct stats *st) {
|
||||||
printf("Statistics: %s - %s\n", tb_start, tb_end);
|
printf("Statistics: %s - %s\n", tb_start, tb_end);
|
||||||
|
|
||||||
if (!Modes.net_only) {
|
if (!Modes.net_only) {
|
||||||
printf("%d sample blocks processed\n", st->blocks_processed);
|
printf("Local receiver:\n");
|
||||||
printf("%d sample blocks dropped\n", st->blocks_dropped);
|
printf(" %u sample blocks processed\n", st->blocks_processed);
|
||||||
|
printf(" %u sample blocks dropped\n", st->blocks_dropped);
|
||||||
|
|
||||||
if (st->blocks_processed > 0) {
|
if (st->blocks_processed > 0) {
|
||||||
long cpu_millis = (long)st->cputime.tv_sec*1000L + st->cputime.tv_nsec/1000000L;
|
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));
|
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);
|
cpu_millis, sample_millis, 100.0 * cpu_millis / sample_millis);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%d ModeA/C detected\n", st->ModeAC);
|
printf(" %u Mode A/C messages received\n", st->demod_modeac);
|
||||||
printf("%d Mode-S preambles with poor correlation\n", st->preamble_no_correlation);
|
printf(" %u Mode-S message preambles received\n", st->demod_preambles);
|
||||||
printf("%d Mode-S preambles with noise in the quiet period\n", st->preamble_not_quiet);
|
printf(" %u with bad message format or invalid CRC\n", st->demod_rejected_bad);
|
||||||
printf("%d valid Mode-S preambles\n", st->valid_preamble);
|
printf(" %u with unrecognized ICAO address\n", st->demod_rejected_unknown_icao);
|
||||||
for (j = 0; j < MODES_MAX_PHASE_STATS; ++j)
|
printf(" %u accepted with correct CRC\n", st->demod_accepted[0]);
|
||||||
if (st->preamble_phase[j] > 0)
|
for (j = 1; j <= Modes.nfix_crc; ++j)
|
||||||
printf(" %d with phase offset %d\n", st->preamble_phase[j], j);
|
printf(" %u accepted with %d-bit error repaired\n", st->demod_accepted[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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (st->noise_power_count) {
|
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));
|
10 * log10(st->noise_power_sum / st->noise_power_count));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (st->signal_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));
|
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));
|
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);
|
st->strong_signal_count);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("%d remote messages accepted\n"
|
if (Modes.net) {
|
||||||
"%d remote messages rejected\n",
|
printf("Messages from network clients:\n");
|
||||||
st->remote_accepted,
|
printf(" %u Mode A/C messages received\n", st->remote_received_modeac);
|
||||||
st->remote_rejected);
|
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);
|
st->messages_total);
|
||||||
|
|
||||||
printf("%d global CPR attempts with valid positions\n"
|
printf("%u global CPR attempts with valid positions\n"
|
||||||
"%d global CPR attempts with bad data\n"
|
"%u global CPR attempts with bad data\n"
|
||||||
"%d global CPR attempts with insufficient data\n"
|
"%u global CPR attempts with insufficient data\n"
|
||||||
"%d local CPR attempts with valid positions\n"
|
"%u local CPR attempts with valid positions\n"
|
||||||
"%d local CPR attempts with insufficient data\n"
|
"%u local CPR attempts with insufficient data\n"
|
||||||
"%d CPR messages that look like transponder failures filtered\n",
|
"%u CPR messages that look like transponder failures filtered\n",
|
||||||
st->cpr_global_ok,
|
st->cpr_global_ok,
|
||||||
st->cpr_global_bad,
|
st->cpr_global_bad,
|
||||||
st->cpr_global_skipped,
|
st->cpr_global_skipped,
|
||||||
|
@ -149,6 +129,9 @@ void display_stats(struct stats *st) {
|
||||||
st->cpr_local_skipped,
|
st->cpr_local_skipped,
|
||||||
st->cpr_filtered);
|
st->cpr_filtered);
|
||||||
|
|
||||||
|
if (Modes.net && Modes.net_http_port)
|
||||||
|
printf("%d HTTP requests\n", st->http_requests);
|
||||||
|
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -157,26 +140,6 @@ void reset_stats(struct stats *st) {
|
||||||
*st = st_zero;
|
*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) {
|
void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target) {
|
||||||
int i;
|
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->end = st1->end > st2->end ? st1->end : st2->end;
|
||||||
|
|
||||||
target->preamble_no_correlation = st1->preamble_no_correlation + st2->preamble_no_correlation;
|
target->demod_preambles = st1->demod_preambles + st2->demod_preambles;
|
||||||
target->preamble_not_quiet = st1->preamble_not_quiet + st2->preamble_not_quiet;
|
target->demod_rejected_bad = st1->demod_rejected_bad + st2->demod_rejected_bad;
|
||||||
target->valid_preamble = st1->valid_preamble + st2->valid_preamble;
|
target->demod_rejected_unknown_icao = st1->demod_rejected_unknown_icao + st2->demod_rejected_unknown_icao;
|
||||||
for (i = 0; i < MODES_MAX_PHASE_STATS; ++i)
|
for (i = 0; i < MODES_MAX_BITERRORS+1; ++i)
|
||||||
target->preamble_phase[i] = st1->preamble_phase[i] + st2->preamble_phase[i];
|
target->demod_accepted[i] = st1->demod_accepted[i] + st2->demod_accepted[i];
|
||||||
|
target->demod_modeac = st1->demod_modeac + st2->demod_modeac;
|
||||||
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->blocks_processed = st1->blocks_processed + st2->blocks_processed;
|
target->blocks_processed = st1->blocks_processed + st2->blocks_processed;
|
||||||
target->blocks_dropped = st1->blocks_dropped + st2->blocks_dropped;
|
target->blocks_dropped = st1->blocks_dropped + st2->blocks_dropped;
|
||||||
|
@ -215,13 +169,6 @@ void add_stats(const struct stats *st1, const struct stats *st2, struct stats *t
|
||||||
target->cputime.tv_sec += target->cputime.tv_nsec / 1000000000L;
|
target->cputime.tv_sec += target->cputime.tv_nsec / 1000000000L;
|
||||||
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:
|
// noise floor:
|
||||||
target->noise_power_sum = st1->noise_power_sum + st2->noise_power_sum;
|
target->noise_power_sum = st1->noise_power_sum + st2->noise_power_sum;
|
||||||
target->noise_power_count = st1->noise_power_count + st2->noise_power_count;
|
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
|
// strong signals
|
||||||
target->strong_signal_count = st1->strong_signal_count + st2->strong_signal_count;
|
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:
|
// CPR decoding:
|
||||||
target->cpr_global_ok = st1->cpr_global_ok + st2->cpr_global_ok;
|
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_bad = st1->cpr_global_bad + st2->cpr_global_bad;
|
||||||
|
|
55
stats.h
55
stats.h
|
@ -50,45 +50,22 @@
|
||||||
#ifndef DUMP1090_STATS_H
|
#ifndef DUMP1090_STATS_H
|
||||||
#define 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 {
|
struct stats {
|
||||||
time_t start;
|
time_t start;
|
||||||
time_t end;
|
time_t end;
|
||||||
|
|
||||||
// Statistics
|
// Mode S demodulator counts:
|
||||||
unsigned int preamble_no_correlation;
|
uint32_t demod_preambles;
|
||||||
unsigned int preamble_not_quiet;
|
uint32_t demod_rejected_bad;
|
||||||
unsigned int valid_preamble;
|
uint32_t demod_rejected_unknown_icao;
|
||||||
unsigned int preamble_phase[MODES_MAX_PHASE_STATS];
|
uint32_t demod_accepted[MODES_MAX_BITERRORS+1];
|
||||||
|
|
||||||
struct demod_stats demod;
|
// Mode A/C demodulator counts:
|
||||||
struct demod_stats demod_phasecorrected;
|
uint32_t demod_modeac;
|
||||||
|
|
||||||
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;
|
|
||||||
|
|
||||||
|
// timing:
|
||||||
|
uint32_t blocks_processed;
|
||||||
|
uint32_t blocks_dropped;
|
||||||
struct timespec cputime;
|
struct timespec cputime;
|
||||||
|
|
||||||
// noise floor:
|
// noise floor:
|
||||||
|
@ -106,11 +83,17 @@ struct stats {
|
||||||
uint32_t strong_signal_count;
|
uint32_t strong_signal_count;
|
||||||
|
|
||||||
// remote messages:
|
// remote messages:
|
||||||
unsigned int remote_accepted;
|
uint32_t remote_received_modeac;
|
||||||
unsigned int remote_rejected;
|
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:
|
// total messages:
|
||||||
unsigned int messages_total;
|
uint32_t messages_total;
|
||||||
|
|
||||||
|
// network:
|
||||||
|
uint32_t http_requests;
|
||||||
|
|
||||||
// CPR decoding:
|
// CPR decoding:
|
||||||
unsigned int cpr_global_ok;
|
unsigned int cpr_global_ok;
|
||||||
|
|
Loading…
Reference in a new issue