# Repack bits & header generator

**URL:** <https://www.ruby-forum.com/t/repack-bits-header-generator/230981>\
**Category:** GNU Radio\
**Created:** [July 16, 2014, 12:17am UTC](https://www.ruby-forum.com/t/repack-bits-header-generator/230981 "2014-07-16T00:17:08Z")\
**Posts on this page:** 2\
**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 16, 2014, 12:17am UTC](https://www.ruby-forum.com/t/repack-bits-header-generator/230981/1 "2014-07-16T00:17:08Z")

</div>

HI all,  
I want to ask about the repack bits block  
[http://gnuradio.org/doc/doxygen/classgr\_1\_1blocks\_1\_1repack\_\_bits\_\_bb.html](http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1repack __bits__ bb.html)

- Does it change the rate of the output relative to the input ?
- what does it mean it makes an alignment to the output ?
- Also I don’t understand this part in doxygen “the number of input bits  
is  
padded with zeros if the number of input bits is not an integer multiple  
of  
, or bits are truncated from the input if is set to true.”

Also I have another question , after reading from doxygen , I still  
doesn’t  
understand the difference between the stream to tagged stream block and  
the  
header generator block ?

Thanks

---

<div class="post-metadata">

**Author:** ![Sara\_ChSSrif](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@Sara\_ChSSrif](https://www.ruby-forum.com/u/Sara_ChSSrif)\
**Post date:** [July 16, 2014, 12:23am UTC](https://www.ruby-forum.com/t/repack-bits-header-generator/230981/2 "2014-07-16T00:23:42Z")

</div>

On 07/16/2014 12:16 AM, Sara C. wrote:

> HI all,  
> I want to ask about the repack bits block  
> [GNU Radio Manual and C++ API Reference: gr::blocks::repack\_bits\_bb Class Reference](http://gnuradio.org/doc/doxygen/classgr_1_1blocks_1_1repack __bits__ bb.html)
> 
> - Does it change the rate of the output relative to the input ?

Yes.

> - what does it mean it makes an alignment to the output ?
> - Also I don’t understand this part in doxygen “the number of input bits  
> is padded with zeros if the number of input bits is not an integer  
> multiple of , or bits are truncated from the input if is set to true.”

That is the answer to your previous question 🙂

An example: When Unpacking 3 bits per byte, say you have a packet of  
length 2 bytes. That means 16 bits total. However, you must honor packet  
boundaries. How do you do that?

There’s only really one choice: Output 6 bytes total, each with 3 bits.  
The last byte only has one relevant bit (the 16th bit).

So far, so good. But you need an inverse operation. Say you repack 3-\>8  
again. Now you get a packet of 6 bytes incoming, which means… what? 18  
Bits total? No, somehow you have to tell the block that the last byte  
only contains one valid bit. This is how you do it.

> Also I have another question , after reading from doxygen , I still  
> doesn’t understand the difference between the stream to tagged stream  
> block and the header generator block ?

Those two blocks are completely different. One add tags, one generates  
headers.

Martin
