Editing Packet Communications

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 16: Line 16:


Links to the flowgraphs have been updated to GNU Radio version 3.9.4.0.
Links to the flowgraphs have been updated to GNU Radio version 3.9.4.0.
If using GNURadio 3.8:
-In the "''Simulating Baseband Packet Processing''" Tutorial, "'''NOTE:'''" sections have been added where a small change is needed or a difference occurs.
-The "''Using BPSK with Hardware Simulation''" has an entirely separate section for version 3.8.


== Simulating Baseband Packet Processing ==
== Simulating Baseband Packet Processing ==
Line 36: Line 30:


This flowgraph can be downloaded from [[Media:Pkt_7_base.grc]].
This flowgraph can be downloaded from [[Media:Pkt_7_base.grc]].
'''NOTE: If using GNURadio 3.8, a small change will need to be made:
Move the connections coming out of the 'header' and 'payload' ports on the async protocol formatter from the 'print' port of the Message Debug block to the 'print_pdu' port. 
'''


==== Message Strobe ====
==== Message Strobe ====
Line 101: Line 91:
</pre>
</pre>


The first PDU DEBUG PRINT is the header data containing the payload length, packet number, and a CRC8 of the header.
The first PDU DEBUG PRINT is the header data containing the payload length, packet number, and a CRC16 of the header.


The second PDU DEBUG PRINT is the payload including a CRC32 of the data.
The second PDU DEBUG PRINT is the payload including a CRC32 of the data.
Line 108: Line 98:


The third PDU DEBUG PRINT is the received payload ("GNU Radio").
The third PDU DEBUG PRINT is the received payload ("GNU Radio").
'''NOTE: If using GNURadio 3.8, the output will differ in the VERBOSE PDU DEBUG PRINT section. Instead of the hexidecimal representation of "GNU Radio", the actual ASCII text "GNU Radio" will print in the termainal as shown below.'''
<pre>
* MESSAGE DEBUG PRINT PDU VERBOSE *
()
pdu_length = 4
contents =
0000: 0d 10 00 3a
***********************************
* MESSAGE DEBUG PRINT PDU VERBOSE *
()
pdu_length = 13
contents =
0000: 47 4e 55 20 52 61 64 69 6f 8f aa 09 f1
***********************************
----------------------------------------------------------------------
Tag Debug:
Input Stream: 00
  Offset: 13  Source: n/a    Key: packet_len  Value: 13
  Offset: 13  Source: n/a    Key: packet_num  Value: 1
