A lightweight TCP/IP stack with ARP, ICMP, UDP, simplified TCP, and socket APIs—built for teaching, research, and simple communication with Linux servers and clients.
English: Let’s write a TCP/IP Stack from Scratch(Part1: Ethernet Frame I/O) | by Skaiuijing | Medium
We will open three terminals:
- One for the Linux TCP server
- One for the litterTCP client
- One for tcpdump to capture packets
git clone https://github.com/skaiui2/litterTCP.git
Inside the project directory, run the script I prepared:
cd litterTCP/
chmod +x do.sh
./do.sh
This will create a TAP interface for our TCP/IP stack.
mkdir build
cd build/
cmake ..
Then go back to the project root:
cd ..
cd linux_tcp
gcc tcp_handle.c -o handle
./handle
This program listens for incoming TCP connections from our litterTCP stack.
First, disable unrelated IPv6 traffic to keep the output clean:
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.ens33.disable_ipv6=1
Then capture packets on our TAP interface:
sudo tcpdump -i tap0
You should now see raw Ethernet frames flowing through the interface.
Open a third terminal:
cd ..
chmod +x k.sh
./k.sh
This will start the litterTCP TCP client, which connects to the Linux TCP server.
You will see the messages sent by the litterTCP client, and the server will respond accordingly.
You will see the incoming packets from the Linux server
You will see the complete TCP exchange captured at the Ethernet frame level.
Everything works perfectly — a full TCP session implemented by our own TCP/IP stack.






