mirror of
https://github.com/zvx-echo6/meshai.git
synced 2026-05-22 07:34:47 +02:00
fix: Dedup packets across sources, translate numeric port numbers to names
Packet dedup: track seen packet IDs across all sources. Same packet from Meshview + MeshMonitor counted once, not twice. Fixes inflated counts. Portnum: numeric values (3, 4, 71) mapped to names (Position, NodeInfo, Neighbors). LLM prompt: guidance on normal vs abnormal packet rates per type.
This commit is contained in:
parent
1d97854319
commit
a80ed6cc7c
3 changed files with 39 additions and 2 deletions
|
|
@ -458,12 +458,20 @@ class MeshDataStore:
|
|||
- Deliverability (source overlap)
|
||||
Does NOT rebuild the full node model.
|
||||
"""
|
||||
# Recount packets per node from all sources
|
||||
# Recount packets per node from all sources (deduped by packet ID)
|
||||
packet_counts: dict[int, int] = {}
|
||||
packets_by_type: dict[int, dict[str, int]] = {}
|
||||
seen_packet_ids: set = set()
|
||||
|
||||
for name, source in self._sources.items():
|
||||
for pkt in (source.packets if hasattr(source, 'packets') else []):
|
||||
# Dedup: skip packets already seen from another source
|
||||
pkt_id = pkt.get("packet_id") or pkt.get("id")
|
||||
if pkt_id is not None:
|
||||
if pkt_id in seen_packet_ids:
|
||||
continue
|
||||
seen_packet_ids.add(pkt_id)
|
||||
|
||||
from_node = pkt.get("from_node") or pkt.get("from_node_id") or pkt.get("from")
|
||||
if from_node is None:
|
||||
continue
|
||||
|
|
@ -478,7 +486,7 @@ class MeshDataStore:
|
|||
|
||||
packet_counts[from_node] = packet_counts.get(from_node, 0) + 1
|
||||
|
||||
portnum = pkt.get("portnum") or pkt.get("portnum_name") or pkt.get("type") or "UNKNOWN"
|
||||
portnum = str(pkt.get("portnum") or pkt.get("portnum_name") or pkt.get("type") or "UNKNOWN")
|
||||
if from_node not in packets_by_type:
|
||||
packets_by_type[from_node] = {}
|
||||
packets_by_type[from_node][portnum] = packets_by_type[from_node].get(portnum, 0) + 1
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue