Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 06-14-2018, 06:56 AM   #1
Poison Nuke
LQ Newbie
Registered: Aug 2012
Location: Germany
Posts: 25

Rep: Reputation: Disabled
how to measure kernel to udp time?


I have integrated a simple udp sender into a touch-driver, to receive every touch-event on another computer inside a Unity application. With nothing else to render at 600fps I have a end to end latency of 80-100 milliseconds (counted frames between visible touchdown and reaction on screen).

I want to narrow down the source of this extrem high latency. So first step is the time between touchdown - kernel-module - udp stack and finally the electrical signal on the LAN.

Any suggestions, how to measure any part of this?
Old 06-14-2018, 04:52 PM   #2
Senior Member
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 2,946

Rep: Reputation: 788Reputation: 788Reputation: 788Reputation: 788Reputation: 788Reputation: 788Reputation: 788
You can measure the network stack <-> wire <-> network stack with ping. For two computers going through a single router I get a small number:

PING ( 56(84) bytes of data.
64 bytes from icmp_seq=1 ttl=63 time=0.178 ms
64 bytes from icmp_seq=2 ttl=63 time=0.300 ms
64 bytes from icmp_seq=3 ttl=63 time=0.331 ms
64 bytes from icmp_seq=4 ttl=63 time=0.293 ms
Maybe the sending end is buffering the input to reduce the number of packets going over the wire. Call fflush to make sure that the write buffer is emptied and passed to UDP.
Old 06-15-2018, 08:38 AM   #3
Poison Nuke
LQ Newbie
Registered: Aug 2012
Location: Germany
Posts: 25

Original Poster
Rep: Reputation: Disabled
both computers are wired directly, so microsecond delay between the PHYs. I have now written a small Python script, which sends UDP packets to my application and I create an UDP answer inside the app and measure the time with Python. That way around I was able to measure the latency of both network stacks up to layer 7. Interestingly, the measured times, with 2000 sent packets, look like that:
Average receive: 0.00431398940086
95 percentile: 0.00771732330322
min: 0.00134086608887 max: 0.0193440914154
which is a 10 to 20-fold difference to the camera based measurement.

Im trying to implement a UDP server into the kernel-module, to see if there is a difference (I hope the timestamps of dmesg are precise enough, otherwise I would need to implement a multi-thread timing). But I have some issues with that and will create a new thread with some code-related problems.

I was looking for fflush, but looks like it is not meant for something like that? There is no stream open at all. Im using raw kernel-sockets. And looking into wireshark, all packets have constant time-gap.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to measure kernel space time and user space time in linux bhas.bhaskar Linux - Newbie 1 11-28-2010 11:01 AM
How to Measure Time to execute a function in Kernel space barunparichha Linux - Software 4 01-07-2008 11:48 AM
how to measure execution time in kernel space? didio Linux - Kernel 1 10-08-2007 10:01 PM
LXer: Measure Time in Linux with Time Base LXer Syndicated Linux News 0 04-11-2007 06:46 AM
RFC 868 udp 37 time-udp gpl SUSE / openSUSE 2 03-31-2005 10:07 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 02:52 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration