A scenario is like this --
You got a task to figure precise round trip time of a remote device or perhaps, need to measure how much time it required to receive the sensor data at requested side.
accurate round trip time from client to sensor, two different
technique is mainly popular.
First, used timespec struct (sec & nano-sec) with
CLOCK_MONOTONIC marco of kernel to measure time between sending
client request and receive of result from server.
timespec struct (sec and nano-sec) variable with network driver
packet timestamp macro SIOCGSTAMPNS for sending socket and receiving
socket and calculate the difference.
Example Output =>
SHELL>$ ./pngclnt_v2 192.168.178.100
0.000000s : 0.019165 sec
0.000000s : 0.020459sec
0.000000s : 0.019314sec
idea is client -- server scenario, which means a server will run on
sensor side and wait for client will request. Once receive the request,
server script will perform the task and respond back to client.