I've implemented a vpn app with PacketTunnelProvider.
When doing a speed test, I can see that the VPN is decreasing the download speed by a large number.
I have a suspect that might cause this, but I'm not sure -
When I want to write packets to the tunnel, I get the packets as an UnsafeMutablePointer<CChar>
then I convert it to NSData:
let data = NSData(bytes: buffer, length: Int(length))
and then I send it to the packetFlow
packetFlow.writePackets([data!], withProtocols: [NSNumber(int: AF_INET)])
Am I right to suspect this might cause the slowness?
I'm sending each packet the moment I get it, so most of the time the array contains only 1 object. Is it ok?