arXiv:2604.21623v1 [cs.CR] 23 Apr 2026
A-THENA: Early Intrusion Detection for IoT with Time-Aware Hybrid Encoding and Network-Specific Augmentation IOANNIS PANOPOULOS, National Technical University of Athens, Greece MARIA LAMPRINI A. BARTSIOKA, National Technical University of Athens, Greece SOKRATIS NIKOLAIDIS, National Technical University of Athens, Greece STYLIANOS I. VENIERIS, Samsung AI Center, UK DIMITRA I. KAKLAMANI, National Technical University of Athens, Greece IAKOVOS S. VENIERIS, National Technical University of Athens, Greece The proliferation of Internet of Things (IoT) devices has significantly expanded attack surfaces, making IoT ecosystems particularly susceptible to sophisticated cyber threats. To address this challenge, this work introduces A-THENA, a lightweight early intrusion detection system (EIDS) that significantly extends preliminary findings on time-aware encodings. A-THENA employs an advanced Transformer-based architecture augmented with a generalized Time-Aware Hybrid Encoding (THE), integrating packet timestamps to effectively capture temporal dynamics essential for accurate and early threat detection. The proposed system further employs a Network-Specific Augmentation (NA) pipeline, which enhances model robustness and generalization. We evaluate A-THENA on three benchmark IoT intrusion detection datasets—CICIoT23-WEB, MQTT-IoT-IDS2020, and IoTID20—where it consistently achieves strong performance. Averaged across all three datasets, it improves accuracy by 6.88 percentage points over the best-performing traditional positional encoding, 3.69 points over the strongest feature-based model, 6.17 points over the leading time-aware alternatives, and 5.11 points over related models, while achieving near-zero false alarms and false negatives. To assess real-world feasibility, we deploy A-THENA on the Raspberry Pi Zero 2 W, demonstrating its ability to perform real-time intrusion detection with minimal latency and memory usage. These results establish A-THENA as an agile, practical, and highly effective solution for securing IoT networks. CCS Concepts: • Security and privacy → Intrusion detection systems; Network security; • Computing methodologies → Machine learning; Neural networks. Additional Key Words and Phrases: Early Intrusion Detection, IoT Security, Network Traffic Augmentation, Resource-Constrained Devices, Time-Aware Positional Encoding, Transformer
1
INTRODUCTION
The Internet of Things (IoT) has transformed digital environments by enabling smart devices to autonomously sense, process, and exchange data in real time across diverse domains such as healthcare, smart homes, and industrial Authors’ Contact Information: Ioannis Panopoulos, [email protected], National Technical University of Athens, Athens, Greece; Maria Lamprini A. Bartsioka, [email protected], National Technical University of Athens, Athens, Greece; Sokratis Nikolaidis, [email protected]. gr, National Technical University of Athens, Athens, Greece; Stylianos I. Venieris, [email protected], Samsung AI Center, Cambridge, UK; Dimitra I. Kaklamani, [email protected], National Technical University of Athens, Athens, Greece; Iakovos S. Venieris, [email protected], National Technical University of Athens, Athens, Greece. Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than the author(s) must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]. © 2026 Copyright held by the owner/author(s). Publication rights licensed to ACM. Manuscript submitted to ACM Manuscript submitted to ACM
1
2
I. Panopoulos et al.
automation [32]. These devices, built upon embedded systems with networking capabilities, operate under strict resource constraints, including limited processing power, memory, and energy availability. As a result, there is a critical need for compact hardware architectures, lightweight software, and efficient data-processing models to support real-time, reliable operation at the network edge. The widespread adoption of IoT devices has introduced significant security vulnerabilities, largely due to their limited computational resources, weak authentication mechanisms, and frequent exposure to untrusted networks. These vulnerabilities make IoT ecosystems prime targets for cyberattacks, ranging from malware infections and Distributed Denial-of-Service (DDoS) attacks to more sophisticated Man-in-the-Middle (MitM) exploits and adversarial manipulation of data streams. Ensuring the security of IoT systems is therefore critical [50], as security breaches can lead to data leaks, service disruptions, and potential physical harm in safety-critical applications. More broadly, the long-term success of the IoT paradigm hinges on user trust. Consumers, industries, and institutions are unlikely to adopt and integrate IoT technologies at scale unless they are confident in the security and trustworthiness of the underlying infrastructure. To mitigate such security risks, Intrusion Detection Systems (IDS) have been widely adopted. IDS solutions monitor network traffic or host activity to detect malicious behavior and potential intrusions. In recent years, Machine Learning (ML) and, more prominently, Deep Learning (DL), have become integral to the development of IDS solutions, driven by their ability to detect complex attack patterns that traditional rule-based systems fail to recognize. Unlike conventional IDS, which rely on manually crafted signatures or predefined heuristics, ML-based IDS can learn from data, enabling the detection of previously unseen threats and zero-day attacks. Particularly in the context of IoT security, where network traffic is highly dynamic and attacks can evolve rapidly, DL models such as Convolutional Neural Networks (CNNs) [46], Recurrent Neural Networks (RNNs) [67], Transformers [40], and hybrid architectures [55] have been increasingly employed to analyze network flows, uncover anomalies, and improve detection accuracy. These models excel at processing large-scale traffic data, automatically extracting meaningful representations, and generalizing beyond known attack signatures. The shift towards ML-driven IDS marks a significant advancement in cybersecurity, providing adaptive, scalable, and real-time threat detection capabilities essential for protecting modern IoT ecosystems. A key challenge in intrusion detection is the need for real-time recognition to minimize response times and mitigate the impact of attacks. This has led to the emergence of Early Intrusion Detection Systems (EIDS) [38], which aim to classify and detect intrusions as early as possible within a network session. Recent DL research has demonstrated the strong performance of Transformers for sequential data processing, particularly in NLP [52]. However, unlike text, network traffic flows are time series, where packet arrival times convey critical contextual information often overlooked by existing IDS models. To address this limitation, this paper proposes A-THENA, a complete Transformer-based EIDS. By significantly extending our initial exploration of time-aware encodings [51], A-THENA effectively models both sequence structure and temporal dynamics, resulting in superior intrusion detection capabilities. Grounded in these foundational concepts, this study makes the following primary contributions:
• A complete, lightweight end-to-end early intrusion detection system, named A-THENA, which introduces the Time-Aware Hybrid Encoding (THE) mechanism; an adaptive encoding strategy that automatically selects the most suitable time-aware representation for a distinct deployment scenario. • A comprehensive evaluation of A-THENA on three diverse benchmark IoT datasets, going beyond prior evaluations on a single dataset [51] and demonstrating the system’s robustness and generalizability. Manuscript submitted to ACM
A-THENA
3
• An extensive comparative study against traditional positional encodings, feature-based ML algorithms, state-ofthe-art time-aware encodings, and recently proposed early detection architectures, establishing the performance advantages of the proposed approach. • A detailed ablation study that quantifies the performance gains contributed by the system’s core components and assesses the effect of applying quantization. 2
BACKGROUND AND RELATED WORK
Recent advancements in deep learning have significantly improved the capabilities of intrusion detection systems, enabling more accurate and adaptive threat detection. However, challenges remain in achieving efficient and early detection, particularly in resource-constrained environments such as IoT networks. This section reviews deep learningbased IDS, positional encoding mechanisms, and augmentation techniques for cybersecurity, highlighting the gaps that motivate our approach. It also situates the baseline methods evaluated in Section 6 within their conceptual context, enabling the reader to understand how each relates to A-THENA’s design choices. 2.1
ML-Based Network Intrusion Detection
Intrusion detection systems leveraging deep learning have gained significant traction in recent years. The predominant approach in the literature relies on extracted features—whether manually engineered statistical properties or automatically learned representations—that abstract away from raw packet content. A smaller but growing subset of recent work processes raw packet bytes directly as model input, eliminating intermediate feature extraction stages entirely. 2.1.1 Feature-Based Approaches. Feature-based IDS rely on domain expertise to extract statistical properties from network traffic. Traditional approaches employ classical classifiers including Support Vector Machines [2, 9], Random Forests [34, 57], Naive Bayes [9, 57], k-Nearest Neighbors [2, 28], and Decision Trees [28, 57], often as ensembles [9, 34]. Recent work has shifted toward deep learning with Multi-Layer Perceptrons [8, 16, 64], sequence models like LSTMs and GRUs [28], autoencoder ensembles [43], and transformer-based architectures [18]. While these methods achieve high accuracy, they face critical limitations. Feature extraction introduces computational overhead that delays threat response, depends heavily on domain expertise that may miss novel attack patterns [28, 43], and most critically for early detection, requires observing substantial session portions to compute meaningful statistics. This creates inherent tension between statistical confidence and detection earliness, as recent IoT-specific work demonstrates: lightweight feature extraction suitable for resource-constrained devices sacrifices the richness needed for early classification, even with sophisticated architectures [18]. Unlike these feature-engineering-centric approaches, A-THENA processes raw packet bytes directly, eliminating intermediate extraction stages and the associated latency, enabling classification from the earliest packets of a flow without waiting for sufficient data to compute statistical summaries. 2.1.2 Raw Traffic Processing. To address the limitations of feature-based representations, recent research has increasingly focused on directly processing raw network traffic, enabling deep models to autonomously learn discriminative representations without relying on domain-specific feature engineering. These approaches employ various deep learning architectures—ranging from CNNs and RNNs to Transformer-based and hybrid models—and can be broadly divided according to their analytical granularity. Flow-level or session-level models process entire sequences of packets as unified entities, capturing long-range dependencies and temporal correlations within complete communication Manuscript submitted to ACM
4
I. Panopoulos et al.
sessions [19, 58, 69, 70, 74, 78]. In contrast, packet-level models operate on individual packets or short, fixed-size windows [14, 49, 73], focusing on local byte patterns and short-term statistical cues. While packet-level models often achieve fine-grained inspection and reduced latency, they may overlook contextual dependencies that span multiple packets, limiting their ability to identify stealthy or evolving threats. Flow-level approaches, by aggregating packets into temporally coherent sequences, capture richer behavioral patterns and enable early yet informed classification decisions—striking a balance between granularity and temporal context. For these reasons, this work adopts a flow-based perspective, emphasizing the analysis of packet sequences to exploit both temporal structure and content dynamics within network flows. 2.1.3 Models for Early Intrusion Detection. EIDS aim to identify malicious behavior early within a network session, enabling faster response and mitigation of potential damage [38]. Unlike conventional IDS that rely on full-session analysis, EIDS seek to classify threats based on incomplete traffic observations, a requirement particularly critical in IoT environments where delayed detection can result in device compromise or large-scale propagation. The fundamental challenge lies in balancing accuracy and earliness: decisions made from partial flows accelerate reaction time but may reduce confidence, while waiting for complete flows increases latency and risk. Recent advances in deep learning have introduced diverse strategies for achieving early detection, spanning both feature-based methods and raw traffic models. Methods such as convolutional autoencoders [37], recurrent and attentionbased architectures [13], adversarial learning frameworks [30], and real-time deep architectures [12] have all been employed. Despite their methodological differences, these studies share a common goal: reducing detection latency while maintaining robust performance under incomplete flow information. In parallel, a few studies have explored training models on variable-length network flows to enable classification at different stages of a session, highlighting the potential of adaptive detection mechanisms that incrementally refine their predictions as additional packets are observed. Among these, eRNN [5] and eTransformer [4] apply recurrent and attention-based architectures, respectively, to variable-length raw packet sequences, while eAtt [24] and eGlo [3] introduce lightweight CNN variants for the same task. Although these architectures demonstrate the feasibility of early classification from raw bytes, none incorporate packet timestamps into the encoding or training process, leaving inter-arrival timing information unexploited. Unlike these prior architectures, A-THENA jointly addresses temporal representation, early detection optimization, and resource efficiency—providing a unified framework rather than isolated solutions to each sub-problem. 2.2
Positional Encoding Mechanisms
Unlike recurrent models that inherently capture sequential order, Transformers rely on fully parallelized self-attention without an intrinsic notion of token order. Positional encodings explicitly encode element positions, enabling the model to learn order-dependent representations while maintaining parallelization advantages. In this work, we consider two encoding categories: (a) input positional encodings, which are directly added to the input embeddings before processing, and (b) attention positional encodings, which are applied to the query and key matrices during self-attention computation. Each category serves a distinct purpose in encoding positional information, influencing how the model attends to different parts of the input sequence. 2.2.1 Traditional Positional Encodings. Traditional positional encodings were developed primarily for natural language processing tasks, where tokens appear in discrete, evenly spaced positions within a sequence. These methods assign positional information based on integer indices, providing the Transformer with explicit knowledge of element order. The Manuscript submitted to ACM
A-THENA
5
three most widely adopted approaches—sinusoidal, Fourier-based, and rotary encodings—differ in their mathematical formulations and parameter requirements, yet all have proven effective across various sequence modeling tasks. In addition, several alternative non-time-aware mechanisms have been proposed to encode position through learned representations or structural operations. Sinusoidal Positional Encoding. The sinusoidal positional encoding was introduced in the original Transformer architecture [68] as a method to inject position-dependent information into the model without relying on learned embeddings. These encodings are computed using sine and cosine functions of varying frequencies, ensuring that each position has a unique representation while also allowing the model to generalize to unseen sequence lengths. Given a sequence of length 𝑛, the sinusoidal positional encoding assigns each position 𝑝𝑜𝑠 ∈ {0, 1, . . . , 𝑛−1} a vector of dimension 𝑑 m , where 𝑑 m denotes the hidden dimension of the Transformer model. The encoding is computed using the following formulas: 𝑃𝐸 (𝑝𝑜𝑠, 2𝑖) = sin
!
𝑝𝑜𝑠 2𝑖
10000 𝑑m 𝑃𝐸 (𝑝𝑜𝑠, 2𝑖+1) = cos
!
𝑝𝑜𝑠 2𝑖
10000 𝑑m where 𝑖 = 0, 1, . . . , 𝑑 m /2−1 indexes the sine and cosine components within the encoding dimension. The choice of the base 10,000 ensures a smooth distribution of frequencies across the encoding dimension, allowing the model to capture both fine-grained and long-range positional dependencies while maintaining numerical stability during training. Fourier-Based Positional Encoding. Since the introduction of the sinusoidal encoding, several alternative methods have been proposed to enhance the effectiveness of positional information in Transformers. The Fourier-based positional encoding [35] extends the idea of the sinusoidal encoding by leveraging a more general Fourier feature mapping. Instead of using a fixed base, this encoding is derived from a learnable frequency basis that enables richer and more flexible positional representations. This approach has been shown to improve the generalization of positional information in various applications. The Fourier positional encoding at position 𝑝𝑜𝑠 is given by: 𝑃𝐸 (𝑝𝑜𝑠, 2𝑖) = sin(2𝜋 𝑓𝑖 𝑝𝑜𝑠) 𝑃𝐸 (𝑝𝑜𝑠, 2𝑖+1) = cos(2𝜋 𝑓𝑖 𝑝𝑜𝑠) where 𝑓𝑖 is the learnable frequency parameter associated with the 𝑖-th sine-cosine pair in the encoding. Rotary Positional Encoding. Another widely adopted method for infusing positional information in Transformer architectures is the rotary positional encoding (RoPE) [63]. RoPE introduces position information by applying deterministic rotations directly to the query and key vectors within each attention head. This rotation-based formulation enables the attention mechanism to capture relative positional relationships and supports efficient extrapolation to longer sequences. Let x = (𝑥 0, 𝑥 1, . . . , 𝑥𝑑h −1 ) denote a query or key vector, where 𝑑 h is the head dimensionality. For position 𝑝𝑜𝑠 and index 𝑖, RoPE rotates each consecutive pair of components (𝑥 2𝑖 , 𝑥 2𝑖+1 ) ∈ R2 according to: " # " #" # 𝑥 2𝑖rot cos(𝑝𝑜𝑠 𝜔𝑖 ) − sin(𝑝𝑜𝑠 𝜔𝑖 ) 𝑥 2𝑖 = rot 𝑥 2𝑖+1 sin(𝑝𝑜𝑠 𝜔𝑖 ) cos(𝑝𝑜𝑠 𝜔𝑖 ) 𝑥 2𝑖+1 where the rotation frequencies are given by: 𝜔𝑖 = 10000−2𝑖/𝑑h Manuscript submitted to ACM
6
I. Panopoulos et al. Additional Non-Time-Aware Encodings. Beyond the three encodings above, several other non-time-aware mechanisms
serve as useful baselines. Embedding-based encodings map integer position indices to dense vectors learned during training, providing data-driven positional representations at the cost of additional parameters and potential overfitting in compact models. Convolutional encodings employ one-dimensional convolutional filters over the input sequence to extract local positional dependencies dynamically, offering adaptivity but at higher parameter cost. Global relative encodings, following the frameworks of Shaw et al. [60] and Huang et al. [22], incorporate relative rather than absolute positional information directly into the attention computation by modifying the attention score as: QK⊤ + QE⊤ r A = softmax √ 𝑑h where Er ∈ R𝑁 ×𝑑h is a learnable relative position embedding matrix. While all of these non-time-aware methods have proven effective in NLP and other settings, they share a common limitation when applied to network traffic: they treat packet sequences as uniformly spaced, discarding the inter-arrival timing information that often distinguishes malicious from benign behavior. Unlike these approaches, A-THENA’s time-aware encodings replace discrete indices with continuous timestamps, directly capturing temporal dynamics without introducing additional model parameters. 2.2.2 Time-Aware Positional Encodings. Conventional positional encodings use integer indices 𝑝𝑜𝑠 ∈ {0, 1, . . . , 𝑛−1}, implicitly assuming uniformly sampled sequences where inter-element intervals are constant or negligible. In contrast, network traffic is inherently a non-uniform time series, with inter-packet arrival times carrying valuable temporal cues. Replacing actual timestamps 𝑡𝑝𝑜𝑠 with discrete indices introduces temporal aliasing, constraining the model’s ability to represent timing dynamics. For instance, a brute-force attack with 0.01-second inter-arrival times and benign traffic with 2.0-second intervals receive identical positional vectors under traditional encodings, making them temporally indistinguishable. This information loss prevents the model from leveraging timing irregularities that often characterize malicious behavior. Applications Across Diverse Domains. Recent advances across multiple domains have demonstrated the value of timeaware positional encodings for irregular or continuous temporal data. One natural extension adapts sinusoidal encodings to incorporate timestamp differences Δ𝑡, enabling the model to learn periodic yet time-dependent representations [54, 59]. Similarly, time-aware rotary encodings extend RoPE with phase shifts proportional to elapsed time, showing improvements on irregular time-series forecasting tasks [65]. These approaches validate the core intuition behind A-THENA’s time-aware sinusoidal and rotary mechanisms. An alternative strategy treats time as a continuous variable and learns its embedding directly. Some methods employ linear mappings—notably CTLPE [29], which adopts a purely linear formulation 𝑃𝐸 (𝑝𝑜𝑠, :) = 𝑎 · 𝑡𝑝𝑜𝑠 + 𝑏 (𝑎, 𝑏 ∈ R𝑑m learnable), constituting the minimal-complexity continuous-time representation but potentially lacking the capacity to capture cyclical and bursty temporal structure. Others discover mixed sinusoidal representations that adapt to varying periodicities in the data [11]. By letting the model determine suitable temporal functions, these approaches offer flexible embeddings for irregularly spaced events without imposing predetermined frequency constraints. Hybrid and compositional strategies explicitly fuse multiple temporal signals. For example, ChronoFormer [75], designed for clinical event modeling, employs an additive scheme by summing an absolute sinusoidal timestamp representation with an MLP-based relative inter-arrival mapping: 𝑃𝐸 (𝑝𝑜𝑠, :) = 𝑃𝐸 abs (𝑡𝑝𝑜𝑠 , :) + 𝑃𝐸 rel (Δ𝑡, :), where Δ𝑡 = 𝑡𝑝𝑜𝑠 − 𝑡𝑝𝑜𝑠 −1 . Packet order and timestamp information can also be merged as sin(𝑝𝑜𝑠 + log Δ𝑡) [77]. These methods aim to capture both sequential structure and timing patterns, closely mirroring the motivations behind our hybrid Manuscript submitted to ACM
A-THENA
7
encoding framework. This idea has been further refined through learnable weighting schemes: FATA [72], designed for sequential tabular data, computes a temporal position as a learnable linear combination 𝑡𝑝𝑜𝑠 = 𝑤 pos · 𝑝𝑜𝑠 + 𝑤 t · 𝑡𝑝𝑜𝑠 + 𝑏, where 𝑤 pos , 𝑤 t , and 𝑏 are trainable parameters, and feeds the result to standard sinusoidal functions, allowing the model to learn the relative importance of sequence order versus actual time intervals. A contrasting line of work avoids mixing these signals at the input stage altogether. PEA [47], explored in the context of astronomical light curve analysis, computes content-only attention and adds a time-aware sinusoidal encoding only to the final encoder output, i.e., output = 𝑧 + 𝑃𝐸 (𝑇 ), cleanly separating content-driven and time-driven reasoning. This design offers competitive performance while reducing training time. More architecturally advanced approaches embed temporal reasoning directly into the model rather than relying solely on explicit positional encodings. Examples include coupling Transformers with neural ordinary differential equations to model continuous-time evolution [25, 62], fusing Time2Vec embeddings with ODE-based architectures [15], and introducing non-stationary kernels or feature-dependent temporal components [39, 71]. While these methods achieve strong accuracy on complex temporal modeling tasks, their substantial computational overhead renders them impractical for resource-constrained environments such as IoT gateways and edge devices. Unlike the methods reviewed above—which either retain discrete indices alongside temporal signals (FATA, ChronoFormer), adopt minimal-complexity linear mappings (CTLPE), or decouple temporal injection from attention entirely (PEA)—A-THENA directly replaces discrete indices with continuous timestamps, eliminating temporal aliasing, and consistently applies this principle across multiple encoding schemes (sinusoidal, Fourier, and rotary). Applications in Intrusion Detection. Within the intrusion detection domain, explicit timestamp modeling remains relatively uncommon. Early work by Han et al. [19] demonstrated that incorporating Δ𝑡 as explicit features improves detection performance through GTID, which augments sinusoidal encodings with a composite position index 𝑝𝑜𝑠 ′ = 𝑝𝑜𝑠 + log2 (𝑡𝑝𝑜𝑠 /𝑎 + 1) (where 𝑎 defaults to 10−7 ), merging sequential order and temporal magnitude as complementary features—but, like FATA, retains the discrete index as a signal component. More recently, Miyamoto et al. [44] demonstrated that applying Time2Vec [27] embeddings to network traffic yields measurable improvements over order-only baselines. Time2Vec is a model-agnostic timestamp encoding composed of one linear term capturing global temporal trends and multiple sinusoidal terms modeling periodic patterns: 𝑃𝐸 (: , 0) = 𝜔 0 · 𝑇 + 𝜙 0,
𝑃𝐸 (: , 𝑖) = sin(𝜔𝑖 · 𝑇 + 𝜙𝑖 ),
where 𝑖 = 1, . . . , 𝑑 m −1 indexes the encoding dimension, offering strong expressive power with minimal built-in inductive bias. However, these studies evaluate isolated encoding formulations without systematic comparison across different time-encoding families. In contrast to both GTID and Time2Vec, A-THENA replaces discrete indices with temporal signals and embeds time-aware encoding within an end-to-end framework that incorporates an earliness-oriented training objective and raw-traffic augmentation—treating temporal representation as an integrated component of a unified system rather than an isolated module, while extending our prior work on multi-encoding evaluations for network traffic [51] into a more comprehensive and efficient framework for lightweight intrusion detection in IoT environments. 2.3
Augmentation Strategies for Cybersecurity Datasets
The availability of real-world cybersecurity datasets is limited, with most existing datasets containing a restricted number of attack sessions, resulting in an insufficient sample size for effective model training. Furthermore, these Manuscript submitted to ACM
8
I. Panopoulos et al.
datasets often include a diverse range of attack types, whose variability and heterogeneity contribute to substantial class imbalances, as certain attack categories may be significantly underrepresented compared to those that generate higher volumes of traffic. To address these challenges, augmentation techniques are essential for enhancing dataset diversity and mitigating class imbalance. By synthetically increasing the number of attack samples, data augmentation improves model generalization, enabling intrusion detection systems to effectively identify both prevalent and rare attack patterns. To make cybersecurity datasets more varied and balanced, recent studies have explored different augmentation techniques. Nevertheless, the proposed models in these studies predominantly operate on extracted feature representations rather than raw network traffic, leading to the adoption of augmentation techniques primarily designed for tabular data. These approaches include the Synthetic Minority Oversampling Technique (SMOTE) [42, 45, 76], Conditional Tabular Generative Adversarial Networks (CTGANs) [7, 42], Variational Autoencoders (VAEs) [36, 76], Long Short-Term Memory (LSTM) networks [20], as well as more advanced methods, such as Transformer-based generative models [41] and diffusion models [26, 61]. These techniques have shown considerable success in boosting tabular data variability and quality. However, the literature is missing similar techniques applied to raw network traffic data. 2.4
Research Gap
The preceding review reveals several interrelated limitations in existing approaches to ML-based intrusion detection that, taken together, motivate A-THENA’s design. Temporal Representation. As discussed in Subsection 2.2.2, current time-aware encodings for intrusion detection either evaluate isolated formulations without systematic comparison [19, 44] or retain discrete indices alongside temporal signals, introducing aliasing artifacts (GTID, FATA). More expressive alternatives, such as Time2Vec and ChronoFormer, have not been evaluated in early detection settings, and purely linear representations (CTLPE) may lack the capacity to capture cyclical and bursty temporal structure. While time-aware encodings have demonstrated value across other domains [29, 54, 59, 65, 75], no prior work systematically compares across encoding families specifically for early intrusion detection or proposes a unified principle—replacing discrete indices with continuous timestamps—that generalizes across multiple encoding architectures. Early Detection. As discussed in Subsection 2.1.3, existing early detection architectures (eRNN, eTransformer, eAtt, eGlo) [3–5, 24] demonstrate the feasibility of variable-length flow classification but lack specialized training objectives that prioritize accurate predictions from minimal packet observations. Moreover, architectures such as those proposed in [13, 30, 37] impose computational demands unsuitable for edge deployment, and none incorporates inter-arrival timing into the encoding process. Data Augmentation. As reviewed in Subsection 2.3, existing augmentation techniques remain tailored to feature-based representations [7, 36, 41, 45], lacking mechanisms to diversify raw traffic while preserving protocol semantics and temporal realism. Integration. These challenges—temporal representation, early detection optimization, realistic data augmentation, and resource efficiency—remain largely disjoint in current research. By jointly addressing all four within a lightweight, deployable framework, A-THENA advances toward practical, real-time protection in resource-constrained IoT environments. Manuscript submitted to ACM
A-THENA 3
9
OUR APPROACH
Network traffic can be conceptualized as a collection of flows traversing network elements. The term flow has multiple definitions within the Internet community. According to RFC 7011 [6], a traffic flow is a set of packets or frames passing through an observation point over a specified time interval. For instance, in a host-based IDS, the observation point is the potential victim, such as an IoT device vulnerable to attacks. Each packet within a flow shares common attributes, with one of the most widely accepted flow definitions being the 5-tuple representation: source and destination IP addresses, source and destination transport layer ports, and the protocol in use. Early intrusion detection in the context of a flow-level IDS refers to the capability of accurately classifying a network flow as early as possible, using only a partial sequence of packets within the flow. The goal is to minimize the time and data required for threat identification, enabling rapid response and mitigation before an attack fully unfolds. An effective early detection system balances classification accuracy with earliness, ensuring that malicious activities are identified promptly while minimizing false positives and computational overhead. In order to facilitate early and accurate detection, our approach prioritizes four key objectives: • Feature-Free Learning: Unlike traditional approaches that depend on predefined or extracted features, our system operates directly on raw packet data, minimizing preprocessing overhead and enabling the model to learn representations autonomously. • Computational Efficiency: Our model’s primary goal is to remain lightweight, ensuring low latency and minimal memory footprint, making it suitable for deployment on resource-constrained environments such as IoT and edge devices. • Rapid Threat Detection: By classifying network flows using only a small fraction of their packets, our system enables early response and mitigation, preventing attacks from fully unfolding. • Adaptability to Variable-Length Flows: The detection mechanism is designed to handle flows of varying durations without requiring fixed-length representations, ensuring flexibility in real-world traffic analysis. Figure 1 illustrates the core architecture and methodological framework of the proposed A-THENA system. To achieve the aforementioned objectives, the model directly ingests raw packet flows (𝐹 ) alongside their corresponding continuous arrival timestamps (𝑇 ). As depicted in the top panel, raw byte sequences are projected into a hidden feature space, where temporal dynamics are injected to establish sequential order and inter-arrival timing. Depending on the specific variant, the timestamps are transformed via Time-Aware (TA) Sinusoidal or Fourier encodings and added directly to the input embeddings, or applied as a TA Rotary Positional Encoding (RoPE) directly within the Transformer encoder’s Multi-Head Attention mechanism. The encoded sequence is then aggregated via average pooling and passed through a classification head to produce class confidences. Crucially, the network is optimized using the Early Detection Loss (EDL), which applies an exponentially decaying penalty to enforce accurate classification from the earliest possible packets. Finally, the bottom panel outlines the Time-Aware Hybrid Encoding (THE) framework: to adapt to diverse network environments, the system evaluates all three time-aware models and dynamically selects the optimal configuration by minimizing the validation loss (argmin𝑖 𝐸𝐷𝐿𝑖val ). To operationalize this architecture, Figure 2 details the end-to-end data processing and experimental workflow used to construct and evaluate the model. Labeled PCAP files are first processed through the Data Preparation pipeline to produce structured flow representations and corresponding labels; this same pipeline is applied to live traffic to generate equivalent representations during real-time inference. After data preparation, the dataset is split into a hold-out test set and a development set undergoing cross-validation. Training and validation subsets are processed by the Offline Manuscript submitted to ACM
10
I. Panopoulos et al.
Encoder (𝑳 layers)
Add & Norm
Model Architecture
Average Pooling 𝒃, 𝒅𝐦
Feed Forward
Linear 𝒃, 𝑪
Softmax
Add & Norm
𝒃, 𝑪
TA RoPE
Multi-Head Attention
Class Confidences
Inference: 𝒃 = 𝟏, 𝒏 ≤ 𝑵
𝑻: 𝒃, 𝒏
TA Sinusoidal TA Fourier
𝒃, 𝒏, 𝒅𝐦
- 𝑭: packet sequence, 𝒑𝒊 ∈ ℝ𝒅
+
𝒑𝟎 𝒃, 𝒏, 𝒅𝐦
Input Projection
𝑭: 𝒃, 𝒏, 𝒅
Time-Aware Sinusoidal Model
Time-aware Hybrid Encoding
Time-Aware Fourier Model Time-Aware RoPE Model
Early Detection Loss (EDL) for Training
𝑬𝑫𝑳𝐯𝐚𝐥 𝐬𝐢𝐧
Training with EDL Augmented Data
𝒕𝟎
Model Selection
𝑬𝑫𝑳𝐯𝐚𝐥 𝐟𝐨𝐮
𝑬𝑫𝑳𝐯𝐚𝐥 𝐫𝐨𝐩𝐞
𝒑𝟏
⋯
𝒑𝒏−𝟏
- 𝑻: timestamp vector, 𝒕𝒊 ∈ ℝ
𝐚𝐫𝐠𝐦𝐢𝐧 𝑬𝑫𝑳𝐯𝐚𝐥 𝒊
𝒕𝟏
⋯
𝒕𝒏−𝟏
Selected Positional Encoding
𝒊
Fig. 1. The A-THENA system architecture. (Top) Transformer encoder ingesting raw packet sequences (𝐹 ) with Time-Aware (TA) encodings from timestamps (𝑇 ): TA Sinusoidal and TA Fourier are added to the input projection, while TA RoPE modifies multi-head attention. The Early Detection Loss (EDL) enforces early classification. (Bottom) The Time-Aware Hybrid Encoding (THE) framework dynamically selects the optimal encoding based on validation loss.
Augmentation module for early-stage simulation and class balancing. During each training fold, batches are further perturbed through Online Augmentation, and the three temporal encoding variants are trained in parallel. Once the THE framework identifies the best-performing encoding based on validation performance, a final training run is conducted on the full development set. The resulting model is then ready for deployment and offline evaluation. The subsequent subsections detail the data preparation pipeline (Section 3.1), the specialized augmentation and training strategies (Section 3.2), and the formal definition of the system architecture and encodings (Section 3.3). 3.1
Data Preparation
Our approach maximizes computational efficiency by directly processing raw packet bytes instead of relying on predefined features. This eliminates preprocessing overhead, reduces latency, and removes the need for manual feature engineering, allowing the model to learn meaningful representations autonomously. Additionally, it preserves finegrained information that traditional feature extraction might discard. The following subsections outline the three key modules of this process. 3.1.1 Flow Identification. The initial step in the proposed system involves maintaining a record of all active flows within the network, regardless of whether they originate from network captures (PCAP files) or real-time network Manuscript submitted to ACM
A-THENA
11
Training
(Sinusoidal)
Labelled PCAP Files
Data Preparation
CrossValidation 1
Data Splitting
Offline Augmentation
train/val
THE Model Selection
Training (Fourier)
Training
dev
Data Splitting
Offline Augmentation
train/val
Labelled PCAP Files
Live Traffic Stream
Offline Augmentation
Training Step
Batch
Training Set Validation Set
Jitter Injection
1
Flow Identification
Subflow Generation
1
1
Packet Filtering
2
Hybrid Oversampling
6
Best Variant
(RoPE)
7
8
Training
9
(Best)
Evaluation
Data Preparation
5
4
2
test
Training & Evaluation
3
Flow Preprocessing
10
3
Final Model
𝑭, 𝑻 , 𝒚
𝑭, 𝑻
2 Augmented Training Set Augmented Validation Set
Traffic Scaling
2
Packet Drop
3
Packet Insertion
4
Noise Injection
5 Model
6
Train with EDL
Online Augmentation
Fig. 2. A-THENA’s Training & Evaluation workflow. Modules are color-coded by functional role: data preparation (brown), model creation (purple), offline augmentation (green), THE variant selection (yellow), online network-specific augmentation (blue), and the EDL-based optimization step (red). Numbered circles denote the execution order within each stage, and arrows show data flow.
traffic. Upon the arrival or departure of a new packet, the system determines whether the packet corresponds to an existing flow or necessitates the creation of a new flow instance. Formally, a flow 𝐹 can be represented as an ordered sequence of packets: 𝐹 = (𝑝 0, 𝑝 1, . . . , 𝑝𝑛−1 ),
(1)
where 𝑝𝑖 ∈ R𝑑 is the 𝑖-th packet, 𝑑 is the length of a packet in number of bytes, and 𝑛 is the length of the flow. In our system, each flow can have a maximum length 𝑁 , therefore, the number of packets in any given flow satisfies the condition 1 ≤ 𝑛 ≤ 𝑁 . To construct network flows from raw traffic, a well-defined methodology must be established. Network attacks exhibit diverse characteristics, behaviors, and patterns. For the conventional 5-tuple definition—which consists of the source IP, destination IP, source port, destination port, and protocol—to be effective in attack detection, these parameters must remain consistent throughout the entire attack session. For instance, brute force attacks (e.g., SSH, FTP, or RDP brute forcing) involve repeated login attempts to a specific service, maintaining a stable 5-tuple across multiple authentication requests. However, many sophisticated cyber threats do not adhere to a consistent 5-tuple structure, rendering detection based solely on this definition inadequate. Examples include distributed attacks, where IP addresses frequently change, and scanning attacks or port-hopping techniques, which result in a high number of Manuscript submitted to ACM
12
I. Panopoulos et al.
ephemeral, often two-packet flows, if classified using the 5-tuple. These limitations prevent an effective representation of the ongoing attack. To address this challenge, the system begins with Level 0 aggregation, corresponding to the standard 5-tuple definition, which is sufficient for most single-session attacks. The system also tracks the number of active flows and periodically compares it against a threshold defined as five times the normal traffic baseline (i.e., the average number of active flows observed during benign operation). If this threshold is exceeded, the system escalates to Level 1 aggregation, where flows are grouped using the 3-tuple (source IP, destination IP, protocol), effectively ignoring transport-layer ports. If the number of aggregated flows remains above the threshold, the system advances to Level 2 aggregation, defined by the 2-tuple (destination IP, protocol); at this stage, the destination IP corresponds to the victim host receiving the attack traffic. Once traffic levels fall back below the threshold, the system gradually returns to Level 0. This adaptive strategy maintains lightweight flow tracking during normal conditions while expanding aggregation only when necessary, thereby improving scalability and preserving detection effectiveness under high-load or attack scenarios. 3.1.2 Packet Filtering. The second stage in data preparation involves isolating network traffic relevant to the specific threat models and topology targeted by the IDS. By discarding irrelevant data, this module significantly reduces computational overhead and focuses the model’s attention on high-risk interactions. The filtering process operates on two distinct levels: protocol selection and network-specific constraints. (1) First, the system filters based on protocol susceptibility. Services such as HTTP, ARP, and ICMP are frequently exploited, making them critical candidates for analysis. For instance, retaining HTTP traffic allows the system to inspect client-server exchanges for web-based threats, including Cross-Site Scripting (XSS), SQL injection, and Denial-of-Service (DoS) attacks. (2) Second, the module accommodates network-specific context to target precise communication channels. This allows for the inclusion of filtering rules based on known network topology or specific attack scenarios. For example, in the context of a brute-force attack targeted at a specific server, the filter can be configured to isolate traffic exclusively between the attacker’s suspected subnet and the victim’s IP address. By narrowing the scope to these specific source-destination pairs, the system effectively eliminates background noise, ensuring that the deep learning model processes only the traffic pertinent to the anticipated attack vector. 3.1.3 Flow Preprocessing. Flow preprocessing constitutes the final stage of the data pipeline, essential for transforming raw network traffic into structured arrays compatible with deep learning models. This phase encompasses data cleaning, byte-level normalization, and the standardization of inputs into fixed-sized arrays. Processing begins at the packet level by stripping superfluous metadata. The Ethernet header is discarded entirely, while the source and destination addresses are removed from the IP header. Eliminating these specific addresses prevents the model from overfitting to environmental artifacts, thereby encouraging it to focus on protocol behavior and payload content rather than network topology. Subsequently, each packet is either truncated or padded to a uniform length, denoted as 𝑑 in Equation (1). To optimize gradient descent and ensure training stability, byte values are normalized to the range [0, 1] by dividing by 255. This scaling step effectively mitigates numerical disparities in the input data, facilitating faster convergence [23]. To capture the temporal dynamics of the flow, packet timestamps are extracted and stored as a separate vector, 𝑇 = (𝑡 0, 𝑡 1, . . . , 𝑡𝑛−1 ), Manuscript submitted to ACM
(2)
A-THENA
13
which serves as a secondary input to the system. The timestamp of the first packet in a flow is set to 0, and subsequent timestamps represent the absolute time elapsed since the first packet’s arrival. This temporal information is vital for recognizing sequential patterns in network traffic and detecting anomalies based on timing deviations. Finally, to accommodate the fixed-length input requirements of Transformer architectures, all flows must be standardized to a uniform sequence length 𝑁 . Flows containing fewer than 𝑁 packets are padded with zero-valued vectors, and their corresponding timestamp sequences are similarly zero-padded. In conjunction with this process, binary attention masks are generated to differentiate between authentic data and padding. Valid positions are assigned a mask value of 1, while padded regions are assigned 0, ensuring that the model’s attention mechanism focuses exclusively on meaningful network activity.
3.2
Training
The training phase of the proposed system aims to develop deep learning models capable of early attack detection using raw network packet data. This phase follows the data preparation stage, leveraging the preprocessed packet representations and their corresponding timestamp vectors as input. 3.2.1 Data Splitting & Cross-Validation. To ensure a rigorous evaluation, we first isolate a hold-out test set, which remains strictly unseen during the entire training process. The remaining dataset constitutes the development set, which is subjected to 𝑘-fold cross-validation. Within each fold, the data is dynamically split into training and validation subsets. This approach allows us to tune hyperparameters and assess model stability using the validation splits, while reserving the hold-out test set for the final confirmation of the model’s effectiveness on real-world, unseen traffic. After cross-validation identifies the best-performing configuration, the development set is employed to train the final model. 3.2.2 Offline Augmentation. Building on the offline augmentation stage introduced in our prior work [51], we substantially enhance its functionality by redesigning subflow generation to be dynamic and class-aware for improved early detection training, and by introducing a hybrid oversampling mechanism that compensates for class imbalance using the resulting subflow distributions. (1) Subflow Generation: A subflow is defined as the first 𝑘 packets of an original flow of length 𝑛, where 1 ≤ 𝑘 < 𝑛. Rather than exhaustively generating all possible subflows—which can create massive data redundancy—we dynamically determine the number of subflows to generate based on the model’s complexity and per-class statistics. We define a target sample count per class, 𝑚 d , proportional to the model’s parameter count (𝑃) and the number of classes (𝐶), aiming for a density of 𝑚 d ≈ (2𝑃)/𝐶. For each class 𝑐 with size 𝑚𝑐 and average flow length 𝑛𝑐 , subflow generation proceeds conditionally: • Minority Classes (𝑚𝑐 < 𝑚 d ): To compensate for the deficit 𝑚 d − 𝑚𝑐 , we compute an augmentation factor 𝑎𝑐 = min (𝑚 d − 𝑚𝑐 )/𝑚𝑐 , 𝑛𝑐 − 1 . As this factor is typically non-integer, we employ stochastic rounding to determine the exact count per sample: each original flow generates ⌊𝑎𝑐 ⌋ subflows, with one additional subflow generated with probability 𝑎𝑐 − ⌊𝑎𝑐 ⌋. Cut-off positions 𝑘 are sampled logarithmically, yielding dense coverage of early packets and sparser sampling toward the tail, an essential property for early-stage detection. • Majority Classes (𝑚𝑐 ≥ 𝑚 d ): Since these classes already possess sufficient statistical representation, further bulk augmentation would exacerbate class bias. However, to ensure the model learns to detect these classes early, we define a fixed augmentation factor 𝑎𝑐 = 0.2; we randomly select 20% of the flows in each class and generate Manuscript submitted to ACM
14
I. Panopoulos et al. exactly one short subflow (restricted to 𝑘 ∈ [1, 5]) for each. This prioritizes the injection of early-stage patterns without bloating the class size. The resulting per-class sample count after subflow generation is 𝑚𝑐′ ≈ (1 + 𝑎𝑐 ) 𝑚𝑐 . (2) Hybrid Oversampling: While subflow generation increases dataset size, residual imbalance may persist. To guarantee perfect class parity, we apply a hybrid oversampling strategy that combines deterministic coverage with stochastic filling. We define a reference size 𝑚 max = max𝑐 (𝑚𝑐′ ) and calculate the required oversampling factor 𝑧𝑐 = (𝑚 max −𝑚𝑐′ )/𝑚𝑐′ for every class 𝑐. We decompose 𝑧𝑐 into an integer component 𝑟 = ⌊𝑧𝑐 ⌋ and a decimal component 𝑝 = 𝑧𝑐 − 𝑟 . The oversampling proceeds in two steps: • Deterministic Step: Every sample in class 𝑐 is duplicated exactly 𝑟 times. This ensures that the base distribution of the minority class is preserved and uniformly upweighted. • Stochastic Step: To account for the remaining fractional deficit, we randomly sample 𝑝 · 𝑚𝑐′ instances from the original set (without replacement within this subset) to receive one additional copy. The final sample size for all classes is therefore 𝑚𝑐′′ ≈ 𝑚 max . As shown in Figure 2 (highlighted in green), this full methodology targets the training set. The validation set undergoes
subflow generation using the same class-specific factors (𝑎𝑐 ) derived from training statistics. We strictly exclude oversampling to preserve original class proportions, ensuring unbiased evaluation on a representative distribution of partial flows. 3.2.3 Online Augmentation. Our online augmentation stage adopts the packet-level perturbation techniques introduced in our prior work [51] and applies them without modification. As shown in Figure 2 (highlighted in red), each flow in a batch is subjected to stochastic perturbations during training, enhancing robustness and complementing offline oversampling. While oversampling replicates minority flows, the online stage ensures that each replica undergoes a distinct random transformation, preventing the model from seeing identical packets twice and reducing memorization risks. By leveraging packet timestamps, the pipeline also introduces time-aware perturbations that increase variability beyond what time-agnostic systems can achieve. (1) Jitter Injection: The first augmentation technique focuses on the timestamps of the packets within a flow. Jitter injection introduces small, random variations in packet arrival times to simulate the real-world jitter commonly observed in network communications. For each timestamp, the minimum temporal distance to adjacent packets, denoted as 𝑡 min , is first calculated, and then a random perturbation is sampled from the continuous uniform distribution and applied: U (−0.7 · 𝑡 min, 0.7 · 𝑡 min ). This perturbation helps simulate network conditions such as congestion or packet delays, making the model more robust to variations in packet timing. (2) Traffic Scaling: The second technique applied to the timestamps is traffic scaling. This method simulates different network speeds by randomly choosing a scaling factor from the set {0.5, 0.75, 1.0, 1.25, 1.5}. This scaling factor is then applied to the timestamps, either increasing them to simulate slower networks or reducing them to mimic high-speed links. This variation exposes the model to different network conditions and improves its ability to generalize across a wide range of traffic speeds. (3) Packet Drop: This is the first augmentation technique to operate at the packet level. Packet drop randomly drops a number of packets from each flow. The maximum number of packets that can be dropped depends on Manuscript submitted to ACM
A-THENA
15
the length of the flow, calculated as max_packets_to_drop = ⌊0.25 · 𝑛 − 0.5⌋, where 𝑛 is the length of the flow. The actual number of packets to drop is drawn from the discrete uniform distribution: U{0, max_packets_to_drop}. (4) Packet Insertion: The packet insertion technique is the second packet-level method. It randomly adds a number of zero-byte packets into a flow. The maximum number of zero packets to be inserted is based on the flow length and is calculated as max_packets_to_insert = ⌊0.15 · 𝑛 − 0.5⌋, The actual number is again drawn from a discrete uniform distribution: U{0, max_packets_to_insert}. (5) Noise Injection: The final augmentation technique involves adding noise to the bytes of the packets. For each flow, at most ⌊𝑛/3⌋ packets are modified, and for each modified packet, at most ⌊𝑑/100⌋ bytes are altered. The positions of the bytes to be modified are randomly selected from a discrete uniform distribution. The noise itself is drawn from a continuous normal distribution with zero mean and a standard deviation of 0.1. Since all values have already been normalized to the range [0, 1], the added noise is small but effective in simulating random variations or errors in the packet data. It is important to emphasize that not every augmentation technique is applied to every sample. For instance, a scaling factor of 1 results in no modification, and if no packets are selected for dropping, insertion, or noise injection, those operations remain inactive. Beyond adopting this component as-is, our contribution includes a rigorous evaluation of both the time-aware augmentation techniques and the full online augmentation pipeline through an extensive ablation study across multiple network environments (Section 6.6). 3.2.4 Early Detection Loss Function. Aiming to improve early classification performance, as initially proposed in our prior work [51], we employ the Early Detection Loss (EDL) to emphasize accurate predictions at earlier stages. In this work, we present an extended evaluation of its effectiveness across multiple datasets. EDL applies greater penalties to misclassifications in shorter flows compared to longer ones, thereby encouraging the model to make accurate decisions even with limited packet information—an essential capability for timely anomaly detection in real-time network traffic analysis. During training, for each batch of 𝑏 samples, the cross-entropy loss is first computed individually for each sample. The overall batch loss is then obtained as a weighted average of these individual losses: 𝐿=
𝑏 −1 ∑︁
𝑤𝑖 𝐶𝐸𝑖 ,
𝑖=0
where 𝑤𝑖 represents the weight associated with the 𝑖-th sample, and 𝐶𝐸𝑖 is the corresponding cross-entropy loss. The weight 𝑤𝑖 is defined as 𝑤𝑖 = 𝑒 −0.1·𝑛𝑖 , where 𝑛𝑖 denotes the length of the 𝑖-th flow in the batch. This weighting mechanism ensures that the model prioritizes minimizing errors in shorter flows, thereby improving its effectiveness in early classification scenarios. By exponentially Manuscript submitted to ACM
16
I. Panopoulos et al. Table 1. System Hyperparameters and their Corresponding Values
Hyperparameter
Symbol
Value
Packet length Maximum flow length
𝑑 𝑁
448 30
Hidden dimension Number of Transformer blocks Number of attention heads Attention head dimension FFN intermediate dimension Dropout rate Number of output classes
𝑑m 𝐿 ℎ 𝑑h 𝑑 ff 𝑝 drop 𝐶
8 1 4 8 16 0.1 dataset-specific
reducing the weight as 𝑛𝑖 increases, the model is encouraged to make more accurate predictions with fewer packets, which is essential for applications requiring quick, real-time decisions. 3.3
System
In this work, we adopt the same lightweight Transformer-based architecture as in our earlier work [51] (as shown in Fig. 1, top), optimized for low-latency detection on constrained devices. Unlike traditional models, Transformers can effectively learn packet relationships independent of their positions, making them well-suited for attack detection and traffic classification. Additionally, the temporal aspect of packet arrival times can be crucial for identifying malicious activity, as many attacks exhibit distinct timing patterns. The Transformer architecture offers a significant advantage in this regard, as it can leverage the temporal information through time-aware positional encodings, allowing it to model temporal dependencies within a flow. This capability improves the accuracy and robustness of attack detection by leveraging both sequential and temporal information. 3.3.1 Base Model. Our base model, defined as the core Transformer architecture excluding positional encoding, is intentionally designed for low-latency inference with minimal parameter count, while preserving sufficient representational capacity for classification. Below, we summarize the architecture and hyperparameters for completeness. Building upon the standard Transformer framework introduced in [68], we incorporate specific modifications tailored for the analysis of network flows. As our task is classification, only the encoder component of the Transformer model is employed. Since the preprocessed raw bytes from each packet directly serve as token embeddings, an explicit input embedding layer is not required. However, to align the input data with the model’s feature space, we apply a fully connected layer that maps the input dimension 𝑑 to the hidden dimension 𝑑 m . The transformed input is subsequently processed through a sequence of 𝐿 Transformer encoder blocks, in which we replace the standard GELU activation function with ReLU to enhance computational efficiency and promote training stability. Following the final Transformer encoder block, global average pooling aggregates the sequence of packet-level embeddings into a single fixed-length vector. This aggregated representation is then passed through a fully connected layer comprising 𝐶 output neurons and is subsequently processed by a softmax activation function to produce class confidence scores. Table 1 summarizes the hyperparameters employed in our system. These values were selected to achieve rapid inference and a lightweight model architecture, essential for efficient operation in practical network environments. Notably, we do not impose the constraint 𝑑 h = 𝑑 m /ℎ, providing additional flexibility in configuring attention heads. The choice of values for input data representation was guided by empirical analysis and practical considerations: Manuscript submitted to ACM
A-THENA
17
• A maximum sequence length of 𝑁 = 30 packets allows the model to capture sufficient contextual information while maintaining low computational complexity, considering that most malicious activities manifest within shorter packet sequences. • A packet feature size of 𝑑 = 448 provides comprehensive representation, capturing essential packet information such as critical headers and payload content, necessary for accurate attack detection. The total number of trainable parameters in our base model is calculated as 𝑃 = 𝑑 m [2𝐿(2ℎ𝑑 h + 𝑑 ff + 3) + 𝑑 + 𝐶 + 1] + 𝐿(3ℎ𝑑 h + 𝑑 ff ) + 𝐶, which indicates that increasing either the model width (𝑑 m ) or depth (𝐿) significantly increases the model’s parameter count, with direct implications for computational overhead and memory usage. With our selected hyperparameters, the base model consists of approximately 5,070 total trainable parameters, excluding any positional encoding mechanisms. This lightweight architecture facilitates rapid decision-making while maintaining the necessary representational power to distinguish between normal and attack traffic. 3.3.2 Time-Aware Positional Encodings. As discussed in Subsection 2.2, conventional positional encodings rely on uniformly spaced sequence indices. In network traffic, however, packet flows exhibit non-uniform inter-arrival times, rendering this assumption invalid and limiting the suitability of standard positional encoding schemes. To address this limitation, A-THENA’s encoding mechanism replaces the discrete index vector (0, 1, . . . , 𝑛−1) with the timestamp vector 𝑇 = (𝑡 0, 𝑡 1, . . . , 𝑡𝑛−1 ). This modification is applied to standard sinusoidal, Fourier-based, and rotary encodings to produce three time-aware variants: TA Sinusoidal, TA Fourier, and TA RoPE. These variants were first introduced in our prior work [51] as individual alternatives to traditional encodings, specifically engineered to capture the temporal irregularities inherent in sequential network traffic. Figure 3 demonstrates the capability of the time-aware positional encodings to effectively represent temporal patterns within network traffic, compared to conventional positional encodings. The first row depicts traditional positional encodings, which rely exclusively on discrete packet indices and thus omit temporal context. The subsequent rows introduce the proposed time-aware positional encodings, computed using the timestamps of packets within individual network flows. Specifically, the second row corresponds to a representative SSH brute-force attack scenario, characterized by packets transmitted in rapid succession, thus yielding subtle encoding variations. The third row illustrates benign network traffic with moderately spaced packet transmissions, resulting in clearer encoding distinctions. Finally, the fourth row corresponds to a web-based backdoor malware attack scenario with significantly delayed packet transmissions, exhibiting the most pronounced encoding variations. Across all positional encoding methods considered, the proposed time-aware variants distinctly and systematically reflect absolute temporal differences, thereby highlighting their suitability for accurately capturing critical timing information essential for enhanced network flow classification. Beyond network traffic analysis, time-aware encodings can be extended to encompass other types of time series data, where samples are generated at irregular intervals, leading to unevenly spaced timestamps. Examples of such data include sensor readings recorded only during significant changes, user activity logs (e.g., clicks, searches, and logins), as well as social media and communication logs, among others. By integrating time-aware encodings, these domains can benefit from more precise temporal representations, improving downstream predictive tasks. Theoretical Justification. Traditional positional encodings rely on uniformly spaced indices that fail to capture the non-uniform, irregular nature of packet inter-arrival times found in real-world network traffic. In contrast, time-aware Manuscript submitted to ACM
I. Panopoulos et al.
0.75 1.00
0 1 2 3 4 5 6 7 Encoding Dimension
0.00 4.49 14.22 40.95 43.01 50.57 54.24 87.56
0 0.34 -0.94 0.00 0.00 0.00 0.00 0.00 0.00 1 0.94 0.34 0.00 0.00 0.00 0.00 0.00 0.00 2 0.00 0.00 0.99 -0.12 0.00 0.00 0.00 0.00 3 0.00 0.00 0.12 0.99 0.00 0.00 0.00 0.00 4 0.00 0.00 0.00 0.00 1.00 -0.01 0.00 0.00 5 0.00 0.00 0.00 0.00 0.01 1.00 0.00 0.00 6 0.00 0.00 0.00 0.00 0.00 0.00 1.00 -0.00 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00 0 -0.43 -0.91 0.00 0.00 0.00 0.00 0.00 0.00 1 0.91 -0.43 0.00 0.00 0.00 0.00 0.00 0.00 2 0.00 0.00 0.98 -0.20 0.00 0.00 0.00 0.00 3 0.00 0.00 0.20 0.98 0.00 0.00 0.00 0.00 4 0.00 0.00 0.00 0.00 1.00 -0.02 0.00 0.00 5 0.00 0.00 0.00 0.00 0.02 1.00 0.00 0.00 6 0.00 0.00 0.00 0.00 0.00 0.00 1.00 -0.00 7 0.00 0.00 0.00 0.00 0.00 0.00 0.00 1.00
0.75 0.50 0.25 0.00
0.25 0.50 0.75 1.00
0 1 2 3 4 5 6 7 Encoding Dimension
0 -0.13 -0.99 0.00 0.00 0.00 0.00 0.00 0.00 1 0.99 -0.13 0.00 0.00 0.00 0.00 0.00 0.00 2 0.00 0.00 0.14 -0.99 0.00 0.00 0.00 0.00 3 0.00 0.00 0.99 0.14 0.00 0.00 0.00 0.00 4 0.00 0.00 0.00 0.00 0.99 -0.14 0.00 0.00 5 0.00 0.00 0.00 0.00 0.14 0.99 0.00 0.00 6 0.00 0.00 0.00 0.00 0.00 0.00 1.00 -0.01 7 0.00 0.00 0.00 0.00 0.00 0.00 0.01 1.00 0 1 2 3 4 5 6 7 Encoding Dimension
1.00 0.75 0.50 0.25 0.00
Encoding Value
Encoding Dimension
0.50
Encoding Dimension
0.25
0.00 1.00 2.01 3.02 4.02 5.03 6.05 7.05
0 -0.84 0.54 0.00 0.00 0.00 0.00 0.00 0.00 1 -0.54 -0.84 0.00 0.00 0.00 0.00 0.00 0.00 2 0.00 0.00 0.54 -0.84 0.00 0.00 0.00 0.00 3 0.00 0.00 0.84 0.54 0.00 0.00 0.00 0.00 4 0.00 0.00 0.00 0.00 1.00 -0.10 0.00 0.00 5 0.00 0.00 0.00 0.00 0.10 1.00 0.00 0.00 6 0.00 0.00 0.00 0.00 0.00 0.00 1.00 -0.01 7 0.00 0.00 0.00 0.00 0.00 0.00 0.01 1.00
Encoding Dimension
0.00
1.00
Encoding Value
0.25
Timestamp (ms)
0.50
0.00 1.12 1.12 1.22 1.32 1.32 1.32 1.32
Timestamp (ms)
0.75
0 4 8 12 16 20 24 28
Encoding Dimension
RoPE Rotation Matrix (Position=10)
Timestamp (ms)
0.00 4.49 14.22 40.95 43.01 50.57 54.24 87.56
Fourier-based Positional Encoding
1.00
Encoding Value
Timestamp (ms)
0.00 1.00 2.01 3.02 4.02 5.03 6.05 7.05
Timestamp (ms)
0.00 1.12 1.12 1.22 1.32 1.32 1.32 1.32
Timestamp (ms)
Position
Sinusoidal Positional Encoding
0 4 8 12 16 20 24 28
Position
18
0.25 0.50 0.75 1.00
Fig. 3. Comparison of standard index-based positional encodings (top row) against the proposed time-aware variants applied to SSH brute-force, benign, and backdoor malware traffic scenarios.
encodings replace fixed indices with actual packet timestamps, providing an input that reflects the temporal structure of a flow. Theoretically, this enhances the Transformer’s inductive bias by embedding time directly into the self-attention computation. The dot-product attention mechanism can now weigh packet-packet interactions based not only on content but also on temporal proximity—making it more sensitive to traffic bursts, delays, and timing anomalies. This is especially valuable in intrusion detection, where attacks often exhibit characteristic timing patterns (e.g., periodic scanning, flood attacks). By interpreting timestamp-based encodings as a mapping into a temporal frequency space (via sinusoidal or Fourier functions), we enable the model to capture these temporal dynamics in a principled way, ultimately improving its ability to detect malicious flows early and accurately. Consider a generic positional encoding function 𝑃𝐸 (𝑝𝑜𝑠) that maps each position to a vector representation. • Under traditional encodings, 𝑝𝑜𝑠 is a discrete integer index. Consequently, the positional difference between any two consecutive packets is always identical (𝑝𝑜𝑠+1 vs. 𝑝𝑜𝑠). Manuscript submitted to ACM
A-THENA
19
• Under our time-aware formulation, 𝑝𝑜𝑠 is replaced by the continuous timestamp 𝑡𝑝𝑜𝑠 . As a result, the geometric distance between the encodings of two packets becomes a direct function of their actual temporal separation (Δ𝑡 = 𝑡𝑝𝑜𝑠+1 − 𝑡𝑝𝑜𝑠 ). For example, a brute-force attack might transmit packets with a Δ𝑡 of 0.01 seconds, whereas benign traffic might have a Δ𝑡 of 2.0 seconds. In our model, the encoding vectors 𝑃𝐸 (𝑡𝑝𝑜𝑠 ) and 𝑃𝐸 (𝑡𝑝𝑜𝑠 + 0.01) will be very close in the embedding space, whereas 𝑃𝐸 (𝑡𝑝𝑜𝑠 ) and 𝑃𝐸 (𝑡𝑝𝑜𝑠 + 2.0) will be significantly more distant. This enables the encoding to act as a frequency-based transformation of the time series of packet arrivals, embedding both fine- and coarse-grained temporal variations. The attention mechanism, in turn, becomes sensitive to timing patterns in network flows, making it theoretically more suited for detecting irregular, bursty, or periodic attack behaviors compared to index-based encodings. 3.3.3 A-THENA. The proposed system identifies the optimal time-aware positional encoding by evaluating each encoding’s effectiveness with respect to the specific characteristics of the attack types analyzed. Among the sinusoidal, Fourier-based, and rotary formulations, the model with the lowest average validation loss across cross-validation folds is selected, ensuring strong generalization to unseen data. This selection process underpins our Time-Aware Hybrid Encoding (THE) framework (Fig. 1, bottom), which captures the temporal dynamics of network flows through an adaptive combination of multiple encoding strategies. By dynamically choosing the encoding variant best aligned with the observed traffic patterns, THE introduces an adaptive capability not present in prior time-aware encoding approaches. Concurrently, the Network-Specific Augmentation (NA) techniques, detailed in Subsections 3.2.2 & 3.2.3, enhance data diversity and further support robust generalization. The synergistic combination of time-aware representation learning and augmentation-driven robustness constitutes the core of the proposed early intrusion detection system, A-THENA. 3.4
Problem Definition
As defined in Equations 1 and 2, a flow is characterized by its packet sequence 𝐹 and corresponding timestamp sequence 𝑇 . The model therefore processes the combined packet–timestamp pairs {(𝑝𝑖 , 𝑡𝑖 ) | 𝑖 = 0, 1, . . . , 𝑛−1}, where 𝑝𝑖 ∈ R𝑑 denotes the 𝑖-th packet and 𝑡𝑖 its arrival time. The goal of early intrusion detection is to learn a parameterized function 𝑓𝜃 that predicts the class label 𝑦 ∈ Y, where Y contains the benign and attack classes of interest, using only a prefix of the flow. At decision step 𝑘, with 1 ≤ 𝑘 ≤ min(𝑛, 𝑁 ) and 𝑁 denoting the model’s maximum input length, the prediction is given by ŷ𝑘 = 𝑓𝜃 (𝐹 0:𝑘 −1,𝑇0:𝑘 −1 ), where ŷ𝑘 is the predicted probability distribution over Y. The objective is to correctly infer the true class 𝑦 while minimizing both the classification error and the required observation length 𝑘, subject to achieving a confidence level threshold 𝜏, which specifies the minimum required prediction confidence (see Section 5.3.1). 4
IMPLEMENTATION
The implementation of A-THENA is structured into three main components: network data processing, model development, and deployment on edge devices. We employ Scapy [10], a Python library for packet manipulation and network traffic analysis, to extract relevant packet flows from raw PCAP files, enabling efficient flow reconstruction and preprocessing. The Transformer-based detection models are developed using TensorFlow [1], incorporating time-aware Manuscript submitted to ACM
20
I. Panopoulos et al. Table 2. Attack Categories in the Selected Datasets
CICIoT23-WEB
MQTT-IoT-IDS2020
(1) SQL Injection (2) Command Injection (3) Backdoor Malware (4) Uploading Attack (5) Cross-Site Scripting (XSS)
(1) Aggressive Scan (2) UDP Scan (3) MQTT Brute-Force (4) Sparta SSH Brute-Force
IoTID20 (1) DoS SYN Flooding (2) Mirai ACK Flooding (3) Mirai Host Brute-Force (4) Mirai HTTP Flooding
(5) Mirai UDP Flooding (6) MiTM ARP Spoofing (7) Host & Port Scan (8) OS Scan
positional encodings to capture fine-grained temporal dependencies within network flows, thereby improving early threat detection. To facilitate real-time inference on resource-constrained IoT devices, the trained models are deployed on the Raspberry Pi Zero 2 W using LiteRT, a lightweight runtime optimized for efficient deep learning execution. This deployment strategy ensures low-latency processing, high detection accuracy, and minimal resource overhead, making the system well-suited for practical IoT security applications where computational efficiency and rapid response times are critical. To support reproducibility and facilitate further research, the complete source code of A-THENA is publicly available on GitHub1 . 5
EXPERIMENTAL METHODOLOGY
This section provides a detailed overview of the methodology employed for conducting experiments and systematically evaluating the performance of our system. It details the experimental setup, dataset characteristics, and evaluation framework, ensuring a rigorous and reproducible analysis of the proposed approach. 5.1
Datasets
To ensure a comprehensive and robust evaluation, this work significantly expands upon our prior work [51], which utilized a single dataset. We employ three publicly available benchmark datasets for intrusion detection in IoT environments: CICIoT2023 [48], MQTT-IoT-IDS2020 [21], and IoTID20 [66]. As outlined in Table 2, each dataset encompasses distinct attack categories. In the case of CICIoT2023, we specifically focus on web-based attacks, resulting in a subset of the dataset referred to as CICIoT23-WEB. Consequently, incorporating the benign traffic class, the final classification tasks consist of 6, 5, and 9 classes for CICIoT23-WEB, MQTT-IoT-IDS2020, and IoTID20, respectively. The selected datasets provide a diverse and representative set of IoT intrusion scenarios, enabling a comprehensive evaluation of the system’s generalization capabilities. CICIoT23-WEB focuses on web-based application-layer attacks (e.g., SQL Injection, Command Injection, XSS) that target IoT web services. MQTT-IoT-IDS2020 covers protocol-specific and reconnaissance attacks (e.g., MQTT Brute-Force, SSH Brute-Force, UDP Scans) affecting IoT communication protocols. IoTID20 includes Mirai botnet-driven DDoS attacks (e.g., SYN Flooding, HTTP Flooding, MiTM ARP Spoofing)
1 https://github.com/ioannispan/A-THENA
Manuscript submitted to ACM
A-THENA
21 Table 3. Dataset Statistics for MQTT-IoT-IDS2020 Before and After Offline Augmentation
Benign
Aggressive Scan
UDP Scan
MQTT Brute-Force
Sparta SSH Brute-Force
Total
Original
6015
2412
1322
6440
6440
22629
Test
602
241
132
644
644
2263
Training (𝑚𝑐 ) 𝑚 d − 𝑚𝑐 𝑎𝑐 Training (𝑚𝑐′ ) 𝑧𝑐 Training (𝒎′′ 𝒄)
4331 <0 0.2 5211 0.07 5576
1736 295 0.17 2054 1.714 5575
952 1079 1.13 2034 1.74 5573
4636 <0 0.2 5574 0 5574
4637 <0 0.2 5562 0.002 5573
16292 – – 20435 – 27871
Validation (𝑚𝑐 ) Validation (𝒎′𝒄 )
1082 1322
435 512
238 514
1160 1383
1159 1391
4074 5122
Split
representing large-scale IoT security threats. By testing across these datasets, the system is validated against applicationlayer, protocol-specific, and DDoS-based intrusions, demonstrating its robustness and real-world applicability in IoT security. Table 3 summarizes the offline augmentation pipeline for MQTT-IoT-IDS2020, which comprises 22,629 samples across five classes. We first allocate 10% of the data to the test set (2,263 samples), and then perform 5-fold cross-validation on the remaining 90%, resulting in training and validation partitions of 16,292 and 4,074 samples, respectively. The training set exhibits moderate class imbalance, with the minority class (UDP Scan) containing 952 samples and the majority classes (MQTT Brute-Force, Sparta SSH Brute-Force) reaching 4,637 samples. Given the model’s parameter count and number of classes, the target sample count per class is computed as 𝑚 d ≈ (2𝑃)/𝐶 = (2 · 5,077)/5 = 10,154/5 ≈ 2,030.8 → 2,031. Classes falling below this threshold (Aggressive Scan, UDP Scan) undergo augmentation proportional to their deficit, with UDP Scan receiving the highest augmentation factor (𝑎 2 = 1.13) due to its minority status. Majority classes receive minimal augmentation (𝑎 0 = 𝑎 3 = 𝑎 4 = 0.2) to inject early-stage detection patterns without exacerbating imbalance. Following subflow generation, the training set expands to 20,435 samples. Hybrid oversampling then equalizes all classes to ∼5,574 samples, yielding a final balanced training set of 27,871 samples. The validation set undergoes only subflow generation, expanding from 4,074 to 5,122 samples while preserving the original class distribution for unbiased evaluation. The remaining datasets follow analogous augmentation procedures. CICIoT23-WEB contains 2,240 samples across six classes, split into 1,611 training, 423 validation, and 226 test samples. Offline augmentation expands the training set to 10,175 balanced samples through intensive subflow generation (with augmentation factors up to 29 for underrepresented classes), while the validation set increases from 423 to 2,024 samples. IoTID20 comprises 19,612 samples across nine classes, divided into 14,120 training, 3,530 validation, and 1,962 test samples. Although not the largest dataset, it exhibits moderate class imbalance, which is mitigated through a combination of conservative augmentation for most classes and stronger augmentation for the smallest ones. Subflow generation expands the training set to 18,092 samples, and subsequent hybrid oversampling produces a balanced set of 31,140 samples; the validation set grows from 3,530 to 4,524 samples. Manuscript submitted to ACM
22
I. Panopoulos et al.
5.2
Training Configuration
Training is conducted using the Adam optimizer [31] and the EDL loss function (Subsection 3.2.4), with early stopping applied to the validation loss using a patience of 7 epochs. Both encoding selection and hyperparameter tuning are performed via 5-fold cross-validation. After identifying the best temporal encoding variant, the final model is trained on the full development set, using a 90%/10% split for training and validation. Dataset-specific hyperparameters are as follows: CICIoT23-WEB uses a batch size of 4 and a learning rate of 10−4 ; IoTID20 uses a batch size of 8 and a learning rate of 10−4 ; and MQTT-IoT-IDS2020 uses a batch size of 8 and a learning rate of 2 × 10−4 . 5.3
Evaluation Metrics
To assess the effectiveness of A-THENA, we design an evaluation process to closely replicate real-world deployment conditions. This approach ensures that performance metrics accurately reflect the system’s practicality and reliability in real-world applications. In practice, when deployed on a host machine, the system continuously monitors network flows to promptly determine whether an attack is occurring. Given the critical need for early threat detection in cybersecurity, the evaluation focuses on both the accuracy and responsiveness of the system. 5.3.1 Confidence-Based Performance Metrics. To evaluate performance, a set of confidence-based metrics is employed. Given a confidence threshold 𝜏 applied to the top-1 softmax score, the evaluation focuses on how quickly the system arrives at a confident decision. The process begins with the first packet of each test flow, gradually adding packets until the model’s confidence reaches or exceeds 𝜏. If the threshold is not met after processing all 𝑁 packets, the final classification is based on the full sequence. Because 𝜏 directly dictates the trade-off between classification speed and accuracy, we treat it as a tunable hyperparameter; a detailed sensitivity analysis of its impact is provided in Section 6.4. A key metric is Earliness (E), measuring the number of packets needed before the model reaches the confidence threshold and a correct prediction is made; across a batch or test set, we report the maximum earliness observed over all correctly classified flows, representing the worst-case detection delay. Lower values indicate faster, more efficient classification, which is crucial for real-time intrusion detection. At the threshold point, Top-1 Accuracy (A), i.e., the percentage of correctly classified flows, False Negative Rate (FNR), i.e., the proportion of attack flows that are incorrectly classified as benign, and False Alarm Rate (FAR), i.e., the proportion of benign flows mistakenly classified as attacks, are also calculated. A high FNR is particularly concerning, as undetected attacks pose a severe security risk. Respectively, minimizing FAR is essential to prevent unnecessary security alerts, which can lead to operational inefficiencies and desensitization to genuine threats. Lastly, the Early Risk Detection Error (ERDE) [17] is utilized, a metric that evaluates both the correctness of the model’s predictions and the delay in reaching a decision. ERDE is a parametric metric; flows requiring more than 𝑜 packets for accurate classification incur a higher penalty. Given a flow 𝐹 ∈ F , it is computed as follows: 𝑇𝑃 | F| 1 ERDE𝑜 (𝐹 ) = 1 1 − 1+exp(𝑡 d −𝑜 ) 0
if 𝐹 is a False Positive if 𝐹 is a False Negative if 𝐹 is a True Positive if 𝐹 is a True Negative
where 𝑇 𝑃 denotes the number of True Positives, and 𝑡 d represents the number of packets required to correctly classify a malicious flow, i.e., the flow’s earliness. Manuscript submitted to ACM
A-THENA
23 Table 4. Summary of Positional Encoding Mechanisms
Category
Encoding
Learnable
Parameter Count
Input Type — discrete index discrete index discrete index discrete index discrete index discrete index
NonTime-Aware
None Embedding Convolutional Global Relative Sinusoidal Fourier RoPE
✗ ✓ ✓ ✓ ✗ ✓ ✗
0 𝑑𝑚 · 𝑁 = 240 𝑑𝑚 · (𝐾 · 𝑑 + 1) = 10760 𝑁 · 𝑑ℎ = 240 0 𝑑𝑚 /2 = 4 0
Time-Aware (Related Work)
GTID [19] FATA [72] Time2Vec [44] CTLPE [29] Chrono [75]a PEA [47]
✗ ✓ ✓ ✓ ✓ ✗
0 3 2 · 𝑑𝑚 = 16 2 · 𝑑𝑚 = 16 2 · 𝑑𝑚 = 16 0
index + Δ𝑡 index + timestamp continuous timestamp continuous timestamp timestamp + Δ𝑡 continuous timestamp
Time-Aware (A-THENA)
TA Sinusoidal TA Fourier TA RoPE
✗ ✓ ✗
0 𝑑𝑚 /2 = 4 0
continuous timestamp continuous timestamp continuous timestamp
a Parameter count assumes an MLP with one fully-connected layer for relative embeddings; exact size
may vary.
5.3.2 Resource-Constrained Deployment Evaluation. Beyond classification performance, the feasibility of deploying the proposed system on resource-limited edge devices is also assessed. To simulate real-world IoT applications, the system is deployed on the Raspberry Pi Zero 2 W, a compact, low-power embedded device featuring a 1GHz quad-core 64-bit ARM Cortex A53 processor and 512 MB of RAM, commonly used in IoT environments. This evaluation measures two key factors: • Latency: The time required for the model to process and classify a flow. Low latency is essential for real-time intrusion detection. • Memory Requirements: The system’s RAM and storage footprint, which determines whether it can be deployed on constrained IoT devices without excessive resource consumption. The Raspberry Pi Zero 2 W serves as an ideal test platform, as its limited processing power and memory reflect the constraints of real-world IoT deployments. By validating the system’s efficiency in such an environment, its suitability for lightweight cybersecurity applications is demonstrated. 6
RESULTS
This section provides a detailed analysis of our evaluation results, highlighting the effectiveness of our approach in comparison to existing methods. 6.1
Comparison Methods
The proposed system is evaluated against a diverse range of methods, organized into four comparison groups. Table 4 provides a unified comparison of all evaluated encoding mechanisms, detailing their input types, learnability, and parameter complexity. Conceptual descriptions and novelty contrasts for each method are presented in Section 2; this Manuscript submitted to ACM
24
I. Panopoulos et al. Table 5. Hyperparameters for Traditional Machine Learning Baselines
Algorithm
Hyperparameter
Naive Bayes
-
Logistic Regression (LR)
regularization (𝐶) max iterations
k-Nearest Neighbors (kNN)
neighbors (𝑘) metric weights
Support Vector Machine (SVM)
kernel regularization (𝐶)
Multi-Layer Perceptron (MLP)
hidden layers activation
CICIoT23-WEB
MQTT-IoT-IDS2020
IoTID20
-
-
-
0.1 2000
0.1 2000
0.1 2000
7 Euclidean distance
3 Euclidean distance
9 Euclidean distance
RBF 10
RBF 0.1
RBF 10
(64, 32) ReLU
(64, 32) ReLU
(64, 32) ReLU
Random Forest (RF)
estimators max depth
50 10
10 10
10 10
XGBoost
estimators eval metric
50 logloss
10 logloss
10 logloss
subsection focuses on the experimental rationale for each group and any implementation-specific details required for reproducibility. 6.1.1 Non-Time-Aware Positional Encodings. We include seven traditional positional encoding mechanisms (top section of Table 4) to quantify the benefit of temporal awareness by establishing a positional-information baseline. These methods—No Encoding, Embedding, Convolutional (𝐾=3, 𝑑𝑚 filters), Global Relative [22, 60], Sinusoidal, Fourier, and RoPE—all operate on discrete indices and are detailed conceptually in Subsection 2.2.1. Each encoding is integrated into the same base Transformer architecture (Section 3.3.1), augmentation pipeline, and EDL training objective used by A-THENA, ensuring that observed differences are attributable solely to the positional encoding mechanism. 6.1.2 Traditional Machine Learning Baselines. To contextualize A-THENA’s raw-traffic approach against the established feature-engineering paradigm (see Subsection 2.1.1), we compare against seven classical algorithms: Naive Bayes, Logistic Regression, kNN, SVM, MLP, Random Forest, and XGBoost. For these methods, we extract 77 statistical features from network flows using CICFlowMeter-V4.0 [33], following standard practice in cybersecurity research [53, 56]. Features include packet count, statistical measures of packet lengths in both directions, TCP flag counts, and flow active time, with standard preprocessing (categorical-to-numerical conversion and standardization). Table 5 presents the hyperparameters selected for each algorithm and dataset following systematic tuning, balancing model complexity with classification performance. 6.1.3 Time-Aware Encodings from Related Work. Six recent time-aware encodings (middle section of Table 4) are included to benchmark A-THENA’s temporal representation against the most relevant prior work. The conceptual motivation, mathematical formulations, and novelty contrasts for each method—GTID, FATA, Time2Vec, CTLPE, ChronoFormer, and PEA—are presented in Subsection 2.2.2. To ensure a fair comparison, we integrate each encoding Manuscript submitted to ACM
A-THENA
25 Table 6. Performance of Non-Time-Aware Encoding Mechanisms
Encoding Method
A
CICIoT23-WEB E FAR FNR ERDE5
A
MQTT-IoT-IDS2020 E FAR FNR ERDE5
A
E
IoTID20 FAR FNR
ERDE5
None Embedding Convolutional Global Relative
70.80 83.19 79.20 83.19
1 8 2 3
100.0 60.31 100.0 100.0
0.0 0.0 0.0 0.0
0.152 0.134 0.157 0.167
89.35 90.68 92.00 93.33
30 5 1 3
19.93 19.93 20.10 13.29
0.0 0.0 0.0 0.0
0.045 0.052 0.046 0.036
80.28 85.37 89.25 84.66
30 30 30 30
0.0 0.0 0.0 0.0
1.41 2.56 0.96 1.60
0.124 0.257 0.328 0.179
Sinusoidal Fourier RoPE
86.73 88.94 77.88
2 2 1
20.63 49.21 100.0
0.0 0.0 0.0
0.044 0.086 0.153
92.58 95.01 93.99
4 5 1
14.78 12.46 13.29
0.0 0.0 0.0
0.042 0.046 0.035
79.41 85.73 87.67
30 30 30
0.0 0.0 0.0
5.70 3.07 2.94
0.199 0.304 0.297
TA Sinusoidal TA Fourier TA RoPE
100.0 100.0 83.19
1 4 7
0.0 0.0 0.0
0.0 0.0 0.0
0.015 0.059 0.029
96.69 100.0 100.0
3 1 4
0.0 0.0 0.0
0.0 0.0 0.0
0.017 0.014 0.021
69.16 87.67 93.83
30 30 30
0.0 0.0 0.0
19.46 1.41 1.34
0.409 0.245 0.422
A-THENA
100.0
1
0.0
0.0
0.015
100.0
1
0.0
0.0
0.014
93.83
30
0.0
1.34
0.422
into our base Transformer architecture (Section 3.3.1), utilizing the identical augmentation pipeline and EDL objective. Specifically, we reimplement only the encoding component rather than the full architectures from the original studies, isolating the impact of temporal representation. For ChronoFormer’s relative component, we employ the simplest possible MLP—one fully connected layer—that maps each Δ𝑡 to a vector of dimensionality 𝑑 m . 6.1.4 Early Intrusion Detection Architectures. We compare against four neural network architectures proposed for early intrusion detection [3–5, 24]: eRNN, eTransformer, eAtt, and eGlo (see Subsection 2.1.3 for conceptual context). These models represent alternative architectural approaches to early detection but do not utilize packet timestamps, allowing us to assess both the architectural efficiency of A-THENA’s lightweight design and the specific contribution of time-aware representation learning to early threat identification. 6.2
Detection Performance Evaluation
This subsection presents a comprehensive evaluation of A-THENA across three IoT intrusion detection datasets, assessing both its accuracy and its ability to provide timely predictions under the confidence-based early detection framework described in Section 5.3.1. For each model and baseline, we report Top-1 Accuracy (A, in percentage), Earliness (E, in packets), False Alarm Rate (FAR, in percentage), False Negative Rate (FNR, in percentage), and the Early Risk Detection Error computed on the first 5 packets (ERDE5 ), all evaluated at a confidence threshold of 𝜏 = 0.95, which we select based on the sensitivity analysis in Section 6.4, as it provides near-optimal accuracy while maintaining minimal impact on detection latency. 6.2.1 Non-Time-Aware Encoding Baselines. Table 6 presents a comparative performance analysis of traditional non-timeaware positional encodings versus the proposed time-aware variants across the three evaluated datasets. The results reveal distinct dataset-specific trends, highlighting the importance of evaluating intrusion detection systems on diverse network scenarios. Specifically, CICIoT23-WEB shows the highest variability in performance across encoding methods, suggesting that encoding effectiveness depends heavily on the attack types present. In contrast, MQTT-IoT-IDS2020 demonstrates more stable performance, indicating reduced sensitivity to encoding variations, while IoTID20 highlights the importance of handling longer network flows, as its attack complexity necessitates extended packet sequences for accurate detection. Manuscript submitted to ACM
26
I. Panopoulos et al. Table 7. Five-Fold Cross-Validation Results Across Datasets
Metric Validation Loss
TA Sinusoidal TA Fourier TA RoPE
CICIoT23-WEB
MQTT-IoT-IDS2020
IoTID20
2.24 × 10 −7 ± 4.1 × 10−9
1.80 × 10 −6 ± 3.2 × 10−8
3.85 × 10 −7 ± 5.6 × 10−9 3.69 × 10 −6 ± 7.5 × 10−8
9.85 × 10 −8 ± 1.4 × 10−9 1.03 × 10 −6 ± 2.1 × 10−8
7.37 × 10 −2 ± 1.9 × 10−3 6.40 × 10 −2 ± 1.6 × 10−3 5.48 × 10 −2 ± 1.3 × 10−3
99.87 ± 0.05 1.2 ± 0.4 0.08 ± 0.12 0.03 ± 0.05 0.017 ± 0.005
100.0 ± 0.00 1.6 ± 0.8 0.00 ± 0.00 0.00 ± 0.00 0.013 ± 0.003
94.41 ± 0.22 30.0 ± 0.0 0.11 ± 0.10 1.62 ± 0.21 0.488 ± 0.012
Accuracy Earliness FAR FNR ERDE5
A-THENA’s time-aware hybrid encoding consistently yields the highest accuracy across all evaluated datasets, underscoring its effectiveness in modeling the temporal dynamics of network traffic. In contrast, traditional positional encodings perform notably worse, with A-THENA achieving accuracy gains of 11.06, 4.99, and 4.58 percentage points over the best non-time-aware alternatives on CICIoT23-WEB, MQTT-IoT-IDS2020, and IoTID20, respectively. This performance gap can be attributed to the inability of conventional encodings to account for irregular packet inter-arrival times, which carry critical discriminative information for detecting anomalies in IoT traffic. Among the non-time-aware baselines, models without any positional encoding perform particularly poorly on CICIoT23-WEB (70.80% accuracy), demonstrating that some form of positional information is essential. Learned positional encodings (Embedding and Convolutional) show mixed results, with the Convolutional approach achieving strong performance on IoTID20 (89.25% accuracy) but struggling on CICIoT23-WEB (79.20%). The classical functionbased encodings (Sinusoidal, Fourier, RoPE) generally outperform learned approaches, with Fourier encoding reaching 95.01% accuracy on MQTT-IoT-IDS2020, yet still falling short of time-aware variants. Notably, Global Relative encoding, which incorporates relative positional relationships, achieves competitive accuracy (93.33% on MQTT-IoT-IDS2020) but cannot match the temporal precision provided by time-aware methods. Moreover, FAR values drop to 0% across all datasets when using time-aware variants, eliminating unnecessary alerts and stabilizing early prediction behavior. While ERDE5 scores do not always align directly with accuracy, this discrepancy primarily reflects differences in earliness rather than model uncertainty, consistent with observations that marginal variations in earliness have limited operational impact on end-to-end latency (see Subsection 6.3.2). The final model for A-THENA for each dataset is selected based on the lowest validation loss, as reported in Table 7. Each dataset converges to a different time-aware encoding variant—sinusoidal for CICIoT23-WEB, Fourier for MQTT-IoT-IDS2020, and RoPE for IoTID20—further confirming the importance of A-THENA’s hybrid encoding design. Rather than relying on a single temporal representation, A-THENA flexibly adapts to the temporal characteristics of each dataset, enabling optimal performance across diverse IoT traffic patterns. The distinct selection of encodings demonstrates that no single temporal mechanism is universally optimal; instead, the hybrid design allows the model to exploit dataset-specific temporal structures, ultimately yielding the strongest accuracy, FAR/FNR, and earliness trade-offs observed in our experiments. Interpretation of Perfect Accuracy Results. Careful and nuanced interpretation is required by the perfect test-set accuracy reported for CICIoT23-WEB and MQTT-IoT-IDS2020. This outcome is driven by several factors: (1) the attacks in these datasets exhibit strong temporal regularities that are effectively captured by the time-aware encodings; (2) Manuscript submitted to ACM
A-THENA
27
CICIoT23-WEB
Top-1 Confidence (%)
100 95
95
90
90 A-THENA Sinusoidal (Non-time-aware) k = 1 (identical temporal input)
85 80
MQTT-IoT-IDS2020
100
1
5
10 15 20 Number of Packets Observed
25
30
A-THENA Fourier (Non-time-aware) k = 1 (identical temporal input)
85 80
1
5
10 15 20 Number of Packets Observed
25
30
Fig. 4. Prediction confidence trajectories as the number of observed packets (𝑘) increases. The plots contrast A-THENA against corresponding non-time-aware baselines for a representative Backdoor Malware attack (left) and an MQTT Brute-Force attack (right).
the distinction between benign and malicious flows is substantial, leading to limited intra-class variability; and (3) the combined use of raw packet payloads and temporal information yields highly discriminative flow representations. To verify that such results are not artifacts of overfitting or data leakage, Table 7 reports the corresponding 5-fold cross-validation outcomes. As shown, the cross-validation metrics are closely aligned with the final test-set performance and exhibit extremely low variance across folds, supporting that the perfect accuracy achieved on these datasets reflects genuine model robustness rather than memorization. Interpretability of Early Predictions (E = 1). Our early detection analysis reveals a counterintuitive result: A-THENA achieves perfect accuracy at E = 1 on CICIoT23-WEB and MQTT-IoT-IDS2020, where only the first packet is observed. Since the first packet’s timestamp is normalized to 𝑡 0 = 0, both time-aware and non-time-aware models receive identical temporal input at inference, meaning time cannot serve as a direct discriminative feature at this step. The performance gap at E = 1 therefore reflects a powerful training-time inductive bias rather than an inference-time artifact. During training, the model processes full sequence lengths up to 𝑁 = 30, allowing self-attention to propagate temporal information from later packets back to earlier representations. This is analogous to how a language model trained on full sentences learns richer, more contextualized single-word representations than one trained on isolated tokens; the temporal context seen during training shapes the embedding space even when that context is absent at inference. Figure 4 provides direct visual evidence of this effect. It shows the top-1 confidence trajectory as a function of packets observed (𝑘) for a representative Backdoor Malware flow from CICIoT23-WEB and an MQTT Brute-Force flow from MQTT-IoT-IDS2020, comparing A-THENA against the best-performing non-time-aware baseline on each dataset. At 𝑘 = 1, A-THENA already exhibits markedly higher confidence than the non-time-aware baseline on both datasets, despite both models receiving identical input at that step. Furthermore, A-THENA’s confidence curve is notably more stable across subsequent packets, reflecting the more discriminative and temporally coherent representations learned through time-aware training. These observations confirm that time-aware encodings improve performance primarily through better learned representations rather than direct exploitation of timestamp values at inference. 6.2.2 Comparison with Traditional Machine Learning. Table 8 compares A-THENA against seven classical machine learning algorithms operating on hand-crafted statistical features. The results demonstrate A-THENA’s substantial superiority over all traditional machine learning baselines across the three datasets. On CICIoT23-WEB, A-THENA achieves perfect 100% accuracy, outperforming the best traditional method (Random Forest at 93.81%) by 6.19 percentage points. The performance gap widens dramatically for simpler classifiers: Naive Bayes manages only 43.36% accuracy, while Logistic Regression and MLP achieve 75.22% and 73.89%, respectively. On MQTT-IoT-IDS2020, A-THENA again Manuscript submitted to ACM
28
I. Panopoulos et al. Table 8. Comparison With Feature-Based Methods
Encoding Method
A
CICIoT23-WEB E FAR FNR
ERDE5
A
MQTT-IoT-IDS2020 E FAR FNR ERDE5
A
E
IoTID20 FAR FNR
ERDE5
Naive Bayes LR kNN SVM MLP Random Forest XGBoost
43.36 75.22 80.09 81.86 73.89 93.81 82.74
1 30 30 30 30 30 30
0.0 42.86 46.03 33.33 46.03 0.0 0.0
0.0 0.0 0.0 0.0 0.61 0.0 12.27
0.006 0.616 0.429 0.612 0.674 0.666 0.265
92.80 97.61 93.19 96.86 97.57 98.85 98.01
1 29 12 30 30 30 30
3.99 7.97 8.14 11.96 7.97 1.99 9.80
3.49 0.0 0.0 1.02 0.0 0.0 0.0
0.048 0.580 0.151 0.448 0.509 0.140 0.759
40.72 86.90 68.65 89.65 88.33 90.11 89.25
1 30 30 30 30 30 30
93.25 16.75 69.00 10.00 11.75 1.25 6.75
4.35 1.79 1.41 0.42 1.66 6.66 1.54
0.135 0.715 0.299 0.655 0.581 0.593 0.806
A-THENA
100.0
1
0.0
0.0
0.015
100.0
1
0.0
0.0
0.014
93.83
30
0.0
1.34
0.422
Table 9. Comparison With Related Work
Encoding Method
A
CICIoT23-WEB E FAR FNR
ERDE5
A
MQTT-IoT-IDS2020 E FAR FNR ERDE5
A
E
IoTID20 FAR FNR
ERDE5
GTID [19] FATA [72] Time2Vec [44] CTLPE [29] Chrono [75] PEA [47]
87.17 83.19 88.94 80.97 83.19 72.12
7 5 5 24 11 30
0.0 0.0 66.67 57.14 33.33 82.54
0.0 20.25 0.0 3.07 13.50 0.0
0.031 0.054 0.134 0.136 0.185 0.138
92.84 95.01 97.48 94.30 96.82 92.89
30 5 30 2 30 30
13.95 9.97 10.13 14.29 7.97 15.61
1.02 0.0 0.0 0.0 0.0 0.0
0.152 0.057 0.149 0.037 0.191 0.086
78.64 88.33 88.89 84.45 75.94 78.24
30 30 30 30 30 30
12.25 0.0 1.75 3.25 0.0 0.0
5.25 0.0 1.47 0.45 2.50 1.47
0.139 0.103 0.084 0.078 0.200 0.150
eRNN [3] eTransformer [24] eAtt [4] eGlo [5]
86.73 91.59 89.82 88.05
17 30 3 2
19.05 0.0 19.05 28.57
0.0 0.0 0.0 0.0
0.090 0.111 0.047 0.054
94.83 95.58 95.23 89.35
6 3 1 1
18.44 11.13 19.10 33.39
0.0 0.0 0.0 0.0
0.058 0.033 0.045 0.067
91.34 85.58 89.30 82.31
30 30 30 3
0.0 0.0 0.0 0.0
0.0 0.45 0.0 4.16
0.159 0.094 0.181 0.053
A-THENA
100.0
1
0.0
0.0
0.015
100.0
1
0.0
0.0
0.014
93.83
30
0.0
1.34
0.422
reaches perfect accuracy, surpassing the strongest baseline (Random Forest at 98.85%) by 1.15 points. For IoTID20, A-THENA achieves 93.83% accuracy, exceeding the best traditional method (Random Forest at 90.11%) by 3.72 percentage points. Among the traditional approaches, ensemble methods consistently outperform individual classifiers. Random Forest emerges as the strongest baseline across all datasets, achieving competitive accuracy and maintaining low false alarm rates on CICIoT23-WEB (0% FAR) and MQTT-IoT-IDS2020 (1.99% FAR). However, it struggles with IoTID20’s complex attacks, producing a notably high 6.66% FNR—meaning approximately one in fifteen attacks would go undetected. XGBoost demonstrates comparable accuracy but exhibits inconsistent false detection rates, including an alarming 12.27% FNR on CICIoT23-WEB and elevated FAR values across datasets. A crucial observation concerns the earliness metric: almost all traditional ML methods require complete flows (30 packets) for confident classification, as feature extraction necessitates computing statistical aggregates over entire sessions. In stark contrast, A-THENA achieves confident predictions from just a single packet on CICIoT23-WEB and MQTT-IoT-IDS2020. This fundamental architectural difference—processing raw packets sequentially versus extracting session-level statistics—enables A-THENA to identify threats at the earliest possible moment, a capability that featurebased approaches cannot match. 6.2.3 Time-Aware Encoding Mechanisms. Table 9 (top section) summarizes the performance of the six time-aware positional encoding mechanisms drawn from related work. Across all datasets, A-THENA’s hybrid encoding delivers Manuscript submitted to ACM
A-THENA
29
the highest overall effectiveness. Among the competing approaches, Time2Vec stands out as the strongest baseline. On CICIoT23-WEB, A-THENA outperforms Time2Vec by 11.06 percentage points while avoiding the latter’s exceptionally high false alarm rate of 66.67%. On MQTT-IoT-IDS2020, A-THENA achieves perfect accuracy with zero false alarms, surpassing Time2Vec’s accuracy of 97.48%. On IoTID20, it further improves upon Time2Vec by an additional 4.94 percentage points. Among related methods, performance varies substantially. GTID and FATA show strengths on individual datasets but suffer from high false detection rates or inconsistent behavior across benchmarks. Time2Vec achieves competitive accuracy but consistently exhibits elevated FAR values that limit practical usability. CTLPE and Chrono demonstrate moderate performance but struggle with inconsistent earliness or degraded accuracy on at least one dataset. PEA, which injects temporal information at the output rather than the input or attention layers, underperforms across all benchmarks. Overall, related encodings often trade accuracy for high false detection rates or unstable earliness. In contrast, A-THENA uniquely combines high accuracy with 0% FAR on all datasets, demonstrating that integrating time-awareness directly into the input representation and attention computation provides the most robust and reliable temporal modeling for IoT intrusion detection. 6.2.4 Comparison with Early Detection DL Architectures. Table 9 (bottom section) reports the performance results for four specialized neural network architectures explicitly designed for early intrusion detection: eRNN, eTransformer, eAtt, and eGlo. Critically, these models do not incorporate packet timestamps in their classification process, relying solely on packet content and sequence order. This comparison therefore isolates the contribution of temporal awareness versus purely architectural innovations for early threat identification. A-THENA demonstrates substantially stronger performance across all datasets, avoiding the critical trade-offs observed in competing architectures. On CICIoT23-WEB, it achieves an 8.41 percentage point improvement over the best alternative, eTransformer (91.59%), while maintaining zero false alarms. On MQTT-IoT-IDS2020, A-THENA surpasses the strongest baseline by 4.42 percentage points; in contrast, other fast-response models like eAtt and eGlo incur unacceptable FAR values of up to 33.39% to match A-THENA’s single-packet earliness. Similarly, on IoTID20, A-THENA secures a 2.49 percentage point gain over the closest competitor (eRNN), ensuring superior overall detection even as baselines like eAtt and eGlo sacrifice significant detection power to achieve comparable stability or speed. These results validate A-THENA’s core hypothesis: incorporating temporal information through time-aware encodings provides advantages that architectural innovations alone cannot replicate. While early detection architectures demonstrate that specialized designs can improve performance over general-purpose models, they fundamentally lack the temporal discriminability that timing patterns provide. By unifying a lightweight Transformer architecture with adaptive time-aware encodings, A-THENA achieves superior accuracy, earliness, and false detection rates—establishing a new standard for IoT intrusion detection systems.
6.3
Computational Efficiency and Deployment Feasibility
Beyond detection accuracy, the practical viability of an intrusion detection system in IoT environments depends heavily on its computational footprint and real-time responsiveness. Edge devices typically operate under strict constraints on model size, memory availability, and processing latency. This subsection evaluates A-THENA’s efficiency along these dimensions on a Raspberry Pi Zero 2 W, benchmarking it against both traditional feature-based machine learning pipelines and state-of-the-art deep learning architectures. Manuscript submitted to ACM
30
I. Panopoulos et al. Table 10. Model Complexity and Efficiency Comparison (𝑛 = 30)
Model
Size on Disk
Average Inference Latency
Average End-to-End Latency
Memory Footprint
Naive Bayes LR kNN SVM MLP Random Forest XGBoost
7.0 - 12.0 KB 4.0 - 6.5 KB 6.34 - 19.43 MB 2.84 - 8.86 MB 180.0 - 183.1 KB 163.1 - 793.2 KB 51.6 - 244.1 KB
2.48 ms 0.84 ms 7.69 ms 2.00 ms 1.54 ms 25.20 ms 3.66 ms
666.14 ms 664.50 ms 671.35 ms 665.66 ms 665.20 ms 688.86 ms 667.32 ms
4.98 MB 12.36 MB 17.63 MB 12.76 MB 9.62 MB 20.30 MB 17.74 MB
eRNN [3] eTransformer [24] eAtt [4] eGlo [5]
~211.5 KB ~4.9 MB ~68.5 KB ~74.3 KB
20.12 ms 35.79 ms 1.39 ms 0.57 ms
20.12 ms 35.79 ms 1.39 ms 0.57 ms
9.13 MB 7.96 MB 3.38 MB 3.25 MB
A-THENA
~40.0 KB
1.42 ms
1.42 ms
3.25 MB
Table 10 presents the storage requirements, latency, and runtime memory footprint for all models when classifying flows of 30 packets. Average latency values of ≤2 ms and memory footprints of ≤5 MB are shown in bold. Inference latency measurements correspond to the mean over 1,000 runs per model, while memory footprints include the overhead of the Python interpreter for LiteRT models and the scikit-learn execution environment for traditional ML baselines. Consequently, all memory values should be interpreted as approximate but reflective of realistic deployment conditions. 6.3.1 Overhead of Traditional Feature Extraction Pipelines. Table 10 highlights the dominant role of feature extraction in the computational overhead of traditional machine learning pipelines. Although feature-based classifiers exhibit fast inference once features are available—requiring only 0.84 ms for Logistic Regression and 2.00 ms for SVM—the CICFlowMeter preprocessing stage introduces an average delay of 664 ms for a 30-packet flow. This preprocessing cost overwhelmingly determines the end-to-end latency for all classical methods. Crucially, this 664 ms delay represents an inherent architectural limitation rather than an inefficiency of the classifiers themselves. Computing the 77 statistical features requires multiple passes over the full packet sequence, maintaining internal state, and performing aggregate computations. Even at the smallest scale, extracting features for single-packet flows still requires 290 ms on average, underscoring the intrinsic expense of the feature computation process. Memory usage further complicates deployment of traditional pipelines. Although feature extraction alone consumes a modest 3.45 MB, the total runtime memory required to compute features, load and execute the classifier reaches up to 20.30 MB for the most accurate model (Random Forest)—more than six times higher than A-THENA’s footprint. Storage requirements also vary significantly across datasets. Compact linear models remain small (4.0–6.5 KB for Logistic Regression and 7.0–12.0 KB for Naive Bayes), but instance-based methods scale poorly: kNN ranges from 6.34 to 19.43 MB depending on training set size, while SVM models range from 2.84 to 8.86 MB. This variability creates uncertainty for deployment planning, as storage must accommodate worst-case model sizes. Finally, the feature extraction paradigm fundamentally conflicts with the objective of early detection. Because statistical features are meaningful only after a sufficient number of packets have been observed, nearly all traditional classifiers require full 30-packet flows (E = 30 in Table 8) before producing a confident prediction. Metrics such as average packet length or directional traffic ratios cannot be inferred from the first few packets and as a result, even a Manuscript submitted to ACM
A-THENA
31
perfectly accurate classical classifier would still incur the 664 ms preprocessing delay and the requirement for complete flows, yielding detection latencies that are unsuitable for real-time IoT threat response. 6.3.2 Latency and Memory Footprint of Early Detection DL Architectures. Table 10 confirms that operating directly on raw packets eliminates the feature-extraction bottleneck. Because A-THENA and competing deep learning architectures ingest packet sequences directly, their end-to-end latency effectively converges with their inference time. This architectural advantage allows A-THENA to achieve detection speeds approximately 480× faster than feature-based pipelines, delivering a classification verdict before traditional methods have even finished computing the necessary flow statistics. A-THENA achieves a favorable combination of inference speed, compactness, and memory efficiency. With a latency of just 1.42 ms for 30-packet flows, the system supports near real-time threat detection with minimal operational delay. Its 40 KB storage size is the smallest among all evaluated deep learning models and substantially smaller than the storage demands of feature-based ensemble models. The 3.25 MB runtime memory footprint matches eGlo as the most memory-efficient solution, making A-THENA suitable for deployment on devices with tight memory budgets. Experimental measurements confirm that the system’s latency scales sub-linearly with sequence length: a single-packet flow requires only 0.17 ms, indicating that input length has minimal impact on runtime. Latency remains consistent across all positional encodings tested, with differences below 0.05 ms—within expected measurement variation. Instead, latency is largely determined by model size, underscoring the importance of A-THENA’s compact architectural design. Compared to other early-detection architectures, A-THENA provides a superior balance of accuracy, speed, and resource usage. While eGlo and eAtt offer fast inference, their representational capacity is insufficient to achieve high accuracy across all datasets. Conversely, larger models such as eTransformer deliver greater capacity at the cost of significantly higher latency and memory overhead. A-THENA’s hybrid temporal encoding and lightweight architecture allow it to maintain low latency without compromising detection performance. These findings establish A-THENA as well-suited for resource-constrained IoT environments. By removing the feature extraction stage, maintaining a compact 40 KB footprint, operating with only 3.25 MB of memory, and achieving 1.42 ms inference latency, our system meets the stringent efficiency demands of edge deployments. It achieves ordersof-magnitude faster processing than traditional ML pipelines and matches or exceeds the efficiency of specialized early-detection models while simultaneously delivering the highest accuracy, earliest detection, and lowest false detection rates across all evaluated datasets. 6.4
Sensitivity Analysis of Confidence Threshold
To evaluate A-THENA ’s flexibility, we analyze the impact of the confidence threshold 𝜏. Figure 5 shows how varying 𝜏 ∈ [0.50, 0.99] affects the Accuracy–Earliness trade-off (left) and the fraction of flows that do not reach the threshold before reaching the maximum sequence length (right). The left panel highlights the trade-off between detection speed and accuracy, most evident in the IoTID20 dataset. Lower thresholds (e.g., 𝜏 ≤ 0.60) enable rapid decisions (within 15 packets) but limit accuracy to about 88.9%. The relationship is not strictly monotonic: a slight accuracy dip appears for 𝜏 ∈ [0.65, 0.75], likely due to ambiguous intermediate packets. Higher thresholds (𝜏 ≥ 0.85) force the model to wait for later packets, resolving ambiguity and achieving peak accuracy (93.83% at 𝜏 = 0.95). In contrast, CICIoT23-WEB and MQTT-IoT-IDS2020 exhibit near-perfect accuracy with single-packet earliness for 𝜏 ≤ 0.95, with only minor degradation at extreme thresholds. The right panel shows that overly high thresholds introduce instability. While 𝜏 ≤ 0.95 is consistently reached, extreme values (𝜏 ≥ 0.98) Manuscript submitted to ACM
32
I. Panopoulos et al.
Accuracy (%)
97.5
= 0.98, 0.99 = 0.98, 0.99
0.95
95.0
= 0.95, 0.98, 0.99
92.5 90.0
= 0.55, 0.60
87.5 85.0
= 0.90
= 0.85
= 0.50
1
3
5
= 0.80 = 0.75
= 0.65, 0.70
15 18 Earliness
27
Flows Never Reaching (%)
0.95
100.0
30
35 30 25 20 15 10 5 0
CICIoT23-WEB MQTT-IoT-IDS2020 IoTID20
0.5
0.6
0.7 0.8 Confidence Threshold
0.9
1.0
Fig. 5. Sensitivity analysis of the confidence threshold (𝜏). The left panel illustrates the trade-off between classification accuracy and earliness (in packets) as 𝜏 varies. The right panel displays the percentage of network flows that fail to reach the target confidence threshold within the maximum sequence length limit (𝑁 = 30) for each 𝜏 value.
0 2 4 6 8 10 12 14 Key Packet Index
0 2 4 6 8 10 12 14 Key Packet Index
0 4 8 12 16 20 24 28
Query Packet Index
0 2 4 6 8 10 12 14
Mirai HTTP Flooding Example (n=30) RoPE (Non-time-aware) A-THENA
Query Packet Index
0 2 4 6 8 10 12 14
Query Packet Index
Query Packet Index
Host & Port Scan Example (n=15) RoPE (Non-time-aware) A-THENA
0 4 8 12 16 20 24 28 Key Packet Index
0 4 8 12 16 20 24 28
1.0 0.8 0.6 0.4 0.2
0 4 8 12 16 20 24 28 Key Packet Index
0.0
Fig. 6. Attention weight heatmaps comparing A-THENA (TA RoPE) and RoPE on two representative flows from IoTID20. (Left pair) Host & Port Scan flow (𝑛 = 15). (Right pair) Mirai HTTP Flooding flow (𝑛 = 30).
in IoTID20 lead to up to 33% of flows failing to meet the threshold within 30 packets. These cases revert to full-sequence predictions, increasing delay and slightly reducing accuracy. Overall, 𝜏 = 0.95 provides the best balance, maximizing accuracy while avoiding instability. Lowering 𝜏 offers negligible practical benefit, as full-sequence processing latency is only 1.42 ms on a Raspberry Pi Zero 2 W (Section 6.3.2). Thus, prioritizing accuracy is preferable. Ultimately, 𝜏 serves as a highly adaptable hyperparameter. Practitioners can dynamically tune the threshold to match specific network constraints—lowering it for ultra-low-latency environments where microsecond-level reactions are critical, or maintaining it at strict levels to ensure near-zero false alarms in sensitive deployments. 6.5
Case Studies: Visualizing Temporal Attention Dynamics
To provide further insight into the behavior of the proposed Time-Aware Hybrid Encoding, we present two representative case studies from the IoTID20 dataset, visualizing the self-attention patterns learned by A-THENA and the respective nontime-aware baseline (RoPE). Figure 6 shows the attention weight matrices for two attack scenarios with different temporal characteristics. These case studies demonstrate that A-THENA leverages time-aware encodings to fundamentally reshape attention dynamics, enabling clearer separation of temporal patterns and more interpretable behavior. Case Study 1: High-Frequency Bursts. The left two panels of Figure 6 depict a 15-packet sequence from a Host & Port Scan attack. This attack is characterized by a rapid burst of reconnaissance packets (indices 5 through 11) sent with Manuscript submitted to ACM
33
30
80
25
40
20 FAR (%)
Earliness
60
CICIoT23-WEB
15 10
100
1.0
80
0.8
60
0.6
ERDE5
100
40
5
20
0.2
0
0
0
0.0
100
30
80
25
10
0
0
100
30
80
25
40 20
NA NoTA NoA
E A-TH
CE
NT
QUA
20 15 10
0
80
0.8
60
0.6
40
0.2
0
0.0
100
1.0
80
0.8
60
0.6
40 20
ENA NoTA NoA A-TH
CE
NT QUA
0.4
20
IoTID20
5
0
1.0
ERDE5
5
100
ERDE5
15
20
60
FAR (%)
40
20
FNR (%)
Earliness
60
MQTT-IoT-IDS2020
A-THENA A-THENA Ablations
0.4
20
Earliness
Accuracy (%)
Accuracy (%)
Accuracy (%)
A-THENA
0.4 0.2
0
NA NoTA NoA
E A-TH
CE
NT QUA
0.0
NA NoTA NoA
E A-TH
CE
NT QUA
Fig. 7. Impact of augmentation, EDL, and quantization on A-THENA’s performance.
near-zero inter-arrival times. While both models recognize the malicious payloads within this window, their attention distributions differ significantly. RoPE produces a diffuse, block-like pattern over the burst, treating packets as merely sequential. In contrast, A-THENA exploits the near-zero inter-arrival times, sharply anchoring attention to the burst onset and forming a more structured representation of the attack. Case Study 2: Periodic / Delayed Attacks. The right two panels of Figure 6 illustrate a 30-packet sequence from a Mirai HTTP Flooding attack, characterized by periodic malicious requests separated by deliberately long temporal gaps (e.g., indices 0, 10, 20, and 29). Under RoPE, attention is diluted across the full 30-packet sequence, yielding a near-uniform distribution; although the model captures "Keep-Alive" payloads, it cannot leverage timing gaps, resulting in noisy, unstructured attention. In contrast, A-THENA encodes these gaps as larger positional distances, causing these packets to emerge as temporal outliers. This produces a sharp grid-like pattern, where periodically delayed packets attend strongly to the initial connection and to each other, effectively capturing the attack’s temporal signature. Manuscript submitted to ACM
34
I. Panopoulos et al. Table 11. Quantization Benefits
6.6
System
Latency Speedup
Memory Reduction
eRNN [3] eTransformer [24] eAtt [4] eGlo [5]
0.86× 1.52× 1.43× 1.25×
1.04× 1.77× 1.08× 1.13×
A-THENA
1.37×
1.00×
Ablation Study: Dissecting A-THENA’s Components
This subsection examines the core design components of A-THENA, including the online augmentation pipeline, the Early Detection Loss (EDL) function, and the impact of quantization. To analyze the role of augmentation, NoTA (No Timestamp Augmentation) applies only packet augmentation, omitting the two time-aware techniques (Jitter Injection and Traffic Scaling). In contrast, NoA (No Augmentation) removes all five augmentation methods, providing a baseline for assessing the impact of online data augmentation on early intrusion detection. The CE (Cross-Entropy) variant replaces A-THENA’s EDL loss function with a traditional cross-entropy loss, allowing an evaluation of the effectiveness of loss-based optimization for early detection. Lastly, QUANT applies post-training INT8 quantization, measuring the trade-off between model compression and detection performance. Figure 7 summarizes the performance of A-THENA and its ablated variants across all three datasets, illustrating the contribution of each component to the overall system. The results strongly support the architectural choices underlying A-THENA, showing that every component materially enhances IoT intrusion detection effectiveness. In particular, incorporating time-aware augmentation yields substantial gains in accuracy and robustness, consistently outperforming packet-only augmentation. These findings highlight the importance of timestamp-aware transformations and specialized early-detection optimization for achieving reliable real-time intrusion detection in IoT settings. Quantization Analysis. Table 11 presents the effects of post-training INT8 quantization on both latency speedup and memory reduction for A-THENA and related work models. The results show that quantization mainly enhances latency performance for A-THENA, achieving a 1.37× improvement. However, no reduction in memory footprint is observed. This lack of memory reduction is likely due to the inherent memory overhead associated with the LiteRT runtime. Specifically, LiteRT’s memory arena, which manages intermediate tensors during model inference, imposes a fixed memory overhead. This overhead can be substantial, sometimes even exceeding the model’s own size. Consequently, irrespective of how compact the model is, this baseline memory requirement remains relatively constant, limiting potential memory savings through quantization. Among the evaluated architectures, the eTransformer model experiences the most significant benefits, achieving a latency speedup of 1.52× and a substantial memory reduction of 1.77×. Other architectures demonstrate comparatively marginal improvements in these metrics. The limited effectiveness of quantization for A-THENA can further be explained by its already compact Transformer architecture, which offers minimal scope for additional compression. Conversely, larger models like eTransformer, containing over one million parameters, substantially benefit from reducing high-precision weights to INT8, resulting in considerable memory and latency improvements. Additionally, the slight performance degradation observed in the eRNN model (0.86× latency speedup) implies that out-of-the-box post-training quantization may introduce inefficiencies in recurrent computations. Manuscript submitted to ACM
A-THENA 7
35
CONCLUSION
This study introduced A-THENA, an early intrusion detection system that advances time-aware modeling for IoT security. By combining a hybrid positional encoding mechanism, a tailored augmentation strategy, and a custom loss function, the system captures fine-grained temporal signatures that characterize malicious behavior. Treating packet flows as non-uniform time series enables A-THENA to mitigate temporal aliasing effects and learn timing patterns that traditional encodings overlook. Experimental results across multiple IoT-focused datasets confirm its effectiveness, achieving near-perfect detection performance with minimal false alarms, while deployments on edge hardware validate its suitability for resource-constrained environments. Compared to prior work on time-aware encodings, A-THENA offers a unified hybrid framework, improved cross-dataset generalization, and new insights into early-stage intrusion detection across heterogeneous IoT protocols. Although A-THENA demonstrates strong performance, several constraints remain that outline the boundaries of its current applicability. The approach depends on reliable packet timestamps, and environments with significant jitter or timestamp noise may require additional synchronization to ensure stable performance. Additionally, the adaptive flow aggregation strategy, while theoretically motivated, has not yet been stress-tested under extreme traffic loads, leaving its scalability beyond edge scenarios an open question. Furthermore, the system has not yet been evaluated against adversarial behaviors specifically crafted to manipulate temporal patterns, limiting guarantees on robustness. These constraints define natural directions for future research, including extending the framework to a broader spectrum of low-power platforms and increasingly hostile environments. References [1] Martín Abadi, Paul Barham, Jianmin Chen, Zhifeng Chen, Andy Davis, Jeffrey Dean, Matthieu Devin, Sanjay Ghemawat, Geoffrey Irving, Michael Isard, et al. 2016. TensorFlow: A System for Large-Scale Machine Learning. In 12th USENIX Symposium on Operating Systems Design and Implementation (OSDI 16). 265–283. [2] Iram Abrar, Zahrah Ayub, Faheem Masoodi, and Alwi M Bamhdi. 2020. A Machine Learning Approach for Intrusion Detection System on NSL-KDD Dataset. In 2020 International Conference on Smart Electronics and Communication (ICOSEC). IEEE, 919–924. doi:10.1109/icosec49089.2020.9215232 [3] Tanwir Ahmad and Dragos Truscan. 2024. Early Detection with Explainability of Network Attacks Using Deep Learning. In 2024 IEEE International Conference on Software Testing, Verification and Validation Workshops (ICSTW). IEEE, 161–167. doi:10.1109/icstw60967.2024.00040 [4] Tanwir Ahmad, Dragos Truscan, and Jüri Vain. 2023. Preliminary Results in Using Attention for Increasing Attack Identification Efficiency. In 2023 IEEE International Conference on Software Testing, Verification and Validation Workshops (ICSTW). IEEE, 159–164. doi:10.1109/icstw58534.2023.00038 [5] Tanwir Ahmad, Dragos Truscan, Juri Vain, and Ivan Porres. 2022. Early Detection of Network Attacks Using Deep Learning. In 2022 IEEE International Conference on Software Testing, Verification and Validation Workshops (ICSTW). IEEE, 30–39. doi:10.1109/icstw55395.2022.00020 [6] Paul Aitken. 2013. Specification of the IP Flow Information Export (IPFIX) Protocol for the Exchange of Flow Information. Technical Report. RFC Editor. doi:10.17487/rfc7011 [7] Saleh Alabdulwahab, Young-Tak Kim, and Yunsik Son. 2024. Privacy-Preserving Synthetic Data Generation Method for IoT-Sensor Network IDS Using CTGAN. Sensors 24, 22 (Nov. 2024), 7389. doi:10.3390/s24227389 [8] Muhannad Almohaimeed and Faisal Albalwy. 2024. Enhancing IoT Network Security Using Feature Selection for Intrusion Detection Systems. Applied Sciences 14, 24 (Dec. 2024), 11966. doi:10.3390/app142411966 [9] Ayoob Almotairi, Samer Atawneh, Osama A. Khashan, and Nour M. Khafajah. 2024. Enhancing intrusion detection in IoT networks using machine learning-based feature selection and ensemble models. Systems Science & Control Engineering 12, 1 (March 2024), 2321381. doi:10.1080/21642583. 2024.2321381 [10] Philippe Biondi. 2024. Scapy: Packet Manipulation Tool. https://scapy.net. Accessed: April 24, 2026. [11] Nguyen Kim Hai Bui, Nguyen Duy Chien, Péter Kovács, and Gergő Bognár. 2025. Transformer Encoder and Multi-Features Time2Vec for Financial Prediction. In 2025 33rd European Signal Processing Conference (EUSIPCO). IEEE, 1682–1686. doi:10.23919/eusipco63237.2025.11226721 [12] Christian Callegari, Stefano Giordano, and Michele Pagano. 2024. A Real Time Deep Learning Based Approach for Detecting Network Attacks. Big Data Research 36 (May 2024), 100446. doi:10.1016/j.bdr.2024.100446 [13] Taki Eddine Toufik Djaidja, Bouziane Brik, Sidi Mohammed Senouci, Abdelwahab Boualouache, and Yacine Ghamri-Doudane. 2024. Early Network Intrusion Detection Enabled by Attention Mechanisms and RNNs. IEEE Transactions on Information Forensics and Security 19 (2024), 7783–7793. doi:10.1109/tifs.2024.3441862 Manuscript submitted to ACM
36
I. Panopoulos et al.
[14] Armando Domi, Christos Zonios, Giorgos Tatsis, Anastasios Drosou, and Dimitrios Tzovaras. 2025. NetPacketformer: Real-Time, Context-Aware Network Intrusion Detection with Transformers. In 2025 IEEE International Conference on Cyber Security and Resilience (CSR). IEEE, 687–692. doi:10.1109/csr64739.2025.11130136 [15] Yifan Fan, Hao Ma, Yiying Zhang, Siwei LI, Xiaoyan Guo, and Ben Wang. 2025. A DDoS attack detection method based on improved transformer and temporal feature enhancement. The Journal of Supercomputing 81, 8 (June 2025). doi:10.1007/s11227-025-07440-2 [16] Kaniz Farhana, Maqsudur Rahman, and Md. Tofael Ahmed. 2020. An intrusion detection system for packet and flow based networks using deep neural network approach. International Journal of Electrical and Computer Engineering (IJECE) 10, 5 (Oct. 2020), 5514. doi:10.11591/ijece.v10i5.pp5514-5525 [17] Diego Fernandez, Laura Vigoya, Fidel Cacheda, Francisco J. Novoa, Manuel F. Lopez-Vizcaino, and Victor Carneiro. 2018. A Practical Application of a Dataset Analysis in an Intrusion Detection System. In 2018 IEEE 17th International Symposium on Network Computing and Applications (NCA). IEEE, 1–5. doi:10.1109/nca.2018.8548316 [18] Mohamed Amine Ferrag, Mthandazo Ndhlovu, Norbert Tihanyi, Lucas C. Cordeiro, Merouane Debbah, Thierry Lestable, and Narinderjit Singh Thandi. 2024. Revolutionizing Cyber Threat Detection With Large Language Models: A Privacy-Preserving BERT-Based Lightweight Model for IoT/IIoT Devices. IEEE Access 12 (2024), 23733–23750. doi:10.1109/access.2024.3363469 [19] Xueying Han, Susu Cui, Song Liu, Chen Zhang, Bo Jiang, and Zhigang Lu. 2023. Network intrusion detection based on n-gram frequency and time-aware transformer. Computers & Security 128 (May 2023), 103171. doi:10.1016/j.cose.2023.103171 [20] Ramin Hasibi, Matin Shokri, and Mehdi Dehghan. 2019. Augmentation Scheme for Dealing with Imbalanced Network Traffic Classification Using Deep Learning. arXiv:1901.00204 [cs.NI] https://arxiv.org/abs/1901.00204 [21] Hanan Hindy, Ethan Bayne, Miroslav Bures, Robert Atkinson, Christos Tachtatzis, and Xavier Bellekens. 2021. Machine Learning Based IoT Intrusion Detection System: An MQTT Case Study (MQTT-IoT-IDS2020 Dataset). Springer International Publishing, 73–84. doi:10.1007/978-3-030-64758-2_6 [22] Cheng-Zhi Anna Huang, Ashish Vaswani, Jakob Uszkoreit, Ian Simon, Curtis Hawthorne, Noam Shazeer, Andrew M. Dai, Matthew D. Hoffman, Monica Dinculescu, and Douglas Eck. 2019. Music Transformer: Generating Music with Long-Term Structure. In 7th International Conference on Learning Representations, ICLR 2019. [23] Lei Huang, Jie Qin, Yi Zhou, Fan Zhu, Li Liu, and Ling Shao. 2023. Normalization Techniques in Training DNNs: Methodology, Analysis and Application. IEEE Transactions on Pattern Analysis and Machine Intelligence 45, 8 (Aug. 2023), 10173–10196. doi:10.1109/tpami.2023.3250241 [24] Md Mahbub Islam, Tanwir Ahmad, and Dragos Truscan. 2023. An Evaluation of Transformer Models for Early Intrusion Detection in Cloud Continuum. In 2023 IEEE International Conference on Cloud Computing Technology and Science (CloudCom). IEEE, 279–284. doi:10.1109/cloudcom59040.2023.00052 [25] Jinquan Ji, Yu Cao, Yukun Ma, and Jianzhuo Yan. 2025. TITD: enhancing optimized temporal position encoding with time intervals and temporal decay in irregular time series forecasting. Applied Intelligence 55, 6 (Feb. 2025). doi:10.1007/s10489-025-06293-9 [26] Xi Jiang, Shinan Liu, Aaron Gember-Jacobson, Arjun Nitin Bhagoji, Paul Schmitt, Francesco Bronzino, and Nick Feamster. 2024. NetDiffusion: Network Data Augmentation Through Protocol-Constrained Traffic Generation. Proceedings of the ACM on Measurement and Analysis of Computing Systems 8, 1 (Feb. 2024), 1–32. doi:10.1145/3639037 [27] Seyed Mehran Kazemi, Rishab Goel, Sepehr Eghbali, Janahan Ramanan, Jaspreet Sahota, Sanjay Thakur, Stella Wu, Cathal Smyth, Pascal Poupart, and Marcus Brubaker. 2019. Time2Vec: Learning a Vector Representation of Time. arXiv:1907.05321 [cs.LG] https://arxiv.org/abs/1907.05321 [28] Muhammad Almas Khan, Muazzam A. Khan, Sana Ullah Jan, Jawad Ahmad, Sajjad Shaukat Jamal, Awais Aziz Shah, Nikolaos Pitropakis, and William J. Buchanan. 2021. A Deep Learning-Based Intrusion Detection System for MQTT Enabled IoT. Sensors 21, 21 (Oct. 2021), 7016. doi:10.3390/s21217016 [29] Byunghyun Kim and Jae-Gil Lee. 2024. Continuous-Time Linear Positional Embedding for Irregular Time Series Forecasting. arXiv:2409.20092 [cs.LG] https://arxiv.org/abs/2409.20092 [30] Taehoon Kim and Wooguil Pak. 2022. Early Detection of Network Intrusions Using a GAN-Based One-Class Classifier. IEEE Access 10 (2022), 119357–119367. doi:10.1109/access.2022.3221400 [31] Diederik P. Kingma and Jimmy Ba. 2015. Adam: A Method for Stochastic Optimization. In International Conference on Learning Representations (ICLR). [32] Hermann Kopetz and Wilfried Steiner. 2022. Real-Time Systems: Design Principles for Distributed Embedded Applications. Springer Nature, Chapter Internet of Things, 325–341. [33] Arash Habibi Lashkari, Gerard Draper-Gil, Mohammad Saiful Islam Mamun, and Ali A. Ghorbani. 2018. CICFlowMeter (formerly ISCXFlowMeter): a network traffic bi-flow generator and analyser for anomaly detection. GitHub repository, https://github.com/ISCX/CICFlowMeter. Version V4.0. [34] Thi-Thu-Huong Le, Yustus Eko Oktian, and Howon Kim. 2022. XGBoost for Imbalanced Multiclass Classification-Based Industrial Internet of Things Intrusion Detection Systems. Sustainability 14, 14 (July 2022), 8707. doi:10.3390/su14148707 [35] Yang Li, Si Si, Gang Li, Cho-Jui Hsieh, and Samy Bengio. 2021. Learnable Fourier Features for Multi-dimensional Spatial Positional Encoding. In Advances in Neural Information Processing Systems, Vol. 34. 15816–15829. [36] Chang Liu, Ruslan Antypenko, Iryna Sushko, and Oksana Zakharchenko. 2022. Intrusion Detection System After Data Augmentation Schemes Based on the VAE and CVAE. IEEE Transactions on Reliability 71, 2 (June 2022), 1000–1010. doi:10.1109/tr.2022.3164877 [37] Willian Tessaro Lunardi, Martin Andreoni Lopez, and Jean-Pierre Giacalone. 2023. ARCADE: Adversarially Regularized Convolutional Autoencoder for Network Anomaly Detection. IEEE Transactions on Network and Service Management 20, 2 (June 2023), 1305–1318. doi:10.1109/tnsm.2022.3229706 [38] Manuel López-Vizcaíno, Francisco J. Novoa, Diego Fernández, Víctor Carneiro, and Fidel Cacheda. 2019. Early Intrusion Detection for OS Scan Attacks. In 2019 IEEE 18th International Symposium on Network Computing and Applications (NCA). 1–5. doi:10.1109/nca.2019.8935067 Manuscript submitted to ACM
A-THENA
37
[39] Yu Ma, Zhining Liu, Chenyi Zhuang, Yize Tan, Yi Dong, Wenliang Zhong, and Jinjie Gu. 2022. Non-stationary Time-aware Kernelized Attention for Temporal Event Prediction. In Proceedings of the 28th ACM SIGKDD Conference on Knowledge Discovery and Data Mining (KDD ’22). ACM, 1224–1232. doi:10.1145/3534678.3539470 [40] Liam Daly Manocchio, Siamak Layeghy, Wai Weng Lo, Gayan K. Kulatilleke, Mohanad Sarhan, and Marius Portmann. 2024. FlowTransformer: A transformer framework for flow-based network intrusion detection systems. Expert Systems with Applications 241 (May 2024), 122564. doi:10.1016/j. eswa.2023.122564 [41] Francisco S. Melícias, Tiago F. R. Ribeiro, Carlos Rabadão, Leonel Santos, and Rogério Luís De C. Costa. 2024. GPT and Interpolation-Based Data Augmentation for Multiclass Intrusion Detection in IIoT. IEEE Access 12 (2024), 17945–17965. doi:10.1109/access.2024.3360879 [42] Safaa Menssouri and El Mehdi Amhoud. 2025. A Conditional Tabular GAN-Enhanced Intrusion Detection System for Rare Attacks in IoT Networks. In 2025 IEEE International Conference on Communications Workshops (ICC Workshops). IEEE, 1918–1923. doi:10.1109/iccworkshops67674.2025.11162182 [43] Yisroel Mirsky, Tomer Doitshman, Yuval Elovici, and Asaf Shabtai. 2018. Kitsune: An Ensemble of Autoencoders for Online Network Intrusion Detection. In Proceedings 2018 Network and Distributed System Security Symposium (NDSS 2018). Internet Society. doi:10.14722/ndss.2018.23204 [44] Kohei Miyamoto, Chansu Han, Tao Ban, Takeshi Takahashi, and Jun’Ichi Takeuchi. 2024. Intrusion Detection Simplified: A Feature-free Approach to Traffic Classification Using Transformers. In 2024 Annual Computer Security Applications Conference Workshops (ACSAC Workshops). IEEE, 20–29. doi:10.1109/acsacw65225.2024.00011 [45] Rasheed Mohammad, Faisal Saeed, Abdulwahab Ali Almazroi, Faisal S. Alsubaei, and Abdulaleem Ali Almazroi. 2024. Enhancing Intrusion Detection Systems Using a Deep Learning and Data Augmentation Approach. Systems 12, 3 (March 2024), 79. doi:10.3390/systems12030079 [46] Leila Mohammadpour, Teck Chaw Ling, Chee Sun Liew, and Alihossein Aryanfar. 2022. A Survey of CNN-Based Network Intrusion Detection. Applied Sciences 12, 16 (Aug. 2022), 8162. doi:10.3390/app12168162 [47] Daniel Moreno-Cartagena, Guillermo Cabrera-Vives, Pavlos Protopapas, Cristobal Donoso-Oliva, Manuel Pérez-Carrasco, and Martina Cádiz-Leyton. 2023. Positional Encodings for Light Curve Transformers: Playing with Positions and Attention. [48] Euclides Carlos Pinto Neto, Sajjad Dadkhah, Raphael Ferreira, Alireza Zohourian, Rongxing Lu, and Ali A. Ghorbani. 2023. CICIoT2023: A Real-Time Dataset and Benchmark for Large-Scale Attacks in IoT Environment. Sensors 23, 13 (June 2023), 5941. doi:10.3390/s23135941 [49] Aleksander Ogonowski, Michał Żebrowski, Arkadiusz Ćwiek, Tobiasz Jarosiewicz, Konrad Klimaszewski, Adam Padee, Piotr Wasiuk, and Michał Wójcik. 2025. Preliminary study on artificial intelligence methods for cybersecurity threat detection in computer networks based on raw data packets. Computer Science 26, SI (July 2025). doi:10.7494/csci.2025.26.si.7079 [50] Abiodun Esther Omolara, Abdullah Alabdulatif, Oludare Isaac Abiodun, Moatsum Alawida, Abdulatif Alabdulatif, Wafa’ Hamdan Alshoura, and Humaira Arshad. 2022. The internet of things security: A survey encompassing unexplored areas and new insights. Computers & Security 112 (Jan. 2022), 102494. doi:10.1016/j.cose.2021.102494 [51] Ioannis Panopoulos, Maria-Lamprini A. Bartsioka, Sokratis Nikolaidis, Stylianos I. Venieris, Dimitra I. Kaklamani, and Iakovos S. Venieris. 2025. Dynamic Temporal Positional Encodings for Early Intrusion Detection in IoT. In 2025 10th International Conference on Smart and Sustainable Technologies (SpliTech). IEEE, 1–6. doi:10.23919/splitech65624.2025.11091651 [52] Narendra Patwardhan, Stefano Marrone, and Carlo Sansone. 2023. Transformers in the Real World: A Survey on NLP Applications. Information 14, 4 (April 2023), 242. doi:10.3390/info14040242 [53] María Rodríguez, Álvaro Alesanco, Lorena Mehavilla, and José García. 2022. Evaluation of Machine Learning Techniques for Traffic Flow-Based Intrusion Detection. Sensors 22, 23 (Nov. 2022), 9326. doi:10.3390/s22239326 [54] Hyewon Ryu, Sara Yu, and Ki Yong Lee. 2023. TI-former: A Time-Interval Prediction Transformer for Timestamped Sequences. In 2023 IEEE/ACIS 21st International Conference on Software Engineering Research, Management and Applications (SERA). IEEE, 319–325. doi:10.1109/sera57763.2023.10197830 [55] Makhduma F. Saiyedand and Irfan Al-Anbagi. 2024. Deep Ensemble Learning With Pruning for DDoS Attack Detection in IoT Networks. IEEE Transactions on Machine Learning in Communications and Networking 2 (2024), 596–616. doi:10.1109/tmlcn.2024.3395419 [56] Mohanad Sarhan, Siamak Layeghy, Nour Moustafa, and Marius Portmann. 2021. NetFlow Datasets for Machine Learning-Based Network Intrusion Detection Systems. Springer International Publishing, 117–135. doi:10.1007/978-3-030-72802-1_9 [57] Muhammad Shafiq, Zhihong Tian, Ali Kashif Bashir, Xiaojiang Du, and Mohsen Guizani. 2021. CorrAUC: A Malicious Bot-IoT Traffic Detection Method in IoT Network Using Machine-Learning Techniques. IEEE Internet of Things Journal 8, 5 (March 2021), 3242–3254. doi:10.1109/jiot.2020.3002255 [58] Mohaddeseh Shahhosseini, Hoda Mashayekhi, and Mohsen Rezvani. 2022. A Deep Learning Approach for Botnet Detection Using Raw Network Traffic Data. Journal of Network and Systems Management 30, 3 (April 2022). doi:10.1007/s10922-022-09655-7 [59] Ankit Sharma, Thiruvengadam Samon, Akhash Vellandurai, and Vinoth Kumar. 2023. TA-SAITS: Time Aware-Self Attention based Imputation of Time Series algorithm for Partially Observable Multi-Variate Time Series. In 2023 International Conference on Machine Learning and Applications (ICMLA). IEEE, 2228–2233. doi:10.1109/icmla58977.2023.00336 [60] Peter Shaw, Jakob Uszkoreit, and Ashish Vaswani. 2018. Self-Attention with Relative Position Representations. In Proceedings of the 2018 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies, Volume 2 (Short Papers). Association for Computational Linguistics, 464–468. doi:10.18653/v1/n18-2074 [61] Nirhoshan Sivaroopan, Dumindu Bandara, Chamara Madarasingha, Guillaume Jourjon, Anura P. Jayasumana, and Kanchana Thilakarathna. 2024. NetDiffus: Network traffic generation by diffusion models through time-series imaging. Computer Networks 251 (Sept. 2024), 110616. doi:10.1016/j.comnet.2024.110616 Manuscript submitted to ACM
38
I. Panopoulos et al.
[62] Ziyang Song, Qincheng Lu, He Zhu, David Buckeridge, and Yue Li. 2025. TrajGPT: Irregular Time-Series Representation Learning of Health Trajectory. IEEE Journal of Biomedical and Health Informatics (2025), 1–14. doi:10.1109/jbhi.2025.3620205 [63] Jianlin Su, Murtadha Ahmed, Yu Lu, Shengfeng Pan, Wen Bo, and Yunfeng Liu. 2024. RoFormer: Enhanced transformer with Rotary Position Embedding. Neurocomputing 568 (Feb. 2024), 127063. doi:10.1016/j.neucom.2023.127063 [64] Petros Toupas, Dimitra Chamou, Konstantinos M. Giannoutakis, Anastasios Drosou, and Dimitrios Tzovaras. 2019. An Intrusion Detection System for Multi-class Classification Based on Deep Neural Networks. In 2019 18th IEEE International Conference On Machine Learning And Applications (ICMLA). IEEE, 1253–1258. doi:10.1109/icmla.2019.00206 [65] Talia Tseriotou, Adam Tsakalidis, and Maria Liakata. 2024. TempoFormer: A Transformer for Temporally-aware Representations in Change Detection. In Proceedings of the 2024 Conference on Empirical Methods in Natural Language Processing. Association for Computational Linguistics, 19635–19653. doi:10.18653/v1/2024.emnlp-main.1095 [66] Imtiaz Ullah and Qusay H. Mahmoud. 2020. A Scheme for Generating a Dataset for Anomalous Activity Detection in IoT Networks. Springer International Publishing, 508–520. doi:10.1007/978-3-030-47358-7_52 [67] Imtiaz Ullah and Qusay H. Mahmoud. 2022. Design and Development of RNN Anomaly Detection Model for IoT Networks. IEEE Access 10 (2022), 62722–62750. doi:10.1109/access.2022.3176317 [68] Ashish Vaswani, Noam Shazeer, Niki Parmar, Jakob Uszkoreit, Llion Jones, Aidan N Gomez, Lukasz Kaiser, and Illia Polosukhin. 2017. Attention is All you Need. In Advances in Neural Information Processing Systems, Vol. 30. [69] Wei Wang, Yiqiang Sheng, Jinlin Wang, Xuewen Zeng, Xiaozhou Ye, Yongzhong Huang, and Ming Zhu. 2018. HAST-IDS: Learning Hierarchical SpatialTemporal Features Using Deep Neural Networks to Improve Intrusion Detection. IEEE Access 6 (2018), 1792–1806. doi:10.1109/access.2017.2780250 [70] Yue Wang, Yiming Jiang, and Julong Lan. 2021. FCNN: An Efficient Intrusion Detection Method Based on Raw Network Traffic. Security and Communication Networks 2021 (June 2021), 1–13. doi:10.1155/2021/5533269 [71] Tingsong Xiao, Zelin Xu, Wenchong He, Zhengkun Xiao, Yupu Zhang, Zibo Liu, Shigang Chen, My T. Thai, Jiang Bian, Parisa Rashidi, and Zhe Jiang. 2025. XTSFormer: Cross-Temporal-Scale Transformer for Irregular-Time Event Prediction in Clinical Applications. Proceedings of the AAAI Conference on Artificial Intelligence 39, 27 (April 2025), 28502–28510. doi:10.1609/aaai.v39i27.35073 [72] Dongyu Zhang, Liang Wang, Xin Dai, Shubham Jain, Junpeng Wang, Yujie Fan, Chin-Chia Michael Yeh, Yan Zheng, Zhongfang Zhuang, and Wei Zhang. 2023. FATA-Trans: Field And Time-Aware Transformer for Sequential Tabular Data. In Proceedings of the 32nd ACM International Conference on Information and Knowledge Management (CIKM ’23). ACM, 3247–3256. doi:10.1145/3583780.3614879 [73] Xueqin Zhang, Jiahao Chen, Yue Zhou, Liangxiu Han, and Jiajun Lin. 2019. A Multiple-Layer Representation Learning Model for Network-Based Attack Detection. IEEE Access 7 (2019), 91992–92008. doi:10.1109/access.2019.2927465 [74] Yong Zhang, Xu Chen, Da Guo, Mei Song, Yinglei Teng, and Xiaojuan Wang. 2019. PCCN: Parallel Cross Convolutional Neural Network for Abnormal Network Traffic Flows Detection in Multi-Class Imbalanced Network Traffic Flows. IEEE Access 7 (2019), 119904–119916. doi:10.1109/ access.2019.2933165 [75] Yuanyun Zhang and Shi Li. 2025. ChronoFormer: Time-Aware Transformer Architectures for Structured Clinical Event Modeling. arXiv:2504.07373 [cs.LG] https://arxiv.org/abs/2504.07373 [76] Ying Zhang and Qiang Liu. 2022. On IoT intrusion detection based on data augmentation for enhancing learning on unbalanced samples. Future Generation Computer Systems 133 (Aug. 2022), 213–227. doi:10.1016/j.future.2022.03.007 [77] Jilei Zhou, Guanran Jiang, Wei Du, and Cong Han. 2022. Profiling temporal learning interests with time-aware transformers and knowledge graph for online course recommendation. Electronic Commerce Research 23, 4 (March 2022), 2357–2377. doi:10.1007/s10660-022-09541-z [78] Yujie Zhu, Dezhi Han, and Xinming Yin. 2021. A hierarchical network intrusion detection model based on unsupervised clustering. In Proceedings of the 13th International Conference on Management of Digital EcoSystems (MEDES ’21). ACM, 22–29. doi:10.1145/3444757.3485098
Received 5 August 2025; revised 2 April 2026; accepted 9 April 2026
Manuscript submitted to ACM