Fix pcapng timestamp resolution + imported-session duration

- pcap.py: _parse_tsresol now pads options to a 32-bit boundary
  ((-length) % 4) and uses 2** for the MSB-set (power-of-2) case, so
  nanosecond if_tsresol is read correctly (was defaulting to µs and
  scaling timestamps 1000x)
- database/server: set imported session started/ended from the first/last
  packet timestamps (falling back to wall-clock for synthetic SPB)
- frontend: formatDuration renders hours
- tests: tsresol (ns after padded option, default µs, ns round-trip) and
  session-window/fallback (119 total)
This commit is contained in:
catarrh committed 2026-08-15 02:02:44 +03:00
1 parent 5ba55ac3a9
commit c21b655fe1
5 files changed
+82 -4

No files matched your search

+2 -2
View File
@@ -378,9 +378,9 @@ def _parse_tsresol(options, endian):
if code == 9 and length == 1:
b = options[i]
if b & 0x80:
return 10 ** (-(b & 0x7F))
return 2 ** (-(b & 0x7F))
return 10 ** (-b)
i += length + (length & 1) # options are padded to 32-bit
i += length + ((-length) % 4) # options are padded to a 32-bit boundary
return 1e-6 # default: microseconds