iOS Simulator network activity¶
getDeviceState networkActivity reads an iOS Simulator’s per-process sockets and traffic from
the host. Simulator processes run on the host as the same user, so plain host tools see them with
no privileges. Source: src/features/utility/networkActivity/.
Read path¶
ps -axo pid=,ppid=,rss=,pcpu=,command=(the sharedreadHostProcessTablesnapshot).simulatorProcessTreekeeps thelaunchd_simwhose command names/CoreSimulator/Devices/<UDID>/and every descendant. Other host processes that name the directory are not roots. An empty tree means the simulator is not booted, and the read stops with an error.- In parallel:
lsof -nP -a -i -p <tree pids> -F pcPnT: per process, each internet socket’s protocol,local->remotename and TCP state. lsof exits 1 when a listed pid has exited or none holds a socket. It still prints what it found. The reader parses exit 1 and fails only when stderr has text.nettop -P -L 1 -x -J bytes_in,bytes_out: one host-wide sample of<name>.<pid>,<in>,<out>rows, joined to the tree by pid.simctl listapps: each app’s bundle path.- A process gets an
appIdwhen itspsexecutable starts with an app’s bundle path. The longest path wins, so an extension inside an app maps to that app.psshows runtime-root apps under/var/run/...andsimctl listappsunder/private/var/run/.... The matcher drops/privatefrom both before comparing. - The reader leaves out processes with no socket and no bytes. It sorts the rest by bytes, then
socket count, and caps them at 50;
activeProcessCountandtruncatedreport the cut. The name is lsof’s, then nettop’s (truncated to 15 characters), then the executable basename.
Byte counts¶
A single nettop sample reports the bytes on the flows open at that moment, counted from each flow’s start. A flow that closed before nettop started is not reported. On a held connection the count matched the server’s sent-byte total exactly (2424879 bytes, #19020).
Platform support¶
Only an iOS Simulator is read. Android and physical iOS devices return supported: false, and a
failed ps becomes a field error. A failed lsof, nettop or simctl listapps degrades only
its part (no sockets, zero bytes, no appId) and adds a warnings entry.
The design choice is recorded in Read Simulator network activity with host tools.