Submitted:
16 October 2026
Posted:
16 October 2026
You are already at the latest version
Abstract
IoT botnets generate diverse network behaviors, including scanning, command-and-control communication, and distributed denial-of-service activity. Traditional machine learn-ing models can achieve high detection accuracy using engineered network-flow features, but they often provide limited behav-ioral explanation. This work presents a network flow-window framework for IoT botnet behavior detection and explanation using both conventional machine learning baselines and a multi-agent large language model (LLM) reasoning pipeline. The proposed approach aggregates Zeek network flows into fixed-size behavioral windows and uses two IoT-23 scenarios: a scanning-dominated scenario for behavior-window construction and a main three-class scenario containing benign, C&C, and DDoS behavior. For the second scenario, non-leakage machine learning baselines achieved strong performance, with XGBoost and Random Forest reaching 99.42% accuracy using only network-derived window features. The multi-agent LLM pipeline, consisting of a behavior analyst, threat classifier, and judge agent, achieved 98.24% classifier accuracy and 97.65% judge accuracy over valid parsed outputs on a balanced 342-window evaluation set. When one invalid JSON response is counted as an automated failure, the end-to-end judge accuracy is 97.37%. Error analysis showed that most remaining errors occurred in behaviorally ambiguous cases, particularly benign windows with high-volume one-way DNS-like traffic and low-volume C&C windows mixed with benign-looking NTP traffic. The results suggest that conventional ML remains highly effective for structured classification, while multi-agent LLM reasoning adds interpretable evidence-based analysis and supports more transparent investigation of IoT botnet behavior.
Keywords:
IoT security
; botnet detection
; large language models
; multi-agent systems
; intrusion detection
; explainable AI
; LLM-as-a-Judge
I. Introduction
The rapid growth of Internet of Things (IoT) devices has increased the attack surface of modern networks. Many IoT devices operate with limited computational resources, weak authentication mechanisms, outdated firmware, and continuous network connectivity, making them attractive targets for botnet malware. The Mirai botnet demonstrated how large numbers of compromised IoT devices can be coordinated to perform large-scale malicious activity, including scanning, command-and-control (C&C) communication, and distributed denial-of-service (DDoS) attacks [1,2] Detecting such behaviors from network traffic is therefore an important task for IoT security monitoring.
Network-flow analysis is widely used for intrusion detection because it captures behavioral patterns without requiring ac-cess to packet payloads. Flow-level features such as protocol usage, destination ports, connection states, byte counts, packet counts, and destination diversity can reveal suspicious behav-ior even when payload inspection is unavailable or impractical. Public datasets such as IoT-23 provide labeled benign and malicious IoT traffic traces that enable the evaluation of botnet detection methods under realistic network conditions [6,7] Several studies have investigated machine learning (ML) and deep learning (DL) models for IoT botnet detection and have shown that structured flow features can achieve strong classifi-cation performance [8,9] However, conventional classifiers often provide limited explanation of why a traffic window is considered malicious, which can reduce their usefulness for security analysts who need interpretable evidence during investigation.
Recent advances in large language models (LLMs) provide a new opportunity for explainable security analysis. LLMs can reason over textual descriptions of network behavior, identify suspicious and benign indicators, express uncertainty, and generate human-readable explanations. Recent surveys have discussed the potential of LLMs for cybersecurity tasks, while also highlighting risks such as hallucination, unsup-ported reasoning, and privacy or security concerns [3,4] In addition, LLM-as-a-judge methods have been studied as a way to verify and evaluate model outputs, although their reliability depends on careful prompting and task design [5]. Therefore, directly applying a single LLM to intrusion detection may produce unstable or weakly supported decisions. To address this limitation, this work investigates a multi-agent LLM pipeline in which separate agents analyze behavior, classify threats, and verify the final decision.
This paper proposes a network flow-window framework for IoT botnet behavior detection and explanation. Zeek-style connection logs from the IoT-23 dataset are aggregated into fixed-size behavioral windows of 10 flows [13] . Each window is represented using network-derived statistical and categorical features, as well as a textual flow description used by the LLM agents. The framework is evaluated on two IoT-23 scenarios. The first scenario focuses on scanning behavior, while the second scenario contains benign, C&C, and DDoS traffic. This allows the evaluation to cover multiple botnet behaviors rather than a single attack type.
The experimental design compares conventional ML base-lines with a multi-agent LLM reasoning pipeline. For the second scenario, clean non-leakage ML baselines are trained using only network-derived window features. In parallel, a three-agent LLM architecture is evaluated using a behavior analyst agent, a threat classifier agent, and a judge agent. The best LLM configuration combines a refined analyst and classifier with a balanced judge prompt, showing that prompt refinement must be agent-specific rather than uniformly ap-plied to all agents.
The main contributions of this work are as follows:
- A flow-window-based framework for representing IoT botnet behavior using network connection logs.
- An evaluation across multiple IoT-23 scenarios covering scanning, C&C, and DDoS behavior.
- A comparison between non-leakage ML baselines and a multi-agent LLM reasoning pipeline.
- An error analysis showing that several remaining LLM errors occur in behaviorally ambiguous windows or in cases where dataset labels conflict with observable net-work evidence.
II. Related Work
IoT botnet detection has been widely studied due to the large number of vulnerable IoT devices and the impact of botnet-driven attacks. Existing studies commonly rely on network traffic analysis and labeled IoT datasets to distinguish benign behavior from malicious activity. The IoT-23 dataset is fre-quently used in this area because it contains labeled benign and malware-related IoT traffic, including scenarios that exhibit scanning, C&C communication, and attack behavior [6,7] Prior work has shown that conventional machine learning models, including Decision Trees, Random Forests, Support Vector Machines, and gradient boosting methods, can achieve strong performance on IoT botnet detection tasks when trained on statistical flow features [8,9]
Deep learning has also been applied to IoT intrusion detec-tion. Models such as Multilayer Perceptrons (MLPs), Convo-lutional Neural Networks (CNNs), Recurrent Neural Networks (RNNs), and Long Short-Term Memory (LSTM) networks have been investigated for learning complex traffic patterns. Sequence-based models are particularly relevant when network traffic is represented as ordered flows rather than isolated records. However, many DL-based IDS approaches require larger training datasets, careful tuning, and higher computa-tional cost. More importantly, both ML and DL models often provide limited analyst-readable explanations, even when their classification performance is high.
Explainable intrusion detection has therefore become an important research direction. Methods such as SHAP and LIME can identify which input features contributed to a prediction and have been used to improve the transparency of security models [10,11,12]. These methods are useful for feature-level interpretation, such as showing whether packet counts, destination ports, or connection states influenced a decision. However, feature attribution alone does not always provide a complete behavioral explanation. For example, it may indicate that a destination port was important without clearly explaining whether the behavior resembles scanning, C&C communication, or DDoS activity.
Large language models (LLMs) have recently attracted attention in cybersecurity because they can process textual descriptions, logs, alerts, and structured security information. Recent surveys discuss the potential of LLMs for tasks such as vulnerability analysis, malware interpretation, threat in-telligence, log analysis, and intrusion detection, while also emphasizing limitations such as hallucination, inconsistent reasoning, and unsupported explanations [3,4] In parallel, LLM-as-a-Judge approaches have been proposed to evaluate or validate model outputs, including checking whether generated answers are supported by evidence [5]. This idea is relevant to intrusion detection because security decisions should be both accurate and evidence-based.
Despite these advances, limited work has explored multi-agent LLM reasoning for IoT botnet behavior detection using network flow windows. Most existing IoT botnet studies focus on conventional ML/DL classification, while many LLM-based cybersecurity studies rely on a single LLM for direct analysis. This leaves a gap for frameworks that combine struc-tured flow-window representation, conventional ML baselines, and multi-agent LLM reasoning with a dedicated verification stage. This paper addresses this gap by evaluating a multi-agent LLM pipeline against non-leakage ML baselines on IoT-23 scenarios covering scanning, C&C, and DDoS behavior.
III. Proposed Methodology
This section presents the proposed framework for IoT botnet behavior detection and explanation using network flow windows, conventional machine learning baselines, and multi-agent LLM reasoning. The methodology is designed to analyze short-term device behavior rather than isolated network flows. The overall pipeline consists of four main stages: data prepro-cessing, flow-window construction, baseline feature extraction, and multi-agent LLM-based reasoning.
A. Framework Overview
The framework uses the same behavior-window representa-tion for both analysis paths. In the ML path, each window is represented as structured numerical features. In the LLM path, each window is converted into a concise textual description that supports reasoning over observable network behavior.
As shown in Figure 1, the proposed framework begins with labeled IoT network traffic.
The framework follows two complementary analysis paths. In the first path, each behavior window is converted into a numerical feature vector and used to train conventional ma-chine learning and neural baselines. These baselines provide quantitative reference performance using structured network-derived features. In the second path, the same window is converted into a structured textual description and analyzed by a multi-agent LLM pipeline. This path is designed to generate not only a predicted label but also evidence-based explanations, uncertainty notes, and judge-validated decisions.
Unlike conventional flow-level intrusion detection, the pro-posed approach focuses on short-term behavioral patterns. This is important because IoT botnet behavior may not be fully visible in a single flow. For example, scanning may appear as repeated failed connections across many destinations, C&C behavior may involve repeated communication with IRC-like services, and DDoS activity may appear as rapid traffic concentration toward a specific destination or service.
B. Dataset and Scenario Selection
This study uses the IoT-23 dataset, which provides labeled benign and malicious IoT network traffic in the form of packet captures and Zeek connection logs [6,7] The experiments use the labeled conn.log.labeled files because they provide structured connection-level features suitable for both ML baselines and LLM prompt construction.
Two IoT-23 scenarios are considered. The first scenario, CTU-IoT-Malware-Capture-1-1, contains benign traf-fic and a large number of malicious flows labeled as PartOfAHorizontalPortScan. This scenario is used to eval-uate scanning-oriented behavior detection. The second sce-nario, CTU-IoT-Malware-Capture-34-1, contains be-nign traffic as well as malicious C&C, DDoS, and a small number of scanning flows. This second scenario is used for a three-class behavior evaluation involving Benign, C&C, and DDoS. The small scanning portion in Capture 34 is excluded from the three-class evaluation because it is not sufficiently represented compared with the other classes.
C. Data Cleaning and Preprocessing
The Zeek connection logs contain metadata lines, tabular flow records, and label fields. During preprocessing, meta-data lines are removed, the tab-separated fields are parsed, and label-related columns are standardized. In some logs, the detailed label field appears under different names, such as det_label; this is normalized to detailed_label. Placeholder values such as - and (empty) are handled consistently. Numerical fields, including duration, byte counts, and packet counts, are converted into numeric format, while categorical fields such as protocol, service, and connection state are retained for feature extraction and prompt construc-tion.
To avoid data leakage in the baseline experiments, label-derived fields are not used as input features. In particular, the ML baselines do not use the ground-truth label, detailed label, majority label, majority detailed label, label distribution, or detailed-label distribution as predictive features. These fields are used only for assigning ground-truth labels and evaluating model performance.
D. Flow-Window Construction
Botnet behavior often emerges across multiple related flows rather than a single isolated connection. Therefore, the cleaned records are first sorted by source IP address and timestamp. Consecutive flows from the same source device are then grouped into non-overlapping windows of 10 flows. Each window represents a short-term behavioral segment of the device.
For each window, aggregate network features are extracted, including the number of unique destination IPs, number of unique destination ports, most frequent destination ports, protocol distribution, service distribution, connection state distribution, average duration, total bytes sent and received, and total packets sent and received. Additional indicators are extracted for relevant ports and services, such as port 53, port 80, port 123, port 6667, IRC service, HTTP service, and DNS service. These features are used by the conventional ML baselines.
The same window is also converted into a textual flow description for LLM analysis. The description includes the window identifier, time range, number of flows, destination diversity, port distribution, protocol and service distributions, connection states, byte and packet totals, and the majority label information used only as contextual support during LLM reasoning. The LLM prompts are explicitly instructed not to blindly follow dataset labels and to base the decision on visible behavioral evidence.
E. Machine Learning Baselines
To provide quantitative reference performance, several base-line models are trained on the aggregated window-level repre-sentation. The baselines include Logistic Regression, Random Forest, Gradient Boosting, XGBoost, and a Multilayer Percep-tron (MLP). These models are trained using only non-leakage network-derived features. The purpose of these baselines is to measure how well conventional classifiers can separate the behavior classes when provided with structured window-level statistics.
The ML baseline path is used mainly as a performance reference. While these models can achieve high classification accuracy, their outputs do not directly provide the same type of natural-language evidence, uncertainty assessment, and cor-rected explanation produced by the multi-agent LLM pipeline.
F. Multi-Agent LLM Architecture
The internal structure of the LLM reasoning pipeline is shown in Figure 2. The architecture separates evidence extrac-tion, threat classification, and decision validation into three agent roles.
This separation is intended to reduce unsupported claims and make the reasoning process easier to inspect. The analyst agent focuses on what is happening in the window, the classifier agent decides which behavior class is best supported, and the judge agent checks whether the decision is consistent with the available evidence.
The Behavior Analyst Agent receives the structured flow-window description and produces a security-oriented behavior summary. It identifies suspicious indicators, benign indicators, and uncertainties, but it is instructed not to produce the final class label. This separation encourages evidence extraction before classification.
The Threat Classifier Agent receives both the original flow-window description and the Behavior Analyst output. It predicts the behavior class and provides a confidence score, supporting evidence, an alternative label, and the reason for the alternative. For Capture 1, the classifier distinguishes between Benign and Scanning. For Capture 34, it distinguishes among Benign, C&C, and DDoS.
The Judge/Orchestrator Agent reviews the flow-window description and the outputs of the previous agents. Its role is to verify whether the predicted label is supported by the evidence, identify unsupported or overstated claims, correct confidence-scale issues, and generate the final decision. The judge also receives Zeek-specific guidance, including the fact that orig_bytes and resp_bytes may refer to application-layer bytes rather than total packet bytes. This prevents unsupported claims such as saying that no traffic was sent when packets were observed but application-layer bytes were zero.
G. Prompt Design
Prompt design is a central component of the proposed methodology. The prompts are structured to provide enough behavioral context for security reasoning without exposing the LLM to raw tables or long logs. Each prompt includes a con-cise flow-window summary and task-specific instructions. The analyst prompt focuses on evidence extraction, the classifier prompt focuses on label selection with supporting evidence, and the judge prompt focuses on verification and correction.
The prompt design was refined through experimentation. A key observation was that prompt refinement should be agent-specific. Fully refining all agents made the judge overly conservative toward C&C behavior. The best configuration used a refined analyst and classifier prompt together with a balanced judge prompt. This configuration improved classi-fication performance while preserving the judge’s ability to validate rather than overcorrect the classifier.
H. Evaluation Metrics
For the ML baselines, standard classification metrics are used, including accuracy, precision, recall, F1-score, and con-fusion matrices. For the LLM pipeline, two performance levels are measured: the accuracy of the Threat Classifier Agent and the accuracy of the final Judge/Orchestrator decision. In addition, the generated explanations are inspected for evidence relevance, unsupported claims, corrected explanations, and hallucination risk.
This dual evaluation allows the study to assess both predic-tive performance and explanation quality. The goal is not only to determine whether a model predicts the correct label, but also whether it provides defensible reasoning that can support human security analysis.
For the Judge/Orchestrator Agent, two accuracy values are distinguished when needed. The first is the valid-output judge accuracy, which is computed only over outputs that are successfully parsed into the required JSON structure. The second is the strict end-to-end judge accuracy, which counts invalid or malformed JSON outputs as incorrect automated predictions. This distinction is important because one Capture 34 DDoS case produced the correct raw label but invalid JSON formatting.
IV. Experimental Setup
This section describes the experimental configuration used to evaluate the proposed framework. The experiments are designed to compare conventional machine learning baselines with the proposed multi-agent LLM reasoning pipeline on IoT botnet behavior detection tasks. The evaluation covers two IoT-23 scenarios: a scanning-oriented scenario and a second scenario containing benign, C&C, and DDoS behavior.
A. Dataset Configuration
The experiments use labeled Zeek connection logs from the IoT-23 dataset. Two scenarios are considered. The first sce-nario is CTU-IoT-Malware-Capture-1-1, which con-tains benign traffic and a large number of flows labeled as PartOfAHorizontalPortScan. This scenario is used for the scanning-oriented evaluation. After parsing and cleaning, this capture contains 1,008,748 flow records, including 469,275 benign flows and 539,473 malicious flows. The detailed labels are dominated by PartOfAHorizontalPortScan, with only a very small number of C&C records.
The second scenario is CTU-IoT-Malware-Capture-34-1. This capture is used to evaluate the framework on a broader multi-class behavior task. After preprocessing, it contains 23,145 flow records, including 1,923 benign flows and 21,222 malicious flows. The detailed label distribution includes 14,394 DDoS flows, 6,706 C&C flows, 1,923 benign flows, and 122 PartOfAHorizontalPortScan flows. Since the scanning portion in this capture is small compared with the other behaviors, the multi-class evaluation focuses on three classes: Benign, C&C, and DDoS.
B. Implementation Environment
The experimental pipeline was implemented in Python. Data preprocessing and feature extraction were performed using pandas and numpy. Machine learning baselines were im-plemented using scikit-learn and XGBoost. The eval-uated baseline models include Logistic Regression, Random Forest, Gradient Boosting, XGBoost, and Multilayer Percep-tron (MLP). The LLM experiments were executed through the OpenRouter API using an instruction-tuned chat model.
Deterministic generation was used by setting the temperature to 0.
The implementation was organized into separate scripts for dataset exploration, preprocessing, window construction, ML baseline training, multi-agent LLM execution, and error inspection. This modular organization made it possible to evaluate each stage independently and revise the pipeline after observing intermediate results.
C. Flow-Window Dataset Construction
For both scenarios, the cleaned Zeek records were sorted by source IP address and timestamp. Consecutive flows generated by the same source device were grouped into non-overlapping windows of 10 flows. Each window was summarized using network-derived features such as destination diversity, port diversity, protocol distribution, service distribution, connection state distribution, average duration, total bytes, and total pack-ets.
For Capture 34, the 10-flow windowing process produced 2,314 behavior windows. The resulting behavior distribution was 1,441 DDoS windows, 747 C&C windows, 114 benign windows, and 12 scanning windows. The scanning windows were excluded from the Capture 34 multi-class evaluation because they were not sufficiently represented. Therefore, the final Capture 34 ML dataset contained 2,302 windows from three classes: Benign, C&C, and DDoS.
D. Machine Learning Baseline Experiment
The ML baseline experiment was conducted on the Capture 34 aggregated window-level representation. Each window was represented using only network-derived features. To avoid data leakage, label-derived fields such as label, detailed_label, majority_label, majority_detailed_label, label_distribution, and detailed_label_distribution were excluded from the input features.
The final no-leakage feature set contained 41 features, including destination and port diversity, byte and packet totals, connection-state counts, protocol and service distributions, and port/service indicators such as ports 53, 80, 123, and 6667. The dataset was split into training and testing sets using a 70/30 stratified split. This produced 1,611 training windows and 691 testing windows. The test set contained 34 benign windows, 224 C&C windows, and 433 DDoS windows.
The following baseline models were trained and evaluated:
- Logistic Regression
- Random Forest
- Gradient Boosting
- XGBoost
- Multilayer Perceptron (MLP)
These models provide a quantitative reference for how well conventional classifiers can separate the behavior classes using structured network-window features.
E. Multi-Agent LLM Experiment
The LLM experiment evaluates the proposed multi-agent reasoning pipeline on behavior-window prompts. Each se-lected window is converted into a structured natural-language description containing its key behavioral features, including the number of flows, destination and port diversity, top des-tination ports, protocol and service distributions, connection states, byte counts, packet counts, and timing information.
For Capture 1, the LLM pipeline was evaluated on a behavior-rule-based subset for the binary task of Benign versus Scanning. This subset was designed to align labels with visible behavioral evidence in the prompt and to reduce ambiguity caused by mixed or weakly supported windows.
For Capture 34, the LLM pipeline was evaluated on a balanced three-class subset consisting of 114 benign windows, 114 C&C windows, and 114 DDoS windows, for a total of 342 windows. This balanced subset was selected because benign windows were the smallest class after window construction.
The multi-agent LLM pipeline consists of three agents:
- Behavior Analyst Agent: extracts suspicious indicators, benign indicators, and uncertainty from the flow-window description.
- Threat Classifier Agent: predicts the behavior class and provides supporting evidence, confidence, an alternative label, and a reason for the alternative.
- Judge/Orchestrator Agent: validates the classifier out-put, checks whether the evidence supports the decision, identifies unsupported or overstated claims, and produces the final label.
Several prompt configurations were evaluated. The original configuration used general prompts for all agents. A fully refined configuration improved classifier behavior but made the judge overly conservative toward C&C cases. The final configuration used a refined analyst and classifier prompt together with a balanced judge prompt. This configuration was selected because it achieved the best overall performance while preserving the judge’s validation role.
F. Evaluation Metrics
The ML baselines are evaluated using accuracy, preci-sion, recall, F1-score, and confusion matrices. For the LLM framework, two levels of accuracy are reported: the accu-racy of the Threat Classifier Agent and the accuracy of the final Judge/Orchestrator decision. In addition, the generated explanations are inspected qualitatively based on evidence relevance, unsupported or overstated claims, corrected expla-nations, and hallucination risk.
This evaluation design allows the study to compare conven-tional predictive performance with the additional interpretabil-ity provided by the multi-agent LLM pipeline.
V. Results and Analysis
This section presents the experimental results obtained from the proposed framework. The analysis focuses on three main aspects: the distribution of the constructed behavior windows, the performance of conventional no-leakage ML baselines on the Capture 34 scenario, and the performance of the multi-agent LLM pipeline under different prompt configurations. The results are reported with emphasis on both predictive performance and interpretability.
A. Flow-Window Distribution
The first scenario, CTU-IoT-Malware-Capture-1-1, is dominated by scanning-related behavior. After preprocess-ing, this capture contained 1,008,748 flow records, including 469,275 benign flows and 539,473 malicious flows. The de-tailed labels were dominated by PartOfAHorizontalPortScan, with only a very small number of C&C records. Therefore, this scenario was used mainly for scanning-oriented behavior evaluation.
The second scenario, CTU-IoT-Malware-Capture-34-1, provided a more diverse behavior distribution. After preprocessing, this capture contained 23,145 flow records.
The detailed label distribution included 14,394 DDoS flows, 6,706 C&C flows, 1,923 benign flows, and 122 PartOfAHorizontalPortScan flows. After grouping the traffic into non-overlapping 10-flow windows, Capture 34 produced 2,314 behavior windows. Table I summarizes the resulting window-level distribution.
Because the scanning class in Capture 34 contained only 12 windows, it was excluded from the three-class Capture 34 evaluation. The final Capture 34 task therefore focused on Benign, C&C, and DDoS. This produced 2,302 windows for ML baseline evaluation. For the LLM evaluation, a balanced subset of 342 windows was constructed by selecting 114 windows from each class.
B. No-Leakage ML Baseline Results
The ML baselines were evaluated on the Capture 34 ag-gregated window representation. Unlike the initial exploratory baseline, the final ML experiment excluded all label-derived features to avoid data leakage. The input feature set contained 41 network-derived features, including destination diversity, port diversity, byte and packet totals, connection-state counts, protocol and service distributions, and port/service indicators such as ports 53, 80, 123, and 6667.
The dataset was split using a 70/30 stratified train-test split. The training set contained 1,611 windows, and the test set contained 691 windows. The test set included 34 benign windows, 224 C&C windows, and 433 DDoS windows. Table IIsummarizes the final no-leakage ML baseline results.
The no-leakage ML results show that the Capture 34 behav-ior classes are highly separable using structured window-level network features. XGBoost and Random Forest achieved the highest accuracy, both reaching 99.42%. Logistic Regression also performed strongly, which indicates that several behavior classes are separable using relatively direct feature relation-ships. The MLP achieved lower macro recall, mainly because it was less effective on the minority benign class.
These results demonstrate that conventional ML models remain highly effective when sufficient structured features are available. However, their outputs are primarily predictive and do not directly provide analyst-readable behavioral expla-nations. This motivates the use of the LLM pipeline as an explanatory and evidence-validation layer rather than only as a replacement for conventional classifiers.
C. Multi-Agent LLM Results on Capture 34
The multi-agent LLM pipeline was evaluated on a balanced Capture 34 subset containing 114 benign windows, 114 C&C windows, and 114 DDoS windows. The task was formulated as a three-class behavior classification problem. Each window was converted into a structured textual description and pro-cessed by three agents: the Behavior Analyst Agent, the Threat Classifier Agent, and the Judge/Orchestrator Agent.
Three prompt configurations were evaluated. The first con-figuration used the original prompts. The second configuration used fully refined prompts for all agents. The third config-uration used a refined analyst and classifier prompt with a balanced judge prompt.
The reported judge accuracy in Table III is computed over valid parsed outputs. For the best configuration, one DDoS window produced an invalid JSON response. Counting this invalid response as an automated failure gives a strict end-to-end judge accuracy of 0.9737.
The original prompt configuration achieved strong perfor-mance, with 92.69% classifier accuracy and 91.81% judge accuracy. After prompt refinement, the classifier accuracy improved to 95.60%. However, applying the refined prompting strategy to all agents caused the judge accuracy to drop to 67.16%. Error inspection showed that the fully refined judge became overly conservative toward C&C behavior and revised many true C&C windows to benign.
The best configuration was obtained by using a refined Behavior Analyst Agent and Threat Classifier Agent together with a balanced Judge/Orchestrator Agent. This configura-tion achieved 98.24% classifier accuracy and 97.65% judge accuracy over valid parsed outputs. When the invalid JSON response is counted as an incorrect automated output, the strict end-to-end judge accuracy is 97.37%. This result shows that prompt refinement should be agent-specific. A prompt that improves the classifier may not necessarily improve the judge, because the judge has a different role: it should verify and correct unsupported claims without overcorrecting valid threat classifications.
D. Final LLM Confusion Analysis
Table IV shows the confusion matrix of the Threat Classifier Agent under the best LLM configuration.
The classifier correctly identified all DDoS windows and most C&C and benign windows. The remaining classifier errors consisted of four benign windows classified as DDoS and two C&C windows classified as benign. The benign-to-DDoS errors were mainly associated with high-volume one-way traffic, repeated S0 connection states, and no response packets. Although these windows were labeled benign, their visible behavior was similar to flooding-like activity.
Table V shows the confusion matrix of the Judge/Orchestrator Agent under the same configuration.
The judge achieved strong performance overall, but it in-troduced a small number of additional errors. Five benign windows were classified as DDoS, and three C&C windows were classified as benign. One DDoS case produced an invalid JSON output that could not be parsed, although the raw model response indicated the correct DDoS label. Based on the confusion matrix, the judge produced 333 correct automated decisions out of 342 total windows, resulting in a strict end-to-end accuracy of 97.37%. If the invalid JSON case is excluded and only valid parsed outputs are considered, the judge accuracy is 97.65%. This distinction highlights the importance of output validation when LLMs are integrated into automated detection pipelines.
E. Comparison Between ML and LLM Results
Table VI compares the best conventional ML results with the best multi-agent LLM results on the Capture 34 task.
The valid judge accuracy excludes the malformed JSON response, while the end-to-end judge accuracy counts it as an incorrect automated output.
The ML baselines achieved slightly higher accuracy than the LLM pipeline. This is expected because the ML models were trained directly on structured numerical features and evaluated on the same representation type. The LLM pipeline, how-ever, provides additional value by generating natural-language explanations, identifying suspicious and benign indicators, reporting uncertainty, and allowing judge-based validation of the reasoning process. Therefore, the results do not suggest that LLMs should replace conventional ML classifiers. Instead, they suggest that multi-agent LLM reasoning can complement ML-based intrusion detection by improving interpretability and analyst support.
Figure 3 visualizes the performance comparison between the no-leakage ML baselines and the multi-agent LLM pipeline on the Capture 34 three-class behavior task. The figure uses strict end-to-end judge accuracy for the LLM Judge/Orchestrator Agent, where the invalid JSON response is counted as an incorrect automated output.
As shown in Figure 3, XGBoost and Random Forest achieved the highest accuracy among the evaluated models. The LLM Threat Classifier achieved competitive performance compared with the ML baselines, while the Judge/Orchestrator Agent achieved slightly lower strict end-to-end accuracy due to the invalid JSON output being counted as an automated failure. This reinforces the practical role of the LLM pipeline as an explanation and validation layer rather than a replacement for efficient ML classifiers.
F. Qualitative Error Analysis
The final error inspection showed that the remaining LLM errors were concentrated in behaviorally ambiguous cases. The most common error type was benign windows classified as DDoS. These windows often showed high packet counts, one-way traffic, repeated S0 connection states, and no re-sponse packets. For example, several benign-labeled windows involved TCP traffic to port 53 with thousands of outbound packets and no responses. Although the dataset labeled these windows as benign, the observed behavior resembled flooding or probing activity. Therefore, these errors reveal a possible mismatch between dataset labels and visible network evidence. The second error type involved C&C windows classified as benign. These windows typically contained low traffic volume, some bidirectional communication, and a mixture of port 6667 and port 123 activity. Because port 123 is associated with NTP and some windows contained only limited IRC-like evidence, the judge sometimes revised the classifier decision from C&C to benign. These cases show that low-volume C&C communication can be difficult to distinguish from benign communication when only short windows and flow-level summaries are available.
The error analysis also identified one practical formatting issue. In one DDoS case, the judge generated a response that contained the correct final label but included invalid JSON syntax in one field. As a result, the output was counted as an invalid prediction by the parser. This highlights the need for robust JSON validation and retry mechanisms when LLM outputs are used in automated pipelines.
VI. Discussion
The results show that structured ML models and multi-agent LLM reasoning address different needs in IoT botnet behavior detection. Conventional ML models provide highly accurate and scalable classification from network-window fea-tures, while the LLM pipeline provides analyst-readable ex-planations, uncertainty notes, and evidence validation. There-fore, the proposed framework is best interpreted as a hybrid detection-and-explanation approach rather than an attempt to replace ML classifiers with LLMs.
A. ML Performance and Structured Window Features
The no-leakage ML baselines achieved the strongest pre-dictive performance on the Capture 34 three-class task. This indicates that the behavior classes are highly separable using structured network-window indicators such as port usage, service distribution, connection states, packet counts, and des-tination concentration. The strong results after removing label-derived features also confirm that the baseline comparison is not driven by data leakage.
However, high predictive accuracy alone does not provide a complete operational explanation. Conventional ML models can identify the most likely class, but they do not naturally explain the behavioral evidence behind the decision in analyst-readable terms. This motivates the use of the multi-agent LLM pipeline as an explanation and validation layer rather than as a replacement for ML-based detection.
B. Value of Multi-Agent LLM Reasoning
The best multi-agent LLM configuration achieved 98.24% classifier accuracy, 97.65% judge accuracy over valid parsed outputs, and 97.37% strict end-to-end judge accuracy when the invalid JSON response was counted as an automated failure. Although these results are slightly lower than the strongest ML baselines, the LLM pipeline provides additional interpretabil-ity. The Behavior Analyst Agent summarizes the window behavior, the Threat Classifier Agent identifies the most likely class with supporting evidence, and the Judge/Orchestrator Agent checks whether the classification is supported by the observed flow evidence.
This type of reasoning is useful for security analysts because it connects the prediction to observable indicators, such as high packet counts, one-way traffic, repeated S0 states, IRC communication, or concentration on a single destination port. The LLM output also includes uncertainty and alternative labels, which can help analysts identify cases that require manual review. Therefore, the main value of the LLM compo-nent is not only classification accuracy, but also explanation, verification, and analyst support.
C. Prompt Refinement and Agent-Specific Behavior
A key finding is that prompt refinement must be agent-specific. The fully refined prompt configuration improved the Threat Classifier Agent but significantly reduced the Judge/Orchestrator Agent accuracy. Error inspection showed that the fully refined judge became overly conservative toward C&C behavior and revised many true C&C cases to benign. In contrast, the best configuration used a refined analyst and classifier with a balanced judge prompt.
This result is important because it shows that each LLM agent has a different function. The classifier should be guided toward discriminative decision-making, while the judge should verify evidence without overcorrecting valid threat classifica-tions. Applying the same refinement logic to all agents can create new biases. Therefore, multi-agent LLM systems should be evaluated at the agent level rather than only as a single end-to-end pipeline.
D. Error Patterns and Label–Behavior Tension
The final error analysis showed that most remaining LLM errors occurred in ambiguous cases. The most common error type was benign windows classified as DDoS. These win-dows often contained high-volume one-way traffic, repeated S0 states, no response packets, and traffic toward port 53. Although the dataset labeled these windows as benign, their visible behavior resembled flooding or probing activity. In these cases, the LLM decision was behaviorally reasonable even when it disagreed with the dataset label.
Another error type involved C&C windows classified as benign. These windows typically contained low traffic volume, some bidirectional communication, and a mixture of port 6667 and port 123 traffic. Since port 123 is commonly associated with NTP, the judge sometimes interpreted these windows as benign when IRC-like evidence was limited. These cases high-light the difficulty of identifying low-volume C&C behavior from short flow windows.
These observations suggest that behavior-window evaluation is sensitive to how labels align with visible evidence. A dataset label may describe the broader scenario, while a short 10-flow window may contain only partial or ambiguous evidence of that behavior. This is particularly important for LLM-based evaluation, because the model reasons only over the information included in the prompt.
E. Practical Implications
The results suggest a practical hybrid IDS design. Con-ventional ML models can be used for efficient large-scale classification of structured flow-window features, while the multi-agent LLM pipeline can be applied to selected windows for explanation, evidence validation, and analyst support. This hybrid design is more realistic than relying on LLMs alone for high-volume traffic processing.
In a security operations setting, the LLM pipeline could help explain why a device is suspected of C&C or DDoS behavior, identify which indicators support the decision, and highlight uncertainty when the evidence is incomplete. The judge component can also reduce unsupported reasoning by checking whether the explanation is grounded in the flow-window evidence. However, the invalid JSON case observed in the final experiment shows that output validation and retry mechanisms are necessary before using LLM outputs in fully automated workflows.
Figure 4 summarizes the practical trade-off between the two representation paths. Structured ML models provide fast and accurate classification, while the multi-agent LLM path pro-vides analyst-readable reasoning and validation.
F. Summary
Overall, the findings show that structured ML models provide the strongest predictive performance, while multi-agent LLM reasoning adds interpretability and evidence-based validation. The proposed framework is therefore most useful as a combined approach: ML models provide scalable detec-tion, and LLM agents provide human-readable reasoning for investigation and decision support. The results also show that prompt design is not a one-time task; it must be evaluated carefully for each agent role and each behavior type.
VII. Limitations
Although the proposed framework demonstrates strong re-sults, several limitations should be acknowledged. First, the evaluation is still limited to two scenarios from the IoT-23 dataset. These scenarios cover scanning, C&C, and DDoS behavior, but they do not represent all possible IoT botnet behaviors, malware families, device types, or deployment environments. Therefore, additional datasets and captures are required before generalizing the findings to broader real-world IoT networks.
Second, the LLM evaluation was performed on a balanced subset of 342 Capture 34 behavior windows. This design en-abled controlled comparison among Benign, C&C, and DDoS classes, but it does not fully reflect the original class imbalance of the dataset. In the full Capture 34 window distribution, DDoS and C&C windows are much more frequent than benign windows. Future work should evaluate the framework under both balanced and naturally imbalanced conditions.
Third, the framework uses fixed-size non-overlapping win-dows of 10 flows. This choice provides a consistent repre-sentation for ML and LLM experiments, but different botnet behaviors may require different temporal contexts. Slow or stealthy C&C communication may require longer windows, while short flooding behavior may be captured in smaller windows. Sliding windows or adaptive window sizes may provide a more complete view of device behavior.
Fourth, the LLM pipeline is sensitive to prompt design. The experiments showed that fully refining all agents improved the classifier but reduced judge accuracy because the judge became overly conservative toward C&C cases. This indicates that prompt refinement must be evaluated separately for each agent role. The LLM component also introduces additional latency, cost, and output-formatting risks compared with con-ventional ML models. One final DDoS case produced a correct raw label but invalid JSON formatting, showing the need for stronger validation and retry mechanisms.
Finally, explanation quality was assessed through qualitative error inspection rather than a formal user study with security analysts. Although the generated explanations were useful for identifying evidence, uncertainty, and label-behavior conflicts, future work should evaluate whether such explanations im-prove analyst decision-making in realistic SOC workflows.
VIII. Future Work
Future work should extend the evaluation to additional IoT-23 scenarios and other IoT intrusion detection datasets, such as Bot-IoT, N-BaIoT, and CICIoT2023. Although the current study evaluates scanning, C&C, and DDoS behavior, additional datasets are needed to assess generalization across different IoT devices, malware families, traffic conditions, and attack stages. Cross-scenario and cross-dataset evaluation would help determine whether the proposed flow-window representation remains effective under different network en-vironments.
Another important direction is to investigate adaptive behavior-window construction. The current framework uses fixed-size non-overlapping windows of 10 flows. Future work should compare different window sizes, sliding windows, and time-based windows to determine how much temporal context is needed for different botnet behaviors. Short windows may be suitable for rapid DDoS-like activity, while longer windows may be more effective for low-volume or stealthy C&C communication. Adaptive windowing methods could also be explored to adjust the window size according to traffic density and behavioral changes.
Future work should also evaluate stronger sequence-based and hybrid detection models. While the current no-leakage ML baselines achieved high performance on structured window features, sequence-aware models may provide additional value for behaviors that depend on flow order. Possible extensions include GRU, bidirectional LSTM, temporal convolutional net-works, attention-based models, and lightweight Transformer architectures. These models could be compared against aggregated window features to determine when preserving flow order improves detection.
The multi-agent LLM framework should be expanded be-yond static prompting. Future work should evaluate addi-tional LLMs, different agent-role configurations, and retrieval-augmented reasoning using trusted cybersecurity knowledge sources such as Zeek field semantics, IoT botnet behavior descriptions, and MITRE ATT&CK techniques. More robust output validation, JSON repair, and retry mechanisms should also be integrated to reduce formatting failures in automated pipelines.
A promising research direction is the development of a hybrid human-in-the-loop IDS. In such a system, conventional ML or sequence-based models would perform scalable detec-tion, while the multi-agent LLM pipeline would be applied se-lectively to suspicious or ambiguous windows for explanation, uncertainty assessment, and analyst support. Analyst feedback could then be used to refine labels, update prompts, or support active learning.
Finally, deployment-oriented trust mechanisms could be investigated as a separate extension. Blockchain or distributed ledger technologies may be useful for preserving tamper-resistant alert histories, recording LLM-generated explana-tions, and sharing verified indicators across distributed IoT monitoring domains. However, such mechanisms should be treated as an auditability and collaboration layer rather than a replacement for detection or explanation. A future doctoral-level extension could therefore combine adaptive ML/DL detection, multi-agent LLM explanation, and trusted decentral-ized alert sharing into a collaborative explainable IoT security framework.
IX. Conclusion
This study presented a network flow-window framework for IoT botnet behavior detection and explanation using con-ventional machine learning baselines and multi-agent LLM reasoning. The proposed approach aggregates Zeek connection logs into fixed-size behavior windows and analyzes them using both structured numerical features and textual flow-window descriptions. The framework was evaluated on two IoT-23 scenarios covering scanning, C&C, and DDoS behavior.
The experimental results show that conventional ML models remain highly effective for structured IoT botnet detection. On the Capture 34 three-class task, no-leakage ML baselines achieved strong performance, with XGBoost and Random For-est reaching 99.42% accuracy using only network-derived win-dow features. These results confirm that port usage, connection states, service distributions, packet counts, and destination concentration provide strong indicators for separating benign, C&C, and DDoS behavior.
The multi-agent LLM pipeline also achieved strong per-formance while providing additional interpretability. The best configuration, consisting of a refined Behavior Analyst Agent, a refined Threat Classifier Agent, and a balanced Judge/Orchestrator Agent, achieved 98.24% classifier accuracy and 97.65% judge accuracy over valid parsed outputs on a balanced 342-window Capture 34 evaluation set. When the invalid JSON response is counted as an automated failure, the strict end-to-end judge accuracy is 97.37%. The results showed that LLM-based reasoning can produce analyst-readable sum-maries, supporting evidence, uncertainty notes, and corrected explanations that are not directly provided by conventional classifiers.
A key finding is that prompt refinement must be agent-specific. Fully refining all agents improved the classifier but substantially reduced judge accuracy because the judge be-came overly conservative toward C&C behavior. In contrast, combining a refined analyst and classifier with a balanced judge produced the best overall results. This highlights the importance of evaluating each LLM agent according to its role rather than treating the multi-agent pipeline as a single prompt.
The final error analysis showed that most remaining LLM errors occurred in ambiguous windows, especially benign-labeled windows with high-volume one-way traffic and re-peated S0 states, and low-volume C&C windows mixed with benign-looking NTP traffic. These cases suggest that some disagreements between the LLM and the dataset label reflect label–behavior tension rather than simple model failure.
Overall, the results indicate that conventional ML models are highly suitable for scalable classification, while multi-agent LLM reasoning can complement them by providing evidence-based explanations and validation. A practical IoT security system could therefore combine ML-based detection with selective LLM-based analysis for alert interpretation, uncertainty assessment, and analyst support.
References
- Krebs. “Source code for IoT botnet ‘Mirai’ released,” KrebsOnSe-curity. 2016. Available online: https://krebsonsecurity.com/2016/10/.
- Antonakakis, M.; April, T.; Bailey, M.; Bernhard, M.; Bursztein, E.; Cochran, J.; Durumeric, Z.; Halderman, J. A.; Invernizzi, L.; Kallitsis, M. [CrossRef] [PubMed]
- Kumar, D.; Lever, C.; Ma, Z.; Mason, J.; Menscher, D.; Seaman, C.; Sullivan, N.; Thomas, K.; Zhou, Y. Understanding the Mirai botnet. Proc. 26th USENIX Security Symposium, 2017; pp. 1093–1110. [Google Scholar]
- Xu; Wang, S.; Li, N.; Wang, K.; Zhao, Y.; Chen, K.; Yu, T.; Liu, Y.; Wang, H. Large language models for cyber security: A systematic literature review. arXiv 2024, arXiv:2405.04760. [Google Scholar]
- Yao, Y.; Duan, J.; Xu, K.; Cai, Y.; Sun, Z.; Zhang, Y. A survey on large language model security and privacy: The good, the bad, and the ugly. ACM Comput. Surv. 2024, vol. 57(no. 2), 1–39. [Google Scholar]
- Li; Dong, Q.; Chen, J.; Su, H.; Zhou, Y.; Ai, Q.; Ye, Z.; Liu, Y. LLMs-as-judges: A comprehensive survey on LLM-based evaluation methods. arXiv 2024, arXiv:2412.05579. [Google Scholar]
- Stratosphere IPS, “IoT-23: A labeled dataset of malware and benign IoT traffic,” 2020. Available online: https://www.stratosphereips.org/.
- Garcia, S.; Parmisano, A.; Erquiaga, M. J. “IoT-23: A labeled dataset with malicious and benign IoT network traffic,” Stratosphere Laboratory, CTU University. 2020. Available online: https://mcfp.felk.cvut.cz/.
- Ferrag, M. A.; Friha, O.; Maglaras, L.; Janicke, H.; Shu, L. Advancing IoT security: A systematic review of machine learning and deep learning techniques for IoT botnet detection. Alex. Eng. J. 2023, vol. 75, 181–199. [Google Scholar]
- Verma; Ranga, V. IoT botnet detection: A comparative perfor-mance analysis of various machine learning models on IoT-23 dataset. Indian J. Sci. Technol. 2022, vol. 15(no. 17), 806–815. [Google Scholar]
- Warnecke; Arp, D.; Wressnegger, C.; Rieck, K. Evaluating explanation methods for deep learning in security. Proc. IEEE European Symposium on Security and Privacy (EuroS&P), 2020; pp. 158–174. [Google Scholar]
- Lundberg, S. M.; Lee, S.-I. A unified approach to interpreting model predictions. Proc. Advances in Neural Information Processing Systems (NeurIPS), 2017; pp. 4765–4774. [Google Scholar]
- Ribeiro, M. T.; Singh, S.; Guestrin, C. Why should I trust you? Explaining the predictions of any classifier. Proc. 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, 2016; pp. 1135–1144. [Google Scholar]
- Paxson. Bro: A system for detecting network intruders in real-time. Comput. Netw. 1999, vol. 31(no. 23–24), 2435–2463. [Google Scholar] [CrossRef]
Figure 1.
Overall architecture of the proposed framework.

Figure 2.
Multi-agent LLM architecture for behavior-level detection and explanation.

Figure 3.
Performance comparison between ML baselines and multi-agent LLM agents.

Figure 4.
Comparison between structured ML classification and multi-agent LLM reasoning.

![]() |
Table II.
No-leakage ml baseline results on capture 34.
| Model | Accuracy | Macro Prec. | Macro Rec. | Macro F1 |
|---|---|---|---|---|
| XGBoost | 0.9942 | 0.9865 | 0.9879 | 0.9872 |
| Random Forest | 0.9942 | 0.9797 | 0.9889 | 0.9842 |
| Gradient Boosting | 0.9928 | 0.9865 | 0.9699 | 0.9776 |
| Logistic Regression | 0.9913 | 0.9745 | 0.9778 | 0.9761 |
| MLP | 0.9682 | 0.9591 | 0.8734 | 0.9055 |
Table III.
LLM prompt configuration results on Capture 34.
|
Prompt configuration Original prompts |
Classifier Acc. 0.9269 |
Judge Acc. (valid) 0.9181 |
|---|---|---|
| Fully refined prompts | 0.9560 | 0.6716 |
Refined classifier + balanced judge 0.9824 0.9765.
Table IV.
Final LLM classifier confusion matrix on Capture 34.
| True label | Predicted Benign | Predicted C&C | Predicted DDoS |
|---|---|---|---|
| Benign | 110 | 0 | 4 |
| C&C | 2 | 112 | 0 |
| DDoS | 0 | 0 | 114 |
Table V.
Final LLM judge confusion matrix on Capture 34.
|
True label Benign |
Benign C&C 109 0 |
DDoS 5 |
Invalid 0 |
|---|---|---|---|
| C&C | 3 111 | 0 | 0 |
| DDoS | 0 0 | 113 | 1 |
Table VI.
Comparison of ML baselines and multi-agent LLM results on Capture 34.
| Method | Accuracy |
|---|---|
| XGBoost | 0.9942 |
| Random Forest | 0.9942 |
| Gradient Boosting | 0.9928 |
| Logistic Regression | 0.9913 |
| MLP | 0.9682 |
| LLM Threat Classifier | 0.9824 |
| LLM Judge/Orchestrator (valid) | 0.9765 |
LLM Judge/Orchestrator (end-to-end) 0.9737.
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Copyright: This open access article is published under a Creative Commons CC BY 4.0 license, which permit the free download, distribution, and reuse, provided that the author and preprint are cited in any reuse.
