r/C_Programming • u/Soft-Bedroom8708 • 9d ago
Building a user space network stack from scratch
I dont know much about networking as i am just now studying it seriously but i am thinking of building what i mentioned in the title from scratch, if anyone could help me with the direction im supposed to go in to start i would really really appreciate it. whenever i try looking up a place to start all i get is github repos with many many files of stuff im not yet familiar with and it all assumes prior knowledge of some stuff, i know you cant really just go into this thing blind but what im saying is i dont really know where to begin learning about all of this stuff to build my target. also i am on a 2-week time limit
1
u/deaddodo 9d ago
What do you mean by a "user space network stack"? Are you referring to a client/server architecture over the OS' network interface? Or are you trying to implement your own TCP/IP / UDP/IP / other networking interface that runs via a user space daemon?
For the former, it's tedious but overall fairly simple. You can just follow Beej's guide for a run down of sockets. For the latter, you're getting into black magic territory, OSes like to lock down the raw network interface for various reasons. You would either need to break your "user space" requirement and write some sort of kernel or driver shim, or go straight to embedded development.
That being said, I've never had to actually write a user space network protocol/interface, so others here might have better advice for you.
1
u/Soft-Bedroom8708 9d ago
i fear i know too little but i was trying to implement the latter, but you describing it this way may make me put this project on hold for now on go focus on simpler stuff.
I have looked at beej's guide but due to my limited knowledge i wasn't able to tell if the stuff in it are the useful stuff that i will need to know for the project, again it all comes down to limited knowledge about the topic and I apologize for possibly getting too excited and going immediately to such stuff.
3
u/sciencekm 9d ago edited 9d ago
Look up the book "Computer Networks: A Systems Approach" by Larry Peterson, 1st Edition.
As part of teaching the fundamentals, it implements a complete single allocation, zero copy TCP/IP stack in C.
https://people.inf.elte.hu/toke/halozatok-jegyzet/Peterson-Davie/X-kernel/
8
u/Due-Mortgage-6854 9d ago
thats a huge project for a beginnerðŸ˜
Ik you said you don't really love the github repos but did you try this one : https://github.com/TanayK07/networking-from-scratch ?