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
Networking
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Networking
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.
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
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
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
-
- Member
- Posts: 1600
- Joined: Wed Oct 18, 2006 11:59 am
- Location: Vienna/Austria
- Contact:
Re:Networking
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.
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.
... the osdever formerly known as beyond infinity ...
BlueillusionOS iso image
BlueillusionOS iso image
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:Networking
well, i updated the page with info i gathered so far. but as i'm not exactly Nick Stacky it takes a little time ...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?