# What do Packet Encoder and Packet Decoder do?

**URL:** <https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249>\
**Category:** GNU Radio\
**Created:** [July 30, 2014, 10:45am UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249 "2014-07-30T10:45:08Z")\
**Posts on this page:** 6\
**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:** [July 30, 2014, 10:45am UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/1 "2014-07-30T10:45:08Z")

</div>

Hi all,

Can anyone tell me what do _Packet Encoder_ and _Packet Decoder_ blocks  
do?  
and it would be great if you can give me some example 🙂  
Thanks in advance

Van-Ly

Van-Ly Nguyen,  
Signals and Systems of Laboratory - SSL  
Faculty of Electronics and Telecommunications - FET  
University of Engineering and Technology - UET  
Vietnam National University, Hanoi - VNU

Tel: (+84) 978 819 406

---

<div class="post-metadata">

**Author:** ![NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/u/NguySSSn_VSSn_LS_S)\
**Post date:** [July 30, 2014, 3:27pm UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/2 "2014-07-30T15:27:01Z")

</div>

On Wed, Jul 30, 2014 at 4:44 AM, Nguyễn Văn Lý  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Hi all,
> 
> Can anyone tell me what do _Packet Encoder_ and _Packet Decoder_ blocks  
> do? and it would be great if you can give me some example 🙂  
> Thanks in advance
> 
> Van-Ly

These are very simple example blocks to show you how to packetize data.  
Packet bytes go in, they get wrapped into a packet of a given payload  
length with a header, access code, and preamble. The header is just a 2x  
repetition of the payload length (16 bits for each field). Leaving the  
preamble and access code blank just chooses the defaults.

The decoder just looks for the access code with the number of available  
bits wrong. When it’s found, it reads the header to get the payload  
length,  
extracts the payload, and outputs the payload.

Hope this helps.

Tom

---

<div class="post-metadata">

**Author:** ![NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/u/NguySSSn_VSSn_LS_S)\
**Post date:** [July 30, 2014, 4:15pm UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/3 "2014-07-30T16:15:12Z")

</div>

Thank you Tom,

I found a note in documentation of the \*Packet Encoder \*block where it  
declares that the _Packet Encoder_ is for use with the gnuradio  
modulator  
blocks: GMSK, DPSK, QAM. I don’t know why only these modulator blocks  
are  
supported, but not some popular things like BPSK or QPSK. Another thing  
is  
that my task requires the use of OFDM.

Suppose now I have a simple flow graph as below:  
File Source -------\> Packet Encoder -------\> Packet Decoder ---------\>  
File  
Sink  
I wonder what types of file can be loaded and processed properly in the  
_File  
Source_ block (text, image, or video …), and the same question for the  
_File  
Sink_ block 🙂

Thank you so much  
Van-Ly

Van-Ly Nguyen,  
Signals and Systems of Laboratory - SSL  
Faculty of Electronics and Telecommunications - FET  
University of Engineering and Technology - UET  
Vietnam National University, Hanoi - VNU

Tel: (+84) 978 819 406

---

<div class="post-metadata">

**Author:** ![NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/u/NguySSSn_VSSn_LS_S)\
**Post date:** [July 30, 2014, 4:20pm UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/4 "2014-07-30T16:20:34Z")

</div>

On 07/30/2014 04:14 PM, Nguyễn Văn Lý wrote:

> Thank you Tom,
> 
> I found a note in documentation of the _Packet Encoder block_ where it  
> declares that the _Packet Encoder_ is for use with the gnuradio  
> modulator blocks: GMSK, DPSK, QAM. I don’t know why only these modulator  
> blocks are supported, but not some popular things like BPSK or QPSK.  
> Another thing is that my task requires the use of OFDM.

These should also work (they are basically subsets of QAM), but _you_  
have to make sure the absolute phase is correct _before_ going into the  
packet decoder.

> Suppose now I have a simple flow graph as below:  
> File Source -------\> Packet Encoder -------\> Packet Decoder ---------\>  
> File Sink  
> I wonder what types of file can be loaded and processed properly in the  
> _File Source_ block (text, image, or video …), and the same question  
> for the _File Sink_ block 🙂

Any file. The packet blocks really don’t care about the contents.

M

---

<div class="post-metadata">

**Author:** ![NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/u/NguySSSn_VSSn_LS_S)\
**Post date:** [July 31, 2014, 4:31am UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/5 "2014-07-31T04:31:55Z")

</div>

Hi Martin,

Consider the following flow graph.  
File Source -------\>Throttle --------\> Packet Encoder -------\> Packet  
Decoder ---------\>File Sink 2  
\

---------------\> File Sink 1  
If the File Source loads a small-size image (around 50 kB), then the  
Packet  
Decoder works properly and File Sink 2 can open the image. However if  
the  
File Source load a bigger image or video (9 MB, for example), then the  
File  
Sink 2 achieve only more than 1 MB, and it can only display a part of  
the  
image/video. This surprised me.

Then I added a File Sink right after the Packet Encoder (it’s called  
File  
Sink 1) to see what happened after the Packet Encoder. If I let the  
Sample  
Rate = 32k, then the File Sink 1 receives more than 9 MB, but the File  
Sink  
2 still receive more than 1 MB. If I let the Sample Rate be faster, 1M  
or  
4M, then both the File Sink 1 and File Sink 2 only get more than 1MB.  
I wonder if something related to CPU got out of ability with high Sample  
Rate or Packet Encoder - Packet Decoder

Best Regards,  
V-L

Van-Ly Nguyen,  
Signals and Systems of Laboratory - SSL  
Faculty of Electronics and Telecommunications - FET  
University of Engineering and Technology - UET  
Vietnam National University, Hanoi - VNU

Tel: (+84) 978 819 406

On Wed, Jul 30, 2014 at 9:19 PM, Martin B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/9fc29f/32.png) [@NguySSSn\_VSSn\_LS\_S](https://www.ruby-forum.com/u/NguySSSn_VSSn_LS_S)\
**Post date:** [July 31, 2014, 3:28pm UTC](https://www.ruby-forum.com/t/what-do-packet-encoder-and-packet-decoder-do/231249/6 "2014-07-31T15:28:28Z")

</div>

Hm, interesting. You know, in this specific configuration, you don’t  
need a throttle. What happens if you leave it out? It shouldn’t change  
anything, but then, it should work in any case.

Also, you _are_ letting the fg terminate itself, right?

M