----------------------------------------------------------------------
******* MESSAGE DEBUG PRINT ********
(((packet_num . 1)) . #[G N U  R a d i o])
************************************
</pre>


== Using BPSK with Hardware Simulation (version 3.9) ==
== Using BPSK with Hardware Simulation (version 3.9) ==
Line 243: Line 206:
== Using BPSK with Hardware Simulation (version 3.8) ==
== Using BPSK with Hardware Simulation (version 3.8) ==


The Protocol Formatter supports three header format types: default, count, and crc. The crc style is illustrated in the simulation above.
This section is under construction...
 
In order to create a preamble, a default header, and the payload data in one PDU message, an Embedded Python block was created. The code is contained in the GRC file, but also is shown here:
* note that for GNURadio 3.8 a numpy array is used in the handling of the incoming PMT message. It must also be put into a byte array before being placed into the PMT u8vector for publishing to the "PDU_out" port
<pre>
"""
Embedded Python Block
"""
 
import numpy as np
from gnuradio import gr
import pmt
import array
class blk(gr.sync_block):
    """Packet Format"""
 
    def __init__(self):
        gr.sync_block.__init__(self,
            name = "Packet Format GR38",
            in_sig = None,
            out_sig = None)
        self.message_port_register_in(pmt.intern('PDU_in'))
        self.message_port_register_out(pmt.intern('PDU_out0'))
        self.set_msg_handler(pmt.intern('PDU_in'), self.handle_msg)
 
    def handle_msg(self, msg):
        inMsg = pmt.to_python (msg)
        pld = inMsg[1] ## type-> numpy.ndarray
        mLen = len(pld)
        if (mLen > 0):
            ## create a numpy array of type 'int' with preamble and sync word
            tmp_char_list = np.array([85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,85,225,90,232,147],dtype=int)
            ## append length 2x
            tmp_char_list=np.append(tmp_char_list,(mLen >> 8))
            tmp_char_list=np.append(tmp_char_list,(mLen & 255))
            tmp_char_list=np.append(tmp_char_list,(mLen >> 8))
            tmp_char_list=np.append(tmp_char_list,(mLen & 255))
            tmp_char_list_len=len(tmp_char_list)
            ## append original payload
            new_char_list=np.insert(tmp_char_list,tmp_char_list_len,pld)
            new_char_list_len=len(new_char_list)
            ## save final numpy array as byte array, this requires 'import array'
            ## (many thanks to Francis A. for finding this fix)
            byte_array_new_char_list=array.array('B',new_char_list)
            new_bytes_out_len = len(byte_array_new_char_list)
            ## create PMT u8vector using byte array
            new_out_bytes_pmt=pmt.cons(pmt.PMT_NIL,pmt.init_u8vector(new_bytes_out_len,(byte_array_new_char_list)))
            self.message_port_pub(pmt.intern('PDU_out0'), new_out_bytes_pmt)
</pre>


=== Transmitting a Signal ===
=== Transmitting a Signal ===
Build the following flowgraph using the details given below:
[[File:Pkt_xmt_gr38.png]]
 
[[File:Pkt_xmt_gr38.png|800px]]
 
<hr>
 
This flowgraph can be downloaded from [[Media:Pkt_xmt_gr38.grc]]. The BPSK modulation is done in the same manner as the [[Simulation_example:_BPSK_Demodulation|BPSK Demodulation]] tutorial. Do a Generate (F5) or Execute (F6) to create the pkt_xmt_gr38.py file.


=== Receiving a Signal ===
=== Receiving a Signal ===
Build a separate flowgraph using the details below:
* note for GNURadio 3.8: the Linear Equalizer shown in the GNURadio 3.9 example is not available. The LMS DD Equalizer has been used instead.
[[File:pkt_rcv_gr38.png|800px]]
<hr>
This flowgraph can be downloaded from [[Media:Pkt_rcv_gr38.grc]]. For GNU Radio version 3.8 there is one difference:the Linear Equalizer and Adaptive Algorithm object are not available, the LMS DD Equalizer block is used instead.
The output of the Map block is the received bit stream. The 'Correlate Access Code - Tag Stream' block searches for the given access code by slicing the soft decision symbol inputs. Once found, it expects the following 32 samples to contain a header that includes the frame length (16 bits for the length, repeated). It decodes the header to get the frame length in order to set up the the tagged stream key information.
The remaining blocks operate as in the simulation example above.


=== Testing ===
=== Testing ===
When using GRC, doing a Generate and/or Run creates a Python file with the same name as the .grc file. You can execute the Python file without running GRC again.
For testing this system we will use two processes, so we will need two terminal windows.
Terminal 1:
* since you just finished building the pkt_rcv_gr38 flowgraph, you can just do a Run. After a few seconds, a window will open with the GUI Constellation Sink.
Terminal 2:
Open another terminal window.
* change to whatever directory you used to generate the flowgraph for pkt_xmt_gr38
* execute the following command:
    python3 pkt_xmt_gr38.py
* After a few seconds, a window will open with the GUI Time Sink.
The output of the transmitter is:
[[File:pkt_tx_gr38_gui.png|800px]]
The output of the receiver is shown on the GRC console.
<pre>
******* MESSAGE DEBUG PRINT ********
(() . #[G N U  R a d i o])
************************************
******* MESSAGE DEBUG PRINT ********
(() . #[G N U  R a d i o])
************************************
******* MESSAGE DEBUG PRINT ********
(() . #[G N U  R a d i o])
************************************
</pre>
The MESSAGE DEBUG PRINT is the received payload ("GNU Radio").
To terminate each of the processes cleanly, click on the 'X' in the upper corner of the GUI rather than using Control-C.


== Adding Channel Impairments ==
== Adding Channel Impairments ==
Line 398: Line 260:
# BPSK and QPSK are not well suited for burst transmissions due to the need for the receiver to converge on the actual timing and frequency values.
# BPSK and QPSK are not well suited for burst transmissions due to the need for the receiver to converge on the actual timing and frequency values.
# The longer the times between bursts of data, the more the receiver will need to reconverge on the timing and frequency values for the new burst.
# The longer the times between bursts of data, the more the receiver will need to reconverge on the timing and frequency values for the new burst.
# Since almost all amateur radio communications are half duplex and bursts of data, a more appropriate modulation would be FSK or AFSK. The same packet formatting and recovery would still apply. A proof of concept has been added to https://github.com/duggabe/gr-control with <code>pkt_fsk_xmt.grc</code> and <code>pkt_fsk_rcv.grc</code>.
# Since almost all amateur radio communications are half duplex and bursts of data, a more appropriate modulation would be FSK or AFSK. The same packet formatting and recovery would still apply.
 
== Further Observations ==
 
During the development and testing for this tutorial, the following items were observed:
 
* The 'Header/Payload Demux' and 'Protocol Parser' blocks seem to work only with the 'digital.header_format_crc' format.
* The 'Correlate Access Code - Tag Stream' block seems to require the Default Header Format Obj. and expects a 32-bit access code.

Please note that all contributions to GNU Radio are considered to be released under the Creative Commons Attribution-ShareAlike (see GNU Radio:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To edit this page, please answer the question that appears below (more info):

Cancel Editing help (opens in new window)