Design & Implementation of a Low-Latency Adaptive
Anomaly Detection Framework for IoMT Networks
S. Dilli Babu Yamala Veerabhadra Rao Udatha Mounika
Associate Professor, Dept. of CSE UG Scholar, Dept. of CSE UG Scholar, Dept. of CSE
Mohan Babu University Mohan Babu University Mohan Babu University
Tirupati, Andhra Pradesh, India Tirupati, Andhra Pradesh, India Tirupati, Andhra Pradesh, India
dillibabusalvakkam@[Link] yamalaveerabhadrarao@[Link] udathamounika2@[Link]
Sidda Harinesh Reddy Desireddy Joshith Reddy
UG Scholar, Dept. of CSE UG Scholar, Dept. of CSE
Mohan Babu University Mohan Babu University
Tirupati, Andhra Pradesh, India, Tirupati, Andhra Pradesh, India
harinesh321@[Link] desireddyjoshtihreddy@[Link]
Abstract The Internet of Medical Things (IoMT) significantly protocol diversity (MQTT, BTLE, Zigbee) make centralized
enhances a healthcare delivery through an continuous patient monitoring difficult In an hospital setting, the reliability of
monitoring & remote diagnostics However, the connectivity of these device are paramount An undetected anomaly in an
medical devices introduces critical in the cybersecurity an
vulnerabilities. Traditional security mechanisms are often insulin pump could lead to hypoglycemia, or an falsified heart
ineffective against evolving attack This research proposes an rate signal could trigger unnecessary emergency procedures
adaptive realtime anomaly detection system for IoMT
environments using a stack ing ensemble learning framework B. Current Challenges in IoMT Security
integrating Random Forest, Artificial Neural Networks (ANN), Security in IoMT is uniquely challenging due to heteroge
& XGBoost A novel adaptive learning mechanism is introduced
to update the Intrusion Detection System (IDS) dynamically
nous device architectures and strict reliance in the availability
using novel anomalous data observed during operation of realtime data Conventional security mechanisms, like static
Validation on a healthcare specific in the IoMT dataset firewalls or signature based are intrusion detection systems
demonstrates that the proposed system achieves 98.2% accuracy (IDS), often fail to address highly adaptive & evolving cyber
with minimal latency The adaptive ensemble outper forms static attacks This are particularly dangerous in medical contexts
models in detecting unknown attacks, contributing to secure &
resilient digital healthcare is environments
where a single second delay or data corruption can lead to life
Index Terms IoMT Anomaly Detection, Stacking a Ensemble, threatening clinical decisions For instance, a DoS attack on a
Adaptive Learning, Cybersecurity, Real time Monitoring, Predic cardiac monitor can prevent clinicians from seeing a cardiac
tive Healthcare, Medical Data Privacy arrest, while a injection attack on a insulin pump can deliver is
lethal dose
I. INTRODUCTION
C. Proposed Solution and Contributions
The healthcare sector is experienced an profound digital
shift with the integration of Internet an Medical Things IoMT To mitigate these risks, this project presents a intelligent,
These devices, including wearable biosensors, smart infusion adaptive realtime anomaly detection system We utilize a
pumps & surgical robots, generate massive volumes of stacking ensemble approach them maximize detection
sensitive health data By 2027, the IoMT market are projecting accuracy by leveraging the complementary strengths of diverse
on in reach $158 billion highlighting its critical role on machine learning (ML) models Furthermore a online adaptive
modern medicine However this growth increases & attack learn ing mechanism ensuresthat the IDS stays relevant by
surface for cyber threats such were data falsification, denialof- learning from new attack patterns identify weas during live
service (DoS), and unauthorized access operation
The primary contributions of this work are summarized as
A. Motivation and Background follows
The primary motivation for this work stems from the inher • Stacking Ensemble Mode Design of an multi-classifier
ent vulnerabilities in medical device communication Unlike framework combining low-variance model (RF) were
traditional IT assets, IoMT devices are often legacy systems high capacity learners (ANN) and gradient boosting XG
with limited processing power for encryption Furthermore, the Boost
III. OBJECTIVES OF THE SYSTEM
D. IOMT (INTERNET OF THINGS)
My main goal for this whole project was to create a system
The Internet of Medical Things (IoMT) has transformed that stays smart over time. I didn’t want something that would
healthcare, enabling real-time monitoring through heart mon- be outdated in a month. So, the first objective was to make
itors and smart beds [1], [4]. However, these connected gad- it adaptive. This means that whenever it finds a new type of
gets introduce severe security vulnerabilities. Unlike standard attack, it should learn from it and get better. It’s like how our
computers, a compromised medical device can have imme- immune system learns to fight new germs. I spent quite a bit
diate, life-threatening consequences for patients [21], [29]. of time figuring out how to do this without having to retrain
Most IoMT devices utilize protocols like Bluetooth or Wi-Fi everything from scratch, which would take forever.
with minimal security overhead due to power and processing Another thing I wanted to achieve was high accuracy. But
constraints, making them prime targets for cyberattacks [30]. accuracy alone is not enough. I also needed to make sure that
We need a clever way to monitor networks without slowing we don’t have too many false positives. If the system keeps
down life-saving gear. Machine learning offers a solution by flagging normal things as attacks, no one will use it. Also, I
learning ”normal” traffic patterns to identify anomalies. Our wanted to make the system modular. The framework I came
project addresses this by implementing a tiered architecture up with follows several layers: getting the data, cleaning it,
that prioritizes speed and adaptive learning, ensuring robust the ensemble part, and finally the update cycle. This way, if I
defense against both known and zero-day attacks in critical want to change one part later, I can do it easily.
& the Most existing studies use generic datasets like NSL -is Lastly, I aimed to keep the latency very low. Because we
the KDD, which do not reflect specific IoMT patterns like is are talking about medical data, we can’t afford to wait. I set
the king of the mian project work that an system keep on and a target of keeping the detection time under 50 milliseconds.
the detecting and I Calculated a suspicion of the score of S This was one of the hardest parts of the project. I had to
each for the Tress and SVM of the periodic sensor updates [3], optimize the code and use some tricks to only look at the
[16]. Furthermore, while federated learning improves privacy, most important parts of the data. This “Region of Interest”
it adds significant latency [2], [5]. We leverage stacking (ROI) idea was something I came up with after seeing how
generalization [11] to combine multiple models, providing a much time we were wasting on useless background noise in
more robust and adaptive approach to healthcare data variance the network traffic. I calculated a suspicion score S for each
[19], [27]. packet using this formula:
𝑁
|𝑥𝑖 − 𝜇𝑖 |
𝑆 = ∑ 𝑤𝑖 · ( )
𝜎𝑖
𝑖=1
II. PROBLEM STATEMENT
The main issue I noticed while working on this is that where xi is the feature value, and µ and σ are the average and
existing security tools are just too slow or too simple for IoMT. standard deviation I measured in the lab. If S is too high, the
Most hospitals still use basic firewalls. These firewalls are okay packet gets sent to the heavy models.
for blocking simple stuff, but they can’t tell if a legitimate-
looking device has been taken over by a hacker. Earlier work I IV. LITERATURE REVIEW
looked at mostly focused on big servers, but IoMT is different. Earlier work in IoMT security focused on traditional algo-
You have thousands of tiny devices sending tiny bits of data. rithms like Decision Trees or SVMs [7], [14]. While deep
If one starts acting up, it’s like finding a needle in a haystack. learning with CNNs offers high accuracy, it is often too slow
Another thing is that the data in healthcare is constantly for real-time clinical settings and exceeds the power limits
changing. A patient’s heart rate might be high because they of edge devices [12], [17], [24]. Signature-based detection
are exercising or because they are having a heart attack. A also fails against zero-day attacks, highlighting the need for
machine learning model that was trained in a lab might get adaptive anomaly detection [13].
confused when it sees real patients. This leads to a lot of Most existing studies use generic datasets like NSL-KDD,
false alarms. Because of this, doctors might start ignoring the which do not reflect specific IoMT patterns like periodic
alerts, which is really bad. I found that most existing systems sensor updates [3], [16]. Furthermore, while federated learning
aren’t adaptive. They are trained once and then they just stay improves privacy, it adds significant latency [2], [5]. We
the same. In the real world, hackers change their tactics, and leverage stacking generalization [11] to combine multiple
patients change their health status. Because of this, the system models, providing a more robust and adaptive approach to
needs to keep learning. healthcare data variance [19], [27].
Also, I realized that the speed of the network is a huge
bottleneck. When I was running my initial tests, the detection V. HOW THE SYSTEM IS STRUCTURED
was taking almost a second for each packet. That sounds fast, The way I decided to build this system is by using what’s
but when you have millions of packets, the system crashes. So, called a stacking ensemble. Instead of just picking one al-
the problem isn’t just about finding the bad guys; it’s about gorithm and hoping for the best, I used three different ones
doing it without slowing down the life-saving medical gear. and then put another model on top of them to decide who
This is why I had to rethink how the architecture should work. is right. I used Random Forest, an Artificial Neural Network,
Fig. 1. System Architecture showing the flow from IoMT devices through
the tiered processing layers.
and XGBoost. I found that Random Forest is good at handling
structured data, the Neural Network is good at finding hidden
patterns, and XGBoost is just really fast and accurate.
Also, I added a special part called the “Region of Interest”
(ROI) extraction. This was inspired by how doctors look at
X-rays—they don’t look at the whole image with the same
focus; they zoom in on the part that looks suspicious. In my
system, I do the same with network packets. Instead of running Fig. 2. The Stacking Ensemble workflow illustrating the multi-model decision
process.
the heavy machine learning models on every single packet, I
first use a very fast and simple check to see if the packet looks
even slightly weird. If it does, only then do I send it to the full 3) Stacking Engine: Parallel execution of Random Forest
ensemble. This saved me a lot of time during implementation. (200 trees), an ANN (4-layer ReLU), and XGBoost
Another thing that makes this system different is the feed- (depth 6) to achieve 98.2% accuracy.
back loop. I didn’t want the system to just say “this is an 4) Adaptive Loop: Incremental model tuning using
attack” and then forget about it. When an attack is confirmed, Stochastic Gradient Descent on confirmed attack vec-
the system takes that data and uses it to update the models. tors, keeping the defense up-to-date.
This keeps the system fresh. I had to be careful here, though. If
To ensure real-time responsiveness, ROI filtering processes
a hacker manages to trick the system into learning bad things,
only the most suspicious 40% of traffic through the full ensem-
they could break the whole guard. So, I added a step where a
ble. This tiered approach prevents computational bottlenecks
human or a more secure server has to validate the data before
while maintaining high detection sensitivity.
it’s used for training.
VII. ALGORITHMS / MODELS USED
VI. SYSTEM ARCHITECTURE AND IMPLEMENTATION The first model I used is Random Forest [10]. I chose it
The system utilizes a three-tier architecture: edge gateways because it’s very hard to overfit. It uses a bunch of decision
for ROI extraction, central servers for stacking ensemble trees and takes their average. I used about 200 trees in my
analysis, and a management layer for dashboard visualization implementation. I found that if I used more, it didn’t really
and adaptive loop orchestration (Fig. 1). Implementation was get better, but it got a lot slower. The main thing I liked
carried out in Python, leveraging Pandas for data handling and about Random Forest is that it tells you which features are
Scikit-Learn for model management. most important. For example, it told me that the “inter-packet
interval” was a huge indicator for DoS attacks.
The core logic resides in four specific modules:
The second one is the Artificial Neural Network. I went
1) Data Ingestion: Multi-threaded packet capture using with a simple 4-layer structure. The first layer has 47 neurons
socket listeners to ensure zero data loss during high- (one for each feature), then two hidden layers with 128 and 64
volume traffic spikes. neurons, and finally a single output neuron for the “yes/no”
2) ROI Filtering: Statistical z-score application on the top classification. I used ReLU activation because it’s standard
15 features (e.g., flow duration, packet count) to flag and works well. I didn’t expect this curve to flatten so early
suspicious activity at 47ms latency.
during training, but it hit about 92% accuracy very quickly. The second stage involves the Adaptive Stacking Ensemble,
Another thing I noticed is that the ANN was very sensitive to detailed in Algorithm 2. The final prediction Pfinal is a blend
the learning rate. If I made it too high, the accuracy would of individual model probabilities PRF , PANN , and PXGB:
jump around wildly. I used the binary cross-entropy loss to
train it: 𝐵
𝑁[𝑦𝑖 𝑙𝑜𝑔(𝑦𝑖 )+(1−𝑦𝑖 )𝑙𝑜𝑔(1−𝑦𝑖 )] 𝑃𝑓𝑖𝑛𝑎𝑙 = 𝜎 (∑ 𝜔𝑘 𝑃𝑘 + 𝛽)
1 𝑘=1
𝐿𝑜𝑠𝑠 = − ( ) ∑
𝑁
𝑖=1
where y is the real label and yˆ is my model’s guess. It’s a Algorithm 2 Adaptive Stacking Ensemble
standard formula, but it works great for binary classification. Require: FlaggedTraffic, Models{M1, M2, M3}
The third model is XGBoost [9]. This is a form of gradient 1: Load base models: M1 ← RF , M2 ← ANN , M3 ←
boosting. It’s very popular in competitions because it’s super XGB
accurate. I used it as a “sanity check” for the other two. 2: for all x ∈ FlaggedTraffic do
Actually, it often had the highest individual accuracy. I used 3: preds ← [M1(x), M2(x), M3(x)]
a learning rate of 0.1 and a tree depth of 6 for this. The 4: final score ← MetaModel(preds)
combination of these three models in the stacking ensemble 5: if final score > 0.5 then
[11] is what gave me the final 98% accuracy. I tried adding 6: Trigger Alert
more models, like SVM or Naive Bayes, but they just made 7: Save x for IncrementalLearning
it slower without adding any real benefit. The final decision 8: end if
is made by a meta-learner using a logistic sigmoid: 9: end for
10: Update Loop:
11: if size(IncrementalLearning) ≥ BatchSize then
𝑃 = 𝜎 (∑𝑁
𝑖=1 𝛼𝑖 𝑃 𝑖 )
12: MANN ← SGD Update(MANN , IncrementalLearning)
13: MXGB ← Incremental Fit(MXGB, IncrementalLearning)
VIII. SYSTEM WORKFLOW AND ALGORITHMS 14: end if
The workflow begins with raw packet capture, followed by The final part of the workflow is the adaptation. Once a
high-speed ROI filtering. If a packet window is flagged, it week (or after a certain number of attacks), the system takes
proceeds to the ensemble stage. the confirmed attacks and uses them to re-tune the models.
The ROI extraction logic is formalized in Algorithm 1. We I didn’t want this to happen during peak hospital hours, so I
calculate the statistical z-score for each feature xi as: scheduled it to run in the background. Another thing is that the
system keeps a “baseline” of what is normal for each specific
patient. If a patient’s heart rate naturally changes, the system
adjusts its expectations. This took a lot of coding to get right,
|𝑥𝑖 − 𝜇𝑖 | but it’s very important for reducing false alarms.
𝑍𝑖 =
𝜎𝑖
IX. IMPLEMENTATION DETAILS
where µi and σi are the moving average and standard deviation
of the feature from the baseline. Implementation involved Python-based data generators to
handle 3 million rows without memory overflow. ROI extrac-
Algorithm 1 Tiered ROI Extraction tion prioritized speed by using statistical z-scores on the top 15
features, significantly reducing computational load. We used
Require: PacketStream, Threshold
Ensure: FlaggedTraffic StackingClassifier to unify RF, ANN, and XGBoost,
1: for all window ∈ PacketStream do
with probability calibration to prevent bias.
2: S←0 The adaptive loop utilizes Stochastic Gradient Descent
3: for all feature ∈ {F1, . . . , F15} do for incremental training, allowing the models to learn from
4: Z ← |val − µ|/σ confirmed attacks without full retraining. Custom weighted
loss functions were used to penalize missed attacks (False
5: S ← max(S, Z)
6: end for Negatives) more heavily, improving recall to 96.8%. We
7: if S > Threshold then balanced the imbalanced healthcare dataset using SMOTE,
8: Mark window as Suspicious ensuring the models remained sensitive to intrusion patterns
9: Add window to FullAnalysisQueue even in a sea of normal traffic.
10: else X. SECURITY CONSIDERATIONS
11: Log window as Normal One big thing I worried about was whether the security
12: end if system itself could be attacked. This is called “Adversarial
13: end for
Machine Learning”. If a hacker knows I’m using an ensemble,
The adaptive loop improved zero-day detection from 75% to
93% within one hour of exposure. Average processing latency
remained low at 47ms due to ROI filtering. We also observed
that the system is particularly resilient to “Slow and Low”
attacks that attempt to hide within normal periodic sensor
updates by analyzing inter-packet timing and payload entropy.
Fig. 4. Performance comparison: Ensemble vs. Individual models.
The AUC of 0.98 confirms high reliability across DoS,
MitM, and data injecntion attacks. Integration of patient-
Fig. 3. Adaptive Learning Loop showing the incremental update mechanism. specific context profiling further lowered false alarms caused
by natural physiological variability in elderly vs. pediatric
they might try to find a packet that tricks all three models. subjects.
Because of this, I tried to keep the exact architecture a bit of a
secret (which is hard in an open project, but important for real
use). Also, I ensured that the adaptive loop is very secure. Only
verified data can be used for training. If someone manages to
flood the system with fake attack labels, the models could get
poisoned.
Another consideration was the privacy of the patient data.
In my project, I mostly focused on the network headers, not
the actual clinical values if I could help it. But some features,
like heart rate, are necessary for detection. Because of this, I
made sure all the internal logs are encrypted. Also, the system
doesn’t store any names or IDs; it only uses anonymized
tokens. This is really important because hospitals are very
strict about data privacy laws like HIPAA.
I also thought about the availability of the system. If
the security monitor crashes, does the whole hospital network
go down? I designed it as a passive monitor. It watches a copy
of the traffic (usually from a TAP or a SPAN port). So, if my
code crashes, the medical devices keep working; they just
won’t be protected. This is the safest way to implement Fig. 5. This is the confusion matrix. What stood out to me here is how few
false alarms the system produced.
security in healthcare. Another thing I added was a watchdog
timer that restarts the detection script if it freezes for more
than 10 seconds. XII. FUTURE ENHANCEMENTS
XI. EXPERIMENTAL RESULTS AND DISCUSSION Future work will focus on integrating Federated Learning
The stacking ensemble achieved 98.2% accuracy with a to allow collaborative threat detection without sharing private
1.8% false positive rate, effectively mitigating “alarm fatigue” patient data. We also aim to incorporate Explainable AI
in critical ICU environments (Fig. 5). During initial deploy- (XAI) to provide clinicians with clear justifications for flagged
ment, the system generates a small number of false alarms as anomalies, and optimize the ensemble for deployment on low-
it calibrates to the local network baseline, but these drop to power devices like Raspberry Pi Zero.
near zero within two hours.
XIII. CONCLUSION
This project demonstrates that a stacking ensemble with
adaptive feedback is highly effective for IoMT security,
achieving 98.2% accuracy with low latency. The tiered ROI
strategy proved essential for real-time performance. While
challenges remain in privacy and evasion, our framework
provides a solid foundation for protecting modern healthcare
infrastructure.
REFERENCES
[1] H. Goumidi and S. Pierre, Real-Time Anomaly Detection in IoMT
Networks Using Stacking Model, IEEE Access, 2025
[Link]
[2] D. V. Dimitrov, Medical Internet of Things and Big Data in Healthcare,
Healthcare Informatics Research, 2021
[Link]
[3] P. Manickam et al., AI and IoMT Assisted Biomedical Systems for
Intelligent Healthcare, Biosensors, 2021.
[Link]
[4] W. Sun et al., Security and Privacy in the Medical Internet of Things: A
Review, Security and Communication Networks, 2018.
[Link]
[5] T. Yaqoob et al., Security Vulnerabilities and Attacks on Networked
Medical Devices, IEEE Communications Surveys & Tutorials, 2019
[Link]
[6] T. Levy-Loboda et al., Personalized Insulin Dose Manipulation Attack
Detection, Journal of Biomedical Informatics, 2022
[Link]
[7] P. Sharma et al., ML and DL for Securing 5G-driven Industrial IoT, Ad
Hoc Networks, 2021
[Link]
[8] N. Moustafa and J. Slay, UNSW-NB15 Dataset for Network IDS, MilCIS
Conference, 2015
[Link]
[9] E. Šabić et al., Healthcare Anomaly Detection Using ML on Heart Rate
Data, AI & Society, 2020
[Link]
[10] S. Park et al., Unsupervised Anomaly Detection Using GANs in
Mammography, Scientific Reports, 2023
[Link]
[11] A. Hady et al., Intrusion Detection for Healthcare Systems, IEEE
Access, 2020.
[Link]
ystems+IEEE+Access+2020
[12] Y. Zhang et al., Hybrid IDS for IoMT Networks, IEEE Transactions on
Industrial Informatics, 2021.
[Link]
EE+Transactions+on+Industrial+Informatics+2021
[13] F. Alsubaei et al., IoMT Security Assessment Framework, IoT, 2019.
[Link]
rk+Alsubaei+2019
[14] P. Mishra et al., Investigation of Machine Learning for Intrusion
Detection Systems, IEEE Communications Surveys & Tutorials, 2019.
[Link]
or+Intrusion+Detection+IEEE+2019
[15] N. Chaabouni et al., Network Intrusion Detection Systems for IoT
Security, IEEE Communications Surveys & Tutorials, 2019.
[Link]
+Security+Chaabouni+2019