Is it possible to test an TCP stack using TUN / TAP interfaces ? I'm thinking of a mechanism like this:
+--------------------------------+
| TCP Client / Server |
| socket(AF_INET, SOCK_STREAM) |
| e.g. HTTP Server / Client |
+----------+---------------------+
|
| +---------------------+
| | TUN Device |
| | ( kernel does TCP ) |
| +---------------------+
|
+------------+----------------------+
| Linux Kernel + Forwarding Magic |
+-----------------------------------+
|
| +---------------------+
| |TAP Device |
| |Raw ethernet frames |
| +---------------------+
|
+----------+----------------------+
| Raw Socket API |
| socket(AF_PACKET, SOCK_RAW) |
| User mode TCP Stack over raw API|
| a HTTP client/server over it |
+---------------------------------+
The top box, is (say) a standard unmodified HTTP server, listening on a IP address, which has been routed to the TUN device. The bottom box is a custom TCP/IP stack, which works on the raw ethernet frames.
Questions:
- Is it possible to connect two TAP/TUN devices back to back like this ?
- Is 'bridge' needed here ? How else they talk back-to-back ?
- And finally : Is there a better way to do this ?
Thanx in advance.
PS: I'm going to run all of them on same machine. The 'Box' are more like process or set or processes here.