# Problem with streamed tags

**URL:** <https://www.ruby-forum.com/t/problem-with-streamed-tags/242885>\
**Category:** GNU Radio\
**Created:** [August 5, 2015, 10:42am UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885 "2015-08-05T10:42:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sadaf\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/858c86/32.png) [@Sadaf\_N](https://www.ruby-forum.com/u/Sadaf_N)\
**Post date:** [August 5, 2015, 10:42am UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885/1 "2015-08-05T10:42:44Z")

</div>

hi all,

I have three blocks:

1. MESSAGE\_LOADER  
reads a binary file and outputs it byte by byte to the next block  
(PACKET\_CREATOR). On every 28th byte (and on the 0th byte) it adds tags  
denoting the start of a PDU

2. PACKET\_CREATOR (tagged\_stream\_block)  
waits for 28 bytes to arrive. once this is accomplished, it reads the  
first of those 28 bytes and uses it for internal logic. the other 27  
bytes are the payload of a packet, to which it prepends a header and  
appends a crc (2 bytes). NOTE: the length of the header in bits is not  
divisible by 8. because of this, in order to have the whole packet in  
one single chunk of memory, I have to do tedious bit shifting of the 27  
payload bytes that come after the header… once the packet is created, I  
want to pass it to the next block, containing tags in the first header  
byte. So, now I’ve changed things: before, the tags were ‘connected’ to  
the first payload byte. now, I want them to be ‘connected’ to the first  
header byte, which was created in this very block.

3. PACKET\_VERIFIER (tagged\_stream\_block)  
for testing purposes, I want this block to receive the whole packet that  
was created in PACKET\_CREATOR and write it to the screen. In order for  
the block to know when a packet starts, every first byte of a packet  
must contain the length of it.

My question is this: I don’t get this item enumeration thing in  
gnuradio. between the first 2 blocks it was easy enough, as I had to  
simply include tags in every 28th byte, and it is easy to picture item  
enumeration there (the first byte of the file has offset 0, the second  
one 1 etc). but how are the items enumerated between the PACKET\_CREATOR  
and the PACKET\_VERIFIER block?? which item index should I use to add the  
length tag to the first header byte??

I hope I have made myself sufficiently clear…if not, feel free to ask  
for more details. any help is immensely appreciated!

thanks in advance!

---

<div class="post-metadata">

**Author:** ![okcomputer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@okcomputer](https://www.ruby-forum.com/u/okcomputer)\
**Post date:** [August 5, 2015, 9:57pm UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885/2 "2015-08-05T21:57:00Z")

</div>

On 05.08.2015 01:42, Mat Mat wrote:

> My question is this: I don’t get this item enumeration thing in  
> gnuradio. between the first 2 blocks it was easy enough, as I had to  
> simply include tags in every 28th byte, and it is easy to picture item  
> enumeration there (the first byte of the file has offset 0, the second  
> one 1 etc). but how are the items enumerated between the PACKET\_CREATOR  
> and the PACKET\_VERIFIER block?? which item index should I use to add the  
> length tag to the first header byte??

Item 0 will have the first byte of the first packet, regardless of what  
you’re actually doing. There’s a couple of blocks that do something like  
this, and they all set the tag propagation policy to ‘NONE’ (which  
requires manual propagation), and then get/set tags accordingly.

So, if you read the tag from input item 0, and then write one to output  
item 0, I believe it’ll do what you wanted.

M

---

<div class="post-metadata">

**Author:** ![okcomputer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@okcomputer](https://www.ruby-forum.com/u/okcomputer)\
**Post date:** [August 6, 2015, 10:10am UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885/3 "2015-08-06T10:10:03Z")

</div>

hey Martin,

many thanks for the reply! one more question about this though: every  
time the work function is called in the PACKET\_CREATOR, it reads 28  
bytes and outputs 37 bytes (as confirmed by nitems\_read(0) and  
nitems\_written(0)). From what you were saying, and from what I’ve read  
from other sources, I got the following impression: in order to tag  
every first byte of a packet at the output of PACKET\_CREATOR, I have to  
add the tag to the item with item offset equal to the current  
nitems\_written(0)-value in PACKET\_CREATOR. Am I correct?

One other question:

Now I want to modulate the output of PACKET\_CREATOR with GFSK and send  
over the air using a USRP. Furthermore, each packet should be sent at a  
different frequency (freq. hopping), which, as I’ve heard, can also be  
achieved by tagging the input to the USRP sink which sets the center  
frequency of the usrp (as far as I know, at least…). There is a  
GFSK\_mod block that would do the modulation for me. That’s a hier block.  
However, I found no specification in it concerning tag propagation, but  
I would need it to propagate tags to every first modulated symbol of a  
packet to set the center frequency on which the packet should be  
transmitted. Is there a simple way to achieve that without having to  
re-implement the modulator in a custom block with added tag propagation?

many thanks for your help!

---

<div class="post-metadata">

**Author:** ![okcomputer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@okcomputer](https://www.ruby-forum.com/u/okcomputer)\
**Post date:** [August 6, 2015, 7:57pm UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885/4 "2015-08-06T19:57:49Z")

</div>

I’m guessing something went wrong here? 🙂 the post is empty

---

<div class="post-metadata">

**Author:** ![okcomputer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b38774/32.png) [@okcomputer](https://www.ruby-forum.com/u/okcomputer)\
**Post date:** [August 6, 2015, 8:46pm UTC](https://www.ruby-forum.com/t/problem-with-streamed-tags/242885/5 "2015-08-06T20:46:24Z")

</div>

On 06.08.2015 10:57, Mat Mat wrote:

> I’m guessing something went wrong here? 🙂 the post is empty

Urgh, no idea what happened. Main point was, use the QT GUI time sink to  
visually check if tags are in the right spot.

M
