Hello,
Recently, for my study at school, I need to develop an app which could tag each data flow(TCP or UDP) with which app it comes from. In that case we can get a <data flow, app name> tuple, and this could do a lot help for our study.
I'm wondering that is there any good suggestions to make that possible? Does NetworkExtension know which app the data flow come from when it handle with the data flows? I've googled and searched for answers, but the result are not satisfying.
I've noticed that on my iPhone8 with iOS 11, the System offers us the information of how much cellular data each app has used. Will this API be opened to us or is there any alternative methods to implement that function?
Thank you if you could help me!
OK, ‘easy’ question first:
And another question, is there any solutions to figure out what protocol is used in NEAppProxyFlow? HTTP or SSH for example.
There’s two approaches you can use for this:
You can use the remote port number as a rough guide (HTTP on port 80, SSH on port 22, and so on). This isn’t definitive because it’s not uncommon for folks to run protocols on the ‘wrong’ port (HTTP on port 8080, for example).
Beyond that you’ll have to ‘sniff’ the traffic on the flow to see what protocol it looks like. This is easy for HTTP and SSH, and not so easy for various other protocols. Specifically, all protocols within TLS, like HTTPS and IMAPS, look alike on the wire.
For
, I could get itsNEAppProxyTCPFlow
, while forremoteEndpoint
, I could get itsNEAppProxyUDPFlow
, which means I cannot get src and dst host information for a flow at the same time.localEndpoint
You can to consider each protocol separately:
For TCP, the system only assigns a local address to the TCP connection once the connection is in place. If you wait for some traffic to flow over the connection, does
then start returning a value?localEndpoint
For UDP, it’s most common for a UDP flow to not be connected, that is, for the flow to allow outgoing packets to any endpoint. The specific endpoint is then set on a packet-by-packet basis.
UDP does have the notion of connected sockets, that is, you can call a
on a UDP socket to fix the destination endpoint. I don’t know if that’s reflected at the app proxy layer; you would have to create a small test project that does that and then see if that causesconnect
to be populated.remoteEndpoint
Share and Enjoy
—
Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware
let myEmail = "eskimo" + "1" + "@apple.com"