Search code examples
linuxnetwork-monitoring

Network usage of a process in linux


I would like to record the total number of bytes transferred over the network by different versions of VNC. My plan is to start the VNC viewer, run a script remotely that performs some actions and displays some graphics and then disconnects.

How can you record the total network usage of just this one process in linux? I don't want to measure anything else that is happening on the system.


Solution

  • You could run the different versions of the VNC viewers on different port numbers and then record all traffic to those ports with a tool such as tcpdump.

    There may be some way of recording traffic per process but doing it by port is much more obvious and simple

    crude example using perl to add up/filter

    sudo tcpdump -li eth1 ' port 5900'|perl -ne 'print $c,"\n"; $c+=$1 if (/length (\d+)/);'