I tested on a linux VM in my lab with the command date +"%T.%6N" | nc -u 127.0.0.1 7777
It does not show such a high delta on my VM (Ubuntu 20.04 LTS):
[email protected]:~$ /usr/bin/tshark -c1 -ta -l -n -P -x -i lo -f "udp port 7777"; date +"%T.%6N"
Capturing on 'Loopback: lo'
1 17:42:13.157521841 127.0.0.1 → 127.0.0.1 UDP 58 59670 → 7777 Len=16
0000 00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00 ..............E.
0010 00 2c e4 9c 40 00 40 11 58 22 7f 00 00 01 7f 00 .,[email protected]@.X"......
0020 00 01 e9 16 1e 61 00 18 fe 2b 31 37 3a 34 32 3a .....a...+17:42:
0030 31 33 2e 31 35 35 30 38 33 0a 13.155083.
1 packet captured
17:42:13.219419
[email protected]:~$
The timestamps I see are:
17:42:13.155083 (0.000) Date generated it's output
17:42:13.157521 (0.002) Libpcap timestamped the packet
17:42:13.219419 (0.062) Tshark exited (so printing to STDOUT had definitely finished already)
What does your system show with the test above?
Normally its the case that the buffer size is increased (-B|--buffer-size <capture buffer="" size="">) because packets are being dropped.
If the packet rate is low, perhaps decreasing the buffer will reduce the latency.
tcpdump has the
--immediate-mode
option but there is no such option fordumpcap
(ortshark
).Unfortunately, tcpdump doesn't have -T json
Did you try a smaller buffer with
tshark
?I tried, the minimum buffer configurable is 1MiB as long as I understand