Course: Computer Networks (24TU04MJM2) β Woxsen University
Version: 2.0 | Date: February 2026
Team/Author: Woxsen University CN PBL 2026
- What Is This Project?
- How It Works β The Big Picture
- System Architecture
- Pipeline β Step by Step
- The Trust Score Engine
- Machine Learning Models
- Network & Firewall Design
- Project Structure
- Quick Start
- The Dashboard
- Generated Visualisation Plots
- Results & Accuracy
- Access Policy Reference
- Technologies Used
- References
Imagine a university campus where hundreds of devices β laptops, phones, tablets β try to connect to the campus network every hour. The network administrator needs to answer three questions automatically:
- Should this device be allowed in? (Access Control)
- Is this device acting suspiciously? (Intrusion Detection)
- How trustworthy is this device, right now? (Trust Scoring)
This project builds a Smart Campus Network that answers all three questions in real time using a combination of:
- Rule-Based Logic β simple, transparent access policies
- Dynamic Trust Scoring β a live score (0β100) for every login attempt
- Machine Learning β a Decision Tree (access control) and an SVM (intrusion detection)
- A Live Streamlit Dashboard β to monitor all of this in real time
The whole system is simulation-based β we generate realistic authentication logs, process them through our rule engine and ML pipeline, and visualise everything in an interactive dashboard.
When a device connects to the campus network, it goes through the following process:
Device Tries to Connect
β
βΌ
βββββββββββββββββββββββββ
β Authentication Log β MAC address, OS, Role, Timestamp, Login Result
βββββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Parser + Rule Engine β Applies time/role-based access rules
β Trust Score Engine β Calculates a score from 0 to 100
βββββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β ML Models β Decision Tree β Access Control
β β SVM β Intrusion Detection
β β K-Means β Device Clustering
βββββββββββββ¬ββββββββββββ
β
βΌ
βββββββββββββββββββββββββ
β Streamlit Dashboard β Real-time feed, charts, AI prediction panel
βββββββββββββββββββββββββ
Result: Every login attempt gets labelled as ALLOW, RESTRICT, or BLOCK β and any suspicious activity is flagged as an anomaly, instantly visible on the dashboard.
flowchart TD
A[π₯οΈ Device Login Attempt] --> B{Authentication Gateway}
B -->|Sends log entry| C[auth_logs.csv]
C --> D[parser_and_rules.py]
D --> E{Rule Engine}
E -->|MAC registered?| F[Trust Score Engine]
E -->|Unknown MAC| G[π« BLOCK]
F --> H{Score β₯ 70?}
H -->|Yes| I[β
ALLOW]
H -->|40β69| J[β οΈ RESTRICT]
H -->|< 40| G
D --> K[parsed_logs.csv]
K --> L[ml_models.py]
L --> M[π² Decision Tree]
L --> N[π΅ SVM RBF Kernel]
L --> O[π K-Means Clustering]
M --> P[Access Decision Prediction]
N --> Q[Anomaly / Intrusion Flag]
O --> R[Device Fingerprint Cluster]
K --> S[analysis_plots.py]
S --> T[6 Visualisation Plots]
K --> U[dashboard.py]
P --> U
Q --> U
T --> U
U --> V[π₯οΈ Live Streamlit Dashboard]
graph TD
Internet["π Internet"]
FW["π₯ Firewall\nfirewall_rules.bat"]
Router["π Core Router"]
VLAN10["π‘ VLAN 10\n192.168.10.x\nFaculty"]
VLAN20["π‘ VLAN 20\n192.168.20.x\nStudents"]
VLAN30["π‘ VLAN 30\n192.168.30.x\nGuests"]
VLAN40["π‘ VLAN 40\n192.168.40.x\nServers / LMS"]
Internet --> FW
FW --> Router
Router --> VLAN10
Router --> VLAN20
Router --> VLAN30
Router --> VLAN40
VLAN10 -->|"Full Access\n(Anytime)"| VLAN40
VLAN20 -->|"LMS Access\n(07:00β22:00)"| VLAN40
VLAN30 -->|"BLOCKED\nfrom Faculty & Servers"| VLAN40
The project runs in a 5-step pipeline. Each script feeds the next one.
sequenceDiagram
participant You
participant gen as generate_data.py
participant par as parser_and_rules.py
participant ml as ml_models.py
participant plot as analysis_plots.py
participant dash as dashboard.py
You->>gen: python generate_data.py
gen-->>You: data/auth_logs.csv (110 records)
You->>par: python parser_and_rules.py
par-->>You: data/parsed_logs.csv (+ trust scores + anomaly flags)
You->>ml: python ml_models.py
ml-->>You: models/*.pkl + models/metrics.json
You->>plot: python analysis_plots.py
plot-->>You: plots/*.png (6 charts)
You->>dash: streamlit run dashboard.py
dash-->>You: Live dashboard at localhost:8501
This script creates realistic synthetic authentication logs β the kind of data a RADIUS server on a university campus would produce.
It generates 110 records spread across 5 user groups:
| User Group | Count | Behaviour |
|---|---|---|
| π§βπ« Faculty | 25 | Daytime logins (08:00β20:00), registered MACs, 90% success rate |
| π Student | 35 | Day/evening logins (07:00β22:00), registered MACs, 70% success rate |
| π€ Guest | 25 | Random hours, mix of unknown MACs, mostly failures |
| π΄ Intruders | 15 | Off-hours (00:00β05:00), unknown MACs, Unknown OS, all failures |
| π‘ Suspicious Students | 10 | Late-night (23:00), registered MACs but login failures |
Each record has these fields:
timestamp | mac | os | role | login_result
-----------+-------------------+---------+---------+-------------
08:30 | AA:BB:CC:DD:EE:01 | Windows | faculty | success
02:15 | FF:FF:FF:FF:FF:07 | Unknown | guest | failure
MAC Addresses:
AA:BB:CC:DD:EE:01toAA:BB:CC:DD:EE:50β Registered (known) campus devicesFF:FF:FF:FF:FF:01toFF:FF:FF:FF:FF:20β Unknown/unregistered devices
This script reads auth_logs.csv and applies two engines to every record.
Simple rule-based logic that mirrors a real network access policy:
flowchart TD
start([Login Attempt]) --> mac{MAC in whitelist?}
mac -- No --> BLOCK1[π« BLOCK]
mac -- Yes --> os{OS = Unknown?}
os -- Yes --> BLOCK2[π« BLOCK]
os -- No --> role{User Role?}
role -- Faculty --> ALLOW1[β
ALLOW]
role -- Student --> time{Hour 07β22?}
time -- No --> BLOCK3[π« BLOCK]
time -- Yes --> login{Login Success?}
login -- No --> BLOCK4[π« BLOCK]
login -- Yes --> ALLOW2[β
ALLOW]
role -- Guest --> BLOCK5[π« BLOCK]
Every login gets a score from 0 to 100 based on 5 factors:
Trust Score = Baseline (50)
+ Device Factor (MAC registered: +20, Unknown MAC: -30)
+ OS Factor (Known OS: +10, Unknown OS: -20)
+ Role Factor (Faculty: +15, Student: +5, Guest: -10)
+ Time Factor (Business hours 08β18: +10, Off-hours: -20)
+ Behavior Factor (Login success: +10, Failure: -15)
Score β₯ 70 β ALLOW
Score 40β69 β RESTRICT
Score < 40 β BLOCK
Example Calculations:
| Scenario | Score | Decision |
|---|---|---|
| Faculty, registered MAC, Windows, 10:00, success | 50+20+10+15+10+10 = 115 β capped at 100 | β ALLOW |
| Student, registered MAC, Windows, 14:00, success | 50+20+10+5+10+10 = 105 β capped at 100 | β ALLOW |
| Student, registered MAC, Windows, 23:00, failure | 50+20+10+5-20-15 = 50 | |
| Intruder, unknown MAC, Unknown OS, 03:00, failure | 50-30-20-10-20-15 = -45 β floored at 0 | π« BLOCK |
A rule flags a record as an anomaly (1) if all of the following are true:
- Login result =
failureAND - At least one of: hour < 06:00 OR unknown MAC OR Unknown OS
Reads parsed_logs.csv and trains two classifiers. All categorical columns (mac, os, role, access_decision) are label-encoded to numbers before training.
Features used:
mac_encoded | os_encoded | role_encoded | hour | trust_score
Train/Test Split: 75% training, 25% testing (stratified with random_state=42).
graph TD
root["trust_score β€ 65?"]
root -- Yes --> n1["role = guest?"]
root -- No --> leaf1["β
ALLOW"]
n1 -- Yes --> leaf2["π« BLOCK"]
n1 -- No --> n2["mac unknown?"]
n2 -- Yes --> leaf3["π« BLOCK"]
n2 -- No --> leaf4["β οΈ ALLOW/RESTRICT"]
- Task: Predict whether a login should be
ALLOWorBLOCK - Algorithm:
DecisionTreeClassifier(max_depth=5) - Why Decision Tree? Transparent, interpretable β you can see exactly why a decision was made
- Typical Accuracy: ~90%+
- Task: Predict whether a login is
Normal (0)or anAnomaly (1)(potential intrusion) - Algorithm:
SVC(kernel='rbf', C=1.0, gamma='scale', probability=True) - Why SVM with RBF kernel? SVMs are excellent for binary classification with a non-linear boundary, perfect for detecting the edge-case patterns of intrusion attempts
- Typical Accuracy: ~95%+
- Task: Group devices into 3 clusters based on OS type and user role, without any labels
- Algorithm:
KMeans(n_clusters=3) - Why K-Means? Unsupervised clustering can reveal natural groupings in device behaviour, useful for discovering unknown device profiles
All models and label encoders are saved to the models/ folder as .pkl files using joblib.
Generates 6 charts from parsed_logs.csv and saves them to plots/:
| Plot | File | What it Shows |
|---|---|---|
| Login Distribution | login_distribution.png |
Bar chart of success vs failure counts |
| Hourly Activity | hourly_activity.png |
Stacked bar chart of logins per hour of day |
| Anomaly Scatter | anomalies.png |
Scatter plot highlighting intrusion attempts by hour & role |
| Trust Score Distribution | trust_scores.png |
Scatter of all login trust scores with ALLOW/RESTRICT/BLOCK zones |
| Access by Role | access_by_role.png |
Grouped bar chart of ALLOW vs BLOCK per user role |
| Device Clustering | device_clustering.png |
Scatter plot of K-Means device fingerprint clusters |
A real-time monitoring dashboard that auto-refreshes every few seconds, simulating live campus network activity.
The Trust Score is the core innovation of this system. It is a Zero Trust-inspired continuous evaluation of every login attempt. Rather than just checking if a user has the right password, it asks: "How confident are we that this is a legitimate, safe login?"
graph LR
MAC["π§ Device Factor\nMAC in whitelist?\n+20 / -30"] --> SUM
OS["π» OS Factor\nKnown OS?\n+10 / -20"] --> SUM
ROLE["π€ Role Factor\nFaculty / Student / Guest\n+15 / +5 / -10"] --> SUM
TIME["π Time Factor\nBusiness hours?\n+10 / 0 / -20"] --> SUM
BEH["π Behavior Factor\nLogin success?\n+10 / -15"] --> SUM
SUM["β Score\nBaseline = 50\nClamped: 0β100"] --> DEC{Decision}
DEC -->|"β₯ 70"| ALLOW["β
ALLOW"]
DEC -->|"40β69"| RESTRICT["β οΈ RESTRICT"]
DEC -->|"< 40"| BLOCK["π« BLOCK"]
This is inspired by the concept of Context-Based Access Control and Zero Trust Architecture, where no device is trusted by default β trust must be earned and continuously re-evaluated.
The rule engine is fast and transparent but rigid β it can only catch patterns we explicitly coded. ML models can:
- Learn subtle patterns from the data automatically
- Generalise to new, unseen attack patterns
- Provide a second layer of validation on top of the rules
| Model | Type | Task | Accuracy |
|---|---|---|---|
| Decision Tree | Supervised | Access Control Classification | ~90%+ |
| SVM (RBF Kernel) | Supervised | Intrusion / Anomaly Detection | ~95%+ |
| K-Means (k=3) | Unsupervised | Device Fingerprint Clustering | N/A (unsupervised) |
Before training, categorical data is converted using LabelEncoder:
macβmac_encoded(integer)osβos_encoded(integer)roleβrole_encoded(integer)access_decisionβaccess_encoded(0 = ALLOW, 1 = BLOCK)
Final feature matrix X:
[mac_encoded, os_encoded, role_encoded, hour, trust_score]
The campus network is segmented into 4 VLANs to isolate traffic by user type:
VLAN 10 β 192.168.10.0/24 β Faculty (Full access, anytime)
VLAN 20 β 192.168.20.0/24 β Students (LMS access, 07:00β22:00)
VLAN 30 β 192.168.30.0/24 β Guests (Internet only, blocked from internal)
VLAN 40 β 192.168.40.0/24 β Servers (LMS, file servers, faculty resources)
The batch script simulates Windows Firewall rules that enforce the network policy:
| Rule | Action | Description |
|---|---|---|
| Block Unknown OS | BLOCK inbound from VLAN 30 | Prevents unrecognised OS devices from accessing LAN |
| Block Guest β Faculty | BLOCK TCP from 192.168.30.x to 192.168.10.x | Isolates guest devices from faculty resources |
| Allow Faculty | ALLOW all from 192.168.10.x | Faculty get unrestricted access |
| Allow Student β LMS | ALLOW TCP from 192.168.20.x to 192.168.40.x | Students can reach learning servers only |
| MAC Port Security | Simulated note | Real implementation via Cisco switch CLI (switchport port-security maximum 2) |
Note:
firewall_rules.batis a simulation for demonstration. In a real deployment, these rules would be applied through a managed switch (e.g., Cisco CLI) and a RADIUS authentication server (e.g., FreeRADIUS).
CN Live Code (1)/
β
βββ README.md β You are here
β
βββ code/
β βββ generate_data.py β STEP 1: Generates 110 synthetic auth log records
β βββ parser_and_rules.py β STEP 2: Applies access rules + Trust Score Engine
β βββ ml_models.py β STEP 3: Trains Decision Tree, SVM; saves .pkl files
β βββ analysis_plots.py β STEP 4: Generates 6 visualisation charts
β βββ dashboard.py β STEP 5: Streamlit real-time dashboard (675 lines)
β βββ firewall_rules.bat β Simulated Windows firewall rules (VLAN policies)
β
βββ data/ β Auto-generated by running the scripts
β βββ auth_logs.csv β Raw authentication logs (110 records)
β βββ parsed_logs.csv β Processed logs with trust scores + anomaly flags
β
βββ models/ β Auto-generated by ml_models.py
β βββ dt_model.pkl β Trained Decision Tree model
β βββ svm_model.pkl β Trained SVM model
β βββ le_mac.pkl β MAC address label encoder
β βββ le_os.pkl β OS label encoder
β βββ le_role.pkl β Role label encoder
β βββ le_access.pkl β Access decision label encoder
β βββ metrics.json β Accuracy scores (loaded by dashboard)
β
βββ plots/ β Auto-generated by analysis_plots.py
βββ login_distribution.png β Success vs Failure bar chart
βββ hourly_activity.png β Logins per hour of day
βββ anomalies.png β Anomaly scatter plot (role vs hour)
βββ trust_scores.png β Trust score scatter with ALLOW/RESTRICT/BLOCK zones
βββ access_by_role.png β Access decisions grouped by user role
βββ device_clustering.png β K-Means device fingerprint clusters
Make sure you have Python 3.8+ installed. Then install all dependencies:
pip install pandas matplotlib seaborn scikit-learn streamlit joblibNavigate into the code/ folder first:
cd codepython generate_data.pyπ€ Output: ../data/auth_logs.csv (110 records)
python parser_and_rules.pyπ€ Output: ../data/parsed_logs.csv (adds trust_score, anomaly, access_decision columns)
Example terminal output:
--- Summary ---
Total Records : 110
ALLOW decisions : 47
BLOCK decisions : 63
Anomalies Flagged: 22
Avg Trust Score : 54.3
python ml_models.pyπ€ Output: ../models/dt_model.pkl, ../models/svm_model.pkl, ../models/metrics.json, and encoder .pkl files.
Example terminal output:
[1] Decision Tree β Access Control Classification
Accuracy : 92.59%
[2] SVM β Intrusion / Anomaly Detection
Accuracy : 96.30%
python analysis_plots.pyπ€ Output: 6 chart images saved to ../plots/
streamlit run dashboard.pyπ Open your browser at: http://localhost:8501
The dashboard (dashboard.py) is a real-time network monitoring system built with Streamlit. It has 4 tabs:
- Latest 5 event ticker: Shows the most recent login attempts with colour-coded
ALLOW/BLOCK/ANOMALYbadges - Live Activity Timeline: Rolling 2-minute plot of trust scores (auto-updates every few seconds)
- Full Authentication Log: Filterable table (by role, login result, anomaly status)
- Live-updating versions of all 6 analysis charts, reflecting the growing dataset as new events arrive
- Interactive prediction panel: Enter a device's role, OS, hour, MAC type, and login result
- Click Run Security Check to get:
- A Trust Score (0β100)
- An access decision (ALLOW / RESTRICT / BLOCK)
- Decision Tree classification
- SVM threat-level prediction
- Full score breakdown table showing each factor's contribution
- Pipeline architecture overview
- Dataset summary table per role
- Model accuracy results
- Academic references
| Control | Description |
|---|---|
| β‘ Real-Time Monitoring toggle | Start / pause live event generation |
| Refresh Interval slider | Choose 2s / 3s / 5s / 8s auto-refresh |
| Session Stats | Uptime, live events generated, total records |
| Model Performance | Decision Tree & SVM accuracy |
| Access Policy table | Quick reference for the firewall rules |
graph LR
Sidebar["βοΈ Sidebar\nControls + Stats"] --> Dashboard
Dashboard["π₯οΈ Dashboard"] --> T1["π‘ Tab 1\nLive Feed"]
Dashboard --> T2["π Tab 2\nAnalytics"]
Dashboard --> T3["π€ Tab 3\nAI Engine"]
Dashboard --> T4["βΉοΈ Tab 4\nSystem Info"]
T1 --> Ticker["π Event Ticker"]
T1 --> Timeline["π 2-min Timeline"]
T1 --> LogTable["π Filterable Log"]
T3 --> Predict["βΆ Run Security Check"]
Predict --> TrustScore["π Trust Score"]
Predict --> DTpred["π² DT Prediction"]
Predict --> SVMpred["π΅ SVM Threat Level"]
| # | Chart | Description |
|---|---|---|
| 1 | Login Distribution | Simple bar chart β how many logins succeeded vs failed overall |
| 2 | Hourly Activity | Stacked bar chart showing activity patterns across all 24 hours |
| 3 | Anomaly Scatter | Shows suspicious login attempts (red β) by role and hour; highlights the 00:00β06:00 high-risk zone |
| 4 | Trust Score Distribution | Each dot = one login. Three colour zones: green (ALLOW β₯ 70), orange (RESTRICT 40β69), red (BLOCK < 40) |
| 5 | Access by Role | Side-by-side bars showing how many ALLOW vs BLOCK decisions each role received |
| 6 | Device Clustering | K-Means clusters plotted by encoded OS vs encoded Role β reveals natural device groupings |
| Model | Task | Accuracy |
|---|---|---|
| π² Decision Tree | Access Control Classification | ~90%+ |
| π΅ SVM (RBF Kernel) | Intrusion / Anomaly Detection | ~95%+ |
| π K-Means (k=3) | Device Fingerprint Clustering | Unsupervised (no accuracy metric) |
Exact results vary slightly each run due to the random nature of synthetic data generation. All runs use
random_state=42for reproducibility.
| Role | Hours Allowed | MAC Required | OS Required | Decision |
|---|---|---|---|---|
| π§βπ« Faculty | Anytime (00:00β23:59) | Registered | Known | β ALLOW |
| π Student | 07:00β22:00 (login must succeed) | Registered | Known | β ALLOW |
| π€ Guest | β | Registered | β | π« BLOCK |
| β Unknown MAC | β | β | β | π« BLOCK |
| β Unknown OS | β | β | β | π« BLOCK |
| π΄ Off-hours + failure | Before 06:00 or after 22:00 | β | β | π¨ ANOMALY |
| Technology | Version | Purpose |
|---|---|---|
| Python | 3.8+ | Core language |
| pandas | latest | Data manipulation |
| scikit-learn | latest | Decision Tree, SVM, K-Means, LabelEncoder |
| matplotlib | latest | Static chart generation |
| seaborn | latest | Chart styling |
| Streamlit | latest | Real-time web dashboard |
| joblib | latest | Saving / loading ML models |
| Windows Firewall (netsh) | β | Simulated network access rules |
- DEBAC: Dynamic Explainable Behavior-Based Access Control β IEEE, 2023
- Zero Trust Architecture SLR β TechRxiv, 2025
- Context-Based Access Control Using Dynamic Trust Scores β 2020
- Kindervag, J. β Zero Trust Network Architecture β Forrester Research, 2010
- scikit-learn documentation: https://scikit-learn.org
- Streamlit documentation: https://docs.streamlit.io
Developed for Computer Networks PBL β Woxsen University, 2026
Course: 24TU04MJM2 | Smart Campus Network with Automatic Access Control