ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hello
I want to access the timestamp field of the packet being sent or received.
I am not getting clear idea as to which ioctl i should use, and how it should be used in the program.
Also it would be very helpful if somebody could explain rough flow of the program for accessing the timestamp.
Which time stamp are you referring to? One that is sent via a client (or server) application to a peer? Or the one that may be embedded in an ICMP formatted message? I'm not aware of a time stamp field available in either the IP header, or the TCP or UDP headers.
i want to retrieve the time when the packet is actually sent or received and that too in nanoseconds. Latest kernel 2.6.32.2 have a function ktime_get_real() which returns system time in nanoseconds. it is declared in ktime.h and defined in timekeeping.c We tried to call this funtion in our C program , but it gave errors. I am attaching the program....
please help...ld
Is this a compatibility problem? Does linux kernel 2.6.32.2 supports nanosecond time? If not which kernel version supports time in ns format?
How should we proceed?
Hello
What i want to do is to timestamp the frame and send it. I tried using libpcap's pcap_sendpacket() function but it gave error. When libpcap captures packet, it constructs packet header and stores timestamp in the ts field of the packet header. SO is there any other library similar to libpcap which can timestamp and send the packet? If not then how should i get the accurate time at which the packet was sent.
Can i use libnet for sending the packets? and does libnet timestamps the outgoing packets ?If not then what is the solution?
I want to all the programming at the data link layer.
Hello
What i want to do is to timestamp the frame and send it. I tried using libpcap's pcap_sendpacket() function but it gave error. When libpcap captures packet, it constructs packet header and stores timestamp in the ts field of the packet header. SO is there any other library similar to libpcap which can timestamp and send the packet? If not then how should i get the accurate time at which the packet was sent.
Can i use libnet for sending the packets? and does libnet timestamps the outgoing packets ?If not then what is the solution?
I want to all the programming at the data link layer.
Eagerly waiting for the reply.
There's no way to accurately do what you want to do - there's no place (in many protocols) for a timestamp to be inserted. That's intentional, btw, since you don't know how timezone or latency or anything else, for that matter, will impact that measurement. And, frankly, most protocols don't care.
If you want to timestamp your packets, you'll have to come up with a clever way of doing so. For instance, if you're building the packets from the ground up (ie: you're building the IP header + message body) you might look into using a proprietary IP option to include the timestamp. Or, if you're writing your own IP-based protocol, you might look into adding a timestamp field. If this is on the local network, you might just use the arrival stamps to track the packet, and take a stamp just before you call send() (admittedly, all of these may not be terribly accurate).
In the end, there's no good way of doing what you want to do, afaik. Someone may know of a wrapper protocol (maybe something like IPIP or GRE) which contains timestamp information that you might implement. I'm not sure, though.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.