February 22nd, 2007

  • evan

opening ports via an airport

I wanted to temporarily open a port on my NAT to my local machine. I had heard of UPnP, which is supposedly some industry standard -- maybe there's a library available?

But after a bit more looking I saw that Apple invented their own protocol, called NAT-PMP, and the Airports only support that. This is normally pretty annoying, but UPnP is widely reported as bloated (protocol docs mention SOAP among others), and Apple's protocol is hella simple -- send a 12-byte UDP packet to the NAT box and it opens up the port.

So here's a trivial Ruby library for NAT-PMP. I haven't implemented the backoff requirements of the protocol (since UDP is unreliable, they ask you to retry with exponentially increasing timeouts), but it gets the job done. (The Avahi people are already working on integrating support for NAT-PMP, and they'll probably do it all Right.) There's some example code at the bottom of the module.

PS: If you try this and get a "not authorized" error, you have to turn on NAT-PMP in your Airport config. Go to the first page of the settings in the Airport Admin tool and click the "Base Station Config..." button.
  • evan

bittorrent confusion

I find when bittorrenting that my download speed will eventually trend towards zero, while my upload speed remains constant. Like right now according to the status I'm getting 600 bytes/sec down and 30.3 kb/sec up. This makes my download never finish and my share ratio trend to very large.

I thought bittorrent was supposed to figure out how to require people to send me data when I send them data. Is that not the case? Or is there some sort of configuration bit I need to flip? I'm using the standard Python client (btdownloadcurses). I looked at Azureus but Java is total crap on Linux.
  • evan

rtorrent is nice

(Adding on that last post:)
I tried Azureus again. It not only continued to be craptastic (way slower than even the Python client to hash files, random crashes, menus that were visibly laggy to display, all of the UI visually overlapping itself -- maybe it has bad packaging on Ubuntu?), it also exhibited the same mysterious behavior I had before.

cbradfield suggested rtorrent. It has a seriously gratuitously complicated interface (which is sorta amusing because this is even in comparison to Azureus, which is itself a trainwreck of "let's put in a option to twiddle that") but it isn't nasty Java and after a bit of poking it did exactly the right thing. I endorse this software. (But grab the version from their SVN, because they changed the UI around a bit in a way that's easier to use.)

jwz's diagnosis was right: though there were reportedly over a thousand seeders, nobody in the network had about one third of the chunks while everyone had the other two thirds. rtorrent has a nice overview screen (that picture is pretty representative of the program -- serious information density that you can't really parse without looking at the manual) that made it immediately clear; I'm sure Azureus must have a similar display that could've indicated this to me but in my confused clicking around I didn't find it.