Author Topic: Message 5 encoding - where to split?  (Read 1613 times)

Dave61

  • Seaman
  • *
  • Posts: 2
    • View Profile
Message 5 encoding - where to split?
« on: 05 January, 2017, 06:39:39 am »
I am writing some software to encode vessel position data from a database & put it into AIS format so I can send it by UDP to OpenCPN and maybe feed it to other sources such as AISHub once I prove it is working.

I have Message 1,2,3 working fine so far - vessels are showing up on the map properly.
I am having trouble trying to build a message 5 (static data) as this kind of message is too long to fit in 1 message so it normally is split into 2 messages like this:

!AIVDM,2,1,3,B,55P5TL01VIaAL@7WKO@mBplU@<PDhh000000001S;AJ::4A80?4i@E53,0*3E
!AIVDM,2,2,3,B,1@0000000000000,2*55

I have my 424 bits ready to convert. But so far I can't figure out if there is a rule for WHERE I should split the binary data before converting it to NMEA and putting in 2 consecutive messages.
Does anyone know where the split should occur?

malcolmh

  • New User
  • *
  • Posts: 7
    • View Profile
Re: Message 5 encoding - where to split?
« Reply #1 on: 05 January, 2017, 10:51:22 am »
There is no rule for this in the standard, but the usual convention is to split the message on a six-bit boundary, such that the fill bit field is zero on all but the last sentence.

coecles

  • Seaman
  • *
  • Posts: 3
    • View Profile
Re: Message 5 encoding - where to split?
« Reply #2 on: 06 January, 2017, 05:10:09 am »
Dave -

Curious - what would be your goal in feeding the messages to AISHub?

Gary

Dave61

  • Seaman
  • *
  • Posts: 2
    • View Profile
Re: Message 5 encoding - where to split?
« Reply #3 on: 10 January, 2017, 09:37:02 am »
Thanks very much for the reply Malcolm. I got it working now, splitting the message just before the destination field. So far it seems to work well with 166 vessels successfully sending their Msg05 data.

I just wish AIS data had a full timestamp instead of only seconds as there is no real way to send or keep 'old data' in AIVDM format!  :)

Cheers,

Dave

malcolmh

  • New User
  • *
  • Posts: 7
    • View Profile
Re: Message 5 encoding - where to split?
« Reply #4 on: 26 January, 2017, 02:06:09 pm »
Messages 4 & 11 both contain full UTC date & time.

coecles

  • Seaman
  • *
  • Posts: 3
    • View Profile
Re: Message 5 encoding - where to split?
« Reply #5 on: 27 January, 2017, 05:08:23 pm »
Dave, 

Using any Linux device to capture the messages allows one to readily parse and timestamp the receipt of the messages.

The device clock should be synced with one the global time servers to avoid drift.  By parsing upon receipt, we can also discard any malformed messages early, including those with invalid checksums.

We extract the MMSI and message type, add a timestamp, message source, and archive the messages to S3 in compressed format. 

For our own receivers, the timestamp would be accurate to within milliseconds of the message receipt.  From AISHub, the messages are downsampled, so the timestamp should be accurate to within about a minute.

Flat files can be rapidly processed to select archived messages by date, vessel, and type and then reparse the AIVDM content.

Of course, more fields could be extracted, such as lat-lon, to allow simple message selection options without reparsing.

We modify the millisecond field by bumping by a millisecond as necessary to ensure separate message groups have unique ascending timestamps to preserve their sequence in analytics processing.

Example:

!AIVDM,2,1,6,A,5=WU1rD1n4pT<4hiuE<l58U@D<R2Q84@Tv0<vT0k2P5227;l=<S@DRE1@j;P,0*74
2016-12-05T17:44:27.093Z aishub   05 913916393 !AIVDM,2,2,6,A,kkKUSP00000,2*3F
2016-12-05T17:44:27.121Z aishub   01 367598950 !AIVDM,1,1,,A,15NTMIPP00I<WqPA1usWEgvn0>`<,0*76
2016-12-05T17:44:27.122Z aishub   01 316030917 !AIVDM,1,1,,B,14eHwi@009o8hB>LD=plvlr80>`<,0*02
2016-12-05T17:44:27.123Z aishub   21 993692027 !AIVDM,1,1,,A,ENkb9NqR@@@@@@@@@@@@@@@@@@@;Wquu:l9k800003vP000,2*36

For analytics with Spark and Kafka, we process these files, extract fields of interest, do some calculations, and create new files in CSV format:

id,timestamp,messageType,source,latitude,longitude,distance,duration,speed,speedOverGround,heading,courseOverGround,course,motion,duplicate
279202354,2016-12-18T04:24:22.103Z,02,aishub,44.71559833,20.99782667,0,0,0,0,0,155.1,0,U,N
211590050,2016-12-18T04:24:22.106Z,01,aishub,53.52658333,8.57730333,3.2,60.7,0.1,0,0,292.2,329.3,S,N
413823141,2016-12-18T04:24:22.111Z,18,aishub,31.36492167,121.49740667,200.2,101.4,3.8,3.4,166,166.0,170.8,I,N
413697380,2016-12-18T04:24:22.115Z,19,aishub,25.98303333,119.43211,9.3,198.6,0.1,0,8,8.5,347.6,S,N

Gary