Research

Long write-ups on network analysis, automation and self-hosting.

What I built, how it works and what it showed: a research project from my internship in France, and two systems I run at home.

An empty tiered lecture hall with blue seats and long wooden desks

December 2023, 08:28

Delay through a CoDel queue, drawn after my testbed traces: the shape the classifier in the first write-up learned to recognise.

Active Queue Management classification and analysis

A C testbed and a two-stage DTW classifier that identify which AQM algorithm a bottleneck router runs, from RTT traces alone.

The AQM testbed: two desktop towers either side of a network switch on a wooden lab bench, with terminals open on both screens
The testbed: two hosts and the bottleneck between them.

During my research internship at Institut Polytechnique de Paris and later at Télécom SudParis, I developed a full testbed and classification framework capable of identifying which Active Queue Management (AQM) algorithm is running in a bottleneck router. The system was designed to distinguish between algorithms such as CoDel, FQ-CoDel, Cake, PIE, RED, FIFO, and FQ. The ultimate goal was to analyse how these queue disciplines affect congestion, latency, and fairness, and to build a detection system that operates without privileged access to the router.

Objective

The main objective was to identify the AQM algorithm active in a network bottleneck using only RTT traces collected from UDP traffic. This required creating an experimental framework that generated, captured, analysed, and compared large quantities of network data automatically. The classification needed to remain accurate across varying link speeds, queue lengths, and packet sizes.

Architecture overview

The system was structured around three main machines forming a controlled testbed:

  • Client: Responsible for generating UDP traffic and recording RTT measurements in real time.
  • Router: Configured with different AQM algorithms via Linux’s tc qdisc system (CoDel, FQ-CoDel, PIE, RED, Cake, FIFO, and FQ). This device acted as the network bottleneck, enforcing queuing delay and packet drops.
  • Server: Received packets and sent acknowledgements back to the client, closing the feedback loop.

Each component interacted through a Python-based orchestration layer that coordinated configuration, data collection, and experiment timing. The design allowed repeatable testing under controlled parameters such as bitrate, queue size, and packet interval.

Workflow

  1. Connection establishment: The master client connects to the master server over TCP.
  2. Bottleneck measurement (1): The server runs the bitrate measurement server binary. The client runs the corresponding measurement client binary and extracts the bottleneck bitrate.
  3. Bottleneck type verification (2): The server runs the bottleneck type checker binary. The client runs the type checker client binary at the measured bitrate + 2 Mbit/s. If throughput increases significantly, the bottleneck may be CPU or another factor; otherwise it is confirmed as interface speed.
  4. Queue size measurement (3): The server runs the queue measurement server binary. The client extracts the queue length in packets.
  5. Queue consistency check: The client estimates queuing delay based on bitrate, packet size, and measured queue length. If the estimated sojourn time is very small, a warning is raised but the experiment continues.
  6. Simulation-based test time estimation (4): The client runs a CoDel simulation using measured parameters. The simulation suggests an experiment duration; if invalid, 30 seconds is used as default. Final test time = simulation time + 1 second.
  7. AQM/FQ measurement (5): The server starts the AQM/FQ measurement binary. The client launches the classification measurement tool, tuned with adjusted bitrate, packet size, and estimated test time. RTT traces are collected.
  8. File transfer: The client sends all generated CSV files to the server.
  9. Classification (6): The server runs the Python classifier with the correct template family. The classification result is sent back to the client and logged.
  10. Completion: Both sides close the connection.
Architecture diagram: the master client and server coordinate bottleneck measurement, queue-size measurement, a CoDel simulation, RTT capture, CSV transfer and the DTW classifier over SSH.
Figure 1. Overall architecture of the AQM classification and analysis framework.

Detailed architecture components

1. Traffic generation and RTT measurement

I implemented multiple C programs that used both raw UDP sockets and standard UDP sockets to simulate various traffic flows with high timing accuracy. Instead of relying on usleep() or fixed sleep intervals, the sender dynamically tracked elapsed time since the start of transmission and computed how many packets should have been sent by that point. If the actual number of sent packets lagged behind the theoretical rate, the sender immediately sent the necessary packets to catch up.

This timing control approach ensured consistent and precise bitrate regulation without cumulative drift caused by system-level sleep inaccuracies. Each sender operated based on a defined target bitrate, allowing accurate reproduction of network load at different transmission speeds.

  • Bitrate-based pacing by calculating expected packet count from elapsed time since start.
  • Configurable payload size and total packet count per experiment.
  • Support for concurrent sender threads to simulate multiple independent flows.

Round-Trip Times (RTTs) were measured at the client side by timestamping outgoing packets and matching them with acknowledgement timestamps received from the server. The resulting RTT traces were stored as time-series datasets, capturing queue buildup, delay oscillations, and congestion patterns under each tested AQM discipline.

RTT-over-time traces for each AQM: CoDel and PIE show periodic oscillations, RED smoother random variation, FIFO a flat congestion plateau with spikes, and the fair-queuing disciplines stable, well-separated per-flow RTTs.
Figure 2. RTT over time under each queue discipline. CoDel and PIE swing in regular arches, RED wanders, FIFO sits on a plateau, and the fair-queuing disciplines stay flat and well separated.

2. Router configuration and AQM control

The router (a Linux system acting as a virtual bottleneck) was configured using tc qdisc commands. A shell-based configuration script applied the desired AQM discipline on the egress interface:

root@router:~# tc qdisc add dev eth0 root codel limit 1000 target 5ms interval 100ms
root@router:~# tc qdisc add dev eth0 root pie limit 1000 target 20ms tupdate 15ms
root@router:~# tc qdisc add dev eth0 root fq_codel
# etc.

Additional scripts removed qdiscs cleanly after each experiment.

3. Bottleneck analysis and pre-processing

  • Bottleneck bitrate estimation: A C program transmitted UDP packets and the server approximated the link’s maximum sustainable rate by looking at the maximum received rate.
  • Queue length estimation: Another C program measured queue buildup time to calculate queue depth.
  • CPU bottleneck detection: Another C program ensured the observed delay was due to link capacity, not processor limitations.

4. CoDel simulation

I implemented a Python simulation of the CoDel algorithm faithfully based on the Linux kernel’s CoDel implementation. This simulation studied how network parameters such as bottleneck bitrate, packet size, queue length, and added bitrate influence delay control behaviour. It also provided a reference RTT pattern used to calculate the needed total test time and for future classification comparisons.

5. Data collection and storage

Each experiment produced multiple CSV trace files:

  • Per-packet RTT measurements (timestamp, RTT value, sequence number).
  • Metadata files containing AQM type, bitrate, queue length, and parameters.

All data was organised hierarchically by AQM type and bitrate for structured post-processing.

6. Classification and analysis engine

The classifier was implemented in Python using Dynamic Time Warping (DTW) to measure similarity between new RTT traces and pre-recorded template traces of each AQM type. Two classification stages were applied:

  • Stage 1: Distinguish between fair-queuing AQMs (FQ-CoDel, FQ, Cake) and non-fair-queuing ones (CoDel, PIE, RED, FIFO).
  • Stage 2: Perform fine-grained classification within each group using normalised DTW distance metrics and flow correlation behaviour.

Automation framework

A central Python orchestration script handled:

  • SSH-based remote control of client, router, and server machines.
  • Automated setup and teardown of AQM configurations.
  • Timed execution of traffic experiments and collection of logs.
  • Computation of DTW similarity matrices and accuracy statistics.

Results

The developed framework achieved high classification accuracy under a wide range of network conditions, including variations in bitrate, queue length, and packet size. In controlled testbed environments, the system consistently distinguished between all tested AQM algorithms with strong separation in their RTT profiles.

Evaluated with a live client and router over an operational network, the classifier kept an overall accuracy of 87%, holding up outside laboratory conditions.

Classification accuracy per AQM for the ideal testbench, the testbench with a remote server, and home-network tests; the home-network line stays close to the two lab lines.
Figure 3. Accuracy per algorithm: blue is the ideal testbench, orange the ideal testbench with a remote server, and cyan the home-network tests.

Each AQM exhibited a distinct temporal signature in the RTT traces:

  • CoDel and PIE displayed highly recognisable periodic delay oscillations corresponding to their active queue control cycles, making them the most easily distinguishable algorithms.
  • RED showed probabilistic yet smoother delay variations resulting from its random early drop mechanism, producing moderate oscillations without strict periodicity.
  • FQ-CoDel, Cake, and FQ each displayed their own characteristic RTT signatures in single-flow conditions. All three demonstrated clear evidence of per-flow fairness and reduced inter-flow interference, with RTTs remaining stable and well-isolated between flows.
  • FIFO traces were dominated by congestion plateaus and sharp delay spikes, reflecting unregulated queue buildup and absence of any active queue control.

These results confirm that end-to-end RTT measurements carry sufficient information to infer the active queue management policy at a bottleneck router. The classification performance validates the effectiveness of combining precise C-level traffic generation, kernel-level AQM configuration, and DTW-based pattern matching for automated queue behaviour identification.

Conclusion

Terminal output of a live classification run on an operational network, ending with the detected AQM algorithm.
Figure 4. A live classification run on an operational network, ending with the detected algorithm.

This project is a framework for identifying and analysing Active Queue Management (AQM) algorithms using only end-to-end network measurements. It combines C-based traffic generation, precise RTT collection, kernel-level AQM configuration, and Dynamic Time Warping (DTW)-based classification to recognise queue management behaviour accurately and automatically, without any access to the routers.

It correlates time-domain RTT dynamics with the underlying queue control logic, which makes fine-grained differentiation possible between AQMs such as CoDel, PIE, RED, Cake, FQ-CoDel, FQ, and FIFO. The design is modular and fully automated, so it works both in a controlled testbed and on real networks.

The results show that passive AQM classification is feasible and practical. The same approach could serve as a basis for systems that identify, simulate, and tune queue management automatically.

Classification also gives visibility into bottleneck behaviour: network operators can identify the active AQM and tune their congestion control to match. This has dual security implications. Attackers could use AQM identification as a reconnaissance step to craft targeted strategies, but defenders gain from it too: knowing the active AQM lets adaptive congestion control respond under attack or in hostile conditions, preserving network stability and throughput.

Future extensions include integrating reinforcement learning to predict queue type adaptively and simulating all AQMs to generate on-the-fly perfect templates given network parameters.

You can also watch the seven disciplines in the queue simulator.

Home server infrastructure, automation and observability

A self-hosted Ubuntu server running Python services, an automated YouTube pipeline, Prometheus and Grafana, exposed through Cloudflare Zero Trust.

I designed and deployed a self-hosted Ubuntu server environment operating as a personal cloud, automation engine, and monitoring platform. The system runs continuously and hosts multiple production-grade Python services, supported by a full observability stack and secured through a Zero Trust architecture.

Hand-drawn architecture sketch: Python YouTube and FTP services on the server, a Cloudflare secure tunnel replacing NAT port forwarding, SSH portal and request-access pages, and a Grafana usage monitor.
Figure 1. How the pieces connect: services, tunnel, access pages and monitoring, in my original sketch.

Infrastructure architecture

  • Ubuntu Server (VM-based): Centralised host running all automation and monitoring services.
  • Systemd-managed services: All Python applications run as managed services with automatic restart policies and failure handling.
  • Isolated Python virtual environments: Dependency separation for reliability and maintainability.
  • Structured logging: JSON-based logs for automation tasks and service health tracking.

Fully automated YouTube content pipeline

I developed a complete end-to-end automated YouTube publishing system that generates content, converts it to media, assembles the final video, and uploads it without manual intervention.

1. Content generation layer

  • Integration with the Google Gemini API for automated script generation.
  • Automatic fallback to an older Gemini model when API rate limits or quota limits are reached.
  • Structured JSON parsing to extract titles, descriptions, and script bodies reliably.

2. Media processing pipeline

  • Text-to-Speech generation using API-based voice synthesis.
  • Automated audio normalisation and processing.
  • Video rendering using programmatic video assembly.
  • Dynamic audio overlay and synchronisation between narration and visuals.
  • FFmpeg-based encoding and final export pipeline.

3. YouTube integration

  • Secure OAuth-based integration with the YouTube Data API.
  • Automated upload with metadata injection (title, description, tags, visibility).
  • Upload status monitoring and structured success/failure logging.

The entire pipeline is orchestrated through Python, with exception handling, retry mechanisms, and logging to handle API limits and transient failures.

Custom media ingestion service (Python FTP server)

To support content workflows, I implemented a lightweight Python-based FTP server that enables secure transfer of media files from my mobile device directly to the server.

  • Dedicated service for controlled upload of images and videos.
  • Directory-based separation for automated processing pipelines.
  • Runs as a managed background service with restart policies.
  • Monitored via Prometheus exporter for service health and activity metrics.

Observability and monitoring stack

The server is instrumented with full-stack monitoring to ensure continuous visibility into system performance and application health.

1. Infrastructure monitoring

  • Prometheus collects system-level metrics (CPU, RAM, disk I/O, network).
  • Grafana dashboards provide real-time visualisation and historical trend analysis.
Grafana dashboard of host metrics: CPU, memory, disk I/O and network throughput over time.
Figure 2. Host metrics in Grafana: CPU, memory, disk and network over time.

2. Custom application metrics

  • Developed a custom Python Prometheus exporter.
  • Exposes service state (running, failed, restarting).
  • Exports task-level metrics such as upload success rate, processing duration, and error counters.
  • Tracks FTP server activity and connection statistics.
Grafana dashboard fed by the custom Python exporter: service states, upload success rate, processing durations and FTP activity.
Figure 3. The custom exporter’s dashboard: service states, upload success rate, processing time and FTP activity.

3. Uptime monitoring

  • Deployed Uptime Kuma to monitor:
    • Ubuntu server availability
    • peterfarah.com
    • farmavetservices.com
  • Alerting mechanisms for downtime detection.
Uptime Kuma status page listing the server, peterfarah.com and farmavetservices.com monitors with their response-time history.
Figure 4. Uptime Kuma watching the server, peterfarah.com and farmavetservices.com.

Zero Trust remote access architecture

Instead of exposing services via port forwarding, I implemented Cloudflare Zero Trust Tunnel to securely expose internal services while keeping the server protected behind NAT.

Cloudflare Zero Trust application list for the SSH, Grafana and uptime hostnames.
Figure 5. The Zero Trust applications for the SSH, Grafana and uptime hostnames.
  • Secure SSH access via ssh.peterfarah.com.
  • Grafana dashboard accessible at grafana.peterfarah.com.
  • Uptime dashboard accessible at up.peterfarah.com.
  • Request limited access: access.peterfarah.com.
  • No inbound ports opened on the router.
  • Access control policies enforced at the Cloudflare layer.

Engineering principles applied

  • Automation-first system design
  • Resilience through fallback mechanisms and service restart policies
  • Structured observability with custom instrumentation
  • Secure-by-design remote access using Zero Trust architecture
  • Production-style service orchestration in a self-hosted environment

Enterprise-grade home storage on a Synology DS925+

A Synology DS925+ with two 18 TB drives in SHR-1, Btrfs snapshots, Docker apps and a single Cloudflare Zero Trust tunnel.

A four-bay Synology DS925+ on a wooden desk, green drive lights on, a router and access point behind it
Eighteen terabytes twice over, snapshotting quietly in the corner of a room.

To support growing data requirements and ensure reliable backups for the home infrastructure, a dedicated Network Attached Storage (NAS) solution was implemented. The architecture centers around a Synology DS925+, populated with dual 18 TB Seagate Exos enterprise-grade hard drives.

Storage configuration and file system

The drives are configured using Synology Hybrid RAID (SHR1), which is more flexible and easier to expand than traditional RAID 5. To protect against bit rot, the volumes use the Btrfs file system, which adds data scrubbing and snapshots.

Snapshot retention and storage efficiency

Btrfs snapshots run on a retention schedule: daily snapshots are kept for 90 days and monthly snapshots for a full year. Because the NAS is mostly used for mobile photo backups, files are rarely edited or deleted, so the snapshots take up very little extra space while still allowing an immediate rollback after accidental deletion or a ransomware attack.

Automated workflows and cold storage

The NAS is the central, self-hosted hub for several backup streams. Synology Photos syncs mobile media over the network, entirely within a Zero Trust environment, and the NAS also continuously backs up important files from the main PC. For disaster recovery, any data that lives only on the NAS is copied by hand to an offline cold-storage drive every few months, so there is always an air-gapped fallback.

Network integration and transfer speeds

To avoid local network bottlenecks during large file transfers and media syncing, a dedicated 5GHz-capable OpenWrt router was added to the local network. It provides fast, low-latency Wi-Fi, so the NAS isn’t held back by the ISP’s standard equipment.

Containerized applications and observability

The NAS also hosts applications in Docker containers. The observability stack includes Prometheus and Grafana (operating on host networking) alongside an SNMP exporter to monitor system health, storage metrics, and network performance. Additionally, the NAS hosts a custom-built Python application (Treasury Vault) for financial tracking and bookkeeping.

Synology Container Manager project list: the observability stack, the Treasury Vault app and the Cloudflare tunnel.
Figure 1. Container Manager: the observability stack, Treasury Vault and the Cloudflare tunnel.

Centralized Zero Trust architecture

Instead of exposing services via port forwarding, a centralised Cloudflare Zero Trust Tunnel is deployed as a standalone Docker container. Rather than running a separate tunnel for each individual application, this single global gateway handles routing to multiple services (including Grafana, and Treasury Vault) by mapping Cloudflare Public Hostnames directly to the NAS’s local IP and corresponding container ports. This architecture drastically simplifies the deployment of new services while maintaining strict access control and isolating the internal network.

Cloudflare Zero Trust public hostnames mapped to the NAS containers.
Figure 2. Public hostnames mapped to the NAS containers.
  • Grafana dashboard accessible at nas-grafana.peterfarah.com.
  • No inbound ports opened on the router.
  • Access control policies enforced at the Cloudflare layer.