File transfer using Packet and BPSK: Difference between revisions

From GNU Radio
Jump to navigation Jump to search
(initial creation)
 
No edit summary
Line 1: Line 1:
<!-- File_transfer_using_Packet_and_BPSK.mediawiki -->
<!-- File_transfer_using_Packet_and_BPSK.mediawiki -->
<b>THIS IS A WORK IN PROGRESS!<br>
<b>THIS IS A WORK IN PROGRESS!<br>
Please leave comments in the Discussion tab or on the GNU Radio General Chat channel.</b>
Please leave comments in the Discussion tab above, or on the GNU Radio General Chat channel.</b> See [[Chat]].


This package consists of a packet transmitter, a channel simulation, and a packet receiver. It has been developed and tested with GNU Radio version 3.10.6.0.
This package consists of a packet transmitter, a channel simulation, and a packet receiver. It has been developed and tested with GNU Radio version 3.10.6.0.
Line 7: Line 7:
At this point, the basic operation has been proven, but the following items need to be done to provide a more functional package:
At this point, the basic operation has been proven, but the following items need to be done to provide a more functional package:
# Write a program to strip the preamble and filler codes.
# Write a program to strip the preamble and filler codes.
# Accept the input filename in the command line for 'pkt_xmt.py'.
# Add the original filename in the preamble information.
# Write a program to convert a binary file to Base64 (rather than doing it manually online).
# Write a program to convert a binary file to Base64 (rather than doing it manually online).
# Write a program to convert a Base64 file to binary (rather than doing it manually online).
# Write a program to convert a Base64 file to binary (rather than doing it manually online).
Line 43: Line 45:
3. Execute the packet receiver.   
3. Execute the packet receiver.   
     python3 -u pkt_rcv.py
     python3 -u pkt_rcv.py
4. A new window will open showing a Constellation display and a Time Sink.
4. A new window will open (titled "pkt_rcv") showing a Constellation display and a Time Sink.


=== Simulating Channel Impairments ===
=== Simulating Channel Impairments ===
Line 54: Line 56:
2. Go to the gr-control folder.   
2. Go to the gr-control folder.   
     cd ~/gr-control
     cd ~/gr-control
3. Execute the looback program.   
3. Execute the loopback program.   
     python3 -u chan_loopback.py
     python3 -u chan_loopback.py
4. A new window will open showing a chooser for the Sample rate. For the version 3.9 and 3.10 programs, select 768kHz. There are three sliders to introduce impairments, but for initial testing, leave them all as loaded.
4. A new window will open (titled "chan_loopback") showing a chooser for the Sample rate. For the version 3.9 and 3.10 programs, select 768kHz. There are three sliders to introduce impairments, but for initial testing, leave them all as loaded.


=== Transmitting the File ===
=== Transmitting the File ===
Line 74: Line 76:
2. Go to the gr-control/Transmitters folder.   
2. Go to the gr-control/Transmitters folder.   
     cd ~/gr-control/Transmitters
     cd ~/gr-control/Transmitters
3. Get the 'pkt_rcv' window in view. Once you enter the next command, data transmission will start.<br>
3. Execute the packet transmitter.   
3. Execute the packet transmitter.   
     python3 -u pkt_xmt.py
     python3 -u pkt_xmt.py
4. A new window will open showing the message "Press Enter to close."<br>
4. A message will be displayed: "Press Enter to close."<br>
5. The file transmission will begin. The average throughput is 104 bytes per second.<br>
5. The file transmission will begin. The average throughput is 104 bytes per second.<br>
6. The Time Sink display in the receiver will show data bits with a 'packet_len' tag.<br>
6. The Time Sink display in the receiver will show data bits with a 'packet_len' tag.<br>
Line 83: Line 86:
=== Shutdown ===
=== Shutdown ===


1. Close the transmitter window.<br>
1. Close the transmitter window by pressing Enter.<br>
2. Close the receiver window.
2. Close the "pkt_rcv" window by clicking the 'X' in the upper right corner.<br>
3. Close the "chan_loopback" window by clicking the 'X' in the upper right corner.


== Sending Non-text Files ==
== Sending Non-text Files ==
Line 92: Line 96:
== Stripping the Preamble and Filler ==
== Stripping the Preamble and Filler ==


The received file will be stored in "$HOME/gr-control/Receivers/output.txt". That file will contain up to 100 preamble packets, followed by the sent file, followed by up to five filler packets.
The received file will be stored in "$HOME/gr-control/Receivers/output.txt". That file will contain up to 100 preamble packets, followed by the transmitted file, followed by up to five filler packets.


