Skip to main content

Overview

The ML Detector is the intelligence core of ML Defender, running 4 embedded RandomForest models in C++20 for sub-millisecond threat classification. Validated on the CTU-13 dataset with 97.6% accuracy, it provides real-time detection of DDoS attacks, ransomware, and network anomalies.

4 Embedded Models

  • DDoS Detection (97.6% accuracy)
  • Ransomware Detection
  • Traffic Classification
  • Internal Anomaly Detection

Performance

  • <5ms classification latency
  • 10-50K events/sec throughput per quintuple
  • 83 features extracted per flow
  • Zero-copy IPC with Unix sockets

Three-Layer Architecture

The ML Detector implements a tricapa (three-tier) decision cascade that progressively analyzes threats with increasing precision:

Level 1: General Attack Detection

Purpose: Fast binary classification (Attack vs. Benign)
  • Model: Random Forest (23 features)
  • Latency: <1ms
  • Features: High-level flow statistics (packet counts, byte ratios, flag patterns)

Level 2: Specialized Classification

Purpose: Identify attack type (DDoS, Ransomware, Unknown)
  • Model: Random Forest (82 features)
  • Latency: <3ms
  • Features: Deep protocol analysis, timing patterns, behavioral indicators

Level 3: Anomaly Detection

Purpose: Catch novel threats not seen in training
  • Model: Statistical anomaly detection (4 features)
  • Latency: <0.5ms
  • Features: Internal/Web traffic patterns
Design Philosophy: Early exit for benign traffic (Level 1 β†’ Level 3 β†’ END) minimizes CPU for normal operations while deep analysis (Level 2) activates only for threats.

Model Performance

CTU-13 Dataset Validation

Tested on CTU-13 Neris Botnet captures (real-world ransomware behavior):
Test Configuration:
Confusion Matrix:

Feature Extraction

The ML Detector receives 83 features per network flow from the Sniffer component:
  • total_forward_packets, total_backward_packets
  • total_forward_bytes, total_backward_bytes
  • forward_packet_length_mean, backward_packet_length_mean
  • forward_packet_length_std, backward_packet_length_std
  • forward_packet_length_max, backward_packet_length_max
  • forward_packet_length_min, backward_packet_length_min
  • fin_flag_count, syn_flag_count, rst_flag_count
  • psh_flag_count, ack_flag_count, urg_flag_count
  • cwe_flag_count, ece_flag_count
  • forward_psh_flags, backward_psh_flags
  • forward_urg_flags, backward_urg_flags
  • flow_duration, flow_iat_mean, flow_iat_std
  • flow_iat_max, flow_iat_min
  • forward_iat_total, forward_iat_mean, forward_iat_std
  • backward_iat_total, backward_iat_mean, backward_iat_std
  • active_mean, active_std, active_max, active_min
  • idle_mean, idle_std, idle_max, idle_min
  • external_ips_30s: Unique external IPs contacted
  • smb_diversity: Lateral movement tracking
  • dns_entropy: DGA domain detection
  • failed_dns_ratio: C&C failures
  • upload_download_ratio: Exfiltration patterns
  • burst_connections: Rapid connection attempts
  • payload_entropy: Encryption detection
  • … (13 more behavioral features)
  • avg_packet_size, packet_length_variance
  • down_up_ratio, avg_forward_segment_size
  • avg_backward_segment_size
  • subflow_forward_packets, subflow_backward_packets
  • init_win_bytes_forward, init_win_bytes_backward
  • min_seg_size_forward, min_seg_size_backward

ZeroMQ Integration

The ML Detector uses ZeroMQ PULL/PUB pattern for high-performance inter-process communication:

Configuration

Model Metadata

Each RandomForest model includes metadata for feature mapping and thresholds:

Runtime Configuration

Create config/ml_detector.json:

Deployment

Prerequisites

Build

1

Navigate to Directory

2

Configure

3

Compile

Run

Real-time Output:

Integration with Pipeline

Quintuple Co-located Architecture

The ML Detector is part of a specialized 5-component pipeline:
Receives NetworkSecurityEvent protobuf messages with 83 features:

Model Training & Updates

Converting Scikit-learn to ONNX

Model Versioning

ML Defender supports hot-swapping models without downtime:
  1. Place new model in models/production/
  2. Update metadata in models/metadata/
  3. Update config with new path
  4. Send SIGHUP to ml-detector process
The detector will reload models and continue inference with <50ms interruption.

Monitoring & Metrics

Real-time Statistics


Troubleshooting

Possible causes:
  1. Too many features: Reduce to essential features only
  2. Large model: Prune RandomForest trees (max_depth=10)
  3. CPU contention: Pin ml-detector to dedicated cores

Next Steps

Firewall Agent

Configure autonomous blocking based on ML detections

RAG System

Query detections using natural language

Model Training

Train custom models on your network data

Performance Tuning

Optimize for 10Gbps+ environments