NETWORK Programming||Where to start

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

NETWORK Programming||Where to start

Post by Devl0n »

I want to learn network programming at low-level for implementing networking in my OS...So where to learn low-level network programming..any suggest/book suggestion are welcome
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: NETWORK Programming||Where to start

Post by Combuster »

If you're really out for a book, I have an old edition of this which covers pretty much all the theory and has a better index than the average google query. You just have to read it in the less-logical back-to-front order.

What you will not find in any book is how to write a device driver for any network card. So what you will need to do is grab an emulator (choice depending on debuggability, bochs has the most options but is more difficult to set up) and wireshark, check that the virtual network works and is sniffable (try an existing os), then dive into the documentation of the emu's network card, and then get cranking some code to have it initially send anything random, then send whatever packet you found in the book.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

I know the theory I want to understand the implementation or how its implemented.....other OS[on frontend] use socket approach but I want to know how sock is implemented...or how..etc..how OS communicate using modem/ether ports etc...
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: NETWORK Programming||Where to start

Post by Love4Boobies »

You might be interested in this classic (official website here). It doesn't cover any modern protocols but it is more than enough to get you started.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

It's on UNix tcp/ip implementation and I want a low-lev stuff or in other words 50000 feets below that is Ground-UP
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

I want to learn net-implementaion
User avatar
Love4Boobies
Member
Member
Posts: 2111
Joined: Fri Mar 07, 2008 5:36 pm
Location: Bucharest, Romania

Re: NETWORK Programming||Where to start

Post by Love4Boobies »

So... drivers? Like Combuster said, grab the specification for the NIC you wish to write a driver for.
"Computers in the future may weigh no more than 1.5 tons.", Popular Mechanics (1949)
[ Project UDI ]
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: NETWORK Programming||Where to start

Post by iansjack »

You have to walk before you can run. Forget all about protocols, TCP/IP, etc. for the time being and just get a driver for your NIC working. For starters get it receiving data (if you do that, writing data should be easy enough).

Once you have that working you can worry about the higher levels of the networking model.
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

So I have to write for different NIC different for a particular NIC isn't there is any standard for NIC....

Thankyou to all for paying your precious time to my problem
cxzuk
Member
Member
Posts: 164
Joined: Mon Dec 21, 2009 6:03 pm

Re: NETWORK Programming||Where to start

Post by cxzuk »

Drivers can share small chunks but there is no one driver to rule them all.
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

I wanna see others code first as an example to understand I mean interfacing with NIC card...can anybody help
User avatar
thepowersgang
Member
Member
Posts: 734
Joined: Tue Dec 25, 2007 6:03 am
Libera.chat IRC: thePowersGang
Location: Perth, Western Australia
Contact:

Re: NETWORK Programming||Where to start

Post by thepowersgang »

There are a few people here who have written networking stacks, myself among them.

Here's the source for my RTL8139 (a classic 10/100 chip, and still very common) driver. https://github.com/thepowersgang/acess2 ... /rtl8139.c
Kernel Development, It's the brain surgery of programming.
Acess2 OS (c) | Tifflin OS (rust) | mrustc - Rust compiler
Currently Working on: mrustc
Devl0n
Posts: 7
Joined: Tue Feb 12, 2013 4:50 am

Re: NETWORK Programming||Where to start

Post by Devl0n »

@thepowerersgang
Sir,it means we have to write different drvs for different NICS...So I wanna know how to detect NIC Card model and run a particular drv for it
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: NETWORK Programming||Where to start

Post by iansjack »

I'm not convinced that you understand what you are trying to do; there is no simple step-by-step answer to your question.

Detecting hardware is a universal question with an OS. Most people start by targetting the particular hardware they have (either real or virtual). Beyond that you have to scan the PCI and USB buses to see what hardware is there.

As for writing the driver, that is different for each individual hardware component. The Wiki here gives outlines for some hardware, but you really need to get hold of the manufacturers technical manual. If you want complete source code showing how to detect hardware and communicate with it, this is available for just about any device you can think of. It's called the "Linux Source Code". But, beware; it is not easy reading. Writing device drivers, particularly for a NIC is not an easy task.

I think you need to do a lot more reading before you are ready to support a NIC in your own OS.
Post Reply