# Some efforts and tools on GPS simulation and RF signal replay

**URL:** <https://www.ruby-forum.com/t/some-efforts-and-tools-on-gps-simulation-and-rf-signal-replay/232883>\
**Category:** GNU Radio\
**Created:** [November 2, 2014, 1:04pm UTC](https://www.ruby-forum.com/t/some-efforts-and-tools-on-gps-simulation-and-rf-signal-replay/232883 "2014-11-02T13:04:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![addis\_a](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/c4cdca/32.png) [@addis\_a](https://www.ruby-forum.com/u/addis_a)\
**Post date:** [November 2, 2014, 1:04pm UTC](https://www.ruby-forum.com/t/some-efforts-and-tools-on-gps-simulation-and-rf-signal-replay/232883/1 "2014-11-02T13:04:39Z")

</div>

Some efforts were put on replaying GPS signal  
[http://sdr-x.github.io/Some%20efforts%20and%20tools%20on%20GPS%20signal%20replay%20(GPS重放模拟)/](http://sdr-x.github.io/Some%20efforts%20and%20tools%20on%20GPS%20signal%20replay%20%28GPS%E9%87%8D%E6%94%BE%E6%A8%A1%E6%8B%9F%29/),  
but it is only partially successful, not fully successful. Some  
tools/scripts, as side products, are useful. Learn many things from  
here:  
[http://www.aholme.co.uk/GPS/Main.htm](http://www.aholme.co.uk/GPS/Main.htm)

_WARNING：DO NOT SEND ANY REAL GPS SIGNAL. USE CHAMBER AND CLOSE-LOOP  
CABLE!  
MAKE SURE ALL YOUR OPERATIONS ARE LEGAL!_

Get codes, program and sample GPS signals here:

> **[GitHub - JiaoXianjun/GNSS-GPS-SDR: Some efferts on GPS replay, receive and test.](https://github.com/JiaoXianjun/GNSS-GPS-SDR)**
>
> Some efferts on GPS replay, receive and test. Contribute to JiaoXianjun/GNSS-GPS-SDR development by creating an account on GitHub.

To build the C program “gps\_test” in “c” directory (front part of  
software  
GPS receiver) after you get the whole repo:

cd c  
make

To let this make smooth, make sure you have fftw library installed  
correctly (sudo apt-get install …). There should be  
/usr/lib/libfftw.a.

1. offline GPS simulation method 1.1 use C program “gps\_test” to receive  
GPS signal generated by Matlab script gps\_sig\_gen.m

_a_. generate GPS signal file by running gps\_sig\_gen.m in Matlab

```
gps_sig_gen.m

```

to get file gps\_sig\_tmp.bin

_b_. use “gps\_test” program to do some initial demodulation and check  
C/A  
codes:

```
gps_test gps_sig_tmp.bin 2.046e6 8.184e6 5000

```

Above program gps\_test performs initial GPS signal capture by multi-bins  
correlation in frequency domain.

gps\_sig\_tmp.bin: input GPS signal generated by gps\_sig\_gen.m (MATLAB).

2.046e6: carrier frequency

8.184e6: sampling rate

5000: maximum frequency offset for frequency searching

You will find that C/A codes results are aligned with GPS signal we  
generate by Matlab script.  
1.2 use C program “gps\_test” to receive GPS signal captured by others  
instead of my our Matlab script gps\_sig\_gen.m

```
gps_test gps.samples.1bit.I.fs5456.if4092.bin 4.092e6 5.456e6 5000

```

gps.samples.1bit.I.fs5456.if4092.bin: captured by others and can be  
downloaded here: [Raw GPS signal samples data set for testing GPS receivers](http://www.jks.com/gps/gps.html)

You will find C/A codes results are equal to those shown here:  
[http://www.jks.com/gps/gps.html](http://www.jks.com/gps/gps.html)  
2. over the air GPS test method 2.1 playback  
gps.samples.1bit.I.fs5456.if4092.bin( [Raw GPS signal samples data set for testing GPS receivers](http://www.jks.com/gps/gps.html) )

_a_. run gps\_bin1bit\_log2bin.m in Matlab to generate playback file for  
HACKRF (they capture GPS signal with 1bit quantization. we convert it to  
8bit format which is needed by HACKRF):  
gps.samples.8bit.IQ.fs5456.baseband.bin

_b_. run gps\_Nottingham.grc to playback  
gps.samples.8bit.IQ.fs5456.baseband.bin over the air. And  
meanwhile/immediately,

_c_. use rtl-sdr to capture signal:

```
rtl_sdr -g 60 -f 1575.42e6 -s 2.8e6 -n 19.2e6 

```

rtl\_2.8Msps\_1575.42MHz.bin

_d_. run proc\_rtl\_bin\_for\_gps(‘rtl\_2.8Msps\_1575.42MHz.bin’) in Matlab to  
convert 8bit file to 1bit file which is needed by gps\_test  
program：rtl\_2.8Msps\_1575.42MHz\_1bit.bin

_e_. see C/A codes initial capture result by running gps\_test program:

```
gps_test rtl_2.8Msps_1575.42MHz_1bit.bin 0.62e6 2.8e6 100000

```

You will find C/A codes results are equal to those shown here:  
[http://www.jks.com/gps/gps.html](http://www.jks.com/gps/gps.html)  
2.2 playback gps\_sig\_tmp\_for\_hackrf\_tx.bin (generated by gps\_sig\_gen.m)  
to  
air by gps.grc.

_a_. run gps.grc to playback gps\_sig\_tmp\_for\_hackrf\_tx.bin over the air.  
And meanwhile/immediately,

_b_. capture air GPS signal by:

```
rtl_sdr -g 60 -f 1574.8e6 -s 2.8e6 -n 19.2e6 

```

rtl\_2.8Msps\_1574.8MHz.bin

_c_. convert captured 8bit file to 1bit bin file which is needed by  
gps\_test: rtl\_2.8Msps\_1574.8MHz\_1bit.bin

```
proc_rtl_bin_for_gps('rtl_2.8Msps_1574.8MHz.bin'); (MATLAB)

```

_d_. RUN:

```
gps_test rtl_2.8Msps_1574.8MHz_1bit.bin 0.62e6 2.8e6 100000

```

to see GPS signal capture result: C/A codes are supposed to align with  
our  
expectation (Matlab script).

_e_. you can also capture air GPS signal with different intermediate  
frequency by:

```
rtl_sdr -g 60 -f 1575.42e6 -s 2.8e6 -n 19.2e6 

```

rtl\_2.8Msps\_1575.42MHz.bin

_f_. convert captured 8bit file to 1bit bin file which is needed by  
gps\_test: rtl\_2.8Msps\_1575.42MHz\_1bit.bin

```
proc_rtl_bin_for_gps('rtl_2.8Msps_1575.42MHz.bin'); (MATLAB)

```

_g_. RUN:

```
gps_test rtl_2.8Msps_1575.42MHz_1bit.bin 0.62e6 2.8e6 100000

```

to see GPS signal capture result: C/A codes are supposed to align with  
our  
expectation (Matlab script).
