Page 1 of 1

Networking

Posted: Fri Nov 19, 2004 5:43 am
by scarab
Hi there

I was wondering if I could have some tips on networking.

I decided I want TCP/IP, and have started with a SLIP driver. I can send and receive characters over the serial port fine, but I am trying to design a way to integrate networking into my OS, this is the idea I have had:

Each interface will have two threads, one monitering incoming and if there is a new packet it will get it, the other monitering outging and if there is a packet to send it will send it. Then there will be a generic networking thread and it will fetch and send the packets that the interface threads deal with.

Is this a good way to go about it? I am not sure if threads are the way to go? the only other way i can think of is to have some sort of interrupt fire when a new packet is ready (but I suppose that would need threads to fire the interrupt?)

thanks for any advise

andrew

Re:Networking

Posted: Fri Nov 19, 2004 6:39 am
by Pype.Clicker
i suggest you search for a book about network architecture in Linux. It will give you at least a solid background about how networks work and how Network Interface Cards work.

I'm not sure designing the TCP/IP stack on top of SLIP alone is a so good idea. the serial line behave quite differently from a network card...

A NIC card usually have two circular buffers in which they can queue packets written-by-cpu-and-awaiting-to-be-sent and packets received-and-awaiting-to-be-read-by-cpu.
when a packet is succesfully sent or received, the cpu is notified through an IRQ.

Most of the time, you try to push/pull packets to/from the NIC in the interrupt handler so that you experience little penalty. So probably your threads thing is only interresting for emulating a NIC through a serial line.

Re:Networking

Posted: Fri Nov 19, 2004 7:35 am
by scarab
Hi Pype.Clicker

Thankyou for your response. I will search out some books tomorrow. I had thought I would use SLIP as a starting point because it was simple to implement, I thought that if I had a working TCP/IP implemented (tested by the SLIP driver) writing an ethernet card driver would be simpler (seems I had a working TCP/IP that I could test it with) Perhaps I should have started with ethernet.

I probably shouldn't be doing networks yet, seems I can't even write to the disk, but networks is very intersting, I am wondering if the person who started "Osdeving like Nick Stacksky" would like some input from a newbie who absolutly had to have TCP/IP before he could even write to a disk :-) once I have got it working?

Thanks again for your reply and this boards patience with newbies

thanks
Andrew

Re:Networking

Posted: Fri Nov 19, 2004 7:56 am
by distantvoices
you'd need some wrapper around your slip-driver, which does the occasional splitting of IP packets in smaller entities and so forth.

I think, for a NIC, one thread for taking care of the occasional interrupts should suffice. Know ya, the NIC gives Interrupt states (at least I know, rtl8139 does this) like SEND_SUCCESS, SEND_FAIL, RCV_SUCCESS,RCV_FAIL or similar. Well, but what talk I, i have not yet implemented sufficient pci support to power up PCI cards ... well, these are things to come.

For SLIP - well, the threaded approach might work for that too. :-)

Provide yerself with TCP/IP Illustrated, Volume 1+2.

Re:Networking

Posted: Mon Nov 22, 2004 5:15 am
by Pype.Clicker
scarab wrote: I am wondering if the person who started "Osdeving like Nick Stacksky" would like some input from a newbie who absolutly had to have TCP/IP before he could even write to a disk :-) once I have got it working?
well, i updated the page with info i gathered so far. but as i'm not exactly Nick Stacky it takes a little time ...