Commit Graph

158 Commits

Author SHA1 Message Date
Oliver Jowett 825f959e4d Add skeletal BDS0,5 decoding.
These messages duplicate ADS-B messages so it's not clear why
they are being interrogated for, and we don't really trust them
enough to do anything with the position information. But
recognizing/decoding them where possible does let us exclude other
Comm-B message types, avoiding some false positives.
2021-07-29 19:04:52 +08:00
Oliver Jowett c148fdca84 Distinguish "unknown format" from "didn't even try to decode"
when decoding Comm-B messages
2021-07-29 19:04:51 +08:00
Oliver Jowett e3a8e00412 WIP on MRAR decoding 2021-07-29 19:04:49 +08:00
Oliver Jowett c433463392 Reduce CPU further in --no-fix-df mode. Add --enable-df24 option.
This reinstates the fastpath in the 2.4MHz demodulator that
aborts message demodulation early if the DF bits don't match a message
type that we know how to decode, or stops early if the DF bits can
only correspond to a short 56-bit message.

Do this in a more general form where we test against a set of valid
DF values, rather than a switch/case. Then populate the sets based on
the current error-correction settings (e.g. if we are allowed to repair
DF damage with 1 bit error correction, then a DF17 message could appear
with any of DF=17, DF=16, DF=19, DF=21, DF=25, or DF=1 and still be
correctable to a valid DF17 message)

In the default case this produces a small CPU improvement as short
messages might be able to stop earlier and a few DF values can be ignored
early. With --no-fix-df it produces a larger improvement as relatively few
DF values are valid in that mode.

To further reduce CPU, the default behaviour has changed to _not_
decode DF24 messages (Comm-D ELM messages). These are rarely seen in
the wild and dump1090 can't do anything useful with them. Disabling
them allows us to further reduce the set of valid DF values as they
effectively use all DF values from 24..31, 25% of all possible values.
To re-enable DF24 decoding, use the new `--enable-df24` option.

Finally, avoid doing some CRC calculations twice. This was only happening
once per valid decoded message, not per demodulation attempt, so it's not
such a large win.
2021-03-19 17:03:15 +08:00
Oliver Jowett a135d2b915 Add a --no-fix-df option
Usually, all message candidates are speculatively corrected as if
they were DF11/17/18, even if the DF field has a different value. This
allows correction of messages when there is correctable damage to the
DF field.

However, running every message candidate through a couple of CRC checks
is expensive, CPU-wise, when decoding messages off the air, as there are
a large number of message candidates that are actually just junk data, and
computing CRCs for all of those adds up. The --no-fix-df option allows
disabling this sort of correction. The tradeoff is that messages with
damage to the DF field will not be corrected.
2021-03-08 14:23:35 +08:00
Oliver Jowett 5a33b4ee8f Set at least airground = AG_UNCERTAIN for airborne position messages with valid altitudes.
DF18 messages don't have a CA field so we can't set airground from that.
That meant that aircraft tracking wouldn't update airground state at all from a DF18
airborne position message, even if the existing tracked airground state was stale.
It seems reasonable to set at least AG_UNCERTAIN if we're seeing airborne positions
with valid altitude data.

Fixes github issue #113
2021-02-18 13:57:27 +08:00
Oliver Jowett c421c31152 Overhaul of message scoring & error correction.
Major changes:

Try to error-correct all messages that potentially could be DF11/17/18
even if the original DF value is different. This allows messages with
correctable damage in the first 5 bits to be correctable.

Track recently-seen DF18 addresses separately to DF17 addresses.
DF18 does not imply Mode S support, so we don't want to treat it like
a known Mode S emitter, but once we've heard some DF18 for an aircraft
we can be more confident about future DF18 messages for the same
address.

Rework the scoring system so it's just a big enum that lists all the
possible outcomes in the order that we want. This makes the relative
ordering of different messages clearer, and makes it easier to move
messages above/below the accept thresholds as needed.

Don't accept 2-bit-error-corrected messages that are from aircraft we
have not previously seen. This greatly reduces the number of garbage
messages when using 2-bit error correction.

Overall results are:

 * more CPU required for decoding (approx 30% increase in my tests)
   as we're doing a lot more speculative CRC-checking work
 * no significant change to message rates with error correction off
 * about 5% more 1-bit-corrected DF17 decodes, with a
   disproportionate increase in those messages contributing to
   successful position decodes / unique aircraft counts
 * _fewer_ decodes with 2-bit correction (versus old code with 2-bit
   correction), but the message quality is substantially improved,
   the rate of garbage decodes / phantom aircraft is greatly reduced

sample stats:

