Iam trying to calculate packet delay from server to client. Iam capturing the packets using WireShark and filtering them out on both sides to calculate the delay by computing difference between their timestamps.
In WireShark, I can get the timestamps in both Epoch & in HH: MM: SS format with nanosecond precision. The timestamps I read from the file are char array type
1. How can I convert strings to a time format which can be used to compute time difference with high precision ?

The difftime() function computes time difference in epoch units but with only seconds precision.

2. How can I computer time difference with high precision ? Is there any other method than difftime() ?

Thank you for your time!


1. Just parse the string. If you already know the time format then it is not very difficult to split the string into its individual parts (hours, minutes, seconds, milliseconds).

2. The milliseconds is not very useful when the time difference is greater than probably one minute. If the difference is less than one minute then just convert both times to milliseconds and subtract them.