if I malfunctioned my computer TCP stack in kernel just commenting out single important line of code or compiling with excluding TCP stack and install. Then What are the steps in I need to take in coding. Do I need to Implement Ethernet (if creates layer 2 Socket in my stack implementation) then do I need to implement IP
because that comes with if I am using layer 2 socket then implement TCP (this is what final code will be)
If that's so
Then what are the supported protocols I need to implement to cover ethernet layer, Ip layer and (TCP layer -- that I can know I may have used it in code)
Can anyone please tell the machining protocols with each layer
whats before?-->ethernet --> ip -- tcp --> http
<--protocol names please that may be needed
the whole thing is just for as a research thing or learning for my self or just may be programming
CodePudding user response:
I'll assume you want to be able to do something like request https://example.com
from a web server.
For this the following procotols are diretly necessary:
- HTTPS (i.e. HTTP and TLS), but that's usually already implemented in user space, no change here
- DNS to resolve
example.com
to an IP address. Usually implemented in user space as well, based on UDP - UDP to run DNS on top of. Usually implemented in the kernel on top of IP.
- TCP to run HTTPS on top of. Usually implemented in the kernel on top of IP.
- IP to run both TCP and UDP on top of. Usually implemented in the kernel on top of Ethernet.
- Ethernet to send/receive IP packages. Usually implemented in the kernel, with the help of hardware-specific NIC drivers.
But even if you had implemented those, you wouldn't be done. For example, you wouldn't know what your local IP address is.
To do this, you'd implement DHCP. You could get away without implementing this, if you just configured your IP address to a fixed value (as long as it's within the allowed range of your network and doesn't conflict with other devices, this is not a problem).
But when you try to send your first IP packet to the DNS server, you'd realize that you don't know what Ethernet address you should send that to. So you'd need to implement ARP as well. Again, you could theoretically have a static routing table and "fake" the ARP responses by your router this way, but this could be way trickier than just hard-coding the IP adress.
I may have missed some protocol (and I'm sure comments will pop up, if I did), but that should be roughly everything that you'd need to get going.