Debian Codegraph @

stats.h

raw symbols SCIP
1 // Part of dump1090, a Mode S message decoder for RTLSDR devices.
2 //
3 // stats.c: statistics structures and prototypes.
4 //
5 // Copyright (c) 2015 Oliver Jowett <[email protected]>
6 //
7 // This file is free software: you may copy, redistribute and/or modify it
8 // under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, either version 2 of the License, or (at your
10 // option) any later version.
11 //
12 // This file is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 // This file incorporates work covered by the following copyright and
21 // permission notice:
22 //
23 // Copyright (C) 2012 by Salvatore Sanfilippo <[email protected]>
24 //
25 // All rights reserved.
26 //
27 // Redistribution and use in source and binary forms, with or without
28 // modification, are permitted provided that the following conditions are
29 // met:
30 //
31 // * Redistributions of source code must retain the above copyright
32 // notice, this list of conditions and the following disclaimer.
33 //
34 // * Redistributions in binary form must reproduce the above copyright
35 // notice, this list of conditions and the following disclaimer in the
36 // documentation and/or other materials provided with the distribution.
37 //
38 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
39 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
40 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
41 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
42 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
45 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
46 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
47 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
48 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
49
50 #ifndef DUMP1090_STATS_H
51 #define DUMP1090_STATS_H
52
53 struct stats {
54 uint64_t start;
55 uint64_t end;
56
57 // Mode S demodulator counts:
58 uint32_t demod_preambles;
59 uint32_t demod_rejected_bad;
60 uint32_t demod_rejected_unknown_icao;
61 uint32_t demod_accepted[MODES_MAX_BITERRORS+1];
62
63 // Mode A/C demodulator counts:
64 uint32_t demod_modeac;
65
66 uint64_t samples_processed;
67 uint64_t samples_dropped;
68
69 // timing:
70 struct timespec demod_cpu;
71 struct timespec reader_cpu;
72 struct timespec background_cpu;
73
74 // noise floor:
75 double noise_power_sum;
76 uint64_t noise_power_count;
77
78 // mean signal power:
79 double signal_power_sum;
80 uint64_t signal_power_count;
81
82 // peak signal power seen
83 double peak_signal_power;
84
85 // number of signals with power > -3dBFS
86 uint32_t strong_signal_count;
87
88 // remote messages:
89 uint32_t remote_received_modeac;
90 uint32_t remote_received_modes;
91 uint32_t remote_rejected_bad;
92 uint32_t remote_rejected_unknown_icao;
93 uint32_t remote_accepted[MODES_MAX_BITERRORS+1];
94
95 // total messages:
96 uint32_t messages_total;
97
98 #ifdef ENABLE_WEBSERVER
99 // network:
100 uint32_t http_requests;
101 #endif
102
103 // CPR decoding:
104 unsigned int cpr_surface;
105 unsigned int cpr_airborne;
106 unsigned int cpr_global_ok;
107 unsigned int cpr_global_bad;
108 unsigned int cpr_global_skipped;
109 unsigned int cpr_global_range_checks;
110 unsigned int cpr_global_speed_checks;
111 unsigned int cpr_local_ok;
112 unsigned int cpr_local_skipped;
113 unsigned int cpr_local_range_checks;
114 unsigned int cpr_local_speed_checks;
115 unsigned int cpr_local_aircraft_relative;
116 unsigned int cpr_local_receiver_relative;
117 unsigned int cpr_filtered;
118
119 // number of altitude messages ignored because
120 // we had a recent DF17/18 altitude
121 unsigned int suppressed_altitude_messages;
122
123 // aircraft:
124 // total "new" aircraft (i.e. not seen in the last 30 or 300s)
125 unsigned int unique_aircraft;
126 // we saw only a single message
127 unsigned int single_message_aircraft;
128
129 // range histogram
130 #define RANGE_BUCKET_COUNT 76
131 uint32_t range_histogram[RANGE_BUCKET_COUNT];
132 };
133
134 void add_stats(const struct stats *st1, const struct stats *st2, struct stats *target);
135 void display_stats(struct stats *st);
136 void reset_stats(struct stats *st);
137
138 void add_timespecs(const struct timespec *x, const struct timespec *y, struct timespec *z);
139
140 #endif