【RTL-SDR】用RTL-SDR实现航班追踪(ADS-B)

背景介绍#

ADS-B是广播式自动相关监视,顾名思义,即无需人工操作或者询问,可以自动地从相关机载设备获取参数向其他飞机或地面站广播飞机的位置、高度、速度、航向、识别号等信息,以供管制员对飞机状态进行监控。(来自百度百科),然而市面上专门的ADS-B最少要200刀,能不能用我们不到20刀的电视棒代替呢,当然可以,因为我国民航飞机的通讯频率为1090MHz,电视棒(RTL2832U+R820T)接收的频率范围为 24 ~ 1766 MHz。而且因为因为航空CNS标准是公开的(脉冲位置,相对幅度等)。而且通过明文传输信息(112个未加密的脉冲字),因此编制解调软件(SDR)可以正确解调信号。

工具#

电视棒+Linux系统(这里用Ubuntu)
ps:不常用Linux系统的同学可以用虚拟机安装一个,不是很难~可以自行百度一下噻。

开始!!#

首先我们要安装一个软件:dump1090
打开终端
养成好习惯先建一个专属文件夹

mkdir sdr 

在github上克隆源码到虚拟机然后编译

cd sdr
git clone https://github.com/antirez/dump1090.git
cd dump1090/
make 

然后会发现

Package librtlsdr was not found in the pkg-config search path.
Perhaps you should add the directory containing `librtlsdr.pc'
to the PKG_CONFIG_PATH environment variable
No package 'librtlsdr' found
cc -O2 -g -Wall -W  -c dump1090.c
dump1090.c:46:21: fatal error: rtl-sdr.h: 没有那个文件或目录
 #include "rtl-sdr.h"
                     ^
compilation terminated.
Makefile:9: recipe for target 'dump1090.o' failed
make: *** [dump1090.o] Error 1

报错。。仔细一看是缺少librtlsdr这个包
(经过各种百度之后)
首先更新一下

 apt-get update

然后安装包

apt-get install librtlsdr-dev 

之后

make

就可以了。
然后我们要把电视棒导入虚拟机中,怎么做呢。。请百度hh。。
然后用命令检测一下

lsusb

发现了usb就可以执行命令运行文件

./dump1090

就可以啦
运行命令还可以加参数

./dump1090 --raw

可以看见原始(raw)的16进制消息

./dump1090 --interactive

这会出现比较好的交互模式,我出现的航班信息:

./dump1090 --interactive
*5d780d585dc125;
CRC: 5dc125 (ok)
DF 11: All Call Reply.
  Capability  : Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is on airborne)
  ICAO Address: 780d58

*8d780d58587176d9e653a62b36c3;
CRC: 2b36c3 (ok)
DF 17: ADS-B message.
  Capability     : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is on airborne))
  ICAO Address   : 780d58
  Extended Squitter  Type: 11
  Extended Squitter  Sub : 0
  Extended Squitter  Name: Airborne Position (Baro Altitude)
    F flag   : odd
    T flag   : non-UTC
    Altitude : 21575 feet
    Latitude : 93427 (not decoded)
    Longitude: 21414 (not decoded)

*8d780d589940a131488c2c5ec41c;
CRC: 5ec41c (ok)
DF 17: ADS-B message.
  Capability     : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is on airborne))
  ICAO Address   : 780d58
  Extended Squitter  Type: 19
  Extended Squitter  Sub : 1
  Extended Squitter  Name: Airborne Velocity
    EW direction      : 0
    EW velocity       : 161
    NS direction      : 0
    NS velocity       : 394
    Vertical rate src : 0
    Vertical rate sign: 1
    Vertical rate     : 35

*8d780d4b588f8358c0f3c89d206f;
CRC: 9d206f (ok)
DF 17: ADS-B message.
  Capability     : 5 (Level 2+3+4 (DF0,4,5,11,20,21,24,code7 - is on airborne))
  ICAO Address   : 780d4b
  Extended Squitter  Type: 11
  Extended Squitter  Sub : 0
  Extended Squitter  Name: Airborne Position (Baro Altitude)
    F flag   : even
    T flag   : non-UTC
    Altitude : 27600 feet
    Latitude : 109664 (not decoded)
    Longitude: 62408 (not decoded)

当然这样还是不直观,不如放在地图上表示,这两个参数:

./dump1090 --interactive --net

可以将我们的收到的航班信息放在Google地图上,然后在浏览器中输入http://localhost:8080/,就得见了

这里说一个常见报错

Found 1 device(s):
0: Realtek, RTL2838UHIDIR, SN: 00000001 (currently selected)
usb_claim_interface error -6
Error opening the RTLSDR device: Device or resource busy

字面上也看得出,就是电视棒被占用。。简单解决方法就是重新安装一下。

后记#

对于Linux小白的我开始弄这个项目弄了好几天的,所以给大家推荐一个Linux学习网站
然后这篇博文也参考诸多大神的博客,在这里表达一下感谢。
然后想要找大神原文的。。嗯,我把GitHub上的一篇分享给大家。
最后希望无论是各位大神发现错误指点,还是同好有兴趣共同讨论,都可以在下面评论区畅所欲言,本豆花感谢各位赏脸hh。

posted @ 2017-07-26 12:03  Lazy_beanfa  阅读(4098)  评论(0编辑  收藏  举报