1-bit correction, old code:
    141158 total usable messages
    137852 accepted with correct CRC
      3306 accepted with 1-bit error repaired
     27446 DF17 messages
        51 unique aircraft tracks

1-bit correction, new code:
    141296 total usable messages
    137854 accepted with correct CRC
      3442 accepted with 1-bit error repaired
     27528 DF17 messages
        55 unique aircraft tracks

2-bit correction, old code:
    142656 total usable messages
    137809 accepted with correct CRC
      3283 accepted with 1-bit error repaired
      1564 accepted with 2-bit error repaired
     28803 DF17 messages
       349 unique aircraft tracks (<- note that most of these are garbage)

2-bit correction, new code:
    142426 total usable messages
    137822 accepted with correct CRC
      3420 accepted with 1-bit error repaired
      1184 accepted with 2-bit error repaired
     28666 DF17 messages
        55 unique aircraft tracks
2021-02-09 20:10:55 +08:00
Oliver Jowett 6a11387861 Collect stats on messages received by DF type 2021-02-04 16:33:26 +08:00
Oliver Jowett 886b0d3f81 Treat ADS-R as a separate source type (higher priority than TIS-B, lower priority than direct ADS-B) 2019-12-11 12:43:19 -06:00
Oliver Jowett f7123c41e5 When trying to correct a DF11 that had bits set in the top 17 bits of the
residual, use the full 24-bit syndrome.

Previously this would mask off the low 7 bits, which isn't particularly
great - it doesn't really make sense in that it implies a somewhat
random IID value, and it would actually only correct 20 possible bit
errors out of the 51 possible errors, 16 of which were errors in
the top 16 bits of the CRC itself. It is also risky as it will accept
a larger number of possible garbage messages as the lower 7 bits may take
any value.

Instead, use the full syndrome, assuming that the damaged message
had IID=0 - which seems more likely than assuming a random IID, since
IID=0 is used for acquisition squitters and should be arriving regularly.

The reduced rate of corrections for DF11 messages shouldn't have
much of an impact as DF11s carry very little data themselves - they
are mainly used to acquire the aircraft address. Once one good message
for an aircraft turns up (which would require IID=0 anyway before we'd
accept it) it doesn't really matter if we discard more damaged messages,
as they're not contributing to anything useful in the aircraft state
beyond air/ground status, which is also carried in many other messages.
2019-12-02 21:27:18 +08:00
Oliver Jowett 54409b4836 Split beast output into two separate writers for verbatim vs. non-verbatim
in preparation for supporting both types of connection in parallel
2019-11-27 21:01:46 +08:00
Oliver Jowett dfc588335a Move output filtering down a level into the individual output functions. 2019-11-27 20:57:01 +08:00
Oliver Jowett ce89cd08d9 Groundwork to track "reliable" messages & aircraft.
A "reliable" message is a DF17 or DF11 with good CRC.
A "reliable" aircraft is one that's probably real - we decide it's reliable when
we've seen enough reliable messages, or just enough messages in total, that it's unlikely
to be noise.
2019-11-27 20:51:23 +08:00
Oliver Jowett e444d2eb5c Fix reversed sense of Track Angle / Heading bit in surface opstatus messages. 2019-06-06 14:15:14 +08:00
Oliver Jowett d33b1160f2 Add COMMB_AMBIGUOUS for Comm-B messages we're not sure of (not yet used) 2019-05-02 17:29:04 +08:00
Oliver Jowett 1b5b0dfa03 Put ais_charset in its own file to make building commb tests a little easier 2019-05-02 17:24:26 +08:00
Oliver Jowett a24718feca
Merge pull request #41 from henry1952/patch-3
Fix an error in the bit range used to decode CF in DF18 messages (harmless)
2019-04-13 11:38:48 +08:00
henry1952 37e49906d1
Update mode_s.c 2019-04-11 19:01:07 +02:00
Oliver Jowett 56aa2f7d1e Clarify some comments in v1 TSS 2019-03-19 18:23:49 +00:00
Oliver Jowett c05aea65a4 Don't use DF18 when updating the known-Mode-S-address set.
DF18 transponders don't necessarily do Mode S, so we shouldn't assume
that Mode S messages from that address are valid merely because we
heard a DF18. If it really is Mode S equipped, we should hear a
DF11 at some point.
2019-01-21 20:11:12 +00:00
Eric Tran f4692a3784 Ignore altitude reporting when part of airborne position message with air/ground=ground 2018-08-28 17:08:14 +00:00
Oliver Jowett b82922e81c Strip out bad callsigns seen in ADS-B ident messages.
Same rules as apply to Comm-B - alphanumeric + space only.
2018-07-20 20:56:28 +01:00
Oliver Jowett 5a9350a6a1 Derive SPI / Alert from the airborne position message surveillance status field 2018-02-23 19:02:02 +00:00
Oliver Jowett 94824fbb98 Avoid coredump on "untracked" aircraft (icao 000000)
Clean up the first-message-squelch logic a little.
2018-02-23 18:21:01 +00:00
Oliver Jowett 1d5db2fd76 Fix baro/geometric rate flag sense in airborne velocity messages 2018-02-20 00:08:26 +13:00
Oliver Jowett 44e8913c2d Whitespace cleanups 2018-01-09 17:13:34 +00:00
Oliver Jowett a947163dee Fix ADSBv0 ground movement decoding 2018-01-09 14:44:20 +00:00
Oliver Jowett ea1e9c336b Decode/emit emergency/priority status 2018-01-09 14:43:58 +00:00
Oliver Jowett 079061df3c SIL stuff 2017-12-07 13:36:07 -06:00
Oliver Jowett 161d2d8ded More WIP 2017-12-07 10:34:08 -06:00
Oliver Jowett 6986b3847f WIP on new faup1090 output, data aging, refactoring 2017-12-02 17:38:33 +00:00
Oliver Jowett 382554a250 Tweak tracking of AP modes, emit in json & faup1090 output 2017-06-16 10:39:01 +01:00
Oliver Jowett 1ec32903ba Rework heading/track to include HRD/TAH.
Clean up TIS-B flag output.
2017-06-15 21:07:53 +01:00
Oliver Jowett 27b0e9c40f Rename TARGET_* -> INTENT_ALT_*
Rearrange the intent tracking a bit.
2017-06-15 18:23:28 +01:00
Oliver Jowett 2142d2edf5 Whitespace changes only: cleaning up trailing whitespace at EOL 2017-06-15 18:17:07 +01:00
Oliver Jowett 98d64483d6 WIP: More Comm-B & ADS-B decoding. 2017-06-15 18:07:40 +01:00
Oliver Jowett d3fad32d5e Merge remote-tracking branch 'upstream/master' into dev 2016-10-14 21:35:31 +01:00
Oliver Jowett 25ea6d398b Overhaul mode A/C matching to be much cheaper.
The old matching process which tracked mode A values as pseudo-aircraft
got very, very expensive with a large number of mode A/C messages (and
with lots of single-bit errors, which seems common with a Beast doing
the reception)

