1

Linux.

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.

Thanks

2 Answers 2

1

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.

4
  • 1
    Thanks.How did you solve it? What is the alternative?
    – Larry
    Dec 19, 2014 at 9:33
  • 1
    Please take a look at the edited answer. Do you require any further information?
    – MemCtrl
    Dec 19, 2014 at 9:35
  • 1
    Nice! My concern is for http so I think tap may be sufficient.
    – Larry
    Dec 19, 2014 at 9:45
  • UDP is a connection less protocol. It is a fire and forget. So I fail to understand what you meant by "no more connection timeouts when switched to UDP".
    – init
    Apr 7, 2023 at 18:03
2

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.

1
  • 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, 2014 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .