# Trying to figure out time of packet arrival in USRP

**URL:** <https://www.ruby-forum.com/t/trying-to-figure-out-time-of-packet-arrival-in-usrp/204205>\
**Category:** GNU Radio\
**Created:** [March 7, 2011, 8:27pm UTC](https://www.ruby-forum.com/t/trying-to-figure-out-time-of-packet-arrival-in-usrp/204205 "2011-03-07T20:27:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [March 7, 2011, 8:27pm UTC](https://www.ruby-forum.com/t/trying-to-figure-out-time-of-packet-arrival-in-usrp/204205/1 "2011-03-07T20:27:07Z")

</div>

Hello,

I am running usrp\_transmit\_path.py for transmission on one USRP  
and usrp\_receive\_path.py for reception of signals on another USRP.  
I want to determine the exact arrival time of a packet on the USRP.

I get the message stream which is received from packetutils.  
The code in PacketUtils.py gets a packet from the USRP.  
This is populated from copy\_from\_usrp\_buffer in usrp\_source\_base.cc.  
I am assuming there is some polling mechanism to invoke  
usrp\_basic\_rx::read  
for this.  
I want to track the point where this buffer is populated. The time stamp  
of  
the packet when it is detected by USRP without any modifications by  
higher  
layers.  
Can this be done without any changes in Firmware? Any pointers on how to  
proceed will be appreciated.

Thanks.

---

<div class="post-metadata">

**Author:** ![Sapna\_Dasarath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@Sapna\_Dasarath](https://www.ruby-forum.com/u/Sapna_Dasarath)\
**Post date:** [March 9, 2011, 3:27am UTC](https://www.ruby-forum.com/t/trying-to-figure-out-time-of-packet-arrival-in-usrp/204205/2 "2011-03-09T03:27:03Z")

</div>

Thanks for your input Tom. I’ll look at UHD and stream tags.

Regards,  
Sapna

---

<div class="post-metadata">

**Author:** ![Sapna\_Dasarath](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/c67d28/32.png) [@Sapna\_Dasarath](https://www.ruby-forum.com/u/Sapna_Dasarath)\
**Post date:** [March 9, 2011, 3:09am UTC](https://www.ruby-forum.com/t/trying-to-figure-out-time-of-packet-arrival-in-usrp/204205/3 "2011-03-09T03:09:30Z")

</div>

On Mon, Mar 7, 2011 at 2:26 PM, Sapna Dasarath  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)wrote:

> for this.  
> I want to track the point where this buffer is populated. The time stamp of  
> the packet when it is detected by USRP without any modifications by higher  
> layers.  
> Can this be done without any changes in Firmware? Any pointers on how to  
> proceed will be appreciated.
> 
> Thanks.

It sounds like you don’t want to go this route, but the best thing to do  
is  
start using the UHD and stream tags. There is an interface in the UHD  
source  
block to send stream tags of the sample times. The UHD tags frames with  
a  
time stamp based on the internal clock of the FPGA (which you can tell  
to  
reset). The tags are then passed downstream for you to collect later and  
associate a time value with a particular sample.

The legacy USRP2 interface also allows you to collect the time out of  
the  
metadata, but you will have to dig into the libusrp2 library code to get  
access to it.

If you want accurate time stamps for a USRP1, there really isn’t one.  
You  
would have to have a differential timer. Look at clock\_gettime for  
getting  
clock information that you might use.

Tom
