I am trying to write a small script to gather network statistics on my Linux system. Is there any way I can do this? What I'm after is live stats on current network throughput. I have done some reading and found that /proc/net/dev is useful and I can parse in the content of this to work out current network speed. Is this a viable/reliable way of doing this? How do packages like iptraf, iftop calculate speed up and down?  
Network statistics on linux
linux;bash;networking