I would like know which applications on my android connect to what IP addresses. In essence I would like to know what these apps do in the background without my approval.
I tried a netstat OS call in my monitoring app, which already gives me the open connections and the connected IP addresses, but there is no process name, pid or uid that would allow me to map a connection to a particular app. ‘netstat -p’ seems not to provide the process info.
If you read source code for ‘netstat’, it actually reads data from /proc/net/tcp which holds a dump of the TCP socket table, the data will like below.
you will discover each connection has a uid, because Android OS run each application with a user account that means own a unique uid, it will help to map every connection to a single process.
I hope this information will help.