Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When the packet arrives the NIC generates an interrupt and the kernel then takes over. I want to measure the time at which a packet of a particular TCP flow arrives.

How do I do this in Linux? This what tools like tcpdump do.

share|improve this question

migrated from stackoverflow.com Aug 5 '12 at 15:36

This question came from our site for professional and enthusiast programmers.

1  
JFTR i would start to look into systemta - have a look at the sample scripts e.g sourceware.org/systemtap/examples/network/netdev.stp –  Ulrich Dangel Aug 9 '12 at 16:42
add comment

3 Answers

tcpdump timestamps all the packets. So you should be able use tcpdump. Otherwise you could try wireshark, which also monitors network trafic, but with a nice and powerfull GUI. If you don't need to script this process, I would say Wireshark is your friend in this situation.

You can take a peek at http://www.howtogeek.com/104278/how-to-use-wireshark-to-capture-filter-and-inspect-packets/ for more info on how to use Wireshark.

If you are more interested in how to measure this yourself you could either inspect tcpdump with strace or, as suggested, read the source. strace will gives you a list of system calls that you can use in your own application. The easiest solution however, would be to run tcpdump, and then filter the output through awk or some other tool capable of filtering out the timestamp column.

Also, you can find more information about how to use tcpdump on http://danielmiessler.com/study/tcpdump/

share|improve this answer
    
I want to know how tcpdump does it –  Bruce Aug 8 '12 at 14:42
2  
So read the source and ask if you have questions about it –  Useless Aug 8 '12 at 16:20
    
expanded answer with some words about the internals –  Kotte Aug 9 '12 at 5:10
add comment

Take a look at tcptrack tool. You might be able to measure this.

share|improve this answer
    
I don't see how. Tcptrack displays connection statistics, not per-packet processing information. –  Gilles Aug 5 '12 at 22:26
add comment

Do you mean like traceroute? The -p option permit to choose the protocol.

[root@osgiliath ~]# traceroute myserver.mydomain.com -p 443
traceroute to myserver.mydomain.com (10.11.20.30), 30 hops max, 60 byte packets
 1  10.119.9.253 (10.10.10.1)  0.262 ms  0.294 ms  0.360 ms
 2  10.111.225.114 (10.11.20.14)  0.326 ms  0.387 ms  0.466 ms
 3  myserver.mydomain.com (10.11.20.30)  7.558 ms  7.558 ms  7.547 ms
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.