🔬 Analyzer1

Analizador de protocolos — Arquitectura, interfaces y guia de implementacion · v4.0 · s18 · 2026-04-06

Contenido
1. Vision y proposito 1.1 Triple vida 2. Arquitectura 2.1 ProtocolAdapter interface 2.2 Tap Points 2.3 Frames capturados 2.4 Estado del Analyzer 3. Catalogo de protocolos (3 implementados) 3.1 ARINC 429 3.2 MQTT 3.3 WebSocket (s18) 4. FrameInspector (s16+s18) 4.1 Branch ARINC 429 4.2 Branch MQTT (s18) 4.3 Branch WebSocket (s18) 4.4 Componentes compartidos IoT 5. BottomPanel (s18 refactor) 5.1 Waveform ARINC 429 (mejorada s18) 5.2 MQTT Flow 5.3 WebSocket Flow (s18) 5.4 Timeline (mejorada s18) 5.5 Topic Constellation (s18) 5.6 Latency Analyzer (s18) 5.7 Payload Diff (s18) 5.8 Stats 6. Estructura de ficheros 7. Interfaz de usuario 8. Integracion con la plataforma 9. Roadmap

1. Vision y proposito

Analyzer1 es el instrumento de diagnostico de protocolos de la plataforma LRU. Captura, decodifica e inspecciona trafico de cualquier protocolo — desde MQTT IoT hasta ARINC 429 de avionica — con una interfaz unificada.

Principio de diseno: El Analyzer no conoce los detalles de ningun protocolo. Solo conoce la interfaz ProtocolAdapter. Cada protocolo es un modulo independiente. Anadir un protocolo = implementar un adaptador + registrarlo.

1.1 Triple vida

ModoRuta / MecanismoDescripcion
Pagina/Analyzer1Pantalla completa
OverlayAnalyzer1OverlayFlotante arrastrable (Escape cierra)
PanelGridPanel analyzerEmbebido en Sim1, modo compacto

2. Arquitectura

┌─────────────────────────────────────────────────────────────────┐ │ Analyzer1.tsx (392 lin) │ │ ┌─────────┐ ┌───────────────┐ ┌──────────────────────────┐ │ │ │ Sidebar │ │ Frame List │ │ FrameInspector (898 lin)│ │ │ │ 3 protos │ │ (filtrable) │ │ 3 branches: A429/MQTT/WS│ │ │ │ + taps │ │ A429+MQTT+WS │ │ Topic, Badge, Barras │ │ │ └─────────┘ └───────┬───────┘ └────────────┬─────────────┘ │ │ ┌─────────────────────┴────────────────────────┘ │ │ │ AnalyzerBottomPanel (171 lin) │ │ │ [Flow] [Timeline] [Constellation] [Latency] [Diff] [Stats] │ │ │ → bottom/ (10 ficheros, 2235 lin) │ │ └──────────────────────┬───────────────────────────────────────┘ │ ┌──────────────────────┴───────────────────────────────────────┐ │ │ Tap Points │ │ │ ┌──────────┐ ┌──────────────┐ ┌──────────────┐ │ │ │ │ MQTT │ │ ARINC 429 │ │ WebSocket │ │ │ │ │ Sim+DBus │ │ Sim │ │ Sim+CommsMgr │ │ │ │ │ ✓ │ │ ✓ │ │ ✓ │ │ │ │ └──────────┘ └──────────────┘ └──────────────┘ │ │ ┌──────────────────────────────────────────────────────────────┐ │ │ Protocol Adapters (3 carpetas) │ │ │ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ ┌──────┐ │ │ │ │ MQTT │ │ A429 │ │ WS │ │ 1553 │ │ ... │ │ │ │ │ ✓ │ │ ✓ │ │ ✓ │ │ plan │ │ │ │ │ │ └──────┘ └──────┘ └──────┘ └──────┘ └──────┘ │ │ └──────────────────────────────────────────────────────────────┘ └─────────────────────────────────────────────────────────────────┘

2.1 ProtocolAdapter interface

interface ProtocolAdapter {
  readonly protocolId: string;
  readonly name: string;
  readonly family: ProtocolFamily; // 'aviation' | 'industrial' | 'iot'
  decode(raw: string | ArrayBuffer): DecodedFrame;
  inspect(raw: string | ArrayBuffer): string;
  canDecode(raw: string | ArrayBuffer): boolean;
}

2.2 Tap Points

TipoFuenteEstadoHook
mqtt-debugbusDebugBus canales mqtt+commsuseMqttTap
mqtt-simMqttSimulator (3 devices)useMqttSimTap
arinc429-simArinc429Simulator → Sim1useArinc429Tap
ws-realCommsManager subscribe('*') channel ws*✓ s18useWsTap
ws-simWebSocketSimulator (6 generators)✓ s18useWsSimTap
bleCommsManager channel ble*Planificado

2.3 CapturedFrame

interface CapturedFrame {
  id: number; timestamp: number; tapPointId: string;
  protocolId: string; direction: 'rx' | 'tx' | 'internal';
  raw: string; decoded?: DecodedFrame; size: number; starred?: boolean;
}

2.4 AnalyzerState

interface AnalyzerState {
  capturing: boolean; frames: CapturedFrame[]; maxFrames: number;
  selectedFrameId: number | null; activeTapPoints: string[];
  filter: string; autoScroll: boolean;
  stats: { totalFrames: number; framesPerSec: number; bytesTotal: number; };
}

3. Catalogo de protocolos

9 protocolos definidos, 3 implementados:

✈ Aviation
ARINC 429
MIL-STD-1553 plan
AFDX plan
🏭 Industrial
OPC UA plan
Modbus plan
PROFINET plan
📡 IoT
MQTT
WebSocket ✓ s18
BLE stub

3.1 ARINC 429 s16

Decode 32-bit words: Label 8b bit-reversed, SDI 2b, Data 19b, SSM 2b, Parity 1b odd. Tabla A320_LABELS 22 labels con escala/offset/unidad/ATA. Simulador con Sim1 link via window.Sim1Debug.getValues().

3.2 MQTT s17

Parseo topics <red>/<id>/<dir>/<canal>, clasificacion 6 tipos (telemetry/rpc/status/command/event/unknown), deteccion unidades, meta cache getMqttMeta(). 3 dispositivos simulados (esp01 Air Data, esp02 Engine, esp03 Flight Control). Tap real via DebugBus + tap simulado.

3.3 WebSocket s18

Decode de frames WS intercambiados con Node-RED y servidores WebSocket. Clasificacion 8 tipos:

TipoColorIconoDeteccion
data#2ecc71📊Tiene topic+payload, o campos numericos
subscribe#3498db🔔type: 'subscribe'
unsubscribe#7c8098🔕type: 'unsubscribe'
ping/pong#95a5a6Texto ping/pong o type: 'ping'
command#e74c3c_execCommand, command, action
event#9b59b6type: 'event', event field
raw#7c8098·Sin coincidencia / no-JSON

Simulador WebSocket

6 generadores en simulator.ts (182 lin): sensor relay (Sim1 link), status broadcast, _execCommand, system events, subscribe, ping/pong. Intervalo base 600ms.

Tap points

useWsTap: intercepta CommsManager con subscribe('*') filtrando channel.startsWith('ws') + captura publishes salientes via onPublish. Patron reutilizable para BLE (channel.startsWith('ble')).

useWsSimTap: WebSocketSimulator genera trafico sin servidor. Mismo patron que useMqttSimTap.

4. FrameInspector s16+s18

898 lineas. 3 branches de rendering segun protocolo, con componentes compartidos para IoT (MQTT + WS).

4.1 Branch ARINC 429

Binary view coloreada (32 bits, 5 campos), Octal view (labels octal), HexDump con bytes coloreados, campos decodificados con cross-highlight bidireccional.

4.2 Branch MQTT s18

Topic segmentado en cajas coloreadas por segmento. Badge tipo (telemetry/rpc/status/command/event). Campos organizados: Routing / Datos (barras magnitud) / Otros. JSON syntax highlight (keys cyan, strings verde, numbers ambar, booleans purpura). Deteccion timestamps → formato HH:MM:SS.mmm.

4.3 Branch WebSocket s18

Badge tipo coloreado (8 tipos WS). Topic segmentado si presente. Campos con colores semanticos: IDs cyan, IPs verde, commands rojo, status verde, booleans verde/rojo. JSON syntax highlight. Reutiliza componentes IoT compartidos.

4.4 Componentes compartidos IoT

ComponenteFuncion
MqttFieldsViewOrganiza campos en Routing / Datos / Otros con colores semanticos
MqttNumericFieldCampo numerico con barra magnitud, deteccion timestamp
JsonHighlightJSON syntax highlight con regex (keys, strings, numbers, booleans, null)
fieldColor()Colores semanticos por nombre de campo (IDs, IPs, status, commands, timestamps)
isTimestamp()Heuristica: por nombre (ts, timestamp) y por rango valor (>1e12)

5. AnalyzerBottomPanel s18 refactor

Refactorizado de monolito 673 lin a carpeta bottom/ con 10 ficheros (2235 lin). Orquestador delgado (171 lin). 6 tabs:

TabFicheroLineasProtocoloDescripcion
Waveform/FlowWaveformView / MqttFlowView / WsFlowView280+121+202AdaptativoA429: bipolar RZ multi-word. MQTT: pub/sub. WS: bidireccional
TimelineTimelineView353TodosZoom, pan, minimap, tooltips, rafagas
ConstellationTopicConstellation283MQTTGrafo topics, parpadeo, click filtra
LatencyLatencyAnalyzer251TodosHistograma, estadisticas, outliers
DiffPayloadDiff274TodosSide-by-side campos cambiados
StatsStatsView216TodosDonut, sparkline, top topics

5.1 Waveform ARINC 429 s18 mejorada

Multi-word (hasta 4 consecutivas), timing real (toggle 100kb/12.5kb), gaps null (4 bit-periods), escala temporal µs, cursor de medida (click A + click B → delta µs).

5.2 MQTT Flow s17

Diagrama pub/sub: Publisher → Broker → Subscriber. Topic segmentado, badge tipo, barras valores numericos.

5.3 WebSocket Flow s18

Diagrama bidireccional PWA ↔ Node-RED. Badge WS en conexion. Badge tipo debajo. Node-RED con mini logo "N" y URL :1880. Topic segmentado si presente. Ping/pong con texto especial. Barras valores (timestamps excluidos).

5.4 Timeline s18 mejorada

Zoom scroll wheel (1x-20x), drag horizontal pan, mini-map con viewport, tooltips hover (protocolo, timestamp, summary, dir, size), agrupacion rafagas (<50ms), boton Reset.

5.5 Topic Constellation s18

Grafo SVG: nodos = segmentos unicos topics MQTT, aristas = padre/hijo. Tamano proporcional a frecuencia. Parpadeo reciente (<2s). Click filtra sub-arbol. Solo visible si hay frames MQTT.

5.6 Latency Analyzer s18

Histograma latencia inter-frame. Filtro por protocolo. 8 stats: Min, Max, Avg, Median, P95, σ, Jitter, Outliers. Lineas media (verde) y P95 (ambar). Barras rojas para outliers (>2σ). Alerta jitter >100ms.

5.7 Payload Diff s18

Frame seleccionado vs anterior/siguiente del mismo protocolo. Campos: same (gris), modified (amarillo+flecha), added (verde), removed (rojo tachado). Toggle prev/next.

5.8 Stats s17

Donut distribucion protocolos, barra TX/RX/Internal, avg payload size, sparkline throughput 20s, top 5 topics MQTT.

6. Estructura de ficheros

src/pages/Analyzer1/
├── index.ts                           — Re-export
├── Analyzer1.tsx                      — Shell + play por protocolo (s18, 392 lin)
├── Analyzer1Overlay.tsx               — Overlay arrastrable (portal)
├── FrameInspector.tsx                 — 3 branches A429/MQTT/WS (s18, 898 lin)
├── AnalyzerBottomPanel.tsx            — Orquestador 6 tabs (s18, 171 lin)
├── analyzer1.css                      — Estilos + MQTT/WS inspector (s18, 534 lin)
├── types.ts                           — ProtocolAdapter, TapPoint, Frame, State
├── bottom/                            — Visualizaciones BottomPanel (s18)
│   ├── index.ts                       — Barrel (13 lin)
│   ├── constants.ts                   — PROTO_COLORS, ARINC429_RANGES (42 lin)
│   ├── WaveformView.tsx               — Waveform A429 multi-word (280 lin)
│   ├── MqttFlowView.tsx               — MQTT pub/sub flow (121 lin)
│   ├── WsFlowView.tsx                 — WS bidireccional flow (202 lin)
│   ├── TimelineView.tsx               — Timeline zoom/pan/minimap (353 lin)
│   ├── StatsView.tsx                  — Donut + sparkline (216 lin)
│   ├── TopicConstellation.tsx         — Grafo topics MQTT (283 lin)
│   ├── LatencyAnalyzer.tsx            — Histograma latencia (251 lin)
│   └── PayloadDiff.tsx                — Diff side-by-side (274 lin)
└── protocols/
    ├── index.ts                       — Catalogo + registry (79 lin)
    ├── arinc429/
    │   ├── index.ts, adapter.ts (212), labels.ts (67), simulator.ts (151), tap.ts (69)
    ├── mqtt/
    │   ├── index.ts, adapter.ts (309), simulator.ts (224), tap.ts (167)
    └── websocket/                     — s18
        ├── index.ts (9), adapter.ts (302), simulator.ts (182), tap.ts (159)

