Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Can't the operating system directly write data to the PCI bus and the network card would simply send it through the cable? What does the driver do, and in what way does that differ for each network card chipset?

share|improve this question

migrated from stackoverflow.com May 27 '11 at 2:56

This question came from our site for professional and enthusiast programmers.

1  
I wasn't sure where to put it, but since it is about the behaviour of drivers, which are software, which is created by means of programming, I thought it would fit better on SO. –  Anonymous May 25 '11 at 10:22
    
@futlib: I can see what you're saying, but unfortunately it isn't a specific programming question. General programming questions go to programmers.stackexchange.com, but I think this better off in SuperUser (it isn't something programmers really need to know). If your question was "I'm writing a network driver, what's the best way to structure packets in memory?", that's a Stack Overflow question. "I'm writing a network driver, where do I start?" is a programmers question. Hope this helps, and I hope you get a good answer to your question, which ever exchange it ends up on :) –  Binary Worrier May 25 '11 at 10:31
    
@Binary Worrier Agree with you. But I don't think the super users can answer this well. He might be worry about that. –  Benjamin May 25 '11 at 14:29

4 Answers 4

Each network chip will have different I/O registers, memory-mapped buffers, ways of detecting interface speeds, and all sorts of other fundamental technical differences.

The job of the driver is simply to abstract those differences away so that the O/S has a common API for moving packets from the higher network layers down to the hardware (and vice versa).

share|improve this answer
    
So it isn't just a means of writing data to RJ45, similar to a RS232 to USB converter? Could you outline a bit what a network card has to do in order to transmit data? –  Anonymous May 25 '11 at 10:28
    
@Anonymous (futlib?), check my answer. Networking is definitely more than just sending an electrical signal through a wire. –  Synetech May 27 '11 at 3:56

In general terms, any device driver acts an an interface between the 'abstract' view of the hardware the the operating system has, and the 'physical' chipset that actually exists on the board.

This abstraction layer allows different hardware from different vendors to be used in many different operating systems. It also allows 'software' devices (such as a network loopback device) to be implemented that don't have any underlying hardware to control.

To find exactly what a particular driver does, you would need to understand the datasheets for the chips it controls.

share|improve this answer

It could, but the problem with that is each NIC chipset manufacturer designs their devices differently and therefore one model of NIC might require you to write at one address, and another model might require you to write at another address. In addition to looking at NIC chipset datasheets like @Roddy suggests to learn exactly how they go about it, you could also look at the source of Linux drivers for that chipset.

Some advanced NICs use DMA and such to pretty much operate the way you say. The driver in that case really doesn't do much.

It's easier to update a single operating system with a new driver than go around and update every single program that uses a NIC.

share|improve this answer

Each piece of hardware is different from others of the same class, even when adhering to standards. That’s why you need drivers; to simplify using the hardware by providing a common interface. You asked whether the OS can simply write to output. Yes it can; it does this via its drivers.

More specifically about network cards, you ask if the OS can write to PCI bus, through the card, out the cable, and over the Internet. The problem with that question is that you are not familiar with networking. It is a complex thing that is beyond just sending a voltage over a wire. You are forgetting about all the work that allows such a complex web to work like all the addressing and such—it’s not just encoding or decoding an electrical signal.

You will want to look over the OSI model to learn how networking works. It separates the work of transferring data between computers (or other devices) into seven “layers”. Each layers is responsible for its own part; the OS plays its role as do the driver and card itself.

share|improve this answer
    
But isn't the network card just responsible of layer 1? That's what I always thought. –  futlib May 27 '11 at 13:19
    
Generally yes, and that’s all the more reason that some software is required to handle the other parts. The OS can only deal with so much (take a look at how graphics were handled in the DOS days, before DirectX came out). The driver is like a glue between the higher-level APIs of the OS and the lower level interfaces of the hardware. Yes, the OS could “do it itself”, but it would do so by having drivers built-in. –  Synetech May 27 '11 at 15:53
    
What other parts in particular? I believe that the TCP/IP stack is usually device independent, so the NIC driver would implement just layer 2, considering that layer 1 is handled by the hardware? –  futlib Jun 4 '11 at 13:38

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.