Earlier quoted context omitted.
You guys are just to smart for me, I guess I'll have to withdraw from having any conversation at all since I've been downvoted into hellban for asking a question.
Here's some very personal advice. This is my opinion, and others won't agree. However, for what it's worth ... I would suggest that you would benefit from learning how to ask questions. Here's a start: http://www.catb.org/~esr/faqs/smart-questions.html However, there's more advice than that, and that, although a good start, is not to be taken as gospel. You probably also should read the site-specific commentary, and…
TCP in 30 instructions (1993)
21–30 of 41 posts
Re: TCP in 30 instructions (1993)
#22I love the opinionated writing style. I wish I knew more about this so I could relate to the comments about the "compiler braindamage", "mbuf chain stupidity", and "netipl software interrupt bs".
These instructions here are loading the header into registers:
ld [%i0+4],%l3 ! load packet tcp header fields
ld [%i0+8],%l4
ld [%i0+12],%l2
ld [%i0+16],%l0
That's the assembler for this: u_long seq = ((u_long*)ti)[1];
u_long ack = ((u_long*)ti)[2];
u_long flg = ((u_long*)ti)[3];
u_long sum = ((u_long*)ti)[4];
ld loads 4 bytes at a time into a register but there is a sparc instruction ldd that will load 8 bytes into two registers at a time. If the compiler used ldd these four instructions turn into two. That gets us from 33 to 31. I'm not 100% clear which two fields from the pcb can be loaded simultaneously but there is this line ld [%i1+72],%o0 ! compute header checksum
and then further down ld [%i1+68],%o0
which I think are: u_long cksum = tp->ph_sum;
and if ((flg & FMASK) == tp->pred_flags && seq == tp->rcv_nxt) {
Obviously that line is multiple instructions but what I meant is the part where tp->rcv_nxt is loaded into a register.So probably tp->ph_sum and tp->rcv_nxt are adjacent in his version of struct tcpcb and he thinks the compiler should do use the same parallel load instruction (loading two registers from 8 bytes at once) for those fields.
Re: TCP in 30 instructions (1993)
#23Earlier quoted context omitted.
Wouldn't "all the TCP logic" be the entire internet?
The internet is a very large and general term. It comprises millions of servers, routers, generally includes things like web browsers, http, etc. TCP is just one protocol of the thousands of protocols used for the internet, typically to carry other protocols. UDP is also used on the internet. "not all the logic" means that this implementation is not a full implementation of the TCP protocol. Check out: http://en.wiki…
Re: TCP in 30 instructions (1993)
#24Re: TCP in 30 instructions (1993)
#25Might be off topic, but I have always wondered where do these public domain university emails come from? Was E-mail a public forum back then?
Re: TCP in 30 instructions (1993)
#26I am curious to know if today's modern TCP stacks (windows, popular linux distros,etc..) are coded with the same approach. Does anyone know?
In the original TCP implementations from the early 80s, performance was (understandably) not the main priority.. they just wanted to get it working first. Also, nobody was sure what networking protocols would become popular (IP? OSI? XNS?) so a lot of work went into making everything as flexible as possible. This reached an apogee with AT&T's "STREAMS" subsystem (a competitor to the sockets API for writing networking code on UNIX) which was very flexible but also extremely complicated.
What Van Jacobson's work was saying is "look guys: by paying close attention to the fastpath you can saturate your 10Mbps network with TCP traffic" I'm sure everybody who has written a TCP stack has seen this email and has taken the tricks to heart.
These days not all of the tweaks might be still relevant. For instance, the hardware is probably doing the hardware checksum for you. However, the spirit of "do as little as possible in the fastpath" is certainly still followed in modern stacks.
Re: TCP in 30 instructions (1993)
#27I am curious to know if today's modern TCP stacks (windows, popular linux distros,etc..) are coded with the same approach. Does anyone know?
More or less, yes. In the original TCP implementations from the early 80s, performance was (understandably) not the main priority.. they just wanted to get it working first. Also, nobody was sure what networking protocols would become popular (IP? OSI? XNS?) so a lot of work went into making everything as flexible as possible. This reached an apogee with AT&T's "STREAMS" subsystem (a competitor to the sockets API for…
Re: TCP in 30 instructions (1993)
#28Earlier quoted context omitted.
No, it would not be anything close.
Well, TCP is a very simple protocol so I can't imagine what the OP means by "all of TCP" unless he's talking about IP and it's associated services.
I don't think I could implement it in under 4000 sloc, and I'd guess it'd be over two months worth of work for just a minimal TCP stack that could interoperate with the internet at large.
Re: TCP in 30 instructions (1993)
#29Might be off topic, but I have always wondered where do these public domain university emails come from? Was E-mail a public forum back then?
Re: TCP in 30 instructions (1993)
#30Earlier quoted context omitted.
Well, TCP is a very simple protocol so I can't imagine what the OP means by "all of TCP" unless he's talking about IP and it's associated services.
TCP is actually extremely complex, see http://en.m.wikipedia.org/wiki/Transmission_Control_Protocol I don't think I could implement it in under 4000 sloc, and I'd guess it'd be over two months worth of work for just a minimal TCP stack that could interoperate with the internet at large.