In-network classification brings trained machine learning inference into programmable switches, where packets can be classified as they pass through the network. Instead of sending all traffic to a host or separate accelerator for analysis, a switch can use selected packet features and a pre-trained model to make a decision in its match-action pipeline. For industrial automation, this approach raises a practical question: which classification tasks can fit within the data plane’s fixed resources without compromising essential networking functions?
A programmable switch is not a general-purpose machine-learning processor. Its potential comes from a different strength: packet parsing and match-action processing already provide a hardware pipeline for extracting fields, applying rules and producing actions at high packet rates. Mapping a trained model to that pipeline can support fast decisions close to where traffic enters the network, but it requires careful choices about features, model structure and available hardware resources.
Why consider in-network classification?
Network devices sit directly on traffic paths. This makes them a possible location for decisions that need to happen before packets reach a downstream system. Depending on the application, a switch might classify traffic for filtering, mitigation, quality-of-service grouping or further processing. In industrial environments, where network traffic can include operational and IoT devices, early classification could help direct traffic to an appropriate next step. The specific value depends on the task and the device’s capabilities.
Processing inside a switch also avoids relying on a separate computing device for every classification decision. The motivation is not simply to move all machine learning into the network: it is to use the data plane for suitable inference tasks, while recognizing that switches have limited resources and must continue performing their networking role.
How a match-action pipeline represents a classifier
Switch pipelines already perform a process that resembles classification. A parser extracts packet headers, such as protocol fields or transport ports. These fields act as features. Match-action tables then compare the extracted values with entries and return actions or metadata that guide subsequent processing.
A basic Ethernet switch offers an intuitive example: it matches a destination MAC address against a table and uses the result to select an output port. A more complex classifier can use multiple features and stages. In a decision-tree mapping, for example, individual stages can match feature values and encode the resulting branch in metadata. A later stage uses those codes to identify the outcome.
The core implementation insight is to represent model calculations through lookup tables rather than expecting the switch to perform complex mathematical operations directly. Match-action hardware is designed for table lookups, while operations such as multiplication, logarithms or polynomial calculations may be difficult to pipeline efficiently. Tables can store classification results, codes or other values needed by the mapping.
Model choice determines the resource trade-offs
Different algorithms map to a pipeline in different ways. Work on the IIsy prototype explored decision trees, support vector machines (SVM), Naïve Bayes and K-means. These examples show that feasibility depends not only on the algorithm’s name, but also on how its features, intermediate results and final decision are represented.
- Decision trees: Feature-value lookups can encode branches, followed by a final lookup that maps the codes to a class. This fits the match-action model naturally, although tree depth and feature count affect pipeline stages and table requirements.
- SVM: A classifier can use tables to determine which side of a hyperplane an input falls on, then combine votes to select a class. Other mappings calculate parts of the hyperplane values, but can require additional logic or wider actions.
- Naïve Bayes: Probability values can be represented by encoded table outputs, but a design that uses all features as a table key may require wide and deep tables. Combining feature probabilities is another implementation challenge.
- K-means: Tables can provide distance-related values that are combined to identify the nearest cluster. Mappings that use all features as a key can reduce table count but increase key width and table size.
These approaches are not interchangeable in their hardware demands. A design with fewer tables may rely on wider keys or more work in later stages. The practical mapping is a balance among the number of features and classes, table width and depth, pipeline stages, accuracy and the resources left for ordinary switching.
Hardware limits shape accuracy and portability
Switches cannot hold entries for every possible combination of feature values. A wide feature, such as an IP address, illustrates why a direct table covering every value is impractical. Implementations can instead use ranges, ternary or longest-prefix matching where supported, or store selected classification results rather than every possible calculation. These techniques make a model more feasible, but can constrain the representations available or affect accuracy.
Feature selection matters as much as model selection. Packet-header fields are often accessible to a parser, while features requiring state or device-specific metadata may need counters, externs or target-specific functions. Some models also depend on features that a switch cannot readily extract. In addition, using multiple pipelines to expand available processing can affect throughput and may require carrying information between pipelines.
A match-action-only implementation can be easier to port across targets because it avoids reliance on specialized functions. However, hardware architectures differ, and the resources available for tables and stages are finite. A model that works in a software switch is not automatically suitable for a hardware target.
What the IIsy prototype demonstrated
IIsy combined a training environment, a programmable data plane and a control plane that writes the trained model’s parameters into switch tables. The prototype used Scikit-learn for training and P4 for data-plane implementation. When the model type and feature set remained fixed, model updates could be applied through the control plane without changing the P4 program.
For its hardware evaluation, the researchers implemented a decision-tree classifier on NetFPGA SUME using IoT traffic features. The implementation classified the evaluated traffic at line rate. Its reported accuracy depended on the tree depth: a deeper trained tree achieved higher accuracy, while the hardware implementation used a shallower pipeline and fewer features, with a corresponding reduction in accuracy. The result demonstrates a trade-off, not a general performance guarantee for other switches, models or traffic.
Practical implications for automation networks
For system integrators and operations teams considering in-network classification, the central task is to define a narrow, supportable use case. Assess the following before selecting a model:
- Which packet fields or other features are available in the target pipeline?
- How many features, classes and decision stages can the device support alongside its networking workload?
- What classification accuracy is required, and what happens to uncertain or lower-confidence traffic?
- Can the model be updated through the control plane while keeping the data-plane structure unchanged?
- Does the target support the table types and pipeline behavior required by the chosen mapping?
In-network classification is best understood as a constrained inference option, not a replacement for general-purpose machine learning systems. Programmable switches can apply selected trained models through match-action tables and make decisions directly on packet paths. The practical opportunity depends on fitting the model to available features, stages and memory while preserving network operation. For industrial automation, that makes early classification worth evaluating where timely traffic handling matters and the task is simple enough to map reliably to the data plane.
Access Official Technical PDF