rt.data.datasets[0].data = Object.values(protocolCounts);
        protocolChart.update();
      };
      
      ws.onclose = () => {
        console.log('WebSocket connection closed');
        setTimeout(connectWebSocket, 2000); // Try to reconnect after 2 seconds
      };
      
      ws.onerror = (error) => {
        console.error('WebSocket error:', error);
        ws.close();
      };
    }
    
    // Start capture button
    document.getElementById('startCapture').addEventListener('click', () => {
   