libais icon indicating copy to clipboard operation
libais copied to clipboard

Decoding flawed AIS messages

Open schwehr opened this issue 9 years ago • 1 comments

These messages would be rejected by most AIS receivers as bad. Are these messages coming from a receiver that is willing to record messages that were not completely received or are some vessels transmitting incorrect messages? If this is how the messages are being transmitted, someone needs to get these vessels fixed ASAP.

I'm not sure what I think about this request. If I allow these through it makes the overall library more confusing. People using the c++ will have to check to see which fields in messages 1, 2, and 3 are set and maybe if this is a partial message.

All of the sample messages below are 204 bits.

From Michiel Katgert:

About 99% of the messages type 1,2 and 3 are decoded perfectly fine, but 1 % or so raises the error ‘AIS_ERR_BAD_BIT_COUNT’. I looked a bit into this matter and found out that according to standards the message character length is supposed to be 28 characters, which corresponds to 168 bits. This corresponds with the info available on http://catb.org/gpsd/AIVDM.html#_types_1_2_and_3_position_report_class_a . In the C++ code for msgtype 1/2/3 you check for padding !=0 and numchars != 28, so this is correct for the 99 % of messages.

The 1% of failing messages has a different message character length; some examples:

!AIVDM,1,1,,A,137b0v00270B2K<MI`7pgG2l08@K4cG>`<,0*29
!AIVDM,1,1,,A,13aivJ00001:=U6QQoM=:1hr0<0?bRa>`<,0*7B
!AIVDM,1,1,,A,13bWT630020@Lc@ML1A3G:dr0<4juMk>`<,0*27
!AIVDM,1,1,,A,23aDAI0P01P@l>DMLR8nO?vnR8@qPvO>`<,0*50
!AIVDM,1,1,,A,34WTLF50000A29lMLCbhFWLp0D`Jn>C>`<,0*71
!AIVDM,1,1,,A,33chm:0P@90aFLjFGLfe9kLp00w0@?g>`<,0*4F
!AIVDM,1,1,,A,19NSBI0vj6PjnUjPuTbU5l2t0D2njpG>`<,0*07
!AIVDM,1,1,,A,1347pD003bP@C9@MJsQp36Dn0<2p3=e>`<,0*55
!AIVDM,1,1,,A,13aD@;OP00PK2k>MgLD00?vt2@Aakba>`<,0*5E

All of them can however be decoded by for instance the matlab ais decoder from http://www.vrmore.no/vm/om_prosjektet/publikasjoner/rapporter_og_programvare/matlab_toolbox_for_ais_messages or with http://www.maritec.co.za/tools/aisvdmvdodecoding/

Although these messages apparently do not follow the standards, it would be very handy if the libais decoder could decode these messages.

I therefore modified the code of ais1_2_3.cpp [line 24] on my own computer to numchars < 28 and that works for the messages above to decode. I did not check if it influences the rest of the code, but I hope you find this remark useful.

Best regards,

Michiel

ITU 1371-5 says Messages 1, 2, & 3 can only be 168 bits.

screen shot 2015-04-24 at 8 05 27 am

schwehr avatar Apr 24 '15 15:04 schwehr

A decode image for reference:

screen shot 2015-04-24 at 9 28 20 am

schwehr avatar Apr 24 '15 16:04 schwehr