# Packet Flowgraph and underflows

**URL:** <https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901>\
**Category:** GNU Radio\
**Created:** [August 6, 2015, 12:07pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901 "2015-08-06T12:07:00Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 6, 2015, 12:07pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901/1 "2015-08-06T12:07:00Z")

</div>

Hi,

I’ve been looking for a solution to this and can’t seem to find any  
examples.

If I have a flowgraph that transmits packets for instance from a TCP  
stream - if this TCP stream only receives data occasionally it will  
create underflows (showing up as U characters on STDOUT).

What is the proper way of handling such a scenario? I thought of using  
something like the Mute block to transmit a 0 data stream during  
periods of no data. However that seems excessively complicated to  
implement and I think I am missing some pointer here …

Thanks,  
Wolfgang

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Nagele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e495f1/32.png) [@Wolfgang\_Nagele](https://www.ruby-forum.com/u/Wolfgang_Nagele)\
**Post date:** [August 6, 2015, 12:51pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901/2 "2015-08-06T12:51:24Z")

</div>

Hi Wolfgang,

no, you do not need to use something like a mute block.  
The functionality you are looking for is already build into UHD (I’m  
assuming you are using a USRP as your transmitting device)

The UHD sink in GNU Radio is able to react to some specific stream tags  
[1]  
one of which is the length tag.  
You can assign a name for this tag in the UHD source block (‘Length tag  
name’ field).

Now, if you have assigned a value to this ‘Length tag name’ field the  
UHD  
sink is somehow reacting as a tagged stream block [2].  
If samples arrive at the UHD sink, the USRP will only transmit that  
amount  
of samples specified in the length tag starting from that length tag.  
Therefore, you should not see any ‘U’ messages no more as the USRP  
automatically stops transmitting and does not expect any more samples  
follow.

However, keep in mind that with tagged streams every first sample of a  
‘packet’ needs to have the length tag attached.

E.g consider the following stream of samples where the first sample has  
a  
length tag assigned to it with value 10:

1 2 3 4 5 5 7 8 9 10 11  
| |  
length tag next length tag needs to be exactly here  
value = 10 samples

Hope that helps.  
Cheers,  
Julian

[1] [https://gnuradio.org/doc/doxygen/page\_stream\_tags.html](https://gnuradio.org/doc/doxygen/page_stream_tags.html)  
[2] [https://gnuradio.org/doc/doxygen/page\_tagged\_stream\_blocks.html](https://gnuradio.org/doc/doxygen/page_tagged_stream_blocks.html)

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Nagele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e495f1/32.png) [@Wolfgang\_Nagele](https://www.ruby-forum.com/u/Wolfgang_Nagele)\
**Post date:** [August 6, 2015, 1:58pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901/3 "2015-08-06T13:58:35Z")

</div>

Hi Julian,

Thanks for the pointer. I’m using a HackRF - doesn’t look like the  
Osmocom sink supports the same construct. Any way of doing something  
like this in a more generic approach?

Cheers,  
Wolfgang

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Nagele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e495f1/32.png) [@Wolfgang\_Nagele](https://www.ruby-forum.com/u/Wolfgang_Nagele)\
**Post date:** [August 9, 2015, 3:29pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901/4 "2015-08-09T15:29:54Z")

</div>

Hi Julian,

Thanks for this - after a bit of googling I managed to find that as  
well. Was a bit hard to get started but after fiddling with the block  
buffers got it running the way I need it.

Also for reference - in the Osmocom sink the HackRF does not have the  
payload length implementation based on tags yet. In case somebody else  
should need it.

Cheers,  
Wolfgang

---

<div class="post-metadata">

**Author:** ![Wolfgang\_Nagele](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/e495f1/32.png) [@Wolfgang\_Nagele](https://www.ruby-forum.com/u/Wolfgang_Nagele)\
**Post date:** [August 9, 2015, 3:25pm UTC](https://www.ruby-forum.com/t/packet-flowgraph-and-underflows/242901/5 "2015-08-09T15:25:48Z")

</div>

Hi Wolfgang,

sorry for the late reply.

I’m not familiar with the HackRF but something that might be useful for  
you  
as it makes burst mode transmissions in GNU Radio more generic and  
hardware  
independent is Eventstream by Tim O’Shea [1].  
It should be exactly what you were looking for. It kind of implements  
the  
‘mute block’ concept you were talking about.

I hope that gets you started. Let me know if you have any more  
questions.

[1]  
[http://oshearesearch.com/2015/03/15/burst-transmission-in-gnu-radio-sample-streams-with-eventstream/](http://oshearesearch.com/2015/03/15/burst-transmission-in-gnu-radio-sample-streams-with-eventstream/)

Cheers,  
Julian
