Hacker News new | past | comments | ask | show | jobs | submit login
Tiny IP stack, small enough to fit in a "tweet" (sics.se)
46 points by r11t on Sept 23, 2010 | hide | past | favorite | 16 comments



If it receives anything but ICMP packets, it breaks miserably. This should have just been called a tiny ping responder program. (And it can't deal with any problems or normal network issues at all even to do that.) It has no relation to an IP stack other than it reading network data raw.


This is a toy stack, the author notes that several times. No claims were made for completeness.


It is not a toy stack, because it is not a stack. Toy or otherwise.

This does not merely lack completeness. This is an entirely different project that has nothing to do with making an IP stack. It does not even do the first thing an IP stack might do.

I do not get to claim my side project making a compact sandwich is a restaurant either. The author is making sandwiches and should be proud of that because a good sandwich is a great thing, the author should not be telling us he has built a restaurant.


Ok, so it is very far away from a real IP stack, but it can do the first task of an IP stack: respond to pings.

Quit being a douche. The author even bolds it just in case you read the article.


Not only is it nonfunctional, it's also at least 8 bytes longer than it really needs to be:

short s[70];*l=s;t;main(){for(;;){read(0,s,140);if((s[4]>>8)==1&s[10]==8)s[10]=0,s[11]+=8,t=l[4],l[4]=l[3],l[3]=t,write(1,s,140);}}

I feel so dirty now.


2 less:

  short s[70];*l=s+6;t;main(){for(;;){read(0,s,140);if((s[4]>>8)==1&s[10]==8)s[10]=0,s[11]+=8,t=*l,*l=l[1],l[1]=t,write(1,s,140);}}
And 3 less (if I didn't make a mistake with precedence...):

  short s[70];*l=s+6;t;main(){for(;;){read(0,s,140);s[4]>>8==1&s[10]==8?s[10]=0,s[11]+=8,t=*l,*l=l[1],l[1]=t,write(1,s,140):0;}}
1 less for t in main declaration:

  short s[70];*l=s+6;main(t){for(;;){read(0,s,140);s[4]>>8==1&s[10]==8?s[10]=0,s[11]+=8,t=*l,*l=l[1],l[1]=t,write(1,s,140):0;}}
3 less since blocking read returns > 0 (also no reason for braces now)

  short s[70];*l=s+6;main(t){for(;read(0,s,140);)s[4]>>8==1&s[10]==8?s[10]=0,s[11]+=8,t=*l,*l=l[1],l[1]=t,write(1,s,140):0;}


5 less:

  short s[70];*l=s;t;main(){read(0,s,140);s[4]>>8==1&s[10]==8?s[10]=0,s[11]+=8,t=l[4],l[4]=l[3],l[3]=t,write(1,s,140):0;main();}
8 less now, thanks to viraptor:

  short s[70];*l=s+6;main(t){read(0,s,140);s[4]>>8==1&s[10]==8?s[10]=0,s[11]+=8,t=*l,*l=l[1],l[1]=t,write(1,s,140):0;main();}


That will grow the stack until it crashes though it seems.


Unless your compiler is smart enough to optimize the tail-call into a jump...


... which gcc is if you compile with -O2.


While the tweeted 'stack' only responds to pings the other work by sics in general and Adam Dunkels in particular is very interesting. I've ran their Contiki OS and uip stack on a atmega8 microcontroller that had 8 kB of Flash and 1 kB of SRAM. If you are into tiny or embedded operating systems and network stacks I highly recommend taking a look at Contiki.


It's not really an IP stack. But it does ping. So a more accurate name would be: Twing


An IP stack has to expose basic IP functionality, not just responding to pings. Can it, for e.g., do IP forwarding? (that would be an awesome full fledged router) IP checksums?

Also, this program is vulnerable to the classic Ping of Death attack. ;)

http://en.wikipedia.org/wiki/Ping_of_death


Most of the responses here are perfect indications of why technical people have problems communicating with the rest of the world.


Ironically, you were a bit too terse for me to understand your point. Would you care to elaborate please?


I love all the condescending know-it-all replies here when the author says in the second sentence:

Ok, so it is very far away from a real IP stack,

It's sad how often posters here miss the point and jump to semantics as if it matters at all.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: