FlightAware Discussions

Trying to implement BDS 4,4

Hi.

I"m doing som research for self-study and I’m trying to implement BDS 4,4 (Meteorological information) into current version of dump1090-fa (got from github), but I’m not having any success :frowning:

I would like to ask for help or any tips where I should look for or what i’m doing wrong…any tip is welcome!

That I’have done:
In the comm_b.c file, I’ve created a new function called “decodeBDS44” and added this function to “comm_b_decoders” list, so it will be called when DF20 or DF21 arrives and call “decodeCommB” function. Not that I’m not scoring at this time, just trying to show in console the decoded data.

I’ve tested and dump1090-fa is calling my bds44 function. And this is the function:

// BDS4,4 Meteorological Information
static int decodeBDS44(struct modesMessage *mm, bool store)
{
    MODES_NOTUSED(store);
    
    unsigned char *msg = mm->MB;
    
    /*
     * Source of data
     * 0 = Invalid
     * 1 = INS
     * 2 = GNSS
     * 3 = DME/DME
     * 4 = VOR/DME
     * 5-15 = reserved
     */
    unsigned source = getbits(msg,1,4);
    
    // Should not be >4 and not 0
    if (source == 0 || source > 4) {
        return 0;
    }
    
    // Wind speed
    unsigned status_speed_dir = getbit(msg,5);
    unsigned wind_speed_raw = getbits(msg,6,14);
    
    if (status_speed_dir && wind_speed_raw != 0) { // We have some data!
        printf("[%06X] Wind speed: %u, ",mm->addr,wind_speed_raw);
    }
    
    // Temperature - doesn't have status field, just sign
    // Lets decode anyway 
    unsigned sign = getbit(msg,24);
    unsigned temperature_raw = getbits(msg,25,34);        
    printf("[%06X] Temperature: ",mm->addr);
    if (sign) { // if sign, it's negative temperature?!
        printf("-");
    }    
    float temperature = (float)temperature_raw * 0.25;
    printf("%2f\n",temperature);
    
    return 0;
}

The problem is that data is always wrong…I can’t get wind speed or (specially) temperature.
To check if incoming data is valid and has temperature/wind, I’m using my ModeSMixer as datasource…
I’m looking into one specific HEX at ModeSMixer to see if it has temperature/wind speed information and compare with results in console…but I never got a good result.

I apreciate any help!

Note: this is the frame information for BDS 4,4:

I’ve never seen a 4,4 in the wild (it may be regional); do you have a sample message that you believe is a 4,4?

Is there any way to save sample data from drump1090-fa or modesmixer? If yes, I can save…
I’m using data from europe.

Since ModeSMixer show temperature/wind speed/wind dir reported by aircraft, I’m assuming this is from BDS 4,4.
Also, BDS 4,4 and 4,5 are the only places where temperature information is present in ICAO DOC 9871 (Mode-S Frames/data specification).

dump1090 will write the raw message to stdout unless you pass --quiet (look for the line with *[bunch of hex]; before the decoded message is written out)

You can derive the wind vector from BDS5,0 + BDS6,0 (compare the ground vector to the airspeed vector); you can derive temperature (approximately) from Mach + TAS, since the speed of sound depends on air temperature. modesmixer may be doing that?

I can’t say by ModeSMixer, but I’m pretty sure it’s from BDS 4,4 and not calculated. But again: I can’t guarantee.
I’m saying this because I have tested with some flights from here (Brasil) and I could not find even one with this information, only from europe (I have a friend there and I have access to their ads-b data).

I’ve saved some samples from there: https://drive.google.com/file/d/1aNIMY1boi0rMFd7faXMzhXJZKjHvEzsP/view?usp=sharing

What message out of that lot do you think is a 4,4? I took a brief look at all the Comm-B messages that dump1090 didn’t recognize as some other format, and none of them look like plausible 4,4 messages as far as I can see? (I would expect the first byte of a 4,4 to be something like 18/19/1A/1B/28/29/2A/2B)

That’s exactly what I’m thinking: dump is not processind these messages…maybe discarding early in ModeS decoder?! I don’t know.

I just sent and message to ‘sergsero’ (autor of ModeSMixer) asking if MSM uses BDS 4,4 or what for wind/wind-dir/temp.

Ahhhh, another observation: for an specific flight, sometimes temperature/wind-speed/wind-dir is not available (all 3 at same time)…then, after some time, it’s available again. One more ‘why’ i think is coming from BDS 4,4.

Another reason for my thinking is that I could not find not even one flight with these information here in Brazil. If it is calculated from other data, this should be work here, at least for international flights on bigger aircrafts (with more recent equipaments)…but nothing! This tell me that there’s no interrogator here (in fact, all airports here are kind of small…specially compared to european airports). Without interrogator, there’s no BDS 4,4!

I mean, there’s interrogators here (for other BDS’s), but not for BDS4,4 (Meteorological data).
That’s my guess.

Do your aircraft have TAS and mach number displayed?

There seems to be at least a Copenhagen radar requesting 4,4 reports:

http://publicaties.minienm.nl/documenten/availability-and-quality-of-mode-s-mrar-bds4-4-in-the-muac-area-

The demodulator doesn’t care about the MB format. dump1090 will happily demodulate whatever Comm-B response comes along; the question is whether that data is then interpreted or not. You’ll still see the raw messages. Search for “unknown format” in that output above, those are messages where dump1090 couldn’t find a good interpretation of the MB data.

Ah, probably far enough from Cambridge that I don’t hear it.

By the way i found the actual type of the wrong heading BDS5,0 i was getting.
If i remember correctly it’s BDS6,0

So it’s actually a message with magnetic heading and some other stuff.
I don’t remember exactly.
Tried to come up with a way to somehow change the scoring logic in dump1090-fa to better guess in my particular case but eventually gave up on it.

After all it seems to be limited to some very strange transponders.

On the actual topic: Would the following command display messages with unknown format?

view1090-fa --no-interactive | grep 'unknown format'

Oh yes it does and i’m getting quite a few right now.

Edit: A sample of view1090-fa --no-interactive output with unkown format contained if you want to take a look (5 MB)
http://wiedehopf.hopto.org:38172/stuff/unknown_format.txt
(Seems to be only one aircraft though, maybe it’s a strange transponder once again.)

In fact, they have!
Do you know the formula for getting temperature from these data? I’ll try to calculate manually and compare to ModeSMixer.

I have some work in progress to try to fix this, but as you discovered it’s a delicate juggling act to score the messages well.

On the 4,4 messages, it seems i am receiving some and was able to decode them with:
https://github.com/junzis/pyModeS

Note the 4,4 function is deemed experimental.

I first collect some unkown format messages and save them to a file:

awk '/unknown format/ {print;printf "\n"}' RS= <(view1090-fa --no-interactive) >/tmp/unknown

Then i used this small python script (placed inside the cloned pyModeS directory):

#!/usr/bin/python

import pyModeS as pms
import sys


temp = []

for line in sys.stdin :
    temp.append(line)
    if line == "\n" :
        msg=temp[0].replace("*", "").replace(";", "")
        if pms.bds.bds44.is44(msg) :
            for line in temp :
                print line,
            print
            print pms.commb.wind44(msg, rev=False)  # Wind speed (kt) and direction (true) (deg)
            print pms.commb.temp44(msg, rev=False)  # Static air temperature (C)
            print pms.commb.p44(msg, rev=False)     # Average static pressure (hPa)
            print pms.commb.hum44(msg, rev=False)   # Humidity (%)
            print
        temp = []

The python script wants view1090-fa output on std input:

./la.py </tmp/unknown2 > /var/www/stuff/sample.txt

