Class IosTunDiagnostics
- Namespace
- VpnHood.Net.VpnAdapters.IosTun
- Assembly
- VpnHood.Net.VpnAdapters.IosTun.dll
iOS TUN adapter investigation instrumentation, owned by this project (mirrors
TcpStackDiagnostics): it holds the cumulative traffic counters and the freeze locator; every
mutating method is a no-op when Enabled is false, so call sites stay clean, and it costs
nothing in production.
public static class IosTunDiagnostics
- Inheritance
-
IosTunDiagnostics
- Inherited Members
Remarks
The host's memory probe reads the public snapshot properties below to correlate phys_footprint with traffic; it does not own these counters.
Off in production; there is no dedicated switch — Enabled is computed from
VhLogger.MinLogLevel, so below-Information logging (e.g. the /log:debug DebugCommand in
the app UI, flowing to the Extension via ClientOptions.LogServiceOptions) enables all the iOS
diagnostics together.
Properties
Enabled
Read-only master gate: on whenever the effective log level is below Information.
public static bool Enabled { get; }
Property Value
InboundBytes
Cumulative bytes written inbound (server → device) through the TUN adapter.
public static long InboundBytes { get; }
Property Value
LastReadTicks
Environment.TickCount64 at the last outbound read callback (0 = never).
public static long LastReadTicks { get; }
Property Value
LastWriteTicks
Environment.TickCount64 after the last completed TUN write drain (0 = never).
public static long LastWriteTicks { get; }
Property Value
OutboundBytes
Cumulative bytes read outbound (device → server) from the TUN adapter.
public static long OutboundBytes { get; }
Property Value
ReadCallbackCount
Cumulative native TUN read callbacks received.
public static long ReadCallbackCount { get; }
Property Value
ReadPacketCount
Cumulative packets delivered by native TUN read callbacks.
public static long ReadPacketCount { get; }
Property Value
Methods
AddInboundBytes(long)
Adds to the inbound (download) byte counter. No-op unless Enabled.
public static void AddInboundBytes(long bytes)
Parameters
byteslong
AddOutboundBytes(long)
Adds to the outbound (upload) byte counter. No-op unless Enabled.
public static void AddOutboundBytes(long bytes)
Parameters
byteslong
BeginTiming()
Returns a start timestamp for bracketing the native write drain, or 0 when disabled so the paired EndTunWrite(long) becomes a no-op.
public static long BeginTiming()
Returns
EndTunWrite(long)
Records a completed TUN write drain: stamps the time and tracks the worst duration.
public static void EndTunWrite(long startTimestamp)
Parameters
startTimestamplong
MarkTunReadCallback(int)
Records an outbound native read callback and its batch size.
public static void MarkTunReadCallback(int packetCount)
Parameters
packetCountint
TakeMaxReadBatchSize()
Largest native read batch since the last call; reading resets it to 0.
public static long TakeMaxReadBatchSize()
Returns
TakeMaxTunWriteMs()
Worst single TUN write drain (ms) since the last call; reading resets it to 0.
public static long TakeMaxTunWriteMs()
Returns
WriteRouteDumpAsync(IPAddress, int?, NEPacketTunnelNetworkSettings, IReadOnlyList<IpNetwork>, IReadOnlyList<IpNetwork>, IReadOnlyList<IpNetwork>, IReadOnlyList<IpNetwork>, IReadOnlyList<IPAddress>, CancellationToken)
Dumps the routes/addresses/DNS the adapter is about to install to Documents/ext-route-dump.txt
so the host can verify what actually reaches iOS ("connected but no traffic" diagnosis). No-op unless
Enabled. Best-effort: never throws.
public static Task WriteRouteDumpAsync(IPAddress remoteAddress, int? mtu, NEPacketTunnelNetworkSettings networkSettings, IReadOnlyList<IpNetwork> ipv4Networks, IReadOnlyList<IpNetwork> ipv4Routes, IReadOnlyList<IpNetwork> ipv6Networks, IReadOnlyList<IpNetwork> ipv6Routes, IReadOnlyList<IPAddress> dnsServers, CancellationToken cancellationToken)
Parameters
remoteAddressIPAddressmtuint?networkSettingsNEPacketTunnelNetworkSettingsipv4NetworksIReadOnlyList<IpNetwork>ipv4RoutesIReadOnlyList<IpNetwork>ipv6NetworksIReadOnlyList<IpNetwork>ipv6RoutesIReadOnlyList<IpNetwork>dnsServersIReadOnlyList<IPAddress>cancellationTokenCancellationToken