Question

I am working on a program where I'm reading from a Tap. The only issue is, I have no clue how to detect the end of one transmission to the tap and the start of another.

Does reading from the tap act the same way as a SOCK_STREAM ?

Was it helpful?

Solution

Tun/tap tries to look like a regular ethernet controller, but the tap device itself is accessed just like any other file descriptor.

Since it pretends to be an ethernet controller, you have to know in advance how big the ethernet frame itself was that was transmitted - this comes either from the software bridge that the tap device was attached to or the "length" field in the raw ethernet frame.

This, of course can only be the maximum of the MTU size of the tap device, which typically defaults to 1500 bytes.

So, before you do a read() on the file descriptor for the tap device, you've gotta figure out how big the ethernet frame actually is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top