The script looks for message blocks that are 4,4 and prints the message block and the wind speed/direction as well as temperature.

Sample output i got:

*a0000cb218b3b3d7e77000374351;
CRC: 44048a
RSSI: -14.3 dBFS
Time: 113190352518.25us
DF:20 addr:44048A FS:0 DR:0 UM:0 AC:3250 MB:18B3B3D7E77000
 Comm-B, Altitude Reply
  Comm-B format: unknown format
  ICAO Address:  44048A (Mode S / ADS-B)
  Air/Ground:    airborne?
  Baro altitude: 19450 ft


(44.0, 332.6)
-20.1
476
None

More output from the script:
https://pastebin.com/raw/XMqnGCj4

1 Like

This seems plausible (476 hPa matches a baro altitude of 19450ft and the other values seem reasonable)

Got some samples and it’s working here too!
First time i tried to implement BDS 4,4 on dump1090 I used exactly this algoritm from pyModes and didn’t worked (using live data)…but I guess it did and I just didn’t saw results :confused:

Now one question for @obj: is possible do re-use saved data in dump1090 for testing?
Since I know that I have some working data, it’s easier to test/implement this feature using this data. If so, how?!

You can run dump1090 with --net-only --net-ri-port 12345 and then feed the *....; lines to port 12345 e.g. with socat or nc

(I actually have some changes floating around that let you feed it via stdin which is easier, I should dig those up)

tks, I’ll try!!!

Some more 4,4 messages as determined by pyModeS if you want some more to decode:

