Documentation ¶
Overview ¶
This sample creates a stack with TCP and IPv4 protocols on top of a TUN device, and connects to a peer. Similar to "nc <address> <port>". While the sample is running, attempts to connect to its IPv4 address will result in a RST segment.
As an example of how to run it, a TUN device can be created and enabled on a linux host as follows (this only needs to be done once per boot):
[sudo] ip tuntap add user <username> mode tun <device-name> [sudo] ip link set <device-name> up [sudo] ip addr add <ipv4-address>/<mask-length> dev <device-name>
A concrete example:
$ sudo ip tuntap add user wedsonaf mode tun tun0 $ sudo ip link set tun0 up $ sudo ip addr add 192.168.1.1/24 dev tun0
Then one can run tun_tcp_connect as such:
$ ./tun/tun_tcp_connect tun0 192.168.1.2 0 192.168.1.1 1234
This will attempt to connect to the linux host's stack. One can run nc in listen mode to accept a connect from tun_tcp_connect and exchange data.