If you fancy reading some rust, smoltcp [0] by u/whitequark_ [1] is a pretty good starting point, especially considering it intentionally leaves out functionality and compliance for the sake of simplicity and safety [2][3].
Then there are the more complete netmap [4] and lwIP [5] TCP/IP implementations too, but in C.
My bad. Netmap is a "kernel-network-stack bypass" mechanism [0]. Usually a userland TCP/IP implementation is used in conjunction with it [1].
Then there's NetStack for gVisor [2] in golang.
[0] https://news.ycombinator.com/item?id=10365731
[1] https://news.ycombinator.com/item?id=15630088
[2] https://news.ycombinator.com/item?id=15556398