*a0000f3c18bba9cdc000004c6477;
*a0000d1818ab87d74000005e99a8;
*a0000d1818af7fd7400000846a2b;
*a0000d1818ab7fd7400000af1a71;
*a0000d1818a77dd7400000d49f03;
*a0000d18189f83d740000070757b;
*a0000d18189783d74000002695cf;
*a0000d18189b7fd70000002c5592;
*a0000d18189b7fd70000002c5592;
*a0000d1818937fd70000007ab526;
*a0000d18189379d7000000708b82;
*a0000c34189393da8000008836c6;
*a0000c17189b79db400000f56715;
*a0000bbb189779dc400000ebe50d;
*a0000b9e188f7bdd000000e976e7;
*a0000eb1189fabcf800000204e5e;
*a0000b1e189779df000000d02821;
*a0000e9d189bafd0000000087519;
*a0000e9b189ba9d0000000fb6378;
*a0000abc189b79e000000073efb6;
*a0000e3e189ba7d0c0000044c5d8;
*a0000e3d189ba1d0c00000cd951a;
*a000149818c357cd244800d03329;
*a0000ab0189775e10000003c5ac0;
*a0000e35189babd14000001b160a;
*a0000e1918979fd2000000e4e6d0;
*a000149818bf53cd2448001f26f5;
*a0000db6188b91d340000028ed9c;
*a0000d9d188f8dd3c0000063fbaf;
*a0000d9b188f8dd400000029dd2c;
*a000149918bb69cca44800c4c3bf;
*a0000d39189395d5000000b04b05;
*a0000d3218979bd5800000e90042;
*a000149818b76dcca44800cba24b;
*a0000d3118979bd58000006a6e24;
*a0000d1c188f97d600000044aa41;
*a000149818b373cca44800c21625;
*a000149818b373cca44800c21625;
*a000149818b377cca44800ce3d1d;
*a000149818b377cca44800ce3d1d;
*a0000cbf188f91d6c00000c2a61d;
*a000149818af73cce4480098bff1;
*a000149818af73cce4480098bff1;
*a000149818af71cce448009eaa6d;
*a0000cb9188f93d7400000fc62ba;
*a000149818af6dcd244800f17a69;
*a000149818af6dcd244800f17a69;
*a000149818b775cda44800c8a588;
*a0000c9b18878fd8000000ae1790;
*a000149818b779cde44800562092;
*a000149818b779cde44800562092;
*a000149818af83cde44c0062a10b;
*a000149818af85cde44c00689faf;
*a0000c1b188f89da800000dca7ab;
*a000149818ab85cda44c00c917a7;
*a000149818ab83cda44800fb1f03;
*a000149818a77dcca4480056cfc3;
*a0000bb6189b85dbc000002154bd;
*a000149818b383cc244800c1c721;
*a0000b9e189b87dcc00000d96e92;
*a000149818b383cc244800c1c721;
*a000149818b387cc244800cdec19;
*a0000b98189b87dd0000006b47fb;
*a000149818b387cc244800cdec19;
*a000149818b387cc64480047144b;
*a0000b91189b89dd800000e4c8a2;
*a000149818b37fcc644800b69792;
*a000149818af73cca448001247a3;
*a000149818af73cca448001247a3;
*a000149818af73cca448001247a3;
*a000149818af73cca448001247a3;
*a0000b1918a787de40000004d501;
*a000149818b36dcd244800212bef;
*a000149818b36dcd244800212bef;
*a000149818b769cd24480006708d;
*a000149818b769cd24480006708d;
*a000149818bb6dcd644800fd3309;
*a000149818bb6dcd24480077cb5b;
*a000149818b76bcce448004b64bd;
*a000149818b76bcce448004b64bd;
*a000149818af6fcca4480036960b;
*a000149818ab75cc64480053f5a2;
*a000149818b379cc244800365164;
*a000149818b367cd2448003f6803;
*a000149818af67cd244c00d70f85;
*a000149818a779cca448005ae4fb;
*a000149818b76dcce44800415a19;
*a000149818bb6bcd644800f70dad;
*a000149818b76fcd244c00347829;
*a000149818ab73cca44c000101f9;
*a000149818ab73cb24480000c1ed;
*a00006b818a775ef400000b40214;
*a00006b8189371eec000005b1739;
*a0000f9818a3dbcc80000030fb95;
*a0000f981897dbcc800000123c7e;
*a00006b718a36fef4000003f56a7;
*a0000f98189fe5cc80000007413e;
*a00006b8189f6beec000000868db;
*a0000f99189bdfcc8000001d5d8a;
*a0000f99189bdfcc8000001d5d8a;
*a0000e38188795d20000000d5a7b;
*a0000f991893dbcc800000479606;
*a0000f98188fd7cc800000fd60ea;
*a0000f991897d7cc800000789b14;
*a0000f99189bd5cc800000031e66;
*a0000f98189fd3cc8000005c8aba;
*a0000f98189bd5cc8000007dc444;
*a0000f98189fd5cc80000056b41e;
*a0000f98189fd7cc80000050a182;
*a0000f98189bd9cc80000069b90c;
*a0000f981897dfcc8000001e1746;
*a0000f981897ddcc8000001802da;
*a0000f98189bd7cc8000007bd1d8;
*a0000f98189bd1cc80000071ef7c;
*a0000f981893dfccc00000bf9f4e;
*a0000f98187fe3cd400000c4d62b;
*a0000f981887d7ccc0000021780c;
*a0000f101893c7cde66800055df3;
*a0000f101893c7cde66800055df3;
*a0000f10188fc5ce266800cfe2e3;
*a0000f98188bd1cc800000dc2e14;
*a0000f101883b7ce266800272131;
*a0000f101883c3cde66800a4b7a3;
*a0000f981887cdcd0000004496ac;
*a0000f10188bb7cde668006d3a8f;
*a0000f981893d9cc8000003f59b8;
*a0000f101887b7cda668009a5233;
*a0000f981893dbccc00000b3b476;
*a0000f101887b9cda66800883ae7;
*a0000f98188bd5cd00000011fcd2;
*a0000f101887b7cde6680010aa61;
*a0000f98188bdbccc000004895aa;
*a0000f98188bdfccc0000044be92;
*a0000f101887c7cde6680083ecc1;
*a0000f98187bebccc000003609ff;
*a0000f101883c3cde66800a4b7a3;
*a0000f981873ddcd000000702363;
*a0000f10188bc1cde66800f4428b;
*a0000f99188bd3cd000000651854;
*a0000f101887b1cde668001a94c5;
*a0000f981883d1cd0000004b375e;
*a0000f101893b1cde668009c25f7;
*a0000f101893b3cde668009a306b;
*a0000f101897a7ce266800913ce3;
*a0000f1018a7b1cde66800bee21c;
*a0000f1018a3b1ce26680089694c;
*a0000f1b189fc7ce40000047f5cf;
*a0000eb3189fb1cea67c00236ab9;
*a0000f12189fbbcec000005d29aa;
*a0000ebc189bb9cf000000a4fc66;
*a0000e9018a7abcfe6a0007947e9;
*a0000e3618a3a7d0a6b400962547;
*a000129c18bb9bcb000000c41031;
*a0000e3e188fa5d08000004e9936;
*a0000e34189ba7d1800000114d8d;
*a0000e1a188fa1d240000055ccde;
*a0000d9f18aba9d366fc0094ade5;
*a0000e10188b9dd2c0000025bd07;
*a0000d9b189793d4000000f038d6;
*a0000d36189b97d5400000e48d88;
*a0000d1f189f91d5c000007cc0f3;
*a0000d1c189b8fd6000000eae1f1;
*a0000d11189f8fd6c00000d212f5;
*a0000cb218b3b3d7e77000374351;
*a0000cb7189791d780000091bbd0;
*a0000c97189b8bd880000095cc12;
*a0000c3d18afb3d9679c00bbdafb;
*a0001032189babc9c000000face5;
*a0000c3618a7b1d9e7a8006dd613;
*a0000c15189f93dac00000256048;
*a0000bbf189fa1daa7d800b884ae;
*a020169000000031800000578f2b;
*a020169000000031800000578f2b;
*a0000fb71893abcb800000d3d764;
*a0000bb51897a3db27ec003baf37;
*a0000eb518c013d0c00000bac82f;
*a0000f9a188b9fcc800000f141b0;
*a0000f93188f99ccc000002d143c;
*a0000f3d188f8fcd400000911a69;
*a0000f9018c815cd40000011bbd5;
*a0000f9d18c417ccc00000d8b8f8;
*a0000f19188f97ce80000085637a;
*a0201499000000307c0000e4fa32;
*a0201499000000307c0000e4fa32;
*a8200bb6000000307c0000330d46;
*a0000a96189387e100000025267a;
*a0000ebc188b9bcf8000008475f9;
*a0000e9f188f9bd0400000a45631;
*a0000e9f188f9bd0400000a45631;
*a000109818dff9cac0000034108d;
*a0000e91189397d1400000bb966b;
*a000109f18e7f9ca800000664d3d;
*a0000e3b189393d180000094b8c2;
*a0000e1e189385d28000008c8fd8;
*a0000e1e189385d28000008c8fd8;
*a0000e1e189385d28000008c8fd8;
*a0000e1e189385d28000008c8fd8;
*a000111718e3f9cbc00000ae450d;
*a0000e11188b85d3400000b2644d;
*a000113118e3e9cc4000007ad334;
*a000113c18e3d9cc80000038a54a;
*a0000d98188f87d50000009f0de1;
*a0000d3618978bd60000004b336f;
*a0000d1618978bd7000000442a34;
*a000119718f3d1cbc00000e91bf5;
*a0000cb5188f89d8400000acc409;
*a0000c95189f81d9400000164a4a;
*a00011b818f7ddccc00000afcbb3;
*a000123318efe5ccc000009206a9;
*a0000b33189f7ddec000009679b6;
*a0000abb18a377e040000033dacc;
*a000129218f3e7cdc00000a611ea;
*a000129918efe9cd80000064878e;
*a00012b218f3e7cdc0000082f5e2;
*a00012bd18efe7cd8000005697d3;
*a00012be18efe7cd800000d5f9b5;
*a000139418bbddce0000003559af;
*a000139518bbddce0000004b838d;
*a000139a18bfdbce4000006efec4;
*a000139b18c3dbce400000d31a02;
*a00013b918d3e5ce80000084ea2d;
*a000141718d7e9ce800000f6b334;
*a00019111923a7d06314009e5419;
*a0001911191fa7d0231400608b14;
*a00019101927a5d02314004713af;
*a0001911191fa3cfe31400c079d0;
*a0001911191ba1cfe31400ed1c16;
*a00019111913a3cfa3140037116c;
*a00019111903a5cfa31000a8d8a0;
*a000191118f3a7cfa310005ddebe;
*a000191118f3a7cfa310005ddebe;
*a000191118e7abcfe314007ddc96;
*a000191118dfabd02314008e526f;
*a000191118dfabd063140004aa3d;
*a000191118e3a9d0a31400166401;
*a000191118ebabd0a31400469129;
*a000191018f3abd0a31400c36ad7;
*a000191018fbadd0a314009fb4c7;
*a000191018f7afd063140084cd4a;
*a000191018f7afd063140084cd4a;
*a000191018f3afd0631400afbd10;
*a000191118e3abd0a3140010719d;
*a000191118e3abd0e314009a89cf;
*a000191118ebadd0e31400c657df;
*a000191018f7add0e3140068dc7b;
*a000191018ffadd0631400d43862;
*a000191018ffadd0631400d43862;
*a000191018efadd0231400f30158;
*a000191118e3abd0231400fa7530;
*a000191118d7a3d0631000722af9;
*a000191118d7a3d06314004a1cf9;
*a000191118e7a7d0a314002f7c8f;
*a000191018efa9d0a31400152ecd;
*a000191018efa9d063140075d232;
*a000191118eba9d063140020784a;
*a000191118e7a9d06314005de8a4;
*a000191118e3a9d06314007698fe;
*a000191118e7a9d06314005de8a4;
*a000191118ebabd0631400266dd6;
*a000191018efa9d063140075d232;
*a000191118f7abd0631400f63c50;
*a000191118fbb5cfe314008f4924;
*a000191118f7b9cfe31400e6a482;
*a000191118f7b9cfe31400e6a482;
*a000191118f3add02314005d8afc;
*a000191018f3a7d02314003d1332;
*a000191118efa7d0231400939896;
*a000191118f7a7d023140068b94a;
*a000191118f3a7d023140043c910;
*a000191018f7a5d02314001076f4;
*a000191018f7a3d02314001a4850;
*a000191018f7a3d02314001a4850;
*a000191118f3a7cfe31400ef10ec;
*a000191118efa7cfe314003f416a;

Am I missing something?! I’m not so familiar with nc.

./dump1090 --net --net-only

Check:
pi@raspberrypi:~ $ sudo netstat -plnt | grep dump1090
tcp 0 0 0.0.0.0:30001 0.0.0.0:* LISTEN 7921/./dump1090
tcp 0 0 0.0.0.0:30002 0.0.0.0:* LISTEN 7921/./dump1090
tcp 0 0 0.0.0.0:30003 0.0.0.0:* LISTEN 7921/./dump1090
tcp 0 0 0.0.0.0:30004 0.0.0.0:* LISTEN 7921/./dump1090
tcp 0 0 0.0.0.0:30005 0.0.0.0:* LISTEN 7921/./dump1090
tcp 0 0 0.0.0.0:30104 0.0.0.0:* LISTEN 7921/./dump1090

Then:
cat moredata.txt | nc 127.0.0.1 30001

And nothing happens! nc don’t even end/stop running.