TL;DR
SSH bandwith overhead in tunneling mode is neglible
In this LAN testing scenario there were even a lot less pakets in the opposite direction, about 50 % less.
Details of how to get the bandwith overhead:
Setup:
On server running
iperf -s
------------------------------------------------------------
Server listening on TCP port 5001
TCP window size: 128 KByte (default)
------------------------------------------------------------
On client we establish ssh connection to server
ssh -L 5001:127.0.0.1:5001 [email protected]
SSH Compression was not enabled.
To monitor traffic we add
sudo iptables -A INPUT -p tcp --src 192.168.178.55/32 -j ACCEPT
sudo iptables -A OUTPUT -p tcp --dst 192.168.178.55/32 -j ACCEPT
So first try direct connection:
iperf -c 192.168.178.55 -n 1000M
------------------------------------------------------------
Client connecting to 192.168.178.55, TCP port 5001
TCP window size: 83.1 KByte (default)
------------------------------------------------------------
[ 3] local 192.168.178.21 port 60824 connected with 192.168.178.55 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-89.5 sec 1000 MBytes 93.8 Mbits/sec
First result
sudo iptables -L -v
Chain INPUT (policy ACCEPT 609 packets, 30850 bytes)
pkts bytes target prot opt in out source destination
342K 14M ACCEPT tcp -- any any 192.168.178.55 anywhere
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 968 packets, 99600 bytes)
pkts bytes target prot opt in out source destination
93424 1053M ACCEPT tcp -- any any anywhere 192.168.178.55
In between counters are flushed via iptables -Z
2nd try
sudo iptables -L -v
Chain INPUT (policy ACCEPT 387 packets, 19661 bytes)
pkts bytes target prot opt in out source destination
344K 14M ACCEPT tcp -- any any 192.168.178.55 anywhere
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 626 packets, 64440 bytes)
pkts bytes target prot opt in out source destination
93166 1053M ACCEPT tcp -- any any anywhere 192.168.178.55
Now ssh connection
iperf -c 127.0.0.1 -n 1000M
------------------------------------------------------------
Client connecting to 127.0.0.1, TCP port 5001
TCP window size: 2.50 MByte (default)
------------------------------------------------------------
[ 3] local 127.0.0.1 port 38080 connected with 127.0.0.1 port 5001
[ ID] Interval Transfer Bandwidth
[ 3] 0.0-89.4 sec 1000 MBytes 93.8 Mbits/sec
First finding: Same speed eventhough we have a Raspberry PI 3B as Server and a Raspberry PI 4B as client, connected via wired LAN over 2 switches and PI 3B making a backup and thus sending a lot of data while the test (here we measured only data sending from PI4 to PI3B)
sudo iptables -L -v
Chain INPUT (policy ACCEPT 27327 packets, 1050M bytes)
pkts bytes target prot opt in out source destination
154K 6540K ACCEPT tcp -- any any 192.168.178.55 anywhere
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 27791 packets, 1050M bytes)
pkts bytes target prot opt in out source destination
79099 1053M ACCEPT tcp -- any any anywhere 192.168.178.55
With ssh inbetween we have even transfered less packets, total amount of data is the same. So bandwith overhead is neglible, especially compared with OpenVPN which has about 5 % with maximum packetsize https://serverfault.com/questions/249935/openvpn-performance
2nd try
sudo iptables -L -v
Chain INPUT (policy ACCEPT 27450 packets, 1050M bytes)
pkts bytes target prot opt in out source destination
190K 8025K ACCEPT tcp -- any any 192.168.178.55 anywhere
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 27683 packets, 1050M bytes)
pkts bytes target prot opt in out source destination
90036 1054M ACCEPT tcp -- any any anywhere 192.168.178.55
Here we have about 14 % more packets than in the first try, but still 3000 pakets less than with direct connection. We have transmitted 1MB more compared to direct connection. Thats in this case 0,09 % and since we measure at MB level it could be a lot less overhead.
I think the dramatically less pakets on input side reside due to the fact that ssh combines some TCP_ACKs and sends them combined. I was really astonished that there was less data transmitted via ssh Tunnel and searched for any mistake in this experiment, but couldn't find it.