Follow Slashdot stories on Twitter

 



Forgot your password?
typodupeerror
×
Operating Systems Software Linux

The Linux Networking Stack Exposed 69

An anonymous reader writes "The Linux source code is a great way to learn about the design of device drivers for a multitude of device types, including network device drivers. This article will show you the basic architecture of the Linux networking stack and dig into its interfaces for system calls, protocols, and device drivers."
This discussion has been archived. No new comments can be posted.

The Linux Networking Stack Exposed

Comments Filter:
  • well (Score:5, Funny)

    by Anonymous Coward on Monday August 13, 2007 @11:07AM (#20213047)
    I doubt we're going to see any +5 funny mods in this one
    • by Anonymous Coward
      "The Linux Networking Stack Exposed"

      Well the nice thing is that geeks can get their porn at work without tipping anyone off.
    • Re:well (Score:5, Funny)

      by JosefAssad ( 1138611 ) on Monday August 13, 2007 @11:28AM (#20213311) Homepage
      I doubt we're going to see any +5 funny mods in this one

      Oh yeah?

      So, a UDP connection walks into a bar and it goes up to the bartender.

      "Hi bartender, " it says to the bartender.

      "Howdy, UDP connection. What'll it be?" the bartender asks.

      "I'll have a beer please. Here's a dollar," says the UDP connection.

      The bartender takes the dollar, looks at the UDP connection, and continues wiping glasses.

      "So, what'll it be?" the bartender asks the UDP connection.

      The UDP connection forks over another dollar and orders a beer again. The bartender takes the dollar and stares expectantly at the UDP connection as he continues to wipe glasses.

      "So, what are you gonna drink, little UDP connection?" the bartender asks.

      "I would like a beer please," and the UDP connection gives the bartender yet another dollar. The bartender takes the dollar and promptly starts wiping the counter. He looks thatthe UDP connection and asks,

      "Oh, hello there. Can I get you anything?"

      "Yes please," responds the UDP connection, "I'd like a beer. Here is a dollar." And the UDP connection gives the bartender yet another dollar.

      And so on...

      • Re:well (Score:5, Funny)

        by weicco ( 645927 ) on Monday August 13, 2007 @12:15PM (#20213903)

        And when TCP walks into the bar and asks for beer bartender opens the tap and lets beer stream... But before that they have to shake hands three times.

        • Funnypidia?
        • Re:well (Score:4, Informative)

          by kdemetter ( 965669 ) on Monday August 13, 2007 @04:29PM (#20217103)
          it would be more like :

          TCP : Can i get a beer ?
          Bartender : You asked for a beer ?
          TCP : Yes i did .
          Bartender : Ok , here's the beer , that will be ...
          TCP : did you just tell me how much to pay you ?
          Bartender : yes i did .
          TCP : ok , here's ...

          and say the bartender has bad hearing ;

          TCP : Can i get a beer ?
          Bartender : You asked for a lemonade ?
          TCP : no i didn't .
          TCP : Can i get a beer ?
          Bartender : Ok , here's the beer , that will be ...
          TCP : did you just tell me how much to pay you ?
          Bartender : yes i did .
          TCP : ok , here's ...

          TCP constantly verifies that the data was received , while udp only verifies that the data was correct . udp would end up with a lemonade , drink it , and just order a beer again .

        • by Wolfger ( 96957 )
          Sorry to break up the funny train, but TCP acts just like a normal person in this scenario: 1) TCP orders a beer 2) Bartender acknowledges the order and serves up a beer 3) TCP acknowledges receipt of the beer by paying for it. No silly "shaking hands 3 times" nonsense, just sensible interaction.
          • by weicco ( 645927 )

            They have changed the TCP 3 way handshaking? Why wasn't I informed... Oh, maybe because I'm not programming network drivers anymore.

            • by Wolfger ( 96957 )
              I think the problem is that you fail to recognize a 3-way handshake when you see it. Like, the one I just described for you (SYN, SYN-ACK, ACK). You also seem to confuse "a 3-way handshake" with "shaking hands 3 times" (i.e. a series of 3 2-way handshakes). You were programming network drivers, and you don't understand something this simple? Scary.
              • by weicco ( 645927 )

                No I'm not failing to recognize it or whatever. How do you do 3 way handshaking without actually making somekind of interaction between customer and bartender (which customer starts) three times?

                But now when I'm giving it more serious thought it could go like customer shakes hand with bartender and says "hi", bartender answers "hi", customer says "okay" or something like that to end the handshaking and starts Beer Ordering Procedure. In T/TCP "okay" could contain also the order if I remember correctly.

      • Re:well (Score:4, Funny)

        by riffzifnab ( 449869 ) on Monday August 13, 2007 @12:16PM (#20213921) Journal

        Oh yeah?

        So, a UDP connection walks into a bar and it goes up to the bartender.

        "Hi bartender, " it says to the bartender.

        "Howdy, UDP connection. What'll it be?" the bartender asks.

        "I'll have a beer please. Here's a dollar," says the UDP connection.

        The bartender takes the dollar, looks at the UDP connection, and continues wiping glasses.

        "So, what'll it be?" the bartender asks the UDP connection.

        The UDP connection forks over another dollar and orders a beer again. The bartender takes the dollar and stares expectantly at the UDP connection as he continues to wipe glasses.

        "So, what are you gonna drink, little UDP connection?" the bartender asks.

        "I would like a beer please," and the UDP connection gives the bartender yet another dollar. The bartender takes the dollar and promptly starts wiping the counter. He looks thatthe UDP connection and asks,

        "Oh, hello there. Can I get you anything?"

        "Yes please," responds the UDP connection, "I'd like a beer. Here is a dollar." And the UDP connection gives the bartender yet another dollar.

        And so on...
        [Memento joke here]

        So I guess writing stuff down on it's arms would turn the UDP connection into a TFTP session.
      • Re: (Score:3, Funny)

        by Almahtar ( 991773 )
        That is possibly the nerdiest joke I've ever heard... and it does not bode well that I not only got it but laughed at it a lot.
    • Re: (Score:3, Funny)

      by flydpnkrtn ( 114575 )
      (Score:4, Funny)

      Oh how ironic
      • Oh how ironic

        Only if you're

        A) Alanis Morisette, or

        B) operating under a definition of "ironic" such that "ironic" equates to "exactly according to plan."
    • by htiawe ( 973440 )
      Next up Bill Gates will explain Windows BSOD on a big screen projector.
  • How come I don't see any references to NetBIOS in the stack?
    • Stop playing with that new-fangled NetBIOS stuff!

      Wait till a stable version comes out!

      Oh wait...nevermind...

      • by Anonymous Coward
        Says she, glancing at the Banyan Vines tape cartridge on the (distant) "Computing History" corner shelf.

        For the record, Banyan Vines systems commissioned == 1, Banyan Vines systems taken down the local tip == 9. My garage just couldn't stand the waste of space anymore.
    • by mhearne ( 601124 )
      Because the article was about the Linux networking stack, and NetBIOS doesn't exist there. That is handled by SMB/NMB.
  • by Anonymous Coward
  • What about Minix? (Score:5, Interesting)

    by drspliff ( 652992 ) on Monday August 13, 2007 @11:33AM (#20213367)
    Personally I'd say Minix is much easier to navigate, simpler to understand and a much better starting point for new kernel developers or students to begin with (it was designed primarily as an academic project).

    I've tried digging around the Linux source code, but find a lot of it fairly confusing simply because of the amount of time and effort you have to invest in understanding the rest of it and general architecture.

    With Minix, you can pretty much jump in at any place (being very organized and well separated you can find what you're looking for fast), in 3.0 the core syscalls are separated into different files and the core kernel is only around 5000 lines which you can scan through fairly quickly.
    • Re: (Score:3, Insightful)

      by feld ( 980784 )
      yeah, but learning how to write device drivers for Minix is a pretty useless skill.

      The point of this is to teach people a useful skill so they can help the Linux community. If the goal here was teaching people how to write general device drivers it wouldn't be centered around Linux.
      • Re: (Score:3, Insightful)

        by assantisz ( 881107 )

        yeah, but learning how to write device drivers for Minix is a pretty useless skill.

        What? As long as you learn the concepts you will do just fine. And Minix is a fine example of how to study the principles and concepts of operating system design. Once you understand the basics you can go ahead and get your feet dirty in Linux, Solaris, Mac OS, Windows, whatever you like.

    • by ozmanjusri ( 601766 ) <.moc.liamtoh. .ta. .bob_eissua.> on Monday August 13, 2007 @11:43AM (#20213473) Journal
      Personally I'd say Minix is much easier to navigate, simpler to understand and a much better starting point for new kernel developers

      Perhaps you should send a link to the kernel devs and suggest they emulate it...

    • It depends on wether you want to learn a real OS and write real drivers or a toy OS with toy drivers.
      • It depends on wether you want to learn a real OS and write real drivers or a toy OS with toy drivers.

        I once wrote a kind of menu system which mixed Basic and BAT shell scripts, running on DOS, of course. Which category would it belong to ?-)

  • Beg to differ (Score:3, Interesting)

    by Ancient_Hacker ( 751168 ) on Monday August 13, 2007 @11:41AM (#20213439)
    IMHO the networking stack is quite uninteresting. On the bottom, it's constrained by the networking protocols and network interfaces. On the top it's constrained by the Unix and socket interfaces. That doesnt leave a whole lot of room for innovative bits in the middle.
    • "On the top it's constrained by the Unix and socket interfaces. That doesnt leave a whole lot of room for innovative bits in the middle"

      What can't Unix sockets do exactly?

      Can you provide any examples of these 'innovative bits'?

      was: Re:Beg to differ
      • Re: (Score:3, Funny)

        by Anonymous Coward
        An innovative bit is like a 0.8 or a 2, when everyone else is just using 1 and 0 all the time.
      • >>"On the top it's constrained by the Unix and socket interfaces. That doesnt leave a whole lot of room for innovative bits in the middle" >What can't Unix sockets do exactly?

        "constrained" doesn't have to have a negative connotation-- I just meant it's a plain vanilla humdrum interface on both ends.

        >Can you provide any examples of these 'innovative bits'?

        That's the problem, I can't.

      • by mandolin ( 7248 )
        What can't Unix sockets do exactly?

        Zero-copy. ... well, in Linux anyway.

        Also, GP said "Unix and socket interfaces", not "unix sockets". The concepts are related but not equivalent.

    • by Slashcrap ( 869349 ) on Monday August 13, 2007 @12:10PM (#20213867)
      IMHO the networking stack is quite uninteresting. On the bottom, it's constrained by the networking protocols and network interfaces.

      Yes, the Linux network stack has always been constrained by the fact that it has to handle networking.

      I contributed a series of highly innovative patches that added 3D Graphics and AJAX support to the Linux TCP/IP stack. Were those kernel developers interested? Were they fuck.

      Just another reason why Linux will continue to lag behind Windows and OSX in the innovation stakes.
    • IMHO the networking stack is quite uninteresting. On the bottom, it's constrained by the networking protocols and network interfaces. On the top it's constrained by the Unix and socket interfaces. That doesnt leave a whole lot of room for innovative bits in the middle.

      Even if I accept your conclusion, which I don't, the lovely thing about open source is that you can add your own protocols and interfaces as you please. Obviously, only something really amazing has a chance to survive, but it was ever thus in the jungle.

  • The imbedded link is broken. Try here instead: http://www.ibm.com/developerworks/linux/library/l- linux-networking-stack/ [ibm.com]
  • by LordPhantom ( 763327 ) on Monday August 13, 2007 @12:57PM (#20214429)
    .... I became so excited I nearly had a buffer overflow!
  • Seems like both the TCP/IP bible and the TCP/IP packet layout is missing from this article, so here it is:
    1. the book: TCP/IP Illustrated, Volume 1 by W. Richard Stevens
    2.
    from netinet/ip.h /* Per RFC 791 */
    struct ip {
    uint8_t ip_hl:4, /* header length */
    ip_v:4; /* version */
    uint8_t ip_tos; /* type of service */
    uint16_t ip_
  • by Dareth ( 47614 ) on Monday August 13, 2007 @02:27PM (#20215533)
    ... or SCO might find some "new and improved" infringements on the Unix rights they don't own.

    SCO: How do we get our hands on the code for Linux?
    Lawyer: Pay me $$$ and I will get the courts to order it handed over.
    SCO: You are such a bargain!
  • 15 seconds back.

The 11 is for people with the pride of a 10 and the pocketbook of an 8. -- R.B. Greenberg [referring to PDPs?]

Working...