netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eric Dumazet <dada1@cosmosbay.com>
To: Antoine Zen-Ruffinen <antoine.zen@gmail.com>
Cc: netdev@vger.kernel.org, linux-net@vger.kernel.org,
	netfilter-devel@vger.kernel.org, patrik.arlos@bth.se
Subject: Re: Problem with frame time stamping
Date: Tue, 13 Nov 2007 11:36:37 +0100	[thread overview]
Message-ID: <47397E35.6080203@cosmosbay.com> (raw)
In-Reply-To: <2cbbd8de0711130207t82f2f46h9ee1b876a61bad6a@mail.gmail.com>

Antoine Zen-Ruffinen a écrit :
> What does it bring me to have a nanosecond precision if it is not
> related to the actual arrival of frame time ? As it seem I can feel
> skb->tstamp with whatever I want, I always become something else using
> ioctl(). (I'm using kernel 2.6.23).
>
> 2007/11/12, Eric Dumazet <dada1@cosmosbay.com>:
>   
>> On Mon, 12 Nov 2007 16:42:34 +0100
>> "Antoine Zen-Ruffinen" <antoine.zen@gmail.com> wrote:
>>
>>     
>>> Dear all,
>>>
>>> I'm writing a network analyzer software using Linux and I need a VERY
>>> precise frame time stamping. Therefor I am planing to add my own time
>>> stamping algorithm on a modified network driver. For test purpose I
>>> did so :
>>>
>>>       skb->tstamp.tv64 = 0x00010002;
>>>       netif_rx(skb);
>>>
>>> On the user side, I ask for the timestamp that way :
>>>
>>>       ...
>>>       sock = socket(AF_PACKET, SOCK_RAW, type);
>>>       ...
>>>       //bind this socket with the interface using my modified driver.
>>>       ...
>>>       recvByteCount = recv(sock, buffer, 1514, 0);
>>>       ioctl(sock, SIOCGSTAMP, &timeStamp);
>>>
>>> I was surprised to see that the var timeStamp was still holding a
>>> count of second since  year 1970.
>>>       
But then, maybe your problem comes from your code : timeStamp should be 
declared as "struct timeval" of course, to get both tv_sec and tv_usec.

struct timeval tv;
ioctl(sock, SIOCSTAMP, &tv);
printf("packet arrived at %ld.%06ld\n", (long)tv.tv_sec, (long)tv.tv_usec);


If you *want* nanosecond resolution instead of microsecond, use :

struct timespec ts;
ioctl(sock, SIOCSTAMPNS, &ts);
printf("packet arrived at %ld.%09ld\n", (long)ts.tv_sec, (long)ts.tv_nsec);




-
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2007-11-13 10:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-12 15:42 Problem with frame time stamping Antoine Zen-Ruffinen
2007-11-12 16:47 ` Eric Dumazet
2007-11-13 10:07   ` Antoine Zen-Ruffinen
2007-11-13 10:27     ` Eric Dumazet
2007-11-13 10:39       ` Antoine Zen-Ruffinen
2007-11-13 10:43         ` Antoine Zen-Ruffinen
2007-11-13 10:55         ` Eric Dumazet
2007-11-13 12:34           ` Antoine Zen-Ruffinen
2007-11-13 13:13             ` Eric Dumazet
2007-11-13 14:46               ` Antoine Zen-Ruffinen
2007-11-13 10:36     ` Eric Dumazet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47397E35.6080203@cosmosbay.com \
    --to=dada1@cosmosbay.com \
    --cc=antoine.zen@gmail.com \
    --cc=linux-net@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=patrik.arlos@bth.se \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).