lilaura.eu - shitposts and engineering - Projects

About Me >.< | Projects x.x | Club :3 | git - spagetti code, served cold | Mastodon - Shitposts, but short | Matrix (for some reason) | Send me an Email :3


Pingxelflut - Spending too much time to optimize past my Hardware

Chaos Events are always a great place for blursed Ideas to take shape. Last GPN, this happened, and its result is Pingxelflut. While I was on the way back from Karlsruhe on Monday, the day after the Event, Kleines Filmroellchen published a git repo detailing the protocol, and a server/client reference implementation.

I (who had never done anything network past a super simple pixelflut client thrown together with pwntools) decided I wanted to implement it. I knew python, and so I decided that was what I would use.

A couple days later (and with a pretty stupid bug found by Filmroellchen themself), I had a running implementation, managing about 90k pakets per second (pps) I did not want to accept that speed. And I had just applied for a job asking for some C knowledge (that I didn't have). So the plan was clear. Rewrite it in C! (And learn some C in the process)


And so it started. After some initial frustration with lack of easy debugging and a syntax incompatible with my muscle-memory, I got to a point of productivity. A big help in me working on it, was that I couldn't really do anything else. At GPN I had gotten infected with Covid. A harsh reminder to wear masks and regularly test at big events.

With this being the first time writing Network code, I had just copied the socket options from my Python code. Unfortunately, that led to me using IPPROTO_RAW, since that seemed to be the closest thing to what I had used in Python, that my compiler didn't complain about. However, unlike in Python, that will not send the IP header automatically. So, being the genius I am, I did not make the reasonable assumption that there is a way to send ICMP(v6) packets and look up how to do so, but instead started implementing the IPv6 header myself. X.X

With that and a few more challenges (like getting libpng to work, and of course hunting down numerous segfaults and bugs in general), I finally had a functioning C implementation. And not to long after It working, I tested Covid negative. So it was time to go back, set up a pingxelflut server, and bombard it with everything I had.


So, for about the next week, everyday we threw images at one of the SFF-PCs the @schenkelklopfer gave out at GPN. And, while initially my memory speed combined with the number of context switches caused by all the send() syscalls limited the number of packets, I soon found out about sendmmsg(). And multithreading. However, something about the server doesn't like recieving more than ~520kpps. That coresponds to about 300Mbits. Not quite the 1Gbit link the machine has. So some work is needed there.

But this is ICMP. My kernel does not care if the packets reach their destination. And so, everything the server can't handle gets dropped. Assuming my laptop does send all the packets vnstat claims it does, I reach well past 1mpps. However, running 4 or more jobs, my CPU reaches ~95°C basically instantly, probably triggering pretty heavy throtteling to keep my machine alive.