Repository navigation
research(dpi): Anatomy of the "Morning Freeze" & State Flushing β Paqet vs Hawal Core Wire RecoveryΒ #1
Description
π Overview & Problem Statement
Across Iranian network operators (MCI, MTN Irancell, Shatel, Mokhaberat, etc.), network engineers and tunneling operators consistently observe a recurring anomaly between 05:30 and 06:30 AM local time (02:00 β 03:00 UTC), colloquially known as the "Morning Freeze" (ΩΨ±ΫΨ² Ψ΅Ψ¨ΨΪ―Ψ§ΩΫ).
During this window, long-lived encrypted tunnels suddenly stop passing traffic without receiving formal termination packets (RST or FIN). Instead, packets suffer silent absorption (blackholing).
π Comparative Analysis: Paqet vs. Hawal Core
A key finding from empirical observations:
| Feature / Metric | Paqet Wire (hanselime/paqet) |
Hawal Core v2.5.1 (rawpaq) |
|---|---|---|
| Underlying Carrier | Raw-TCP injected frames + KCP | Native Linux Raw-TCP + cBPF socket filtering + KCP |
| Morning Freeze Behavior | Connection freezes; KCP queue stalls indefinitely. | Session detects dead link via TypePong keepalive. |
| Recovery Requirement | Requires changing the core/internal port AND restarting the daemon. Sticking to the same port usually fails to unblock. | Recovers WITHOUT changing the port. Cycling the session/process on the identical port restores wire connectivity. |
| Stateful Memory | Static key, no PFS, high memory footprint (~76 MB). | Ephemeral Noise X25519 (PFS) + ChaCha20-Poly1305 AEAD, <20 MB RAM. |
π¬ What is the "Morning Freeze"? (Root Cause Analysis)
Based on network telemetry and middlebox research:
-
Scheduled Maintenance & Upstream BGP Migration:
- In accordance with standard telecom maintenance windows (lowest traffic trough), the Telecommunication Infrastructure Company (TIC / AS12880) and major domestic transit providers perform routine route updates, re-balancing international egress (e.g. Frankfurt, Turkey, Armenia, Persian Gulf paths).
- This shifts the active L3/L4 route to a different physical gateway or middlebox cluster.
-
Hardware Conntrack & Flow Table Flushing:
- Edge DPI devices (e.g. Huawei, Fortinet, and domestic DPI inspection hardware) operate bounded Transmission Control Block (TCB) / Conntrack tables in hardware TCAM.
- Periodic cron sweeps flush these tables to clear aged flows and prevent buffer exhaustion from long-lived connections.
-
The "Orphan Packet" Blackhole:
- Once the middlebox flow table is purged, mid-stream packets carrying established
PSH+ACKflags and high sequence counters arrive without prior SYN/ACK handshake state. - The newly initialized inspection cluster treats these as unsolicited/orphan packets and drops them silently (
Fail-Closed), locking standard TCP stacks in retransmission backoff loops.
- Once the middlebox flow table is purged, mid-stream packets carrying established
π― Next Steps: Researching Next-Gen Resilience Patterns
While Hawal Core v2.5.1 has proven it does not require changing ports to recover, our goal is to eliminate manual restarts or reactive process reboots entirely.
Key architectural patterns to investigate:
- Zero-Downtime Session Rotation (Warm Re-anchoring):
- Automatically spinning up a parallel ephemeral carrier path in the background every 30β45 minutes, seamlessly migrating active mux streams without user-facing connection drops.
- Decoupling Cryptographic Session from Physical Link:
- Retaining end-to-end authenticated session state while allowing the underlying raw socket to cycle dynamically.
- In-Band Quiet Re-Synchronization:
- Triggering a minimal, low-profile re-anchor handshake on dead-link detection without waiting for an operator or orchestrator restart.
Labels: dpi-research, core-v2, enhancement
Activity
dalroot commentedon Oct 4, 2026
π Research Update: Comprehensive Middlebox Audit & Morning Freeze Mechanics
We have completed and committed an in-depth technical research document to the repository:
π
docs/research/dpi-2026/morning-freeze-and-conntrack-flushing.mdThis update synthesizes network measurements, carrier-grade hardware documentation (Huawei, ZTE, Fortinet), and academic literature (USENIX Security, NDSS, RFCs).
1. Hardware Architecture & Middleboxes in Iranian Infrastructure
Network monitoring and transit routing across AS12880 (TIC) and Tier-1 ISPs (MCI AS197207, MTN Irancell AS44244, Shatel AS31549, TCI AS58224) deploy specific hardware tiers:
2. The Anatomy of the Morning Freeze (05:30 β 06:30 Local Time / 02:00 β 03:00 UTC)
PSH + ACKflags and high sequence counters.SYNhandshake in the active TCB are categorized as Out-of-State Orphan Packets.Fail-Closedpolicy, these packets are silently dropped (blackholed) without sendingRSTorICMP Unreachable.RSTis returned, client-side KCP/TCP protocol engines assume temporary congestion and enter exponential retransmission backoff, locking the session permanently.3. Survival Analysis: What Survives vs. What Freezes?
SYN), allocating a new TCB entry immediately.REKEY_AFTER_TIME = 120s,REJECT_AFTER_TIME = 180s). Every 2 minutes, fresh Noise IK handshakes are negotiated. A dead link triggers an immediate rekey handshake, automatically self-healing without restarting the process.PATH_CHALLENGE), migrating streams to a fresh ephemeral UDP port seamlessly.hanselime/paqet)TypePongdetects dead link in <45s. Hawal's process restart generates a fresh ephemeral raw socket, successfully re-registering on the exact same user port (port 24704) without port modifications.4. Proposed Architectural Mitigations for Hawal Core (Awaiting Final Decision)
To eliminate manual process restarts or panel interventions completely:
TypePongkeepalive detects a silent dead link (e.g. 30s timeout), Hawal's dialer automatically tears down the stalled raw socket, spins up a fresh ephemeral socket, and sends a clean handshake frame within 500msβwithout dropping the local forwarding listener or restarting the process.All findings and code references have been documented in the repository under
docs/research/dpi-2026/. Awaiting maintainer direction on which mitigation pattern to implement.dalroot commentedon Oct 4, 2026
π¬ Codebase Audit & Hypothesis Calibration (Response to Peer Review)
Following an in-depth source code audit of Hawal Core v2.5.1 and evaluation of peer review feedback, we have calibrated our research documentation and design specifications. All updates have been committed to master in
docs/research/dpi-2026/morning-freeze-and-conntrack-flushing.md(commitfb845af).1. Scientific Method: Observation β Hypothesis β Experiment
5.202.5.134β Netherlands192.209.62.115), we have repeatedly recorded silent blackholing during early morning hours (05:30 β 06:30 local time) across persistent tunnels (both Paqet and Hawal v2.5.1). ICMP reachability remains 100% intact, while transport streams stall indefinitely without receiving TCP RST or ICMP Destination Unreachable.PSH+ACKframes without active TCB state are silently dropped under strict stateful inspection (RFC 793/6528).2. Verified Codebase Audit of Hawal Core v2.5.1
session.go:L158-L164&relay.go:L103-L119sess.CloseWithError()resets all active streams (st.onRemoteReset()), which immediately terminates local user TCP connections (c.Close()). Decoupled stream migration is a roadmap goal for v2.6.session.go:L311-L337time.Since(last) > 45*time.Second) driven by a 15sTypePingticker.raw_linux.go:L310-L324PSH | ACK(0x18) with a random ISN. No TCP SYN 3-way handshake is performed on the wire.24704(fixed, user-facing on127.0.0.1).2. Remote Destination Port:
54237(fixed on VPS).3. On-Wire TCP 4-Tuple: Ephemeral source port randomized between 20000β55000 via
pickEphemeralPort()(raw_linux.go:L747-L753).3. Architecture Direction: Event-Driven Recovery vs. Periodic Rotation
A dedicated Carrier Manager that keeps user listeners and logical streams intact while handling reactive carrier reconstruction upon dead-link timeout. When silent blackholing occurs, the stale raw socket is released, a fresh raw socket with a clean 4-tuple is spawned, and the transport reconnects automatically without operator intervention.
dalroot commentedon Oct 4, 2026
π Core Implementation Merged via PR #2
The core engine enhancements, watchdog liveness telemetry, raw socket cleanup, and simulated silent blackhole resilience tests have been officially merged into
mastervia PR #2 (83db40f).Next Steps & Issue Status:
master.dalroot commentedon Oct 5, 2026
π 24-Hour Field Soak Update: Production Recovery During Morning Conntrack Window (Oct 5, 2026)
Following deployment of Hawal Core v2.5.1 to production edge nodes on October 4 at 19:28 UTC, we monitored live network behavior through the critical morning telecommunications maintenance window (05:30β06:30 AM local time / 02:00β03:00 UTC).
1. Empirical Log Evidence (Exact Timestamps & Carrier Re-establishment)
At 06:02:33 AM Tehran time (
02:32:33 UTC), the expected state flush / TIC BGP routing transition triggered a session termination. The new watchdog and carrier recovery subsystem handled the event as designed:(Note: Public IP addresses of client, transit, and destination nodes have been redacted in compliance with project privacy policies).
2. Key Engineering Findings
Local Ingress Listener Preserved (
Zero Zombie State):24704remained continuously bound and listening. Active user connections were not orphaned by process death.1-Second Carrier Re-establishment:
02:32:33to02:32:34).Production Throughput & Connection Health:
PID 3857694) has maintained continuous execution for >18 hours without crash or restart.ESTABLISHEDclient sessions running uninterrupted.3. Documentation & Ledger Updates
IR-16(Definitive confidence on verified node pair).docs/research/dpi-2026/morning-freeze-and-conntrack-flushing.md.HANDOFF.mdwith latest operational state.4. Next Step: Extended Soak Window
In strict adherence to our research guidelines (
AGENTS.mdβ do not generalize a single ISP, port, server pair, or single test date):dalroot commentedon Oct 7, 2026
π¬ Operational Soak Update: Resolution of the 45-Second Reconnect Loop & Stale Endpoint RST Storms (Oct 7, 2026)
Following the 24-hour observation of the morning conntrack window, continuous multi-day soak testing revealed a critical operational edge case on raw packet transports (
rawpaq/ AF_PACKET): an intermittent 45-second reconnection loop when a connection drop occurred.In accordance with our research principles (
AGENTS.md), we isolated the wire-level mechanics, collected concrete empirical packet captures, and implemented a structural architectural fix in Hawal Core v2.5.1.1. Root Cause Analysis & Empirical Evidence
Live kernel logs and network packet captures (
tcpdump&iptables -t mangle) on production edge nodes revealed the exact failure sequence:Ephemeral Port Churning on the Wire:
core/v2/carrier/rawpaq/raw_linux.go, the client raw carrier previously selected an ephemeral port viapickEphemeralPort()on every carrier re-establishment.rawpaqconstructs raw Ethernet/IP/TCP frames directly via LinuxAF_PACKET SOCK_RAW, this ephemeral port was written directly into bytes 0:2 of the on-wire TCP header.50441,24176), while the remote server was still actively retransmitting unacknowledged KCP frames to the client's previous, closed ephemeral port (54237).Kernel TCP RST Emission & DPI Heuristic Trigger:
TCP RSTpackets back to the server.tcp dpt:54237 flags:0x04/0x04).2. Architectural Fix in Hawal Core v2.5.1
We implemented a two-part architectural enhancement to permanently eliminate stale endpoint traffic:
Deterministic Source Port (
source_port):SourcePortconfiguration torawpaqcarrier configs, CLI flags (-source-port), and panel client generator (hawal_engine.py).raw_linux.go,req.SourcePortis honored directly when populating the raw TCP header, ensuring the client consistently binds to the designated tunnel port (matchingcore_portby default).Atomic Session Eviction (
session.Evict()):evicted atomic.Bool) incore/v2/engine/session.go.core/v2/engine/engine.go, incoming links on the server atomically evict prior active sessions in sub-millisecond time.3. Verification & Live Production Rollout
Automated Tests:
core/v2/carrier/rawpaq/rawpaq_port_test.go(TestSourcePortValidation,TestSourcePortCarrierRequest).core/v2/engine/eviction_test.go(TestSessionAtomicEvictionStopsWrites).PASS, including end-to-end blackhole recovery).Production Deployment:
58e07818fe8c4ef163c674054cd5fa507ed1b73ca046801cae0f687a42e0565e) to production edge nodes (Iran5.202.5.134and Netherlands192.209.62.115).tcpdumpconfirms symmetrical, static port binding on the wire (54241:54241):24704forwarder is continuous, zero RST packets recorded, and the 45s reconnect loop is completely resolved.Evidence Ledger:
IR-17indocs/research/dpi-2026/evidence-ledger.md.