Posts

Post not yet marked as solved
2 Replies
1k Views
TLDR: the following code yields `nil` when built with Xcode 10.1 and run on iOS 11:Class nwPathClass = [NWPath class];IMO this should not be the case, why is this happening, can anyone explain this?Long story:I maintain an application that offers VPN through NEPacketTunnelProvider and use KVO on the defaultPath keypath in order to listen for network changes and update all kinds of stuff necessary to keep the tunnel functioning. Here is the code in which the above observation became apparent:- (void) observeValueForKeyPath:(nullable NSString *) keyPath ofObject:(nullable id) object change:(nullable NSDictionary *) change context:(nullable void *) context { if ([keyPath isEqualToString:@"defaultPath"]) { NWPath *oldPath, *newPath; id oldObject = change[NSKeyValueChangeOldKey]; id newObject = change[NSKeyValueChangeNewKey]; if ([oldObject isKindOfClass:[NWPath class]]) { // never evaluates to true oldPath = oldObject; } if ([newObject isKindOfClass:[NWPath class]]) { // never evaluates to true newPath = newObject; } if (newPath.status == NWPathStatusSatisfied && ![oldPath isEqualToPath:newObject]) { // update tunnel things } } }This code is maybe a bit too defensive, but technically this should just work. However, when this code is run on iOS 11, while it was built using Xcode 10.1, the NWPath class cannot be loaded, and therefore I am missing out on some serieous tunnel updating.Fun fact, LLDB does not seem to agree. When I hit a breakpoint and perform the following command:(lldb) po [NWPath class] NWPathI _do_ get a class...Checking what bundle the class is from: Network.framework(lldb) po [NSBundle bundleForClass:[NWPath class]] NSBundle </System/Library/Frameworks/Network.framework> (loaded)Which also kind of surprises me, should this not be NetworkExtension.framework?
Posted
by sven-m.
Last updated
.
Post not yet marked as solved
9 Replies
1.9k Views
Hi,We notice with our app which we ship with an NEPacketTunnelProvider Network Extension that iOS does not correctly track the device and apps’ data usage over cellular networks when the traffic is going through an NEPacketTunnelProvider. All data going through the NEPacketTunnelProvider to the VPN tunnel server is counted towards the total cellular usage of the originating app as well as that of the app containing the NEPacketTunnelProvider. This leads to the containing app seeming to be responsible for 50% of all data usage and it also inflates the displayed total cellular data usage to 200% of the actual usage.It seems all data in packets read from and written to the NEPacketFlow as well as all data read from and written to the BSD sockets used to forward all traffic to the tunnel server are counted towards the containing app’s total cellular data usage.Example:Let’s say we reset our cellular usage tracking and use 500 MB with Safari, 2 GB with Youtube and maybe 100KB for the PacketTunnelApp. We expect to end up with the following usage summary:Safari: 500 MBYoutube: 2 GBPacketTunnelApp: 100 KBTotal cellular usage: ~2,5 GB (= 500 MB + 2 GB + 100 KB)But the actual summary looks like this:Safari: 500 MBYoutube: 2 GBPacketTunnelApp: ~2,5 GB (= 50% of displayed total)Total cellular usage: ~5 GB (= 200% of actual usage)Note that the PacketTunnelApp’s cellular usage is equal to all the other apps combined.Does anyone else also have this problem?
Posted
by sven-m.
Last updated
.