Instead just count A/C messages directly into a 4096-entry array (which
is very fast) and periodically scan the mode S aircraft list to see if
we can match anything up (which is fixed overhead + cost proportional
to the number of mode S aircraft)
2016-10-11 18:00:11 +01:00
Oliver Jowett 60f1f3bcb6 Table-ize the Mode A to C conversions, add a Mode C to Mode A conversion function. 2016-10-11 17:57:25 +01:00
Oliver Jowett 85d3ecee62 Add source & address type for Mode A/C 2016-10-11 17:55:02 +01:00
Oliver Jowett 52fe01c860 Track CPR encoding type directly rather than inferring it from airground.
(airground can change even while airborne if SPI/Alert status gets set)
2016-10-02 00:16:29 +01:00
Oliver Jowett 729d91c1ab Fix up address type categorization to match the spec. 2016-09-15 15:30:34 +01:00
Oliver Jowett 50a606d23f Make it clearer that ADDR_ADSB_ICAO includes Mode S too. 2016-09-14 17:19:49 +01:00
Oliver Jowett 2a4aa29f03 Record the address type details when decoding. 2016-09-14 16:37:07 +01:00
Oliver Jowett 10641303cb Add a couple more ME types. 2016-09-14 16:12:08 +01:00
Oliver Jowett 9e179d46bf Don't accept all-zeros messages (e.g. off the network - the demodulator
doesn't accept them already)
2016-09-14 16:11:31 +01:00
Oliver Jowett b827806ce8 Simplify ident decoding, add some sanity checks to the BDS2,0 case. 2016-09-14 16:02:20 +01:00
Oliver Jowett f9419f13d5 Break up decodeExtendedSquiiter, it was getting pretty large. 2016-09-01 23:13:31 +01:00
Oliver Jowett a1fdc07db2 Restructure decoding to use a helper function to extract bit ranges
With forced inlining this is about as fast, and it is much less
errorprone than the twisty little maze of handcoded bitshifts that
it was before.

(notably, at least one error - in the ACAS RI field - has been fixed)
2016-09-01 22:45:49 +01:00
Oliver Jowett 3e08de91ed WIP on decoding operational status & target state messages. 2016-08-29 11:11:04 +01:00