如何让Linux内核的timetamp? [英] how to get the timetamp for the linux kernel?

查看:219
本文介绍了如何让Linux内核的timetamp?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int netif_rx(struct sk_buff *skb) 
{
if(skb -> stamp.tv_sec ==0)
do_gettimeofday(&skb->stamp);
}

上述API是接收机侧的API,其从发送者接收到的数据。我想计算Ť
他当它接收到的数据,并将其存储在缓冲器中的时间。
在行号2993以上的API是在内核源代码code可供选择:/linux/net/core/dev.c结果
但我得到错误:如结构sk_buff中没有成员名为邮票

the above api is the receiver side api, which receives the data from the sender. I want to calculate t he time when it receives the data and store it in a buffer. the above api at line number 2993 is available in kernel source code at: /linux/net/core/dev.c
but I am getting ERROR: as struct sk_buff has no member named stamp.

http://lxr.free-electrons.com/source/在include / linux / skbuff.h中
可能有人请帮助我:如何得到linux内核的时间戳

http://lxr.free-electrons.com/source/include/linux/skbuff.h Could someone please help me : how to get the timestamp for linux kernel.

后来我改变了我的code为:

Later I changed my code to :

 int netif_rx(struct sk_buff *skb) 
    {
    if(skb -> tstamp.off_sec ==0)
    do_gettimeofday(&skb->tstamp);
    }

现在我得到的错误为:ktime_t没有名为tv_secmemeber。 timeval结构,但是参数类型是UNIO ktime_t的。

now I am getting error as : ktime_t has no memeber named "tv_sec". struct timeval but argument is of type unio ktime_t.

推荐答案

sk_buff-> TSTAMP 是变量 ktime_t 键入。 do_gettimeofday 设置时间 timeval结构的变量。在这里你有不同的类型,所以你需要一个转换。一个简单的人会是:

sk_buff->tstamp is variable of ktime_t type. do_gettimeofday sets time to variable of struct timeval. You have different types here and so you need a conversion. A simple one would be:

int netif_rx(struct sk_buff *skb) 
{
    if(skb -> tstamp.off_sec ==0)
    {
        struct timespec now;
        getnstimeofday(&now);
        skb->tstamp = timespec_to_ktime(now);
    }
}

这篇关于如何让Linux内核的timetamp?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