Debian Codegraph @

docs/msg_creation_guide.org

raw
1
2 * Introduction
3
4 None of the documents out in the wild really do a good job talking
5 about the rights and wrongs of AIS message creation. This is my
6 attempt to capture best practices. This is based on experience
7 implementing pure python and pure C++ decoders of AIS, talking ESR
8 through his writing of a pure python decoder and the GPSD C decoder.
9 The real solution is to introduce a proper language for describing AIS
10 messages, but the majority of the community does not see this as a
11 requirement.
12
13 Unsorted initial list:
14
15 - All messages must have their overall content broadcast in byte
16 aligned message, so make your message clear how it byte aligns. A
17 variable length spare at the end is a good way to do this.
18 - Do not pad more than to then next byte on the end of your message.
19 There is no reason to fill out to the end of a slot. Extra space
20 only increases the chance that VHF noise will corrupt the message.
21 - Avoid defaults or common with lots of 1 bits in them. This will
22 trigger bit stuffing more often and cause problems.
23 - Make sure that values that are needed occur before they are used.
24 Otherwise you are forcing people code to require random access to
25 the bit stream.
26 - Provide example messages, bit streams, and decoded values for people
27 to test against.
28 - Provide an example database SQL CREATE command for your message.
29 This will force you to think carefully about your data structures.
30 If it has spatial geometry, include both a traditional SQL
31 definition and a PostGIS spatial version.
32 - Include a diagram if appropriate!
33 - Do not reference paywalled documents (e.g. ITU 1371)
34 - Include the lookup tables locally for things that have tables. Do
35 not just blindly refer to things like the Beaufort scale. That is
36 not helpful.
37 - State all units. For example, you can *not* just say "Salinity".
38 - Use SI units. Using things like nautical miles or chains for
39 distances is bad. Use km or m and let the software
40 presentation interface do the unit conversions to what ever.
41 - Just because it is done in ITU 1371 does not mean it is a good
42 idea. e.g. Message 22 and 23.
43 - On messages 25 and 26, use an DAC/FI pair (aka app id).
44 Unstructured binary without a specification document is bad. Are we
45 supposed to use the MMSI to id the content?
46 - Always specify longitude (x) first and then specify latitude (y)
47 - Specify the reference datum and only use WGS 84 SRID 4326
48 - Be very careful with vertical reference datums. It may not be
49 possible to convert if a different datum is needed on the ship.
50 - Always specify dates and times in UTC
51 - An integer scaled by a constant is not "floating point". Reserve
52 that term for things like IEEE Floats
53 - If you have a boolean value and want to specify that it can be
54 unknown, you can use two bits and call out all the options. For
55 example "Ice Yes/No", say 0==No Ice, 1==Ice Present, 2==Information
56 not available, 3==Reserved. Use 2 to be unknown to avoid "11" and
57 an increased chance of bit-stuffing. However, this is a terrible
58 example. What does it mean to have ice or no ice? That is a huge
59 question.
60 - Realize that any data transmitted is sent unencrypted and can be
61 read by anyone with a receiver (including spacecraft). Transmitted
62 data is public domain. If you need to keep it private, do not send
63 it over AIS. *Anyone* can read an addressed message.
64 - Consider alternative broadcast methods to the VHF data link (VDL).
65 It has limited bandwidth.
66 - Try to avoid too much state. Lots of messages where the state has
67 to be cached can overload small systems. Try to have messages
68 expire before too long.
69 - When a value is a decimal scaled value, write out the equation. e.g
70 -20.0 to 50.0 C should be "deg C = (raw_value / 10.0) - 20."
71 - Make sure to explain the motivation for a message. Why would this
72 message be sent. What conditions trigger the message to be sent?
73 - Do not count on precise timing of AIS messages. Receivers should
74 have a good (GPS based) local clock, but the message may take from 1
75 sec to as much as a minute or two to get to the end computer
76 (e.g. traveling through networks). Alternatively, the message will
77 be decoded after the fact for analysis. The USCG N-AIS sense of
78 time is +/- 8 minutes. Alternatively, the message might be received
79 by a satellite and downlinked 30 minutes or more later when the
80 satellite gets to a downlink station. Is the message understandable
81 in that sense?