<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: George Kutsurua</title>
    <description>The latest articles on DEV Community by George Kutsurua (@suquant).</description>
    <link>https://dev.to/suquant</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3714248%2Fbe2b572d-e993-4c15-88fa-a34abe41b89a.jpg</url>
      <title>DEV Community: George Kutsurua</title>
      <link>https://dev.to/suquant</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/suquant"/>
    <language>en</language>
    <item>
      <title>Forty Hours "Connected", Zero Bytes: A Postmortem of Our Own Tunnel</title>
      <dc:creator>George Kutsurua</dc:creator>
      <pubDate>Tue, 24 Nov 2026 13:44:26 +0000</pubDate>
      <link>https://dev.to/forestvpn/forty-hours-connected-zero-bytes-a-postmortem-of-our-own-tunnel-al</link>
      <guid>https://dev.to/forestvpn/forty-hours-connected-zero-bytes-a-postmortem-of-our-own-tunnel-al</guid>
      <description>&lt;p&gt;For almost two days the tunnel on our MikroTik router looked healthy: a handshake roughly every three minutes, the server could see the peer, and not a single WARN in the log. In those 40 hours, not one byte of user data crossed the tunnel in either direction.&lt;/p&gt;

&lt;p&gt;There was a network outage, about eight minutes of it. What made it permanent was our own state machine: because of one rule, half a minute of one-way packet loss was enough to put the tunnel into a state with no way out. WireGuard itself behaved exactly as specified. Below are the logs from both ends, the mechanism and the fix, and at the end, what we still don't know.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this tunnel is
&lt;/h2&gt;

&lt;p&gt;Quantum is the tunnel engine we build for &lt;a href="https://fvpn.net" rel="noopener noreferrer"&gt;ForestVPN&lt;/a&gt;. Its handshake is WireGuard's Noise_IKpsk2 with not a single byte changed. That matters: the formal analysis of WireGuard covers the unmodified protocol, and any "improvement" to the handshake puts you outside it. So everything we add goes around the handshake, and the handshake itself stays untouched.&lt;/p&gt;

&lt;p&gt;One of those things is a post-quantum secret in the PSK slot. Noise_IKpsk2 has room for a 32-byte pre-shared key, and the &lt;a href="https://www.wireguard.com/papers/wireguard.pdf" rel="noopener noreferrer"&gt;WireGuard whitepaper&lt;/a&gt; describes it as an optional extra layer of symmetric encryption against future quantum computers. The goal is simple: traffic recorded today should not be decryptable later. The secret in the PSK slot is mixed into the usual X25519 exchange; it doesn't replace it. Our exchange itself has not been formally analysed, which is part of why the scheme is hybrid: a bug in the post-quantum part cannot make the tunnel's encryption weaker than plain WireGuard's. It can still stop the tunnel from carrying anything, as the rest of this post shows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://rosenpass.eu/" rel="noopener noreferrer"&gt;Rosenpass&lt;/a&gt; takes the same route, but negotiates its key separately, with its own daemon on its own UDP port. That didn't work for us: you can't run a separate root daemon inside a mobile app. So our ML-KEM-1024 exchange runs inside the tunnel itself:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The client does a normal handshake, but with a "control" PSK derived from the base one. The result is a session of class &lt;code&gt;Control&lt;/code&gt;. Only housekeeping frames travel over it: keepalives, path probes and the key exchange itself.&lt;/li&gt;
&lt;li&gt;Over the &lt;code&gt;Control&lt;/code&gt; session the client sends an Offer carrying an ML-KEM encapsulation key, and the server answers with a ciphertext. An ML-KEM-1024 key and ciphertext are 1568 bytes each, so that's two full-size datagrams in each direction.&lt;/li&gt;
&lt;li&gt;Both sides now hold a shared 32-byte secret, and the client immediately starts a new handshake with that secret in the PSK slot. In IKpsk2 the PSK only enters the second message, so the client flags this init as "armed", and a server that holds the same secret answers under it. That is a &lt;code&gt;Keyed&lt;/code&gt; session, and user data travels only over &lt;code&gt;Keyed&lt;/code&gt; sessions.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The whole thing exists for the sake of one rule: in &lt;code&gt;require&lt;/code&gt; mode, not a single user byte is sent over a session that lacks the post-quantum secret. There is no silent fallback to classic WireGuard. If there were, any node on the path could trigger it: the exchange frames are encrypted, but they are recognisable by size and timing (two full-size datagrams right after a handshake), and dropping them would be enough. In strict mode such a node can only cut the connection, and that is supposed to be visible. The next 40 hours showed how much weight "supposed to" was carrying.&lt;/p&gt;

&lt;p&gt;The exchange has its own small state machine: &lt;code&gt;pending&lt;/code&gt; → &lt;code&gt;arming&lt;/code&gt; → &lt;code&gt;on&lt;/code&gt;. If something goes wrong (a response is lost, the server has forgotten the secret, a phase hangs for more than 10 seconds), the client resets: it throws the secret away and starts the exchange over. If more than three resets happen in a row without ever reaching &lt;code&gt;on&lt;/code&gt;, the machine moves to &lt;code&gt;failed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;In the version this story is about, the state table said this next to &lt;code&gt;failed&lt;/code&gt;: "Terminal for this Tunn". In other words, final for the lifetime of this tunnel object.&lt;/p&gt;

&lt;h2&gt;
  
  
  The setup
&lt;/h2&gt;

&lt;p&gt;On the MikroTik, our &lt;code&gt;fv&lt;/code&gt; client runs in a RouterOS container in static mode: a config file, one peer, no control plane. The tunnel goes to one of our own servers, with &lt;code&gt;PostQuantum = require&lt;/code&gt; in the config. Our main router, a separate box, sent some internal traffic through this tunnel, including SSH to our servers.&lt;/p&gt;

&lt;p&gt;For two weeks it ran without a hitch, usually with a handshake every couple of minutes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Timeline
&lt;/h2&gt;

