References: <7f72b2de-f411-c4a0-bd1e-f343543cb8e2@...2030...> <6ad04520-6e42-51aa-bd38-b2285e7adaab@...2030...> From: Jan Just Keijser Message-ID: <5d22ace4-0fa0-857c-beef-8010edcf4350@...1147...> Date: Sat, 6 Jan 2018 22:28:01 +0100 MIME-Version: 1.0 In-Reply-To: <6ad04520-6e42-51aa-bd38-b2285e7adaab@...2030...> Content-Type: multipart/alternative; boundary="------------C4C99F25A634AAE891F93DE5" Subject: Re: [Openvpn-devel] OVPN vs IPSec performance as a transport List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Tom Kunz , "Greg Sloop " Cc: openvpn-devel@lists.sourceforge.net This is a multi-part message in MIME format. --------------C4C99F25A634AAE891F93DE5 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 05/01/18 00:52, Tom Kunz wrote: > That would explain it if it always worked that way. > But I can get 400%+ wire speed from A to B with compressible data, and > 102% with incompressible data. If I do the same test from B to A or A > to B, I get those results. If I hop off of that to C, speed goes from > >1Gbps to sub-200Mbps. In either case, the data has left the kernel > space to arrive at "nc", so just simply saying "it's kernel vs user" > doesn't answer it. > > actually, it does answer it: I've ran similar tests a few years back and got similar results. See https://homepages.staff.os3.nl/~delaat/rp/2010-2011/p09/report.pdf for the report. Here's what happens: if you run nc on the VPN endpoints themselves, then the OS can make use of the fact that the tun MTU is set to a very high value - thus you can easily achieve line speeds. However, as soon as you try to reach a machine beyond either VPN endpoint, then all traffic is fragmented to the MTU of the LAN , so normally that's 1500, possibly 6000. On your host C, all packets are chopped into 1500 bytes fragments (payload = 1472 bytes) and *THESE* packets are received by the OpenVPN endpoint, then compressed, encrypted, possibly fragmented and sent to the remove end. The tun MTU is never reached in this case, as each packet is handled separately. So yes, OpenVPN *IS* capped by the number of kernel-to-userspace transitions. On a high clockspeed CPU (e.g. i5-6000 series or higher with high turbo speed) you can achieve close to line speed, although I have yet to find out what MELTDOWN and the fix for it will to do the maximum speeds. As IPsec runs in kernel space, it does not suffer from the large number of transitions and it can thus achieve higher speeds going from A-B->C Hope this clarifies things, JJK > On 01/04/2018 06:37 PM, Greg Sloop wrote: >> I'm sure someone else, or a Google search will get you a more >> detailed run-down - but the gist of the "problem" is this; >> >> OpenVPN is run in user-space, not kernel space. IPSec runs in kernel >> space, and the difference is vastly diminished throughput. >> >> HTH >> >> -Greg >> >> On Jan 4, 2018 3:23 PM, "Tom Kunz" > > wrote: >> >> Hi, >> >> I have been testing OVPN 2.4.4 vs StrongSwan IPSec, to be used as >> transport, and I have found something that I think might be a >> performance issue. I have 3 linux boxes, A, B, and C. All interfaces >> are 1Gbps. Each has an interface to the next one downstream: >> >> A - eth0=10.10.10.10/24 and >> eth1=172.16.0.10/24 >> >> B - eth0=172.16.0.11/24 and >> eth1=172.30.0.11/24 >> >> C - eth0=172.30.0.10/24 and >> eth1=192.168.168.10/24 >> >> Packets route as usual through this with no encryption, and >> throughput >> from A to C is at wire speed. With IPSec between A&B, from >> 172.16.0.10-172.16.0.11, I can still get wire speed from A to C. >> Then I >> turn off IPSec, and I setup A as the server and B as the client, with >> A's config being: >> >> ===== >> >> dev tun >> >> topology subnet >> server 172.17.0.0 255.255.255.0 >> port 1194 >> proto udp >> dh /etc/openvpn/keys/dh2048.pem >> ca /etc/openvpn/keys/ca.crt >> cert /etc/openvpn/keys/server.crt >> key /etc/openvpn/keys/server.key >> verb 3 >> keepalive 10 45 >> cipher aes-256-cbc >> comp-lzo >> >> tun-mtu 50000 >> >> mssfix 0 >> >> fragment 0 >> >> client-config-dir ccd >> >> push "route 10.10.10.0 255.255.255.0" >> >> ===== >> >> and the client B config file is >> >> ===== >> >> verb 3 >> client >> cipher AES-256-CBC >> comp-lzo >> tun-mtu 50000 >> mssfix 0 >> fragment 0 >> remote 172.16.0.10 1194 >> >> dev tun >> redirect-private local >> tls-client >> >> ca /etc/openvpn/keys/ca.crt >> cert /etc/openvpn/keys/client1.crt >> key /etc/openvpn/keys/client1.key >> >> ===== >> >> and I setup static routes on each side so that traffic is going >> through >> the tunnel from A to C and vice versa. >> >> I can pass traffic over this link, however when I do tests for >> speed, I >> am only getting about 200Mbps instead of 1Gbps. >> >> The funny thing is, I know that each of these machines can easily do >> 1Gbps. If I do my performance test from A to B, over the above ovpn >> configs, I can get just over 1Gbps because of the MTU overhead being >> removed. But as soon as I have it make the leap downstream once >> more, I >> lose 80+% of the speed. And again, both non-encrypted traffic >> and IPSec >> do the exact same test at wire speed or just slightly under wire >> speed. >> >> The way I do a speed test is on A: >> >> # nc -l -p 5555 > /dev/null >> >> and over on C: >> >> # dd if=/dev/urandom of=blob.random.1G bs=10M count=100 >> >> # time cat blob.random.1G | nc 10.10.10.10 5555 >> >> tcpdumps over each interface confirm traffic is flowing in the >> expected >> fashion. >> >> Over unencrypted or IPSec, I am looking at about 4s to move 1G of >> data >> from one end to the other, and with ovpn, 15-22s. The machines >> involved >> are 2 Dell R720's with 8+G ram and a homebrew machine with >> several Xeons >> and 32G RAM. Network cards involved are a mix of BCM Tigon3 "tg3" >> driver and IGB driver gigabit NICs. >> >> Anyone have any suggestions or thoughts as to why the big perf >> decrease >> and what might be done to improve it? >> >> Thanks, >> >> Tom >> >> >> >> >> ------------------------------------------------------------------------------ >> Check out the vibrant tech community on one of the world's most >> engaging tech sites, Slashdot.org! http://sdm.link/slashdot >> _______________________________________________ >> Openvpn-devel mailing list >> Openvpn-devel@lists.sourceforge.net >> >> https://lists.sourceforge.net/lists/listinfo/openvpn-devel >> >> > > > > ------------------------------------------------------------------------------ > Check out the vibrant tech community on one of the world's most > engaging tech sites, Slashdot.org! http://sdm.link/slashdot > > > _______________________________________________ > Openvpn-devel mailing list > Openvpn-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/openvpn-devel --------------C4C99F25A634AAE891F93DE5 Content-Type: text/html; charset="windows-1252" Content-Transfer-Encoding: quoted-printable
On 05/01/18 00:52, Tom Kunz wrote:
That would explain it if it always worked that way.
But I can get 400%+ wire speed from A to B with compressible data, and 102% with incompressible data.=A0 If I do the same test from B to A or A to B, I get those results.=A0 If I hop off of that to C, speed goes from >1Gbps to sub-200Mbps.=A0 In either case, the data has left the kernel space to arrive at "nc", so just simply saying "it's kernel vs user" doesn't answer it.


