Professional Documents
Culture Documents
Mode S: Bit From Bit To Abbr. Name
Mode S: Bit From Bit To Abbr. Name
Mode S: Bit From Bit To Abbr. Name
http://adsb-decode-guide.readthedocs.org/en/latest/introduction.html
Introduction
Mode S
Mode S is the signal carrying the ADS-B data from aircrafts. Modulation and
demodulation of Mode S signal is out of scope of this guide. From our antenna and
A/D converter, we are able to receive the encoded messages to a Linux agent. Our
focuses are from this point on; working with those data.
If you are interested on digging deeper on the Mode S signal, a good starting point is
to have a look at this Wikipedia page, and follow the references:
https://en.wikipedia.org/wiki/Secondary_surveillance_radar#Mode_S
ADS-B
An ADS-B message is 120 bits long, following is an example:
BIN format:
10001101010010000100000011010110001000000010110011000011
01110001110000110010110011100000010101110110000010011000
HEX format:
8D4840D6202CC371C32CE0576098
Bit to
Abbr.
Name
DF
Downlink Format
CA
Message Subtype
32
ICAO24
33
88
DATA
Data frame
89
112
PC
Parity check
The type of the message can be identified by checking its Downlink Format (DF), bit
1 to 5. For ADS-B message, we need: DF = 17 (in decimal), or 10001 (in binary),
Within the data frame, another import value is the Type Code. it tells what is inside of
the data frame, it is located from bit 33 to 37 (5 bits)
Bit from
Bit to
Abbr.
Name
33
37
TC
Type Code
TC
Content
17
1 to 4
Aircraft identification
17
9 to 18
Aircraft position
17
19
Aircraft velocities
Note that within different type of the messages, the configurations of the bits in data
frame are different. In next chapter, those will be explained in detail.
Decoding
In this section we will explain how to read bits in different types of ADS-B messages,
decode and calculate information, such as aircraft ID, position, speed, and heading.
Aircraft Identification
An aircraft identification message has
For example:
8D4840D6202CC371C32CE0576098
DF: 17 ,
and
TC: 1 to 4 .
| | ICAO24 |
DATA
|
|
|----|--------|----------------|--------|
| 8D | 4840D6 | 202CC371C32CE0 | 576098 |
| DF | CA | ICAO24 ADDRESS
| TC |
| Data
|
|-------|-----|--------------------------|-------|-----|--------------------------------------------------|--------------------------|
|
10001
|
101
|
010010000100000011010110
|
00100
|
000
001011001100001101110001110000110010110011100000 | 010101110110000010011000 |
Note that TC is inside of the DATA frame. DF and TC can be easily calculated:
DF: 10001 -> 17
TC: 00010 -> 4
Those two values confirm that the message is good for decoding aircraft
identification.
Next, we are decoding the data frame containing the aircraft callsign (identification).
In order to get the callsign, a look-up table is needed for mapping index numbers to
letters:
'#ABCDEFGHIJKLMNOPQRSTUVWXYZ#####_###############0123456789######'
callsign
callsign
callsign
callsign
callsign
callsign
+=
+=
+=
+=
+=
+=
charset[
charset[
charset[
charset[
charset[
charset[
bin2int(csbin[12:18])
bin2int(csbin[18:24])
bin2int(csbin[24:30])
bin2int(csbin[30:36])
bin2int(csbin[36:42])
bin2int(csbin[42:48])
]
]
]
]
]
]
Aircraft Positions
Decoding the positions of the aircraft is a bit more complicated. Naturally, we would
assume to read latitude and longitude directly from the data frame. Unfortunately its
not that simple...
In fact, two different types of the position messages (odd and even frames) are
needed to find out the LAT and LON of the aircraft. The position is described in so
called Compact Position Reporting (CPR) format, which is hard to understand, and
not well documented.
The advantage of CPR is that it uses less bits to encode the position information.
The dis-advantage is obviously the complexity of calculation.
An aircraft position message has
DF: 17 ,
and
TC: from 9 to 18 .
In both message we can find: DF=17 and TC=11 , with the same ICAO24
address 40621D . So those two frames are valid for decoding the positions of this
aircraft.
At each frame, Bit-54 (title F) determine whether it is odd or even:
0 -> Even frame
1 -> Odd frame
131072 is 2^17 since CPR latitude and longitude are encoded in 17 bits. The values
represent the percentages.
Step 2: Calculate the Latitude Index j, using following equation
j=floor(59LatCPRE60LatCPRO+0.5)
j=8
Then we can use the following equations to compute the relative latitudes:
LatE=DLatE(mod(j,60)+LatCPRE)
LatE=LatE360if (LatE270)
LatO=DLatO(mod(j,59)+LatCPRO)
LatO=LatO360if (LatO270)
If a relative latitude results are greater than 270, it means the aircraft is at southern
hemisphere. Then a substraction of 360 is applied. 131072 is 2^17 since CPR
latitude and longitude are encoded in 17 bits.
Here, we have:
Lat_EVEN = 52.25720214843750
Lat_ODD = 52.26578017412606
Then, we need to check if Lat_EVEN and Lat_ODD are in the same latitude zone. If
not, simply make an exit here; wait for new data, the run the computation again.
There are 60 latitude zones pre-computed. You may refer to the python source code
to see how latitudes degrees are divided into different zones. We have a
function NL() retrieving the NL value In our case, both value are in latitude zone 36,
good to continue.
The final Latitude is chosen by the time stamp of the frames, the newest one is used:
Lat={LatELatOif (T0T1)else
In our case:
Lat = Lat_EVEN = 52.25720214843750
ni={N(LatE,0)N(LatO,1)if (T0T1)else
m,
m={floor[LonCPRE(NL(LatE)1)LonCPRONL(LatE)
+0.5]floor[LonCPRE(NL(LatO)1)LonCPRONL(LatO)+0.5]if
(T0T1)else
Longitude is then calculated:
Lon={360.0ni(Mod(m,ni)+LonCPRE)360.0ni(Mod(m,ni)+LonCPRO)if
(T0T1)else
Lon=Lon360if (Lon180)
Step 6: So now we have the final coordinate of the aircraft
Lat: 52.25720
Lon: 3.91937
else:
ni = cprN(lat_odd, 1)
m = math.floor( cprlon_even * (cprNL(lat_odd)-1) - cprlon_odd * cprNL(lat_odd) + 0.5 )
lon = (360.0 / ni) * (m % ni + cprlon_odd)
lat = lat_odd
if lon > 180:
lon = lon - 360
return [lat, lon]
Calculate altitude
Altitude of aircraft in the data frame is much easier to be computed. The bits in the
altitude field (either odd or even frame) are as following:
1100001 1 1000
^
Q-bit
This Q-bit (Bit 48) indicates whether the altitude can be decoded. If the value is zero,
we will exit the calculation. If one, then the altitude value can be computed from the
rest of the bits.
Off the topic: really dont understand why someone wanted to put this bit in the
middle...
After removing Q-bit:
N = 1100001 1000 => 1560 (in decimal)
Alt=N251000 (ft.)
In the example, the altitude at which aircraft is flying is:
1560 * 25 - 1000 = 38000 ft.
The position
So finally, we have all three value (LAT/LON/ALT) of the aircraft position:
LAT: 52.25720
LAT: 3.91937
ALT: 38000 ft
DF: 17 , TC: 19 .
8D40621D99454F9E0004A7715C19
| | ICAO24 |
DATA
|
|
|----|--------|----------------|--------|
| 8D | 40621D | 99454F9E0004A7 | 715C19 |
| DF | CA | ICAO24 ADDRESS
| TC | ......
|-------|-----|--------------------------|-------|------| 10001 | 101 | 010000000110001000011101 | 10011 | ......
We can confirm the DF=17 and TC=19. Good to decode the velocity. Next, lets
extract the DATA frame part:
HEX: 99454F9E0004A7
| TC | ST | IC | IFR | VU | S-EW | V-EW
| S-NS | V-NS
| V-rate sign source | TI | GHD sign |
|-------|-----|----|-----|-----|------|------------|------|------------|--------------------|----|------------|
| 10011 | 001 | 0 | 1 | 000 | 1
| 0101001111 | 1
| 0011110000 | 000000000 0 1
| 00 |
1010011 1 |
There are many parameters in the the velocity message. From left to rights, the
number of bits indicate the following contents:
No. of bits
Content
Type code
Subtype
Velocity uncertainty
10
East-West velocity
10
North-South velocity
Vertical rate
No. of bits
Content
Turn indicator
7+1
NOTE: If you are also refering an interenet document called ADS-B for Dummies
by EuroControl, be very aware, the information table in that document is NOT
correct !! The bits for velocities and sign were ordered wrong in that document.
For calculating the speed and heading we need four values, East-West
Velocity V(ew) , East-West Velocity Sign S(ew) , North-South Velocity V(ns) , NorthSouth Velocity Sign S(ns) . And pay attention on the directions (signs) in the
calculation.
v=V2we+V2sn
h=arctan(VweVsn)3602(deg)
In case of an negative value here, we will simply add 360 degrees.
h=h+360(if h<0)
So, now we have the speed and heading of our example:
V(ew): 0101001111 -> 335
S(ew): 1
Tips on ADS-B
If you have to write every line of code from scratch, reading and decoding ADS-B
messages can be difficult at some point. Here we have some tips for those who
might encounter the same challenges as we had.
Aircraft Identification
After the aircraft ID (aka. Callsign) is decoded, there are sometimes spaces in the
Callsign. Each time you decode on Callsign, you may want to strip the spaces before
Whats next?
Our research goes far beyond the decoding the ADS-B messages. The goal of this
research of Junzi is to collect large amount of aircraft data from ADS-B signals, and
then using data mining methods to understand, improve, and maybe even create
aircraft performance models.
If you are interested, or you have any question regarding the decoding process,
please feel free to contact Junzi Sun (j.sun-1[at]tudelft.nl)