A learning TCP/IP protocol stack from scratch. This protocol stack was created at KlabExpertCamp6 based on microps.
Create a TAP device. In this implementation, microps communicates with the Linux TCP/IP protocol stack by reading and writing to the TAP device.
# microps <-----> TAP (Linux)
# 192.0.2.2/24 192.0.2.1/24
sudo ip tuntap add mode tap user $USER name tap0
sudo ip addr add 192.0.2.1/24 dev tap0
sudo ip link set tap0 upIP forwarding and NAT are configured to allow microps to communicate with the Internet via Linux.
# microps <-----> TAP (Linux) <-----> Internet
sudo bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
sudo iptables -A FORWARD -o tap0 -j ACCEPT
sudo iptables -A FORWARD -i tap0 -j ACCEPT
sudo iptables -t nat -A POSTROUTING -s 192.0.2.0/24 -o <INTERFACE_CONNECTED_TO_INTERNET> -j MASQUERADEmake
wireshark -i tap0
# or
tcpdump -i tap0./test/step17.exeListen for an incoming connection on port 10007.
nc -nv -l 10007Connect to nc.
./test/step28.exeEnter you message on nc.
$ nc -nv -l 10007
Listening on 0.0.0.0 10007
Connection received on 192.0.2.2 7
<YOUR MESSAGE>MIT
