Beta
×

Welcome to the Slashdot Beta site -- learn more here. Use the link in the footer or click here to return to the Classic version of Slashdot.

Thank you!

Before you choose to head back to the Classic look of the site, we'd appreciate it if you share your thoughts on the Beta; your feedback is what drives our ongoing development.

Beta is different and we value you taking the time to try it out. Please take a look at the changes we've made in Beta and  learn more about it. Thanks for reading, and for making the site better!

The Linux Networking Stack Exposed

CmdrTaco posted about 7 years ago | from the august-rules dept.

Operating Systems 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."

cancel ×

69 comments

Sorry! There are no comments related to the filter you selected.

well (5, Funny)

Anonymous Coward | about 7 years ago | (#20213047)

I doubt we're going to see any +5 funny mods in this one

Re:well (-1, Offtopic)

Anonymous Coward | about 7 years ago | (#20213229)

Why does cartoon network have a mini-marathon of pokemon every week and shows the same season 1 episodes? They always show episodes about Ash in the pokemon league or trying to get badges or something. Every time I watch the marathon they show the same episodes. A few of them are different but most of them are the same. They don't even show episodes from the other seasons, just season 1. What's the point of showing the same episodes every week?

well-Stripping packets. (3, Funny)

Anonymous Coward | about 7 years ago | (#20213277)

"The Linux Networking Stack Exposed"

Well the nice thing is that geeks can get their porn at work without tipping anyone off.

Re:well (5, Funny)

JosefAssad (1138611) | about 7 years ago | (#20213311)

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 (5, Funny)

weicco (645927) | about 7 years ago | (#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.

Re:well (1)

owlstead (636356) | about 7 years ago | (#20214911)

Funnypidia?

Re:well (4, Informative)

kdemetter (965669) | about 7 years ago | (#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 .

Re:well (1)

Wolfger (96957) | about 7 years ago | (#20223085)

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.

Re:well (1)

weicco (645927) | about 7 years ago | (#20225997)

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

Re:well (1)

Wolfger (96957) | about 7 years ago | (#20226109)

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.

Re:well (1)

weicco (645927) | about 7 years ago | (#20226375)

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 (4, Funny)

riffzifnab (449869) | about 7 years ago | (#20213921)

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:well (2, Funny)

Almahtar (991773) | about 7 years ago | (#20221801)

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:well (2, Funny)

flydpnkrtn (114575) | about 7 years ago | (#20213927)

(Score:4, Funny)

Oh how ironic

Re:well (1)

Control Group (105494) | about 7 years ago | (#20214077)

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."

Re:well (0)

Anonymous Coward | about 7 years ago | (#20216217)

I thought Linux is open-source , the title of the article is a gimmick! IF somebody says Windows Vista Networking Stack Exposed i can read through !

Re:well (0)

Anonymous Coward | about 7 years ago | (#20218623)

Actually I was thinking that we don't want the network stack exposed. Teeceepions are a highly dangerous form of radiation, and exposure to the network stack can cause serious ilness. There's a reason we keep these thigns shielded most of the time.

Re:well (1)

htiawe (973440) | about 7 years ago | (#20218849)

Next up Bill Gates will explain Windows BSOD on a big screen projector.

Where's the NetBIOS? (2, Funny)

filesiteguy (695431) | about 7 years ago | (#20213049)

How come I don't see any references to NetBIOS in the stack?

Re:Where's the NetBIOS? (-1, Offtopic)

Anonymous Coward | about 7 years ago | (#20213105)

Because you were looking at the Linux Kernel and not the Samba projcet code base.

Re:Where's the NetBIOS? (1, Informative)

utopianfiat (774016) | about 7 years ago | (#20213293)

*woosh*

Banyan Vines! (1)

Chas (5144) | about 7 years ago | (#20213341)

Stop playing with that new-fangled NetBIOS stuff!

Wait till a stable version comes out!

Oh wait...nevermind...

WHOOSH!!! ... (er, WTF, someone else???) (1, Interesting)

Anonymous Coward | about 7 years ago | (#20213683)

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.

Re:Where's the NetBIOS? (1)

mhearne (601124) | about 7 years ago | (#20314875)

Because the article was about the Linux networking stack, and NetBIOS doesn't exist there. That is handled by SMB/NMB.

Expose it, babe! (2, Funny)

Anonymous Coward | about 7 years ago | (#20213069)

Re:Expose it, babe! (-1, Offtopic)

Anonymous Coward | about 7 years ago | (#20213095)

Ohhh Hekma. I can't believe I sucked your jagon!!!

Re:Expose it, babe! (1)

mattmatt (855592) | about 7 years ago | (#20218393)

No no no, you're modding it all wrong. That would be +2 (maybe 3) funny.

Free as in speech? (1)

everphilski (877346) | about 7 years ago | (#20214193)

or free as in beer?

Inquiring minds would like to know ...

Re:Free as in speech? (1)

Torvaun (1040898) | about 7 years ago | (#20220507)

I keep hearing about this 'free beer' on /., but when I ask my local bartenders, they just say it's the reason I don't get to run up a tab.

OOOOhhh (-1, Flamebait)

Creepy Crawler (680178) | about 7 years ago | (#20213145)

Raunchy! Nasty! A Linux Babe for each one of you!!

No Ports Barred!

Re:OOOOhhh (4, Funny)

A beautiful mind (821714) | about 7 years ago | (#20213255)

My server is like a beautiful exotic woman. She ignores the obvious attempts to get close to her, but if you know the right ports, she opens up. Of course, she encourages security and doesn't allow unprotected remote ehm...administration.

Re:OOOOhhh (1)

CodeShark (17400) | about 7 years ago | (#20213411)

*ahem* I believe it is also important for her to resist unwanted intrusions and definitely no takedowns and active penetrations....

Sorry, couldn't resist.

Re:OOOOhhh (1)

somersault (912633) | about 7 years ago | (#20213567)

She won't even look at your software unless you can guarantee 99.999% uptime..

Re:OOOOhhh (0)

Anonymous Coward | about 7 years ago | (#20213729)

Software? Puh-lease!!! She's supposed to have the software. I got the hard-ware.

Re:OOOOhhh (1)

somersault (912633) | about 7 years ago | (#20216511)

It is true that in some situations, it can be better to convert critical software elements over to hardware for a better experience. They tried that with Java though, and it didn't seem to work.. wait, are you talking about something else?

Re:OOOOhhh (2, Funny)

PPH (736903) | about 7 years ago | (#20213459)

Unfortunately, she's only virtual.

Re:OOOOhhh (1)

Tribbin (565963) | about 7 years ago | (#20214681)

How does she handle brute force attacks?

Re:OOOOhhh (1)

CoolVibe (11466) | about 7 years ago | (#20215025)

Ooh, nice network stack. Wanna fsck? *ducks away for making such a lame joke*

Re:OOOOhhh (1)

Agripa (139780) | about 7 years ago | (#20220135)

Nice servers don't go down.

Re:OOOOhhh (1)

mollymoo (202721) | about 7 years ago | (#20232365)

My server is like a beautiful exotic woman. She ignores the obvious attempts to get close to her, but if you know the right ports, she opens up. Of course, she encourages security and doesn't allow unprotected remote ehm...administration.

Two questions, in no particular order:

Does she run Linux? And how big are her tits?

Re:OOOOhhh (0)

Anonymous Coward | about 7 years ago | (#20213359)

Oh, now I finally understand the OSI network model! You must first strip the surrounding layers, only then you can transfer the data packets! Civilized people take the layers on again after the data transfer. Hmm, the standard is very dry. They could have included the vivid analogies themselved. Now, if you excuse me, I shall return to my networking homework again (with a loopback).

What about Minix? (5, Interesting)

drspliff (652992) | about 7 years ago | (#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:What about Minix? (3, Insightful)

feld (980784) | about 7 years ago | (#20213453)

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:What about Minix? (3, Insightful)

assantisz (881107) | about 7 years ago | (#20214283)

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.

Re:What about Minix? (0)

Anonymous Coward | about 7 years ago | (#20214697)

With the possible exception of the NT kernel or exotic kernels, writing a driver is pretty much the same where ever you are. Sure, the functions and some of the mechanisms may be a little different, but 99% of the flow will be identical and the code that bangs the hardware will be the same as well.

Re:What about Minix? (4, Funny)

ozmanjusri (601766) | about 7 years ago | (#20213473)

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...

Re:What about Minix? (-1, Troll)

Anonymous Coward | about 7 years ago | (#20214049)

Linux would probably be in better shape if Linus had studied Minix before starting his own pet OS

Re:What about Minix? (2, Funny)

CoolVibe (11466) | about 7 years ago | (#20215055)

Hey AST, what's up? How's the wife and kids?

Re:What about Minix? (1)

Halvy (748070) | about 7 years ago | (#20215437)


Well put since Linus used Minux and not Unix as a starting reference.


Since I am a green horn at writing drivers, I would not start with Networking... since they seemed pretty covered-- for now.

However if they were USB or other dongle related, then this is where the need seems to be more now (with Linux).

Also, the article/thread seems to head in the very same direction that many other 'beginer' or 'how to's' are... which is.. either the writer asumes an awfule lot on what the reader knows already.. or it cover things the average programmer already knew since he fell out of his crib.

http://www.linuxjournal.com/article/4786 [linuxjournal.com] is an attempt at helping those interested in working with developing USB drivers and it's associated aspects.

And here http://www.us.design-reuse.com/news/news8597.html [design-reuse.com] is interesting tech that helps simplify the device driving process from the start, by helping programmers develop the hardware, automatically after putting in merely the algorithms.

Although this process is not directly related, the point is we have to get away from re-inventing the wheel, by using more automatic code-writing, and into the realm of letting the computer do what it does best (repetition & long calcs).. and let developers do what they do and love best... *designing*.

It's amazing that this thread, which could have been the driest all week, turned out to be the one more interesting & funniest =:]

---NO!! I am NOT trying to be a 'good boy'.. It's just that sometimes I can't help myself :)

Re:What about Minix? (1)

diegocgteleline.es (653730) | about 7 years ago | (#20215683)

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

Re:What about Minix? (1)

ultranova (717540) | about 7 years ago | (#20223991)

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 (2, Interesting)

Ancient_Hacker (751168) | about 7 years ago | (#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.

Unix sockets .. (1)

rs232 (849320) | about 7 years ago | (#20213741)

"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:Unix sockets .. (3, Funny)

Anonymous Coward | about 7 years ago | (#20215873)

An innovative bit is like a 0.8 or a 2, when everyone else is just using 1 and 0 all the time.

Re:Unix sockets .. (1)

Ancient_Hacker (751168) | about 7 years ago | (#20216499)

>>"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.

Re:Unix sockets .. (1)

mandolin (7248) | about 7 years ago | (#20218263)

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.

Re:Beg to differ (5, Funny)

Slashcrap (869349) | about 7 years ago | (#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.

Re:Beg to differ (1)

kylemonger (686302) | about 7 years ago | (#20255687)

I wish +6 Funny bug were still around because this joke deserves it.

Re:Beg to differ (0)

Anonymous Coward | about 7 years ago | (#20214485)

I find it interesting that everybody knows you need to support TCP, and IP, and HTTP, and ethernet, and so on, and there's really only one way to put these together. (HTTP really needs to be separately implemented than TCP, and above it, for things to work right, or else you'd be bogged down in special cases and untestable code forever. If you tried to make one super-driver that did both, it would obviously suck.)

And yet other things that seem equally obvious to me -- the GUI should live on top of the OS, for example -- are routinely violated, and nobody seems to care.

No, I'm not talking about Windows (about which I know little). In Linux, your X server has both support for the X11 networking protocol, and also hardware drivers for your graphics card, for example.

Re:Beg to differ (1)

Daniel Phillips (238627) | about 7 years ago | (#20219445)

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.

Warriors of the Net. (0)

Anonymous Coward | about 7 years ago | (#20214269)

Here's a work safe video [warriorsofthe.net] that relates to the main story. Enjoy!

When I saw this headline.... (4, Funny)

LordPhantom (763327) | about 7 years ago | (#20214429)

.... I became so excited I nearly had a buffer overflow!

Re:When I saw this headline.... (1)

zukinux (1094199) | about 7 years ago | (#20217095)

actually you ment, stack overflow...

Re:When I saw this headline.... (1)

ragefan (267937) | about 7 years ago | (#20217381)

actually you ment, stack overflow...
I'm hoping its more like a queue than a stack!

Need som real info? (1)

viking80 (697716) | about 7 years ago | (#20214769)

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_len; /* total length */
        uint16_t ip_id; /* identification */
        uint16_t ip_off; /* fragment offset field */
        uint8_t ip_ttl; /* time to live */
        uint8_t ip_p; /* protocol */
        uint16_t ip_sum; /* checksum */
        struct in_addr ip_src,ip_dst; /* source and dest address */
};

from netinet/tcp.h: /* Per RFC 793 */
struct tcphdr {
        uint16_t th_sport; /* source port */
        uint16_t th_dport; /* destination port */
        tcp_seq th_seq; /* sequence number */
        tcp_seq th_ack; /* acknowledgement number */
        uint8_t th_x2:4, /* (unused) */
                        th_off:4; /* data offset */
        uint8_t th_flags;
        uint16_t th_win; /* window */
        uint16_t th_sum; /* checksum */
        uint16_t th_urp; /* urgent pointer */
};

Better unexpose the stack code.... (2, Funny)

Dareth (47614) | about 7 years ago | (#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!

I want those (1)

widman (1107617) | about 7 years ago | (#20218475)

15 seconds back.
Check for New Comments
Slashdot Login

Need an Account?

Forgot your password?

Submission Text Formatting Tips

We support a small subset of HTML, namely these tags:

  • b
  • i
  • p
  • br
  • a
  • ol
  • ul
  • li
  • dl
  • dt
  • dd
  • em
  • strong
  • tt
  • blockquote
  • div
  • quote
  • ecode

"ecode" can be used for code snippets, for example:

<ecode>    while(1) { do_something(); } </ecode>