Changes between Version 1 and Version 2 of Tutorials/k0SDR/Tutorial20


Ignore:
Timestamp:
Oct 10, 2016, 3:58:48 PM (8 years ago)
Author:
nilanjan
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Tutorials/k0SDR/Tutorial20

    v1 v2  
    1 == Wireless File Transfer via SDR ==
     1== Example: A Simple Wireless Data Transfer via SDR ==
    22
     3Here is an example of a Quick and Dirty Radio (QDR) to transfer low data rate packets over the air using USRPs. For simplicity this QDR does not utilize any form of correction techniques or feedback for packet retransmission.
     4
     5We'll use two nodes on the grid: node14-7 as the transmitter and node1-20 as the receiver. Load the nodes with 'baseline-sdr-uhd-003.009.003.ndz'.
     6
     7Two applications are being utilized:
     81) rf_hw_intf - configures radio, sets frequency channel, samples rate, gain, reads / writes samples to / from radio front end to circular buffer.
     92) qdr - the sample processing application accesses circular buffer for processing sample data to / from packets.
     10
     11
     12=== Part 1: Run the applications for file transfer ===
     13On node1-20, run the following commands to start the receiving process.
     14
     15node1-20> taskset 0x1 (rf_hw_intf  --freq 950e6 --gain 0 --rx-only &)
     16
     17node1-20> taskset 0x2 qdr --func rx --ftp-data file
     18
     19{{{
     20linux; GNU C++ version 4.8.4; Boost_105400; UHD_003.009.004-0-unknown
     21
     22Creating the usrp device with: addr=192.168.10.2...
     23-- Opening a USRP2/N-Series device...
     24-- Current recv frame size: 1472 bytes
     25-- Current send frame size: 1472 bytes
     26Using Device: Single USRP:
     27  Device: USRP2 / N-Series Device
     28  Mboard 0: N210r4
     29  RX Channel: 0
     30    RX DSP: 0
     31    RX Dboard: A
     32    RX Subdev: SBXv3 RX
     33  TX Channel: 0
     34    TX DSP: 0
     35    TX Dboard: A
     36    TX Subdev: SBXv3 TX
     37
     38Setting RX Rate: 5.000000 Msps...
     39Actual RX Rate: 5.000000 Msps...
     40
     41Setting RX Freq: 950.000000 MHz...
     42Actual RX Freq: 950.000000 MHz...
     43
     44Setting RX Gain: 0.000000 dB...
     45Actual RX Gain: 0.000000 dB...
     46
     47waiting for ready signal...
     48Checking RX: LO: locked ...
     49Setting TX Rate: 5.000000 Msps...
     50Actual TX Rate: 5.000000 Msps...
     51
     52Setting TX Freq: 950.000000 MHz...
     53Actual TX Freq: 950.000000 MHz...
     54
     55Setting TX Gain: 0.000000 dB...
     56Actual TX Gain: 0.000000 dB...
     57
     58Checking TX: LO: locked ...
     59Recv proc started...
     60
     61Preamble: 1
     62Feedback: 0
     63Return Acks: 0
     64FEC: 0
     65BC: 0 CC: 0 TC: 0
     66Fast Walsh: 0
     67Interleave: 0
     68waiting for ready signal...
     69SPB(SHM) = 256
     70[3175.03] 0 0
     71nf - - - - - - - - - - - - - - -
     72}}}
     73
     74Similarly on node14-7, start the transmitting process to send an audio file.
     75
     76node14-7> taskset 0x1 (rf_hw_intf --freq 950e6 --gain 20  --tx-only &)
     77
     78node14-7> taskset 0x2 qdr --func tx --ftp-data SimpleMinds.wav --intv 1000
     79
     80{{{
     81Creating the usrp device with: addr=192.168.10.2...
     82-- Opening a USRP2/N-Series device...
     83-- Current recv frame size: 1472 bytes
     84-- Current send frame size: 1472 bytes
     85Using Device: Single USRP:
     86  Device: USRP2 / N-Series Device
     87  Mboard 0: N210r4
     88  RX Channel: 0
     89    RX DSP: 0
     90    RX Dboard: A
     91    RX Subdev: SBXv3 RX
     92  TX Channel: 0
     93    TX DSP: 0
     94    TX Dboard: A
     95    TX Subdev: SBXv3 TX
     96
     97Setting RX Rate: 5.000000 Msps...
     98Actual RX Rate: 5.000000 Msps...
     99
     100Setting RX Freq: 950.000000 MHz...
     101Actual RX Freq: 950.000000 MHz...
     102
     103Setting RX Gain: 20.000000 dB...
     104Actual RX Gain: 20.000000 dB...
     105
     106Checking RX: LO: locked ...
     107Setting TX Rate: 5.000000 Msps...
     108Actual TX Rate: 5.000000 Msps...
     109
     110Setting TX Freq: 950.000000 MHz...
     111Actual TX Freq: 950.000000 MHz...
     112
     113Setting TX Gain: 20.000000 dB...
     114Actual TX Gain: 20.000000 dB...
     115
     116Checking TX: LO: locked ...
     117Xmit proc started...
     118UDP receive proc started
     119Receiver ready on port: 1339
     120L
     121
     122Preamble: 1
     123Feedback: 0
     124Return Acks: 0
     125FEC: 0
     126BC: 0 CC: 0 TC: 0
     127Fast Walsh: 0
     128Interleave: 0
     129SPB(SHM) = 256
     130root@node14-7:~/RTX_LOOPBACK#
     131}}}
     132
     133While the file is being received, verify that the file size is incrementing. The receiving file name should be the original file name (from the transmitter side) prefixed with "rx_". So look for the file name 'rx_SimpleMinds.wav'
     134
     135Since the file is a .wav audio format we should able to listen to the file as it is downloaded. Start a simple http file server on the receiving node (tunneling is required)
     136
     137node1-20> python -m SimpleHTTPServer 7000
     138
     139Use Chrome to access the server and click on the .wav file being received for playback.
     140
     141Once the transfer is complete, compare the file checksum.
     142
     143node14-7> sum SimpleMinds.wav
     14403167 10205
     145
     146node1-20> sum rx_SimpleMinds.wav
     14703167 10205
     148
     149If the check sums are different then at least some packets were demodulated incorrectly. The incorrect packets will result in distortion in the audio playback.
     150
     151=== Part 2: View signal before demodulation ===
     152Let's slow down the transfer process and look at the signals as they are being received. In order for packet demodulation, the receiver must know where the signal starts. The signal detection starts with the detection of a known sequence of patterns; in this case it is a dual tone signal. On possible detection a simple FFT based correlation is performed to find a start offset.
     153The sample processing application can send a few buffers to octave for viewing pleasure, debugging or verification.
     154
     155Demodulation is carried on from this offset to convert the signal into formatted packets.
     156
     157Rerun the qdr application for raw data processing:
     158node1-20> qdr --func rx --pdu-data --port 1337 --addr 10.10.0.10
     159node14-7> qdr --func tx --pdu-data --intv 2000000
     160
     161From the grid console, run the script below to view signaling:
     162{{{
     163if (exist("rcv_sck","var") == 0)
     164  rcv_port = 1337;
     165  rcv_sck = fUDP_open_rx(rcv_port);
     166  printf("Recv UDP pkts on port %i\n", rcv_port)
     167endif
     168
     169
     170  while(1),
     171    [recv_data, recv_count]=recv(rcv_sck,4000,MSG_WAITALL); y1 = typecast(uint8(recv_data), 'single complex');
     172    sleep(0.1)
     173    [recv_data, recv_count]=recv(rcv_sck,4000,MSG_DONTWAIT); y2 = typecast(uint8(recv_data), 'single complex');
     174    sleep(0.1)
     175    [recv_data, recv_count]=recv(rcv_sck,4000,MSG_DONTWAIT); y3 = typecast(uint8(recv_data), 'single complex');
     176    sleep(0.1)
     177    [recv_data, recv_count]=recv(rcv_sck,4000,MSG_DONTWAIT); y4 = typecast(uint8(recv_data), 'single complex');
     178    sleep(0.1)
     179
     180    S1 = fft(y1);
     181    S2 = fft(y2);
     182    S3 = fft(y3);
     183    S4 = fft(y4);
     184    plot( [abs(S1) abs(S2) abs(S3) abs(S4)] )
     185  endwhile
     186}}}
     187
     188
     189=== Part 3: Select receiver by preamble ===