A Python program will be written to strip those preamble/filler packets, but a text editor can be used until then.
A Python program will be written to strip those preamble/filler packets, but a text editor can be used until then.

Revision as of 23:50, 31 May 2023

THIS IS A WORK IN PROGRESS!
Please leave comments in the Discussion tab above, or on the GNU Radio General Chat channel.
See Chat.

This package consists of a packet transmitter, a channel simulation, and a packet receiver. It has been developed and tested with GNU Radio version 3.10.6.0.

At this point, the basic operation has been proven, but the following items need to be done to provide a more functional package:

  1. Write a program to strip the preamble and filler codes.
  2. Accept the input filename in the command line for 'pkt_xmt.py'.
  3. Add the original filename in the preamble information.
  4. Write a program to convert a binary file to Base64 (rather than doing it manually online).
  5. Write a program to convert a Base64 file to binary (rather than doing it manually online).
  6. Test with two computers using SDR devices (xmt_rcv_switch).


Prerequisites

It is imperative that all of the prerequisites are studied before starting this one.

Download the gr-control software

1. Open a terminal window.
2. Change to the home directory.

   cd ~/  

3. If you don't have 'git', enter

   sudo apt install git  

4. Clone the repository:

   git clone https://github.com/duggabe/gr-control.git

Operation

Receiving the File

pkt_rcv.py receives the BPSK signal and presents it to the Correlate_Access_Code_-_Tag_Stream. That block detects the Access Code and passes the payload to the Stream_CRC32. If the CRC check is valid, the payload is sent to the File_Sink.

Pkt rcv file fg.png


1. Open a new terminal window.
2. Go to the gr-control/Receivers folder.

   cd ~/gr-control/Receivers

3. Execute the packet receiver.

   python3 -u pkt_rcv.py

4. A new window will open (titled "pkt_rcv") showing a Constellation display and a Time Sink.

Simulating Channel Impairments

There are two flowgraphs included to allow loopback testing of a transmitter and a receiver without using SDR hardware. Either operates **in place of** the `xmt_rcv_switch` program. The `chan_loopback` is for the digital modes such as BPSK packet. It allows introduction of noise, frequency offset, and timing offset.

Chan loopback fg.png

1. Open another terminal window.
2. Go to the gr-control folder.

   cd ~/gr-control

3. Execute the loopback program.

   python3 -u chan_loopback.py

4. A new window will open (titled "chan_loopback") showing a chooser for the Sample rate. For the version 3.9 and 3.10 programs, select 768kHz. There are three sliders to introduce impairments, but for initial testing, leave them all as loaded.

Transmitting the File

Pkt xmt file fg.png

The 'EPB: File Source to Tagged Stream' block is an Embedded Python Block which takes the place of a File_Source block, a Stream_to_Tagged_Stream block, and parts of a Burst_Shaper block. The Python block performs the following functions:

  • Send a preamble to allow the receiver to synchronize.
  • Send the selected file with "packet_len" tags.
  • Send a post-file filler to assure that any buffers have been flushed.

The content of the Embedded Python Block is shown here: pkt_xmt_epy_block_0.py

The preamble is composed of the '%' character, followed by 50 capital 'U's, followed by a ']'. It is repeated 100 times to allow the receiver to synchronize. The post-file filler is sent five times.

1. Open another terminal window.
2. Go to the gr-control/Transmitters folder.

   cd ~/gr-control/Transmitters

3. Get the 'pkt_rcv' window in view. Once you enter the next command, data transmission will start.
3. Execute the packet transmitter.

   python3 -u pkt_xmt.py

4. A message will be displayed: "Press Enter to close."
5. The file transmission will begin. The average throughput is 104 bytes per second.
6. The Time Sink display in the receiver will show data bits with a 'packet_len' tag.
7. When the file is complete, the transmitter window will show "End of file".

Shutdown

1. Close the transmitter window by pressing Enter.
2. Close the "pkt_rcv" window by clicking the 'X' in the upper right corner.
3. Close the "chan_loopback" window by clicking the 'X' in the upper right corner.

Sending Non-text Files

Plain text files can be sent with no problems. However, any binary or other non-text files (such as PDF or JPG) must be converted to Base64 before transmission. As an interim measure, a non-text file can be converted using a free online program. The file "$HOME/gr-control/Transmitters/gr-logo.b64" has been provided for testing. It is the GNU Radio logo (gr-logo.png) converted to Base64.

Stripping the Preamble and Filler

The received file will be stored in "$HOME/gr-control/Receivers/output.txt". That file will contain up to 100 preamble packets, followed by the transmitted file, followed by up to five filler packets.

A Python program will be written to strip those preamble/filler packets, but a text editor can be used until then.