Slashdot Mirror


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

24 of 81 comments (clear)

  1. Article mod: -1 Overrated by Looce · · Score: 5, Insightful

    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.

    1. Re:Article mod: -1 Overrated by something_wicked_thi · · Score: 4, Insightful

      Yeah, I've got a program for the author that fits in a tweet:

      #include
      int main() {
          puts("You're a moron and a braggart.");
      }

    2. Re:Article mod: -1 Overrated by BitZtream · · Score: 2, Insightful

      . This is just a program that echoes every single thing back to the originator.

      using the IP stack that already exists on the OS.

      Responding to IP requests using someone elses IP stack does not mean you actually created your own stack.

      --
      Persistent Volume manager for Kubernetes - https://github.com/dwimsey/openshift-pvmanager
    3. Re:Article mod: -1 Overrated by Anonymous Coward · · Score: 2, Insightful

      Apparently, slashdot could use a -1, Don't be a dick moderation.

      Just give the story a - and move on.

  2. Relevance check please by flowerp · · Score: 4, Insightful

    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.
  3. At least 3 ways to make it smaller: by QuantumG · · Score: 2, Insightful

    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.
    1. Re:At least 3 ways to make it smaller: by Mozk · · Score: 4, Funny

      Yeah, but for(;;) loops forever, whereas while(1) only loops while 1 is true. It's completely different! What if 1 becomes false?!

      --
      No existe.
  4. Re:Novel, but pointless by parallel_prankster · · Score: 3, Insightful

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

  5. not very complicated ... and that's the good part by Gopal.V · · Score: 2, Interesting

    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 ;)

  6. Addendum by Looce · · Score: 4, Interesting

    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.

    1. Re:Addendum by cyberstealth1024 · · Score: 4, Informative

      where are you seeing these "rating colors"?

      i didn't know either, so i looked it up -- it's the /. firehose quality filter. When you're logged in, you can see the popularity color on the left side of the summary heading. You can also increase/decrease this rating. See screen cap. Also, when browsing the front page of /., you can filter based on the color...see top-right of screenshot. The rating colors are ROYGBIV + Black. Red is the highest (most popular), black is the lowest. submitted articles initially have the color rating of blue.

      I had seen the color filtering before on the front page, but never looked into enough to find out. I learned something new. Hope you did too!

  7. Re:Pretty Cool by Plug · · Score: 3, Interesting

    Sounds kind-of like this.

  8. I hope this isn't a new trend. by jellomizer · · Score: 3, Insightful

    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.
    1. Re:I hope this isn't a new trend. by pathological+liar · · Score: 4, Insightful

      If you converted Apache into a web browser that might actually be worthy of a story...

    2. Re:I hope this isn't a new trend. by maharius · · Score: 2, Funny

      It is like me saying I can make a Web Browser using a shell script with 2 lines.
      #!/bin/bash
      apachectl start

      If that's what you're using as a web browser, you're doing it wrong.

    3. Re:I hope this isn't a new trend. by loconet · · Score: 2, Informative

      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.

      Oh it is.

      --
      [alk]
  9. Very cool by bjourne · · Score: 3, Insightful

    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.

  10. It's not an IP stack by k2dbk · · Score: 4, Insightful

    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.

  11. similarly big accomplishment by AlgorithMan · · Score: 4, Funny
    hey, I wrote a webbrowser in 8 bytes of BATCH: here's the source code:

    IEXPLORE

    impressive, huh?

    --
    The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
    1. Re:similarly big accomplishment by AlgorithMan · · Score: 2, Funny
      oh and don't forget my downloading prog in BASH:

      wget $@

      man, I'm so f*cking 1337!

      --
      The MAFIAA is a bunch of mindless jerks who will be the first up against the wall when the revolution comes
  12. Re:A message to C haters by Idiomatick · · Score: 3, Insightful

    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.

  13. Re:Pretty Cool by buchner.johannes · · Score: 2, Informative

    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.
  14. Cool yet small... by Spatial · · Score: 2, Informative

    ...is big in the demoscene.

    Check out this 4KB realtime demo called 'Receptor'. (Download / Video)

  15. Re:A message to C haters by FlyingBishop · · Score: 2, Insightful

    Please. Emacs can crash a Mac and create an IP stack in one command.