2

I have an ssh connection that I run to access a remote machine. At present I use autossh to keep the pipe open 24/7.

I am curious as to how much the pipe alone uses bandwidth wise. How can I measure something like this?

note: It is rarely used but handy so it just sits there. So I can make sure nothing is sent for a day while taking measurements if needed.

dibs
  • 123
  • 1
  • 5
  • 1
    Might want to say which operating systems are at the end of each end of the ssh connection. – EightBitTony May 14 '12 at 22:35
  • @EightBitTony I didn't realise this was of importance seeing it's the same protocol but it's OSX 10.6.8 <----> Ubuntu 12.04 – dibs May 14 '12 at 22:49
  • 2
    I only suggest it, because some tools might not be available on some operating systems. i.e. now we know there's no point anyone suggesting a tool for Windows. – EightBitTony May 14 '12 at 23:04
  • @EightBitTony Ah excellent point! – dibs May 14 '12 at 23:26

1 Answers1

2

This could be done with iptables rules to count the packets. I'm assuming that the server is running Ubuntu, so you'd want something like this (assuming that your client's IP is 1.2.3.4):

iptables --insert INPUT 1 --protocol tcp --dport 22 --source 1.2.3.4 -j ACCEPT
iptables --insert OUTPUT 1 --protocol tcp --sport 22 --destination 1.2.3.4 -j ACCEPT

Running iptables -nvL will show the number of packets and total size of packets caught by those rules -- add them up to get the total.

mgorven
  • 30,036
  • 7
  • 76
  • 121
  • 1
    Agreed, also I believe one could specify a LOG target and then parse the log files periodically. Obviously not viable for high-traffic environments, but it could be useful. – EEAA May 14 '12 at 23:18