TwIP - An IP Stack In a Tweet
Adam Dunkels writes "Inspired by the Twitter-sized program that crashes Mac OS X, I just wrote a really, really rudimentary IP stack called twIP, small enough to fit in a Twitter tweet. Although
twIP is very far away from a real IP stack,
it can do the first task of any IP stack: respond to
pings. The entire source code can be found in this 128-character-long tweet. For those who are interested in low-level network programming, a code walkthrough with instructions on how to run the code under FreeBSD is available here. The FAQ: Q: why? A: for fun."
The underlying system must provide a way for user programs to receive and send IP packets.
This is where I stopped reading. Just... no. This is just a program that echoes every single thing back to the originator.
Shit doesn't smell like roses when it is made to fits into a tweet or is in any other way related to Twitter.
--- Eat my sig.
I knew I picked the right man when I cited this guy's PhD thesis in my dissertation. Folk who write things like this know their shit, and are probably safe citations, despite the use of Twitter.
I'd have thought that someone that spent his time studying and implementing minimal-waste embedded network stacks and coming up with something like Contiki would be annoyed by the huge waste of bytes that is Twitter.
... in low level system programming, I recommend reading a good book, like this, and not spending any more time reading this.
Seriously.
Here comes the lameness filter:
unsigned short s[70];*l=s+6;t;main(){for(;;){read(0,s,140);s[10]&=65280;s[11]+=8;t=l[1];l[1]=*l;*l=t;write(1,s,140);}}
And with those 9 chars perhaps you could make it better.
How we know is more important than what we know.
He is talking about the IP Stack, not the computer science stack structure. Calling it an IP stack is an over-exaggeration. This is a cleverly written (no doubt) program using ICMP knowledge to ping back a response packet. Please dont call that a stack!!
I tried this particular piece of code out and it works! Of course, the ping buffer and the IP swap is just so obviously simple ... WOW!
The "everything is a file" unix philosophy really does kick in and pull its weight in this example. Sockets, network devices, hardware block devices ... You can write an app to do pretty much anything with any of these, with just file streams. Oh, yeah ... dd'ing entire flash drives, netcating sockets, rsync'ing root partitions over. I often am completely amazed by the complexity that simple pieces can produce.
Now everyone - stop talking bad about twitter ... it's awesome, it's simple and it's given random people the idea that I'm interesting & intelligent ;)
Quidquid latine dictum sit, altum videtur
Haha! This article is rated purple (2 levels above the lowest -- black) already. Wow.
Anyhow. The fact that the TwIP program requires an IP stack to work is the prime indication that it doesn't really do all that much. Since it can work with raw socket access, and switches the addresses around, well, props, but TFA's "header" code comment says this:
updating the ICMP checksum
which is then contradicted by the code comment before the address swap:
Since we only swap bytes in the IP header, we do not need to update the IP header checksum.
using ICMP and IP interchangeably..?
timothy, take this down. Now. It's your only chance to save face with this article.
Sounds kind-of like this.
I hope this isn't a new trend of 7337 |-|@(|0%$ to try to brag of their mad skill by seeing what code can fit in a Tweet.
The less the code doesn't mean better performance.
The less code can mean less functionality and error checking.
The less code does mean less documentation
The less code could mean harder readability.
We need less people taking their time and effort making unreadable small code and more effort in making good and useful applications and libraries. Granted such exercises may be useful to allow you to think of problems differently but you can get the same effect by changing languages say from C to LISP. Also these examples seem to take in include headers which accounts for thousands of lines of code, which are often limited to either the OS or even just the Programming language.
It is like me saying I can make a Web Browser using a shell script with 2 lines.
#!/bin/bash
apachectl start
If something is so important that you feel the need to post it on the internet... It probably isn't that important.
Very cool program! Taught me some things about IP. The program could be made one byte shorter by using for(;;) instead of while(1) and it is not strictly necessary to use "unsigned short" instead of "short" afaict. I wonder what other interesting programs that can be written in only 140 bytes.
Football Odds
Is this a implementation of RFC5514? I know that it needs to be IPoSN ( IPv6 over Social Networks) and is probably not, but I wonder how hard it would be to have this do IPv6.
Or is it enough, to boot a normal JavaScript based virtual machine on a normal browser, to use this?
Any sufficiently advanced intelligence is indistinguishable from stupidity.
Yes, I can do the same thing with Mono on OSX in less bytes.
I prefer C myself, but don't act like this is somehow special, its just a matter of having a set of supporting libraries that happen to make this particular task require very little visible code.
And you, like the 'author' are ignoring all the code that goes into the libraries to make this happen, namely the fact that its riding on top an existing IP stack, not actually creating its own.
If you are using the BSD sockets API to 'create your own IP stack', then you aren't actually creating your own stack.
You could do both the exploit posted and this crap in less bytes of perl, python, or ruby I'm sure, as long as you ignore all the other supporting libraries and code like he did and you are too.
Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
that program just echoes stdin to stdout (maybe some char manipulations) and YOU have to connect this crap to some prog, which provides the network abilities (netcat might be suitable, i guess)
The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
It's not an IP stack at all (and requires one to function). It replies to a packet that is assumed to be a ping without any error checking. In other words, it's a very short, clever, but minimally functional ping function. The fact that it's short is nice, but that's about it.
impressive, huh?
The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
I wrote my own compiler/language just now. What it does is it disregards your entire source code and then outputs that mac crashing bug. I fail to see your point...
I'm a c/c++ fan but just because you can do something in less lines doesn't mean it is better. Maybe if you said that in your language the mac crash ap compiles to 80bytes and requires only 10 operations then i'd be impressed. Buuuut in that case then asm is the greatest language ever.
I don't hate C because it has limitations or speed issues, I hate C because of pointers and no garbage collection.
C code should be reserved to a limited few because most applications written in it are plagued with bugs and vulnerabilities.
My hair stopped falling out after switching to a newer technology. Maybe I am not a pure-bred developer, but who cares, my life is better!
Well, straight from the IO::All man page but still. It supports CGI! (easily ownable of course)
I don't think anyone is talking about "the computer science stack structure".
4096R/EF7BAFA6 79E1 DF98 D09D 898F 9A11 F6F0 DDDC 23FA EF7B AFA6
Awesome, I love the difference between the first two approaches!
If you're not sure whether to click the link: It is a competition to compress images into 140 chars.
NB: The message above might reflect my opinion right now, but not necessarily tomorrow or next year.
...is big in the demoscene.
Check out this 4KB realtime demo called 'Receptor'. (Download / Video)
Best tools for the job work best. There are situations when you don't want the overhead of a garbage collector and you want to keep track of all your allocations. Embedded programming comes to mind here as well as other low level uses. Sure you may not want to use it for high level stuff but C/C++ can be used for that. I am a java developer by trade myself and I know all the shit Java gets on this site but it works best for what I do. Oh and yes I agree the higher level languages that "hide" all the pointer stuff and does the allocation for you does take away a lot of headaches usually at the tradeoff of a performance hit. If that performance hit is negligible, roll with it.
Turn based strategy game that runs over XMPP. Phalanx
Please. Emacs can crash a Mac and create an IP stack in one command.
Except for the part where the "stack" requires an underlying sockets implementation.
Mine looks like: http://img340.imageshack.us/img340/8872/slashdot.png
Which is damn annoying since my browser window is already set to use half the screen horizontally (the other half is two xterms one above the other) so it's already not very wide...
Oh, TCP/IP is actually pretty easy. You don't need to handle the entire payload of an ethernet frames (1500 bytes). Just set the MTU to something tiny and let the TCP stack segment it for you. I was thinking pretty much the same thought as you. I hereby dub the concept IPoT (IP over Twitter). The minimum MTU allowed for TCP/IP is 88 bytes. Assuming you have to encode them in something 7-bit-clean (say base64), this means that you would need 118 bytes. 160 is a piece of cake. You'd get an MTU of 120 bytes, which while absurdly small, is a perfectly legal MTU.
I could probably write a daemon that uses tuntap and hack together something in under a day. :-D Hmm. I just got an evil idea. Do you suppose that violates the terms of service?
Check out my sci-fi/humor trilogy at PatriotsBooks.
comment.c:1: error: âover-exaggerationâ(TM) undeclared (first use in this function)
Win a signed Stephen Carpenter ESP Guitar from the Deftones: http://def-tag.com/?r=0008781
I admire you for this -- not a NOOP sled, not a trojan, not a game, you built a freaking IP stack in 128 chars. I officially declare you my hero, at least until lunch.
I propose TwERP -- an Enterprise Resource Planning app coded in a tweet.
'He who has to break a thing to find out what it is, has left the path of wisdom.' -- Gandalf to Saruman
"Unix is simple. It just takes a genius to understand its simplicity." â" Dennis Ritchie