Thursday, September 27, 2007

BitTorrent Content for Apple TV, Pt. 2

OK, as promised in BitTorrent Content for Apple TV, Pt. 1, here's a discussion of one of the things you need to do to maximize your success with a BitTorrent client like Azureus or Transmission.

BitTorrent is a file-sharing protocol that makes it easy to download huge files (or folders full of them). Video files such as movies ripped from DVD qualify as huge. If you want to download movie files to play (usually after a format conversion) on Apple TV, you need to use BitTorrent.

So let's say you've installed Azureus and used a BitTorrent search engine such as TorrentScan to locate and download the small torrent files associated with the online movies you covet. You've opened these downloaded torrent files in Azureus, and downloading of the actual target files has begun ... but at a snail's pace. Is there anything you can do to speed it up?

Well, maybe there is. One of the big reasons why downloads go too slow is that the BitTorrent client hasn't been given an open port.
If your setup is anything like mine, your computer (or computers, plural) is "behind a router." That phrase simply means that on your home network there is a piece of gear between your computer and the cable modem or DSL modem that affords it access to the Internet. The computer "talks to" that piece of gear, called a router, the router talks to the modem, and the modem talks to the Internet.

In my own case, the "router" is actually one of Apple's Airport Extreme Base Stations, a wireless (or Wi-Fi) "access point." Your access point may be a "real" router from Belkin or Linksys or any of the other companies that make them. And you may not be using wireless technology at all. Instead, each computer may connect to the router via Ethernet cable. No matter. You're still behind a router, and you probably need to "forward" a network "port" from the router to the computer you'll be using to run the BitTorrent client.

Azureus has a so-called NAT/Server Port Test which can tell you whether a certain network port is open:

Here, I've tested port 22222, a number which I chose at random. I'll talk more in a while about how to select a port number. In my test in Azureus, port 22222 was "OK," meaning it was open and being properly port-forwarded from my router to my computer. Since it was in fact open, I clicked the Apply button to make it Azureus' official "listen port," as then revealed in the Azureus Preferences/Options pane, under Connection:

I had to set up the port forwarding myself, before running that test in Azureus. It was the first tricky part of these proceedings.

The first thing you need to do to port forward to Azureus what is to become its official listen port is give your computer a manually assigned, static IP address. If you have a Mac such as mine, open the Network panel in System Preferences, show AirPort (if that's how you connect to your access point/router, otherwise show Built-in Ethernet), and select the TCP/IP tab:

Right now, chances are you're setting Configure IPv4: to "Using DHCP." It needs to be changed to "Manually." Then, fill in the text boxes as I have done. You can change the "202" in the IP address field to any number from 201 to 255, as long as no other computer on your home network uses that number.

You also have to replace the DNS server addresses I'm using with the one(s) your Internet service provider provides. This is one of the tricky but essential steps. If you have an Apple base station, open it for manual setup in AirPort Utility. Go to the Internet Connection page:

The DNS server IP address(es) assigned to your Internet connection by your ISP appear in gray, meaning that you needn't enter them yourself in this AirPort Utility panel. Instead, the ISP (in my case, Comcast) filled in the addresses for you.

When you direct your Web browser to, say, the URL, a DNS server is the piece of the Internet that translates the supplied URL to an actual IP (Internet Protocol) address for Google. Without access to a DNS server, your browser would be confined to using the literal IP address.

When your computer uses a static IP address such as, it no longer can take advantage of the DNS server addresses that your router knows about ... unless you copy those DNS server addresses from the router's Internet Connection panel in AirPort Utility to your computer's Network Preferences panel. So do so before going any further, and apply the changes.

While you are still in AirPort Utility, you need to "port map," or "port forward," the listen port number you've decided on, which in my example is 22222. To do that, click on the Advanced icon and then on the Port Mapping tab:

Here you see what my setup looked like before I port forwarded 22222. I had forwarded ports 6881, 11111, 25670, and 9090 earlier, each of these port numbers to exactly one of my two computers. (You can't port forward any single port number to more than one computer.)

To port forward 22222, I clicked on the + sign and entered the following:

22222 was entered as both the public port number and the private port number, and the private IP address I entered was, the address which I assigned to my BitTorrent client computer earlier, in Network Preferences. The description field is left blank, as you cannot type anything into it.

When I clicked OK, the list of mapped ports shown in the previous figure had one more item added to it:

22222 ->

After updating the base station (don't forget to do that by clicking on the Update button and waiting for the base station to restart), I was able to successfully run the Azureus NAT/Server Port Test I discussed earlier.

If you don't have an Apple base station, or if you aren't using a Mac, you can probably find instructions for doing port forwarding in your setup at

I promised to talk about how you pick the port number to use with your BitTorrent client as its listen port.

The "well known" BitTorrent ports are in the range 6881-6889, so try 6881 first, if you like.

If you run more than one client either on a single computer or on more than one computer behind the same router, then for each of the clients that will be in simultaneous use you have to open up a different port. Accordingly, client number two would use 6882, number three would use 6883, and so on.

There's nothing really magic about the 6881-6889 range. The game in picking port numbers is to avoid using a number that any other application/service uses.

When a port number is used by an Internet application or service, it has to do with traffic coming into your local network from the wider Internet. When a computer or server out in cyberspace initiates contact with your computer, it uses a specific port number associated with the type of service in question. For example, the World Wide Web typically uses port 80. So if you happened to be running your own Web server, you would have to port forward port 80 to it. That way, Web browsers in cyberspace could access it.

When you open a torrent file in a BitTorrent client, it announces itself to the "tracker" whose URL is listed in the torrent file. The tracker is a special kind of server which co-ordinates between all the clients on the Internet using that same torrent file. When your client announces itself, the tracker learns (among other things) the IP address of your router and the listen port of your client. It shares that information with other clients using the same torrent file. Those other clients typically initiate contact with your client.

When they do, they use your router's IP address and your client's listen port. If your listen port isn't properly port forwarded by your router, the remote clients get no valid response from your local client. That means the remote clients won't be able to share pieces of the torrent with your client. The only source of torrent pieces your client will be able to take advantage of will be those remote clients that it, your client, initiates contact with itself. That's why downloads too too slow when the listen port isn't open.

You can actually pick any port number from 1 to 65565 for your listen port, but the numbers below 1024 are all taken, and many of those between 1024 and 49151 are too. The ones between 49152 and 65565 are less likely to be reserved. Check this list if you want to be ultra-careful. But remember: the vast majority of port numbers will probably never get external traffic coming into your network, for the simple reason that you are not running anything that requires it. If you pick a port number that is officially reserved, there may be no real harm done.

Also, some ISPs go out of their way to interfere with BitTorrent users who use the "well known" port numbers. You can learn more about that here.

No comments: