How to send raw network packets in Python with tun/tap

42 · Julia Evans · Sept. 6, 2022, 5:40 p.m.
Hello! Recently I’ve been working on a project where I implement a bunch of tiny toy working versions of computer networking protocols in Python without using any libraries, as a way to explain how computer networking works. I’m still working on writing up that project, but today I wanted to talk about how to do the very first step: sending network packets in Python. In this post we’re going to send a SYN packet (the first packet in a TCP connection) from a tiny Python program, and get a reply f...