actually, it does answer it: I've ran similar tests a few years back and got similar results. See
=A0 https://hom= epages.staff.os3.nl/~delaat/rp/2010-2011/p09/report.pdf

for the report.
=A0Here's what happens:

if you run nc on the VPN endpoints themselves, then the OS can make use of the fact that the tun MTU is set to a very high value - thus you can easily achieve line speeds. However, as soon as you try to reach a machine beyond either VPN endpoint, then all traffic is fragmented to the MTU of the LAN , so normally that's 1500, possibly 6000.=A0 On your host C, all packets are chopped into 1500 bytes fragments (payload =3D 1472 bytes) and *THESE* packets are received by the OpenVPN endpoint, then compressed, encrypted, possibly fragmented and sent to the remove end. The tun MTU is never reached in this case, as each packet is handled separately.
So yes, OpenVPN *IS* capped by the number of kernel-to-userspace transitions. On a high clockspeed CPU (e.g. i5-6000 series or higher with high turbo speed) you can achieve close to line speed, although I have yet to find out what MELTDOWN and the fix for it will to do the maximum speeds.

As IPsec runs in kernel space, it does not suffer from the large number of transitions and it can thus achieve higher speeds going from A-B->C

Hope this clarifies things,

JJK

=A0
On 01/04/2018 06:37 PM, Greg Sloop <gregs@...1934...> wrote:
I'm sure someone else, or a Google search will get you a more detailed run-down - but the gist of the "problem" is this;

OpenVPN is run in user-space, not kernel space. IPSec =A0runs in kernel space, and the difference is vastly diminished throughput.

HTH

-Greg

On Jan 4, 2018 3:23 PM, "Tom Kunz" <tkunz@...2030...> wrote:
Hi,

I have been testing OVPN 2.4.4 vs StrongSwan IPSec, to be used as
transport, and I have found something that I think might be a
performance issue.=A0 I have 3 linux boxes, A, B, and C.=A0 All interfaces
are 1Gbps.=A0 Each has an interface to the next one downstream:

A - eth0=3D10.10.10.10/24 and eth1=3D172.16.0.10/24

B - eth0=3D
172.16.0.11/24 and eth1=3D172.30.0.11/24

C - eth0=3D
172.30.0.10/24 and eth1=3D192.168.168.10/24

Packets route as usual through this with no encryption, and throughput
from A to C is at wire speed.=A0 With IPSec between A&B, from
172.16.0.10-172.16.0.11, I can still get wire speed from A to C.=A0 Then I
turn off IPSec, and I setup A as the server and B as the client, with
A's config being:

=3D=3D=3D=3D=3D

dev tun

topology subnet
server 172.17.0.0 255.255.255.0
port 1194
proto udp
dh /etc/openvpn/keys/dh2048.pem
ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/server.crt
key /etc/openvpn/keys/server.key
verb 3
keepalive 10 45
cipher aes-256-cbc
comp-lzo

tun-mtu 50000

mssfix 0

fragment 0

client-config-dir ccd

push "route 10.10.10.0 255.255.255.0"

=3D=3D=3D=3D=3D

and the client B config file is

=3D=3D=3D=3D=3D

verb 3
client
cipher AES-256-CBC
comp-lzo
tun-mtu 50000
mssfix 0
fragment 0
remote 172.16.0.10=A0 1194

dev tun
redirect-private local
tls-client

ca /etc/openvpn/keys/ca.crt
cert /etc/openvpn/keys/client1.crt
key /etc/openvpn/keys/client1.key

=3D=3D=3D=3D=3D

and I setup static routes on each side so that traffic is going through
the tunnel from A to C and vice versa.

I can pass traffic over this link, however when I do tests for speed, I
am only getting about 200Mbps instead of 1Gbps.

The funny thing is, I know that each of these machines can easily do
1Gbps.=A0 If I do my performance test from A to B, over the above ovpn
configs, I can get just over 1Gbps because of the MTU overhead being
removed. But as soon as I have it make the leap downstream once more, I
lose 80+% of the speed.=A0 And again, both non-encrypted traffic and IPSec
do the exact same test at wire speed or just slightly under wire speed.

The way I do a speed test is on A:

# nc -l -p 5555 > /dev/null

and over on C:

# dd if=3D/dev/urandom of=3Dblob.random.1G bs=3D10M count=3D1= 00

# time cat blob.random.1G | nc 10.10.10.10 5555

tcpdumps over each interface confirm traffic is flowing in the expected
fashion.

Over unencrypted or IPSec, I am looking at about 4s to move 1G of data
from one end to the other, and with ovpn, 15-22s.=A0 The machines involved
are 2 Dell R720's with 8+G ram and a homebrew machine with several Xeons
and 32G RAM.=A0 Network cards involved are a mix of BCM Tigon3 "tg3"
driver and IGB driver gigabit NICs.

Anyone have any suggestions or thoughts as to why the big perf decrease
and what might be done to improve it?

Thanks,=A0

Tom




--------------------------------------------------------= ----------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashd= ot
_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@...1199...sourc= eforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-devel<= br>




------------------------------------------------------=
------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot


_______________________________________________
Openvpn-devel mailing list
Openvpn-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/op=
envpn-devel

--------------C4C99F25A634AAE891F93DE5--