AIVDM/AIVDO Sentence Layer
AIVDM/AIVDO is a two-layer protocol. The outer layer is a variant of NMEA 0183, the ancient standard for data interchange in marine navigation systems; NMEA 0183 is described at [NMEA].
Here is a typical AIVDM data packet:
!AIVDM,1,1,,B,177KQJ5000G?tO`K>RA1wUbN0TKH,0*5C
And here is what the fields mean:
Field 1, !AIVDM, identifies this as an AIVDM packet.
Field 2 (1 in this example) is the count of fragments in the currently accumulating message. The payload size of each sentence is limited by NMEA 0183’s 82-character maximum, so it is sometimes required to split a payload over several fragment sentences.
Field 3 (1 in this example) is the fragment number of this sentence. It will be one-based. A sentence with a fragment count of 1 and a fragment number of 1 is complete in itself.
Field 4 (empty in this example) is a sequential message ID for multi-sentence messages.
Field 5 (B in this example) is a radio channel code. AIS uses the high side of the duplex from two VHF radio channels: AIS Channel A is 161.975Mhz (87B); AIS Channel B is 162.025Mhz (88B). In the wild, channel codes '1' and '2' may also be encountered; the standards do not prescribe an interpretation of these but it’s obvious enough.
Field 6 (177KQJ5000G?tO`K>RA1wUbN0TKH in this example) is the data payload. We’ll describe how to decode this in later sections.
Field 7 (0) is the number of fill bits requires to pad the data payload to a 6 bit boundary, ranging from 0 to 5. Equivalently, subtracting 5 from this tells how many least significant bits of the last 6-bit nibble in the data payload should be ignored. Note that this pad byte has a tricky interaction with the [ITU1371]requirement for byte alignment in over-the-air AIS messages; see the detailed discussion of message lengths and alignment in a later section.
The *-separated suffix (\*5C) is the NMEA 0183 data-integrity checksum for the sentence, preceded by "*". It is computed on the entire sentence including the AIVDM tag but excluding the leading "!". This checksum is the XOR of all bytes in the payload.
For comparison, here is an example of a multi fragment sentence with a nonempty message ID field:
!AIVDM,2,1,3,B,55P5TL01VIaAL@7WKO@mBplU@<PDhh000000001S;AJ::4A80?4i@E53,0*3E
!AIVDM,2,2,3,B,1@0000000000000,2*55
Technically, NMEA0183 does not actually require that a !-led sentence be AIS. This format can be used for any encapsulated data. The syntax and semantics of fields 1-4 are fixed, and the fill-bit field and NMEA checksum are required, but the payload fields may contain any encapsulated data.
It is, however, a safe bet that any such sentence containing an A or B channel code in field 5 is AIVDM/AIVDO.


AIVDM/AIVDO 语句层
AIVDM/AIVDO 是一种两层协议。外层是 NMEA 0183 的一种变体，NMEA 0183 是一种用于海上导航系统数据交换的古老标准；NMEA 0183 协议的详细描述可以参考 [NMEA]。
以下是一个典型的 AIVDM 数据包：

//
!AIVDO,1,1,,,B>qc:0001R:t?tUFfnT03wj4h4Id,0*73
!AIVDM,1,1,,A,E:hTsH1Pb7W@LHHqIHKqIHIJqpqDEpF8:eLFp1088;AP02,4*0E
//

!AIVDM,1,1,,B,177KQJ5000G?tO`K>RA1wUbN0TKH,0*5C
下面是字段的含义：

字段 1，!AIVDM，标识这是一个 AIVDM 数据包。
字段 2（此示例中为 1）是当前正在累积的消息中的片段总数。由于每条 NMEA 0183 语句的最大有效负载大小为 82 字符，因此有时需要将有效负载拆分为多个片段语句。
字段 3（此示例中为 1）是当前语句的片段编号，采用基于 1 的计数。如果片段总数为 1 且片段编号为 1，则该语句本身是完整的。
字段 4（此示例为空）是多片段消息的序列消息 ID。
字段 5（此示例中为 B）是无线电频道代码。AIS 使用两个 VHF 无线电频道的高端：AIS A频道是 161.975 MHz（87B），AIS B频道是 162.025 MHz（88B）。在实际应用中，也可能遇到频道代码 '1' 和 '2'；标准并没有规定这些代码的含义，但显然它们也有明显的区分。
字段 6（此示例中的 177KQJ5000G?tOK>RA1wUbN0TKH`）是数据有效载荷。稍后我们将描述如何解码它。
字段 7（此示例中的 0）是填充位的数量，用于将数据有效载荷填充到 6 位的边界，范围为 0 到 5。相应地，从这个数字减去 5 就是告诉我们在数据有效载荷的最后一个 6 位字节中需要忽略的最低有效位数。需要注意的是，这个填充字节与 [ITU1371] 对于无线电 AIS 消息的字节对齐要求有一个复杂的相互作用，稍后会详细讨论消息长度和对齐问题。
以 * 分隔的后缀（*5C）是该语句的 NMEA 0183 数据完整性校验和，计算方式是对整个语句进行异或运算，包括 AIVDM 标签，但不包括前导的 ! 字符。
为了便于对比，这里是一个多片段语句的示例，其中消息 ID 字段不为空：



!AIVDM,2,1,3,B,55P5TL01VIaAL@7WKO@mBplU@<PDhh000000001S;AJ::4A80?4i@E53,0*3E
!AIVDM,2,2,3,B,1@0000000000000,2*55
从技术上讲，NMEA 0183 并不要求任何以 ! 开头的语句必须是 AIS 格式。该格式可以用于任何封装数据。字段 1 到字段 4 的语法和语义是固定的，填充位字段和 NMEA 校验和是必需的，但有效载荷字段可以包含任何封装的数据。
然而，如果语句的字段 5 包含 A 或 B 频道代码，可以合理地认为它是 AIVDM/AIVDO 格式的。


http://radarcape/aircraftlist.json?knownposonly=1&vpn=48.38&vpe=12.08&vps=48.19&vpw=10.97&altitude.from=1&altitude.to=25000

http://radarcape/flightpath.json?icao=3C4D63&icao=3C5443&icao=300558&icao=3D41A3&icao=4B1A1D&icao=49130E&lookback=180

http://radarcape/aircraftlist.json?select=avail

http://radarcape/aircraftlist.json?knownposonly=1&vpn=49.19&vpe=16.09&vps=47.46&vpw=7.51&type=b74*,a38*

http://radarcape/aircraftlist.json?icao=3f*,d-e*&altitude.from=1&altitude.to=25000

http://radarcape/flightpath.json?icao=3D2515&lookback=600


1A 34
05 F8 C0 00 00 00
00
7D 00 14
00 00 00 00 00 00 00 00 00 00 00


Lat 32-bit1
 Latitude as 32-bit BAM 2, thus 232 ≡ 360°
Lon 32-bit1
 Latitude as 32-bit BAM 2
Alt 16-bit1
 Signed altitude meters


