Is there a performance loss from using a tap device vs a hardware one like eth0 ?

The goal is to create a user space tcp/ip stack and avoid the kernel as much as possible.

I would like to be sure that developping on top of a tap device is the right thing to do.



I'm posting this as an answer due to insufficient commenting permissions.

From my experience VPN over tcp - tap was abysmal at best over wireless connections due to the the nature of TCP. When switching to UDP no more connection timeouts occurred - even better with tun device. I would suggest you test under poor network connections both TCP and UDP and tap/tun.

  • 1
    Thanks.How did you solve it? What is the alternative? – Larry Dec 19 '14 at 9:33
  • 1
    Please take a look at the edited answer. Do you require any further information? – MemCtrl Dec 19 '14 at 9:35
  • 1
    Nice! My concern is for http so I think tap may be sufficient. – Larry Dec 19 '14 at 9:45

Yes, there is. Using a tap device causes context switches between the client process and the process that holds the tap device. It also causes additional copies, as data needs to be copied from the client process into the kernel, and then from the kernel into the tap holder.

However, Linux is pretty good at context switching, and in-cache copies are fairly cheap, so the overhead might be small enough. I would recommend that you implement your stack in user-space, using tap, and then perform some benchmarking and profiling to decide whether it is worth the effort to move your code into the kernel.

  • user-space tcp stack is exactly what I want to achieve. So you confirm I will need a tap device to make this happen ? And that it cannot be as fast as a hardware interface ? I am willing to deal with layer 2. – Larry Dec 20 '14 at 12:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.