7. Interfaz de usuario

┌──────────┬────────────────────────────────┬───────────────────┐ │ SIDEBAR │ FRAME LIST │ FRAME INSPECTOR │ │ 180px │ (flex: 1) │ 340px (resizable) │ │ │ │ │ │ Aviation │ ← 12:34:56 mqtt telm {ALT.. │ ⚡ EVENT json·5 │ │ ✈ A429▶●│ ← 12:34:56 A429 N1_L 87% │ │ │ ├ Sim ●│ → 12:34:57 WS CMD: ping │ lru / sensors │ │ IoT │ ← 12:34:57 WS lru/sens.. │ │ │ 📡 MQTT▶●│ ← 12:34:57 mqtt eng {N1.. │ DATOS · 3 valores │ │ ├ Sim ●│ │ ALT 35000 ████ │ │ ├ DBus●│ [filtrar frames...] [534] │ CAS 250 ██ │ │ 🔌 WS ▶●│ │ ts 20:45:50 ⏰ │ │ ├ Sim ●│ │ │ │ ├ Comms●│ │ OTROS CAMPOS │ │ 📶 BLE │ │ source node-red │ │ ───── │ │ │ │ Indust. │ │ RAW (JSON) │ │ 🏭 OPC │ │ { "topic": "...", │ │ ⚙ Modb │ │ "ALT": 35000 } │ ├──────────┴────────────────────────────────┴───────────────────┤ │ [⇂Flow] [◇Timeline] [✦Constellation] [Δ Latency] [≡Diff] [▤Stats]│ │ ┌──────┐ ┌──┐ ┌──────┐ │ │ │ PWA │◄──WS──►│NR│ lru / sensors / relay │ │ └──────┘ └──┘ 📊 data │ │ ▐█▌▐██▌▐█▌▐▌ ← barras valores │ ├───────────────────────────────────────────────────────────────┤ │ AN₁ │ ⏸ Parar │ 🗑 │ 534 frames · 8/s · 22.4KB │ ● │ └───────────────────────────────────────────────────────────────┘
ZonaFuncion
HeaderLogo AN₁, capturar/parar, limpiar, estadisticas, auto-scroll
Sidebar3 protocolos implementados con ▶/⏸ + tap points toggleables
Frame ListColores: A429 rojo, MQTT azul, WS verde. Filtro texto
FrameInspectorBranch por protocolo. Topic coloreado, badges, barras, JSON highlight
BottomPanel6 tabs. Badge protocolo. Colapsable

8. Integracion con la plataforma

Analyzer1Provider en App.tsx. Ruta /Analyzer1. Panel analyzer en PanelGrid (panel 11). CSS vars --sim1-*. Los 3 simuladores leen de window.Sim1Debug.getValues() para reflejar valores reales de Sim1.

9. Roadmap

Completado

SprintItemSesion
S3Shell Analyzer1 (triple vida, ProtocolAdapter, MQTT tap)s15
S4ARINC 429 Adapter + FrameInspector + Waveform + Sim1 links16
S4MQTT Adapter enriquecido + Simulador 3 devices + Flow + Timeline + Statss17
S4BottomPanel refactor modular (bottom/ 10 ficheros, 6 tabs)s18
S4Timeline mejorada (zoom/pan/minimap/tooltips/rafagas)s18
S4Waveform real ARINC 429 (multi-word, timing µs, cursor medida)s18
S4TopicConstellation + LatencyAnalyzer + PayloadDiffs18
S4WebSocket Adapter completo (protocolo #3: decode, sim, tap real+sim, flow)s18
S4FrameInspector MQTT/WS enriquecido (topic, badge, barras, JSON highlight)s18

Pendiente

ItemPrioridad
BLE Adapter (protocolo #4, tap real via CommsManager)Media
Ampliar labels A320 (Landing Gear, APU, Hydraulics, TCAS, GPWS)Baja
Touch para Timeline/Waveform (PanelGrid mobile)Baja
TrafficMonitor dashboard, OsiDrill, encode()S5
MIL-1553, Modbus, OPC UA, AFDX adaptersS5-S6
Tap points reales: Serial, BLE directosS6
FDR integration (RabbitMQ Streams replay)S6

LRU Platform · Analyzer1 Architecture · lru_analyzer1_architecture_v4.0_s18.html · s18 · 2026-04-06