&lt;p&gt;All times UTC, 8 October 2026. We never measured the offset between the router and server clocks, so we line up events from the two ends with care.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Time&lt;/th&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;th&gt;What&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;13:13:14&lt;/td&gt;
&lt;td&gt;router&lt;/td&gt;
&lt;td&gt;Last successful handshake before the outage&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:13–13:15&lt;/td&gt;
&lt;td&gt;router&lt;/td&gt;
&lt;td&gt;15 lines of &lt;code&gt;Decapsulate error WrongIndex&lt;/code&gt;: packets from the server &lt;strong&gt;are still arriving&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;~13:14:48&lt;/td&gt;
&lt;td&gt;server&lt;/td&gt;
&lt;td&gt;Outgoing session is stale and data is queued, so the server starts a handshake&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:15:19&lt;/td&gt;
&lt;td&gt;router&lt;/td&gt;
&lt;td&gt;&lt;code&gt;post-quantum exchange ended reason="pq_resets"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:16:18&lt;/td&gt;
&lt;td&gt;server&lt;/td&gt;
&lt;td&gt;Gives up after 90 seconds of attempts (&lt;code&gt;REKEY_ATTEMPT_TIME&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:20:07&lt;/td&gt;
&lt;td&gt;router&lt;/td&gt;
&lt;td&gt;Handshakes succeed again; the path is back&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;13:20:50&lt;/td&gt;
&lt;td&gt;server&lt;/td&gt;
&lt;td&gt;The server-initiated handshake completes&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;next 40 h&lt;/td&gt;
&lt;td&gt;both&lt;/td&gt;
&lt;td&gt;A handshake every 180–197 seconds, mostly 180–184. Zero user data in either direction&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;10 October, ~05:29&lt;/td&gt;
&lt;td&gt;router&lt;/td&gt;
&lt;td&gt;Container restarted. Data flows immediately&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Router log (peer key redacted):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2026-10-08T13:13:14.687613Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242503 session=7
2026-10-08T13:15:19.287223Z  INFO fvpn::net::noise: peer(…) - post-quantum exchange ended reason="pq_resets"
2026-10-08T13:20:07.937619Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242540 session=4
2026-10-08T13:23:07.983870Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242542 session=6
2026-10-08T13:26:11.187995Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242544 session=0
…
2026-10-10T05:22:16.189936Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242567 session=7
2026-10-10T05:25:16.388691Z  INFO fvpn::net::noise: peer(…) - Handshake complete local_idx=3333242569 session=1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;local_idx&lt;/code&gt; grew by only a couple of dozen over 40 hours, and not because the log was trimmed: the counter lives in the low byte of the index and wrapped around several times. &lt;code&gt;session&lt;/code&gt; is the slot number in a ring of eight sessions.&lt;/p&gt;

&lt;p&gt;Notice what isn't there: not one WARN and not one ERROR. From 13:20 on the 8th to 05:25 on the 10th the log holds nothing but &lt;code&gt;Handshake complete&lt;/code&gt; roughly every three minutes, plus five &lt;code&gt;Decapsulate error NoCurrentSession&lt;/code&gt; lines that this build printed to stderr without a timestamp. Judging by this log, or by a "latest handshake" field, the tunnel was fine. Even the move into a state with no exit was logged at INFO, as &lt;code&gt;exchange ended&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The server, meanwhile, knew the truth. Its &lt;code&gt;fv show&lt;/code&gt; for this peer showed a fresh handshake, exchange state &lt;code&gt;pending&lt;/code&gt; and last data "1 day ago". Nobody asked it.&lt;/p&gt;

&lt;h2&gt;
  
  
  We blamed the network first
&lt;/h2&gt;

&lt;p&gt;We didn't notice the outage from an alert. We noticed because the things that went through the tunnel stopped working. The first hypothesis was the network: the link had started dropping UDP to this server.&lt;/p&gt;

&lt;p&gt;So we checked the network. TCP to that server outside the tunnel, from a laptop on the same network: 2 MB at about 5.4 Mbit/s, no sign of rate limiting. That showed the server and the path were up, but said little about UDP. After the container restart, data went through the tunnel straight away: 4 MB at about 13 Mbit/s. The restart on its own proved nothing, though: the new process might have come up on a different source port, and a per-flow limit would have reset along with it. What settled it was the client log. The &lt;code&gt;exchange ended&lt;/code&gt; line meant the client had stopped sending data by itself, under a rule we had written ourselves. And the handshakes, which went through in both directions for all 40 hours, showed that UDP was reaching the server.&lt;/p&gt;

&lt;h2&gt;
  
  
  How a short outage produced four resets
&lt;/h2&gt;

&lt;p&gt;The first thing that bothered us: four resets in one outage is a lot. A reset almost always requires evidence, meaning an authenticated packet from the peer: a repeated init from the server, a response under the control PSK to one of our armed inits, or an explicit refusal. There is one exception, the 10-second phase timeout, and it only fires in &lt;code&gt;pending&lt;/code&gt; and &lt;code&gt;arming&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That leads to a non-obvious conclusion: &lt;strong&gt;a symmetric outage resets nothing&lt;/strong&gt;. If nothing arrives from either side there is no evidence, the secret outlives the expiring sessions, and once the path comes back the tunnel carries on in &lt;code&gt;on&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Our outage was asymmetric. From here on, "downlink" means server to client and "uplink" means client to server. Those 15 &lt;code&gt;WrongIndex&lt;/code&gt; lines were packets from the server that kept reaching the router (by then their slots in the session ring had been taken by new indices). The downlink was delivering; the uplink was losing everything. An outage like that manufactures its own evidence:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The server's outgoing session goes stale. It has queued data, so it starts a handshake.&lt;/li&gt;
&lt;li&gt;The client responds under the post-quantum PSK. The response is lost on the uplink.&lt;/li&gt;
&lt;li&gt;After &lt;code&gt;REKEY_TIMEOUT&lt;/code&gt; (5 seconds plus up to 333 ms of jitter) the server retries the init. To the client that's a second init within 15 seconds, which it reads as a sign that the server has lost the secret. Reset #1, secret discarded.&lt;/li&gt;
&lt;li&gt;The client starts the exchange over. Whatever it sends upstream, a handshake or the Offer, is lost too.&lt;/li&gt;
&lt;li&gt;Three phase timeouts in a row: resets #2, #3 and #4.&lt;/li&gt;
&lt;li&gt;Four resets is more than three. &lt;code&gt;failed&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A repeated init is standard WireGuard behaviour when a response doesn't arrive. But to the client it is indistinguishable from a server that has lost the secret, after a restart for example: in both cases a new init arrives and a session on the shared secret never opened. The rule picks the safe reading and runs the exchange again. We kept that rule. What needed fixing was what happened after it.&lt;/p&gt;

&lt;p&gt;The arithmetic adds up: the server started initiating at about 13:14:48, plus 5 seconds to the retry, plus 30 seconds for three timeouts, gives 13:15:23. The log says 13:15:19, a difference that fits within one retry interval and the clock offset. The INFO logs can't prove the exact trigger, but the mechanism itself is pinned down by unit tests: one lost response gives reset #1, and three timeouts in a row give &lt;code&gt;failed&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The worst part of that arithmetic is that &lt;strong&gt;the eight-minute outage wasn't needed&lt;/strong&gt;. About 35 seconds of uplink loss after the first piece of "evidence" would have done it.&lt;/p&gt;

&lt;p&gt;A word on the 37 session indices used in those 7 minutes (&lt;code&gt;local_idx&lt;/code&gt; went from 3333242503 to 3333242540 in the log above), which at first looked like a handshake storm. There was no storm. The index goes up with every init sent and every response, and two ordinary WireGuard retry series overlapped: the server's 90-second one and the client's. 37 in 413 seconds is 0.09 per second, below the normal limit for a single side (one init per 5 seconds, or 0.2 per second).&lt;/p&gt;

&lt;h2&gt;
  
  
  Why the tunnel stayed dead
&lt;/h2&gt;

&lt;p&gt;Now back to that line, "Terminal for this Tunn". There was no way out of &lt;code&gt;failed&lt;/code&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;without a secret, the client sends inits under the control PSK, the server answers the same way, and every new session comes out as &lt;code&gt;Control&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;data is not sent over a &lt;code&gt;Control&lt;/code&gt; session, by that very rule, so it waits in the queue;&lt;/li&gt;
&lt;li&gt;waiting data doesn't start a new exchange: asked "is anything due?", the machine in &lt;code&gt;failed&lt;/code&gt; answers "nothing".&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That left only the handshakes WireGuard produces on its own. A session expires after &lt;code&gt;REJECT_AFTER_TIME&lt;/code&gt;, 180 seconds, and the next packet with no session triggers an init. Hence the interval of just over three minutes in the log. Every three minutes the tunnel brought up a fresh session it was not allowed to send any data over.&lt;/p&gt;

&lt;h2&gt;
  
  
  Who else was affected
&lt;/h2&gt;

&lt;p&gt;After the postmortem we went through every place this state machine lives and looked at what each one does with &lt;code&gt;failed&lt;/code&gt;.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Where&lt;/th&gt;
&lt;th&gt;What happened after &lt;code&gt;failed&lt;/code&gt;
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;fv run&lt;/code&gt;, static mode (our case, the MikroTik container)&lt;/td&gt;
&lt;td&gt;Dead until restarted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;fv up&lt;/code&gt; with the agent (OpenWrt, MikroTik managed by the control plane)&lt;/td&gt;
&lt;td&gt;Three immediate reconnects, each with a new tunnel object, then status &lt;code&gt;Blocked&lt;/code&gt; until the session was renewed or the process restarted&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Desktop, Windows and Linux&lt;/td&gt;
&lt;td&gt;Three reconnects; for a longer outage, a visible error until the user reconnected manually; the kill switch holds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;iPhone and Android&lt;/td&gt;
&lt;td&gt;Showed the &lt;code&gt;ne.pq_failed&lt;/code&gt; error and didn't claim "connected", but didn't reconnect on their own. The tunnel sat dead until the user tapped something&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Servers&lt;/td&gt;
&lt;td&gt;Never enter &lt;code&gt;failed&lt;/code&gt;; they only respond&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Only the desktop recovered by itself, and only if the outage was short. Everything that runs unattended stayed dead.&lt;/p&gt;

&lt;p&gt;Did this reach users? This tunnel was ours. The exchange was switched on across the whole server fleet on 11 October, the day after the fix; before that it ran only on a few servers in a trial mode. The control plane offers the exchange only to clients that send a particular capability flag, and every released build that sends it already contains the fix. All other clients use the classic handshake.&lt;/p&gt;

&lt;h2&gt;
  
  
  How not to fix it
&lt;/h2&gt;

&lt;p&gt;The obvious first idea: have the daemon watch the state and recreate the tunnel after a while. We decided against it.&lt;/p&gt;

&lt;p&gt;That fix repairs only this one daemon. The desktop, the router agent, iOS and Android would each keep their own copy of the logic, in three languages. We have been burned by exactly this before: once, five implementations handled the same failure in five different ways. Besides, recreating a peer means losing its packet queue and all of its sessions.&lt;/p&gt;

&lt;p&gt;The other options didn't work either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;retry at once, with no pause. A client with a permanently broken path would send four forced inits every 40 seconds, ignoring the normal handshake rate limit, forever. And if the exchange breaks for many clients at once, they would all start doing it at the same moment;&lt;/li&gt;
&lt;li&gt;raise &lt;code&gt;MAX_RESETS&lt;/code&gt; or the phase timeout. That only moves the cliff: any failure longer than the new budget becomes permanent again;&lt;/li&gt;
&lt;li&gt;fall back to the classic handshake after &lt;code&gt;failed&lt;/code&gt;. That breaks the very rule the mechanism exists for.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There was a cleverer variant of the fix below, too: end its pause early as soon as any handshake completes. Recovery would be faster, but the retry rhythm would be set by packets rather than by a timer. A node on the path that lets handshakes through and drops the exchange frames could then dictate how often we retry. We shelved that option until routers need to recover faster.&lt;/p&gt;

&lt;h2&gt;
  
  
  The fix: &lt;code&gt;failed&lt;/code&gt; became a pause
&lt;/h2&gt;

&lt;p&gt;The change itself is small. &lt;code&gt;failed&lt;/code&gt; is no longer a final state but a pause with limits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the pause lasts 30 seconds and doubles with each consecutive &lt;code&gt;failed&lt;/code&gt;, capped at 120 seconds: 30, 60, 120, 120…;&lt;/li&gt;
&lt;li&gt;up to 25% of random jitter is added on top. It is drawn once on entering the pause and only ever lengthens it. If a server restarts and hundreds of clients drop off with it, they retry out of step rather than in one volley;&lt;/li&gt;
&lt;li&gt;nothing post-quantum is sent during the pause, and no packet can start, shorten or extend it; only the timer can. WireGuard's normal timers run as before;&lt;/li&gt;
&lt;li&gt;after the pause the machine goes back to &lt;code&gt;pending&lt;/code&gt; with a fresh reset budget and forces one handshake initiation to open a fresh &lt;code&gt;Control&lt;/code&gt; session;&lt;/li&gt;
&lt;li&gt;only proof of a shared secret clears the counters: a response or a frame that passes verification on a &lt;code&gt;Keyed&lt;/code&gt; session;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;unsupported&lt;/code&gt; (the server answered under the base PSK) stays final: that's a fact about the server's configuration, not about the path, and retrying won't change it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In code it looks like this (Rust, trimmed):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RETRY_AFTER&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_secs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;pub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RETRY_AFTER_CAP&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_secs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;120&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="no"&gt;RETRY_JITTER_DIV&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;u64&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;impl&lt;/span&gt; &lt;span class="nc"&gt;Kem&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;/// 30 s doubled for each consecutive failure, capped at 120 s, plus `draw` reduced&lt;/span&gt;
    &lt;span class="c1"&gt;/// to `[0, cool-down / 4]` ms. Never below the base.&lt;/span&gt;
    &lt;span class="k"&gt;pub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="k"&gt;crate&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="n"&gt;noise&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;cooldown_for&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;failures&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;u32&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;draw&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;u64&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;doublings&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;failures&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saturating_sub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;RETRY_AFTER&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1u32&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;doublings&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;min&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="no"&gt;RETRY_AFTER_CAP&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;spread_ms&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;base&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_millis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="kt"&gt;u64&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="no"&gt;RETRY_JITTER_DIV&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;base&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nc"&gt;Duration&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from_millis&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;draw&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;spread_ms&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the way out of the pause, which simply didn't exist before (&lt;code&gt;phase_since&lt;/code&gt; is always &lt;code&gt;Some&lt;/code&gt; in &lt;code&gt;Failed&lt;/code&gt;; &lt;code&gt;kem_fail&lt;/code&gt; sets it):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;pub&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;kem_client_due&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="kd"&gt;mut&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Instant&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nc"&gt;Due&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;phase&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nc"&gt;Phase&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Failed&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="n"&gt;since&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;phase_since&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="n"&gt;since&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;is_some_and&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;since&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nf"&gt;saturating_since&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;since&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;cooldown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nc"&gt;Due&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="nc"&gt;Nothing&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="c1"&gt;// The same path a `pq_budget` reset takes, minus the reset count.&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pq&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;kem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;unrecovered&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;kem_restart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"pq_retry"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// …&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then there's the question of what to show the outside world. The exchange state reads &lt;code&gt;failed&lt;/code&gt; from the first failure until the first &lt;code&gt;on&lt;/code&gt;, pauses and retries included. If it flipped to &lt;code&gt;pending&lt;/code&gt; for each retry, the error card in the apps would flash every cycle. The &lt;code&gt;pq_resets&lt;/code&gt; counter is never reset for the life of the tunnel, so &lt;code&gt;fv show&lt;/code&gt; still tells you whether it is retrying (the counter keeps climbing) or has recovered (the state is &lt;code&gt;on&lt;/code&gt;). The move to &lt;code&gt;failed&lt;/code&gt; is still logged at INFO, but it now marks the start of a pause, not the end of the story: after it the log shows the recovery (&lt;code&gt;pq_on&lt;/code&gt;), and at DEBUG every retry as well (&lt;code&gt;pq_retry&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  What it costs
&lt;/h3&gt;

&lt;p&gt;We worked out the worst case in advance: every retry loop is a small DDoS against yourself.&lt;/p&gt;

&lt;p&gt;The client sends at most four forced inits per cycle. A cycle lasts at least 70 seconds (30 + 4 × 10) and 160 seconds at the cap. If the path drops precisely the armed inits (the flag is visible on the wire) and lets the Offers through, then together with WireGuard's ordinary retries that comes to up to ~20 inits in the first ~40 seconds of a cycle.&lt;/p&gt;

&lt;p&gt;Each Offer that gets through costs the server one ML-KEM encapsulation, at most once every 5 seconds per peer. That takes about 0.19 ms (measured on a developer's Mac), so a permanently broken client at the cap costs the server no more than 0.76 ms of CPU per 160 seconds. That's cheaper than any reconnect, which needs a control-plane request, a new access token, a handshake and the very same exchange.&lt;/p&gt;

&lt;p&gt;Once the path is fixed, the tunnel recovers within 135 seconds without jitter and 165 seconds with it. That's the rest of the pause (up to 120 seconds), one exchange (a few RTTs, up to 5 seconds of waiting on the server, and up to 2 more if the server is busy) and one more &lt;code&gt;REKEY_TIMEOUT&lt;/code&gt; if the first init is lost. One caveat: if WireGuard has already given up by then (&lt;code&gt;REKEY_ATTEMPT_TIME&lt;/code&gt;, 90 seconds), its timers run before the exchange machine can send its retry, so the retry waits for the next handshake WireGuard starts on its own. In the worst case that wait is the same 180 seconds as in the incident, so the 135/165-second bounds hold only while WireGuard is still retrying.&lt;/p&gt;

&lt;p&gt;A node on the path that drops our frames can keep a client cycling, but no more often than once every 70 seconds at first, and once every 160 seconds when the pause is at its cap. That's the same denial of service it could already cause. A downgrade to classic never happens.&lt;/p&gt;

&lt;h2&gt;
  
  
  How we tested it
&lt;/h2&gt;

&lt;p&gt;Unit tests cover the state machine: no exchange frames are sent and no data gets through during the pause, the delay grows 30/60/120/120 seconds, proof resets it, and the sequence from the incident (lost response, retry, three timeouts, &lt;code&gt;failed&lt;/code&gt;, path back) ends in &lt;code&gt;on&lt;/code&gt;. But a state machine in a vacuum proves nothing about a tunnel: in a unit test, the fixture always delivers the packets.&lt;/p&gt;

&lt;p&gt;That's why we have scenarios built on Linux network namespaces, where a real client and a real server run through netem. The new scenario reproduces the shape of our incident: 20 packets per second each way (the downlink traffic is there so the server initiates handshakes itself, as it did in the field), then 100% loss on the uplink only, a wait for &lt;code&gt;failed&lt;/code&gt;, another 75 seconds of outage, and recovery.&lt;/p&gt;

&lt;p&gt;The first version of the scenario didn't reproduce the bug: the client stayed in &lt;code&gt;on&lt;/code&gt; for all 300 seconds. It turned out that netem on the veth interface was also eating the ARP replies meant for the server. After about 30 seconds the server's neighbour entry for its gateway went stale, and it stopped sending packets at all: its log shows the init, while tcpdump on the client side shows nothing. "Uplink-only loss" had turned into a full symmetric outage, and that, as we now know, resets nothing. A static ARP entry fixed it (&lt;code&gt;pq_e&lt;/code&gt; runs a command in the server's namespace, &lt;code&gt;pq_i&lt;/code&gt; in the namespace that plays the ISP):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;pq_e ip neigh replace 10.12.0.1 lladdr &lt;span class="s2"&gt;"$(pq_i cat /sys/class/net/ve/address)"&lt;/span&gt; dev vx nud permanent
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We could have attached netem through &lt;code&gt;prio&lt;/code&gt; and a &lt;code&gt;tc filter&lt;/code&gt; so it only hit UDP. The static entry is simpler and changes nothing about the path data packets take.&lt;/p&gt;

&lt;p&gt;The old build, full scenario output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pq_wait_elapsed=5.6
pq-psk-failed-recovers: up: client on, 20 pps each way
faults: uplink-only loss 100% (on ve); downlink stays clean
pq-psk-failed-recovers: client reached failed 88s into the outage
pq-psk-failed-recovers: held 75s past failed: pq_state=failed pq_resets=4
pq-psk-failed-recovers: FAIL -- pq_resets=4, expected &amp;gt;= 5 (a retry should have run and failed inside the outage)
faults: cleared
pq-psk-failed-recovers: FAIL -- client still pq_state=failed 150s after the path healed
pq-psk-failed-recovers: end: client pq_state=failed exit pq_state=pending
pq-psk-failed-recovers: FAIL -- client not on at the end
pq-psk-failed-recovers: FAIL -- exit not on at the end
pq-psk-failed-recovers: FAIL -- exit rx_data_packets did not grow (uplink dead)
pq-psk-failed-recovers: FAIL -- client rx_data_packets did not grow (downlink dead)
pq-psk-failed-recovers: FAIL -- client log is missing pq_resets -&amp;gt; pq_retry -&amp;gt; pq_on in order
pq-psk-failed-recovers: states 1 Hz, failed..heal: ['failed'] over 74 samples
pq-psk-failed-recovers: client inits failed..heal: 0 in 75s = 0.0/min, worst 10s bucket 0
pq-psk-failed-recovers: client log order pq_resets@785 pq_retry@None pq_on@23
pq-psk-failed-recovers: FAIL
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Client in &lt;code&gt;failed&lt;/code&gt;, server in &lt;code&gt;pending&lt;/code&gt;, no data in either direction. The same picture the router showed for two days, in a matter of minutes.&lt;/p&gt;

&lt;p&gt;The build with the fix:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pq_wait_elapsed=5.6
pq-psk-failed-recovers: up: client on, 20 pps each way
faults: uplink-only loss 100% (on ve); downlink stays clean
pq-psk-failed-recovers: client reached failed 88s into the outage
pq-psk-failed-recovers: held 75s past failed: pq_state=failed pq_resets=8
faults: cleared
pq-psk-failed-recovers: client on again 55.8s after the path healed (bound 150s)
pq-psk-failed-recovers: end: client pq_state=on exit pq_state=on
pq-psk-failed-recovers: states 1 Hz, failed..heal: ['failed'] over 74 samples
pq-psk-failed-recovers: client inits failed..heal: 4 in 75s = 3.2/min, worst 10s bucket 1
pq-psk-failed-recovers: client log order pq_resets@781 pq_retry@1148 pq_on@1189
pq-psk-failed-recovers: PASS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;pq_resets=8&lt;/code&gt; means one retry managed to start and fail while still inside the outage. So the scenario really did exercise the exit from &lt;code&gt;failed&lt;/code&gt; rather than getting lucky with the timing. After the path healed, the client was back in &lt;code&gt;on&lt;/code&gt; in 55.8 seconds, and during the outage it sent 3.2 inits a minute. The client log shows the sequence: &lt;code&gt;pq_resets&lt;/code&gt;, &lt;code&gt;pq_retry&lt;/code&gt; 30 seconds later, &lt;code&gt;failed&lt;/code&gt; again (the retry inside the outage), &lt;code&gt;pq_retry&lt;/code&gt; after a 60-second pause, and &lt;code&gt;pq_on&lt;/code&gt; 10 ms after that.&lt;/p&gt;

&lt;p&gt;On this same build, before the merge, we ran the full suite of network scenarios: 80 out of 80 passed. We added the random jitter to the pause a little later, after review. The scenario passes on that build too, with recovery in 72.4 seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  What changed around the core
&lt;/h2&gt;

&lt;p&gt;The core fix closed the main hole: the tunnel now recovers on its own. But the incident exposed a second problem: for 40 hours we didn't know it was dead.&lt;/p&gt;

&lt;p&gt;The status display got stricter. Neither the apps nor the routers say "connected" until the exchange has completed, and they show the &lt;code&gt;ne.pq_failed&lt;/code&gt; code. Immediate client-level reconnects on &lt;code&gt;failed&lt;/code&gt; are gone, because the core now retries by itself. If the exchange hasn't succeeded for a couple of minutes, the client may try one other route to the same server, once, and after five minutes it reports an error. That rule exists in one place, in shared Rust code, not in six per-client copies.&lt;/p&gt;

&lt;p&gt;On monitoring we have less to show. Since the incident, a script checks this tunnel once a day: it reads &lt;code&gt;fv show&lt;/code&gt; on the server and flags a problem if the exchange isn't &lt;code&gt;on&lt;/code&gt; or the last data was hours ago. We still have no general server-side alert for "handshakes but no data". So if you're asking "forty hours and not a single alert?", the answer is yes, that's how it went.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons that apply beyond us
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;A terminal state in a long-running unattended process is a time bomb.&lt;/strong&gt; For every such state, answer the question of who gets you out of it, and when. If the answer is "the user, by restarting", then for a router in a closet that means never.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A fresh handshake doesn't mean the tunnel is alive.&lt;/strong&gt; "Latest handshake" is a favourite metric on WireGuard dashboards, and it says nothing about whether data is flowing. Our handshakes stayed fresh for 40 hours. If you monitor plain WireGuard, watch the &lt;code&gt;wg show &amp;lt;iface&amp;gt; transfer&lt;/code&gt; counters grow in both directions (allowing for keepalives, which bump them too). Better still, run an end-to-end check through the tunnel with a realistically sized packet: it catches our case and the classic MTU black hole, where handshakes get through and large packets don't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Asymmetric failures are more dangerous than total ones.&lt;/strong&gt; A total outage usually breaks nothing in the logic: nothing arrives, so nothing changes. One-way loss produces "evidence" that the state machine reacts to. If you test for resilience, test those specifically, and check that your emulator really is losing packets in only one direction. Ours, at first, wasn't.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strictness and availability have to be designed together.&lt;/strong&gt; We kept the "no fallback to classic" rule and still think it's right. The mistake was elsewhere: the refusal was permanent. A failure can be strict and still temporary, with a rate limit and a timer that nothing outside can influence.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ask the end that's waiting for data.&lt;/strong&gt; While the client was reporting handshakes, the server had seen no data for more than a day: its &lt;code&gt;fv show&lt;/code&gt; said &lt;code&gt;last data: 1 day ago&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we still don't know
&lt;/h2&gt;

&lt;p&gt;First and foremost, the cause of the outage itself: eight minutes of loss around 13:12–13:20 UTC. One candidate was the ISP changing our external address, especially since the address really did change during those weeks. But it fits the picture poorly: an address change usually loses packets travelling to the client, and those were exactly the ones getting through. By the time of the postmortem the router logs had rotated, so there was nothing left to check.&lt;/p&gt;

&lt;p&gt;We also don't know how the fix behaves on battery. If a path keeps dropping exchange frames, a device will repeat a ~40-second burst every 160 seconds, forever. If that turns out to be noticeable in battery usage, the next step is a longer cap after several cycles, say 10 minutes after the fifth.&lt;/p&gt;

&lt;p&gt;Finally, it's not clear whether 135–165 seconds of recovery is good enough for routers. For a router that carries a whole network, that may be too long. If so, we'll add an early exit from the pause on a completed &lt;code&gt;Control&lt;/code&gt; handshake, but never sooner than 30 seconds in.&lt;/p&gt;

&lt;p&gt;We did fix one small thing the investigation turned up. The &lt;code&gt;WrongIndex&lt;/code&gt; lines we used to reconstruct the timeline were printed to stderr without a timestamp in that build, so we had to place them by the lines around them. They are now structured DEBUG lines with a time and a reason (&lt;code&gt;reason="wrong_index"&lt;/code&gt;). They still don't show up in the normal INFO log.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;The code and logs in this post are ours; addresses and keys have been redacted. Questions and objections are welcome in the comments, and we'll answer them.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;CTO &amp;amp; Founder, ForestVPN&lt;/em&gt;&lt;/p&gt;

</description>
      <category>wireguard</category>
      <category>networking</category>
      <category>rust</category>
      <category>security</category>
    </item>
    <item>
      <title>Reproducing a flaky network in Linux namespaces with netem</title>
      <dc:creator>George Kutsurua</dc:creator>
      <pubDate>Fri, 30 Oct 2026 16:30:08 +0000</pubDate>
      <link>https://dev.to/forestvpn/reproducing-a-flaky-network-in-linux-namespaces-with-netem-1gln</link>
      <guid>https://dev.to/forestvpn/reproducing-a-flaky-network-in-linux-namespaces-with-netem-1gln</guid>
      <description>&lt;p&gt;Faking a flaky network takes one Linux box. You need three network namespaces, a veth pair on each side of the middle one, and &lt;code&gt;tc netem&lt;/code&gt; on the egress of the middle hop. No VMs and no spare hardware. Everything below runs as root and leaves nothing behind once you delete the namespaces.&lt;/p&gt;

&lt;p&gt;This post is the recipe and the measurement method. We use the same setup in our lab to put a VPN client under impairment and watch what it reports. Here the setup is the subject, and any program that sends packets will do.&lt;/p&gt;

&lt;h2&gt;
  
  
  What we are building
&lt;/h2&gt;

&lt;p&gt;Three namespaces in a line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;client  --  mid  --  server
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;mid&lt;/code&gt; forwards packets and is the only place where we break things. The client and server never know. That matters, because a test that touches the endpoints directly measures your test, not the path.&lt;/p&gt;

&lt;h2&gt;
  
  
  Build the topology
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="k"&gt;for &lt;/span&gt;n &lt;span class="k"&gt;in &lt;/span&gt;c m s&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;ip netns add &lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; ip &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nv"&gt;$n&lt;/span&gt; &lt;span class="nb"&gt;link set &lt;/span&gt;lo up&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done

&lt;/span&gt;ip &lt;span class="nb"&gt;link &lt;/span&gt;add c0 netns c &lt;span class="nb"&gt;type &lt;/span&gt;veth peer name m0 netns m

&lt;span class="c"&gt;# second pair, server side&lt;/span&gt;
ip &lt;span class="nb"&gt;link &lt;/span&gt;add s0 netns s &lt;span class="nb"&gt;type &lt;/span&gt;veth peer name m1 netns m

&lt;span class="k"&gt;for &lt;/span&gt;spec &lt;span class="k"&gt;in &lt;/span&gt;c:c0:10.10.1.2 m:m0:10.10.1.1 m:m1:10.10.2.1 s:s0:10.10.2.2&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do
  &lt;/span&gt;&lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="nt"&gt;--&lt;/span&gt; &lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;spec&lt;/span&gt;&lt;span class="p"&gt;//&lt;/span&gt;:/&lt;span class="p"&gt; &lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt;
  ip &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; addr add &lt;span class="nv"&gt;$3&lt;/span&gt;/24 dev &lt;span class="nv"&gt;$2&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip &lt;span class="nt"&gt;-n&lt;/span&gt; &lt;span class="nv"&gt;$1&lt;/span&gt; &lt;span class="nb"&gt;link set&lt;/span&gt; &lt;span class="nv"&gt;$2&lt;/span&gt; up
&lt;span class="k"&gt;done&lt;/span&gt;

&lt;span class="c"&gt;# routes, then let the middle namespace forward&lt;/span&gt;
ip &lt;span class="nt"&gt;-n&lt;/span&gt; c route add default via 10.10.1.1 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip &lt;span class="nt"&gt;-n&lt;/span&gt; s route add default via 10.10.2.1 &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m sysctl &lt;span class="nt"&gt;-w&lt;/span&gt; net.ipv4.ip_forward&lt;span class="o"&gt;=&lt;/span&gt;1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check that the path works before you break anything:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c ping &lt;span class="nt"&gt;-c&lt;/span&gt; 3 10.10.2.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If that fails, stop here. Every later result depends on a clean baseline, and a typo in a route will look exactly like packet loss.&lt;/p&gt;

&lt;h2&gt;
  
  
  Record a baseline first
&lt;/h2&gt;

&lt;p&gt;Run each measurement once with no impairment and keep the output. When a number looks odd under fault, the baseline tells you whether the fault or the machine produced it.&lt;/p&gt;

&lt;p&gt;We use two tools. &lt;code&gt;ping&lt;/code&gt; gives a per-packet view of delay and loss. &lt;code&gt;iperf3&lt;/code&gt; gives sustained throughput.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;s iperf3 &lt;span class="nt"&gt;-s&lt;/span&gt; &lt;span class="nt"&gt;-D&lt;/span&gt;
&lt;span class="nb"&gt;sleep &lt;/span&gt;1
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c iperf3 &lt;span class="nt"&gt;-c&lt;/span&gt; 10.10.2.2 &lt;span class="nt"&gt;-t&lt;/span&gt; 10 &lt;span class="nt"&gt;--json&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; baseline-iperf.json
&lt;span class="c"&gt;# and the per-packet view&lt;/span&gt;
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c ping &lt;span class="nt"&gt;-c&lt;/span&gt; 50 &lt;span class="nt"&gt;-i&lt;/span&gt; 0.2 10.10.2.2 &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; baseline-ping.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The veth pair is fast, so the baseline will be limited by your CPU and not by any link. That is fine. You are measuring change against yourself, never against an absolute figure.&lt;/p&gt;

&lt;h2&gt;
  
  
  A logger that does not lie
&lt;/h2&gt;

&lt;p&gt;Summary output from &lt;code&gt;ping&lt;/code&gt; hides the shape of a failure. A path that drops every packet for three seconds and then recovers can show the same loss percentage as a path that drops one packet in twenty. Those are different problems.&lt;/p&gt;

&lt;p&gt;So log each probe on its own line, with a timestamp:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c bash &lt;span class="nt"&gt;-c&lt;/span&gt; &lt;span class="s1"&gt;'
while true; do
  t=$(date +%s.%N)
  if ping -c1 -W1 10.10.2.2 &amp;gt;/dev/null 2&amp;gt;&amp;amp;1; then r=ok; else r=fail; fi
  echo "$t,$r"
  sleep 0.2
done'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; probe.csv &amp;amp;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="nv"&gt;$!&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; probe.pid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;One row per probe means you can line the log up against the moment you applied each impairment. Write the time you applied it into a second file. Do this by hand if you must, but do it every time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Impairment one: delay and jitter
&lt;/h2&gt;

&lt;p&gt;Apply netem on the egress of &lt;code&gt;m1&lt;/code&gt;, the interface facing the server:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc add dev m1 root netem delay 80ms 20ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That adds a base delay with random variation around it. Note that netem acts on outgoing packets only. A single qdisc on &lt;code&gt;m1&lt;/code&gt; delays the forward direction. To delay the return path as well, add a matching qdisc on &lt;code&gt;m0&lt;/code&gt;. Without it, only the forward leg is delayed, so a ping's round trip grows by the configured delay once, not twice.&lt;/p&gt;

&lt;p&gt;Change values in place with &lt;code&gt;change&lt;/code&gt;, not &lt;code&gt;add&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc change dev m1 root netem delay 200ms 50ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Remove it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc del dev m1 root
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Impairment two: random loss
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc add dev m1 root netem loss 5%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Random loss is the gentle case. Real networks tend to lose packets in bursts. netem's optional correlation value does little to produce real bursts, so use its Gilbert-Elliott model instead:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc change dev m1 root netem loss gemodel 1% 20%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first number is the chance of moving from a good state into a bad one, the second the chance of moving back. Every packet in the bad state is dropped, so this loses about 5% of packets on average, in runs of about five. Compare the two runs in your probe log. The count of failed probes may be similar, but the runs of consecutive failures will not be. Whatever you test, test it against both shapes. Retransmission logic that copes with scattered loss can struggle with a burst.&lt;/p&gt;

&lt;h2&gt;
  
  
  Impairment three: a narrow link
&lt;/h2&gt;

&lt;p&gt;Netem has a &lt;code&gt;rate&lt;/code&gt; option, but a token bucket filter gives you more honest queueing behaviour. Put netem under it if you want delay as well:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# remove the loss qdisc from the previous step first&lt;/span&gt;
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc del dev m1 root
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc add dev m1 root handle 1: tbf rate 5mbit burst 32kbit latency 400ms
&lt;span class="c"&gt;# netem hangs off the bucket as a child&lt;/span&gt;
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m tc qdisc add dev m1 parent 1:1 handle 10: netem delay 40ms
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run &lt;code&gt;iperf3&lt;/code&gt; again and compare it with the baseline file. Throughput should settle close to the configured rate. If it does not, check that you applied the filter on the interface the traffic actually leaves through.&lt;/p&gt;

&lt;h2&gt;
  
  
  Impairment four: the path that silently shrinks
&lt;/h2&gt;

&lt;p&gt;This one deserves its own section, because it is the hardest to spot from the endpoints.&lt;/p&gt;

&lt;p&gt;A packet with the don't-fragment bit set that is too big for a hop should trigger an ICMP "fragmentation needed" message back to the sender. The sender then lowers its packet size. If that message never arrives, the sender keeps sending large packets that vanish. Small packets still pass. Pings work, the connection opens, and then anything bulky stalls.&lt;/p&gt;

&lt;p&gt;Reproduce it in two steps. First, shrink the MTU on the far-side interface:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip &lt;span class="nt"&gt;-n&lt;/span&gt; m &lt;span class="nb"&gt;link set &lt;/span&gt;m1 mtu 1400
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Second, drop the ICMP errors that the middle hop would generate. Save this as &lt;code&gt;drop-icmp.nft&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight vcl"&gt;&lt;code&gt;table inet t &lt;span class="p"&gt;{&lt;/span&gt;
  chain out &lt;span class="p"&gt;{&lt;/span&gt;
    type filter hook output priority &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    ip protocol icmp icmp type destination-unreachable drop
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Load it inside the middle namespace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m nft &lt;span class="nt"&gt;-f&lt;/span&gt; drop-icmp.nft
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now compare a small probe with a large one:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# small probe&lt;/span&gt;
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c ping &lt;span class="nt"&gt;-c&lt;/span&gt; 3 &lt;span class="nt"&gt;-M&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; 100 10.10.2.2
&lt;span class="c"&gt;# large probe&lt;/span&gt;
ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;c ping &lt;span class="nt"&gt;-c&lt;/span&gt; 3 &lt;span class="nt"&gt;-M&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="nt"&gt;-s&lt;/span&gt; 1472 10.10.2.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first succeeds. The second gets no answer and no error message either. That silence is the whole point. A program that only checks whether the host answers will report a healthy path while real traffic goes nowhere.&lt;/p&gt;

&lt;p&gt;To undo it, delete the nft table and set the MTU back to 1500:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ip netns &lt;span class="nb"&gt;exec &lt;/span&gt;m nft delete table inet t &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; ip &lt;span class="nt"&gt;-n&lt;/span&gt; m &lt;span class="nb"&gt;link set &lt;/span&gt;m1 mtu 1500
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Reading the log
&lt;/h2&gt;

&lt;p&gt;When a run is over, stop the logger and look at three things in &lt;code&gt;probe.csv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;First, the time from the moment you applied an impairment to the first failed probe. Second, the longest outage. Third, the time from the moment you removed the impairment to the first success. Recovery time is the number people forget to measure, and it often tells you more than the failure itself.&lt;/p&gt;

&lt;p&gt;This short awk script covers the second item:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;awk&lt;/span&gt; &lt;span class="nt"&gt;-F&lt;/span&gt;, &lt;span class="s1"&gt;'$2=="fail"{if(!n)s=prev; n++; next} {if(n){d=$1-s; if(d&amp;gt;m)m=d} n=0; prev=$1} END{if(n){d=$1-s; if(d&amp;gt;m)m=d}; print m+0}'&lt;/span&gt; probe.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It prints the longest outage in seconds, measured from the last successful probe before the failures to the first success after them. It takes the duration from the timestamps, not from a count of rows, because a failed probe waits up to a second for its reply on top of the 0.2 second sleep. A probe cycle then takes about 1.2 seconds, so say in your notes that the figure is only as fine as that. The script assumes the first row is a success, which the baseline ping gives you.&lt;/p&gt;

&lt;h2&gt;
  
  
  What this tells you and what it does not
&lt;/h2&gt;

&lt;p&gt;This is a lab. Namespaces on one machine share a clock and a CPU, so timing under heavy load will wobble. Netem's delay and loss are statistical models, not recordings of any real network. Run each condition several times and keep every log, because a single run can mislead you. We publish no results here for that reason: the useful part is the method, and your numbers will depend on your hardware.&lt;/p&gt;

&lt;p&gt;It also tests one direction of cause at a time. Real faults combine. Add delay and loss together, then add the narrow link, and look again. The interactions are often where the surprises are.&lt;/p&gt;

&lt;p&gt;If you test software that reports its own view of the connection, line its reports up against the probe log. In our lab we do this with a VPN client, and the useful question is whether what the client says matches what the probe log shows. When the two disagree, one of them is wrong, and the log is the easier one to audit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean up
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;kill&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;cat &lt;/span&gt;probe.pid&lt;span class="si"&gt;)&lt;/span&gt;
ip netns pids s | xargs &lt;span class="nt"&gt;-r&lt;/span&gt; &lt;span class="nb"&gt;kill
&lt;/span&gt;&lt;span class="k"&gt;for &lt;/span&gt;n &lt;span class="k"&gt;in &lt;/span&gt;c m s&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;do &lt;/span&gt;ip netns del &lt;span class="nv"&gt;$n&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="k"&gt;done&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Deleting the namespaces removes the veth pairs and every qdisc with them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Build the path, then ping it before breaking anything.&lt;/li&gt;
&lt;li&gt;Record a baseline for every tool you plan to use.&lt;/li&gt;
&lt;li&gt;Log one line per probe, with a timestamp.&lt;/li&gt;
&lt;li&gt;Note the time you apply and remove each impairment.&lt;/li&gt;
&lt;li&gt;Impair both directions when you mean a round trip.&lt;/li&gt;
&lt;li&gt;Repeat each condition and keep every log.&lt;/li&gt;
&lt;li&gt;State your method next to every number you share.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This article was created with the help of AI.&lt;/p&gt;

</description>
      <category>linux</category>
      <category>networking</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
