Python monitor bandwidth by a process

view story

http://www.linuxquestions.org – Hello all, I am intending to write a program in python similar to nethogs, showing how much data has been sent, received and what is the transfer speed for that process. I have already written a simple ncurses python program reading /proc file system and displaying all established tcp connections with program name. But I don't know how to get/calculate sent/received data and transfer speed, can somebody advice me where I can read those information from? I've been digging in nethogs source code(it's in C++) but it seems to be difficult to figure out for me, looks like the job do functions in (HowTos)