I would like to provide to the user of my VPN client connection stats for transferred bytes. The VPN connections are established using the Network Extension framework with a normal protocol (IkeV2) and a custom protocol (WireGuard). The iOS App also uses the network extension framework with an implementation for openVPN. Is there a direct way to get the transmitted bytes values for incoming and outgoing traffic through the VPN programmatically ? Thanks a lot for your attention.
In a VPN Client for iOS and macOS that uses the network extension framework, is there a direct way to gather the VPN interface statistics?
Is there a direct way to get the transmitted bytes values for incoming and outgoing traffic through the VPN programmatically ?
For the NEPacketTunnelProvider
API directly, no. This would be an Enhancement Request.
You could also attempt to roll your own implementation of this by monitoring the transmitted and received bytes from NEPacketTunnelFlow
, but that could get hairy as well.
If you are using NWConnection
as the transport here you could take a look at the NWConnection.EstablishmentReport for any info this provides. In-Provider APIs like NWTCPConnection
and NWUDPSession
do not have the API for requestEstablishmentReport(queue:completion:) available though, that would also be an Enhancement Request.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com