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@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@