Where to Sample: Rethinking ML-Based Malicious Traffic Detection at Terabit Scale
Machine Learning (ML)-based malicious traffic detectors can identify unseen attacks, including in encrypted traffic, but scaling them to Terabit rates remains challenging. Packet sampling, commonly used to meet processing limits, can discard essential behavioral information and render detection ineffective. We present Peregrine, a hardware-software co-designed architecture built around a simple principle: compute features before sampling. Peregrine updates ML features over all traffic at line rate in a programmable switch, then downsamples the feature records sent to software inference. We instantiate this design with two detectors that impose distinct feature-computation requirements on the switch. Across 84 attack traces from three datasets, we show that approximate features computed over all packets can outperform exact features computed from sampled packets. In our evaluation, Peregrine preserves detection effectiveness while reducing feature-record rates by three orders of magnitude - even where pre-feature sampling causes detection to collapse.