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:
1 parent
5ba55ac3a9
commit
c21b655fe1
5 files changed
+82
-4
No files matched your search
@@ -37,6 +37,11 @@ def _iso_now():
|
||||
f'{time.time() % 1 * 1000:03.0f}'
|
||||
|
||||
|
||||
def _iso_from_ts(ts):
|
||||
return time.strftime('%Y-%m-%dT%H:%M:%S.', time.localtime(ts)) + \
|
||||
f'{ts % 1 * 1000:03.0f}'
|
||||
|
||||
|
||||
class Database:
|
||||
def __init__(self, db_path=None):
|
||||
if db_path is None:
|
||||
@@ -64,6 +69,12 @@ class Database:
|
||||
(_iso_now(), session_id))
|
||||
self._conn.commit()
|
||||
|
||||
def set_session_times_from_ts(self, session_id, first_ts, last_ts):
|
||||
self._conn.execute(
|
||||
'UPDATE sessions SET started=?, ended=? WHERE id=?',
|
||||
(_iso_from_ts(first_ts), _iso_from_ts(last_ts), session_id))
|
||||
self._conn.commit()
|
||||
|
||||
def rename_session(self, session_id, name):
|
||||
self._conn.execute(
|
||||
'UPDATE sessions SET name=? WHERE id=?',
|
||||
|
||||
Reference in new issue
Block a user