Difference between revisions of "How to become connectable"

From TMB Wiki
Jump to: navigation, search
m (more minor formatting)
m (more minor formatting)
Line 11: Line 11:
 
==IP Addresses==
 
==IP Addresses==
 
For purposes of this document, we'll assume that every device on the internet needs to have an IP address.  Your ISP somehow assigns you an IP address.  It may have been programmed into your router by hand or more likely is assigned automatically by a DHCP server.  DHCP stands for Dynamic Host Configuration Protocol.  Each computer behind your router also has an IP address.  Routers almost always include a DHCP server and by far the easiest way to get a computer connected on your network is to let the router supply the IP address automatically.  This is called a dynamic IP address.  That address is not necessarily the same every time your computer connects to your local network.  For most purposes it wouldn't matter.  You can also tell a computer to use a hard-coded (supplied by you) address.  In that case it's called a static IP address.  It's easy to screw up a static address entry, because you have to supply not only the IP address, but a subnet mask, gateway address and DNS server address(es).  Some routers have an Address Reservation feature where you can use the router to always assign the same IP address to any given computer.  That's really the best of both worlds if you want IP addresses to be predictable.  More about that later...
 
For purposes of this document, we'll assume that every device on the internet needs to have an IP address.  Your ISP somehow assigns you an IP address.  It may have been programmed into your router by hand or more likely is assigned automatically by a DHCP server.  DHCP stands for Dynamic Host Configuration Protocol.  Each computer behind your router also has an IP address.  Routers almost always include a DHCP server and by far the easiest way to get a computer connected on your network is to let the router supply the IP address automatically.  This is called a dynamic IP address.  That address is not necessarily the same every time your computer connects to your local network.  For most purposes it wouldn't matter.  You can also tell a computer to use a hard-coded (supplied by you) address.  In that case it's called a static IP address.  It's easy to screw up a static address entry, because you have to supply not only the IP address, but a subnet mask, gateway address and DNS server address(es).  Some routers have an Address Reservation feature where you can use the router to always assign the same IP address to any given computer.  That's really the best of both worlds if you want IP addresses to be predictable.  More about that later...
 
  
 
== TCP/IP ==
 
== TCP/IP ==
 
The protocol used by BitTorrent is called TCP/IP.  Most of the data moving through the internet is TCP/IP.  Information is divided into small bundles called packets.  Each packet has an originating address and port number (together they make up a "return address" ) and a destination address and port number.  That's how the computers you contact know where to return information - you're sending your return address with every packet.  When your computer opens a new connection it just adds 1 (or some number) to the last port number it used.  When a connection is closed, that port number becomes available again, in case your PC makes it all the way through the 64K or so port numbers.  You can think of the IP address like a street address and the port like an apartment number.  Once you get to the building, you need to know which door to knock on.
 
The protocol used by BitTorrent is called TCP/IP.  Most of the data moving through the internet is TCP/IP.  Information is divided into small bundles called packets.  Each packet has an originating address and port number (together they make up a "return address" ) and a destination address and port number.  That's how the computers you contact know where to return information - you're sending your return address with every packet.  When your computer opens a new connection it just adds 1 (or some number) to the last port number it used.  When a connection is closed, that port number becomes available again, in case your PC makes it all the way through the 64K or so port numbers.  You can think of the IP address like a street address and the port like an apartment number.  Once you get to the building, you need to know which door to knock on.
 
  
 
== How NAT routers work ==
 
== How NAT routers work ==

Revision as of 17:47, 4 October 2007

So what is being "connectable" or "clever"? It refers to whether other people in the same torrent as you can contact you in order to share data. Being connectable is a Good Thing. Why? A connectable user can share data with anyone in the torrent. Two unconnectable people can't establish a connection between them. If you're the only leecher and all the seeders are unconnectable, you won't get any data.

This information is for people who want to become connectable. It's going to take some reading and work on your part to fix it. The payoff is that you'll be able to connect to the non-clever peers in a torrent. That can dramatically improve your speed since those peers are connected to fewer others. If you're seeding, you'll be able to send data to anyone, not just "clever" users. That'll make your ratio go up faster.

First of all, it may be beyond your control to affect this. If you're connecting from a college or from work, you'd have to get the people who administer the network to fix this. They'd have to assign you a static IP address and forward some ports from their firewall/router to that IP address. It's pretty unusual for them to do this. They don't want their bandwidth used for file sharing - that's why they installed that firewall in the first place.

On the other hand, if you own or administer the router you can forward ports yourself. It's my firm belief that you're more likely to succeed if you understand why you're doing things. So, a bit of background first. (When I refer to BT here, I'm talking about the BitTorrent protocol and/or your particular BitTorrent client. For the purposes of this document, it shouldn't matter which BT client you use.)

If this doesn't convince you, nothing will.

IP Addresses

For purposes of this document, we'll assume that every device on the internet needs to have an IP address. Your ISP somehow assigns you an IP address. It may have been programmed into your router by hand or more likely is assigned automatically by a DHCP server. DHCP stands for Dynamic Host Configuration Protocol. Each computer behind your router also has an IP address. Routers almost always include a DHCP server and by far the easiest way to get a computer connected on your network is to let the router supply the IP address automatically. This is called a dynamic IP address. That address is not necessarily the same every time your computer connects to your local network. For most purposes it wouldn't matter. You can also tell a computer to use a hard-coded (supplied by you) address. In that case it's called a static IP address. It's easy to screw up a static address entry, because you have to supply not only the IP address, but a subnet mask, gateway address and DNS server address(es). Some routers have an Address Reservation feature where you can use the router to always assign the same IP address to any given computer. That's really the best of both worlds if you want IP addresses to be predictable. More about that later...

TCP/IP

The protocol used by BitTorrent is called TCP/IP. Most of the data moving through the internet is TCP/IP. Information is divided into small bundles called packets. Each packet has an originating address and port number (together they make up a "return address" ) and a destination address and port number. That's how the computers you contact know where to return information - you're sending your return address with every packet. When your computer opens a new connection it just adds 1 (or some number) to the last port number it used. When a connection is closed, that port number becomes available again, in case your PC makes it all the way through the 64K or so port numbers. You can think of the IP address like a street address and the port like an apartment number. Once you get to the building, you need to know which door to knock on.

How NAT routers work

NAT stands for Network Address Translation. A NAT router allows multiple computers to connect to the internet via a single IP address. For the most part, individual connections to the internet originate at your computer. You want to browse a web page, connect to an email server, etc. When your outgoing connection hits the router, it notes your IP address, port number and the destination address. It assigns a unique port number to your request. That information gets added to a table of such addresses that the router maintains. The router then modifies the outgoing network packet so that to the rest of the internet it looks like the request originated from the router's IP address with that unique port number. When information comes back from the internet, the router knows by the IP it came from and the port it's addressed to where to send that information. It replaces the IP and port with that of the computer that originally sent it. It then passes that on to your network, where your computer receives the data. When your computer closes this connection, the router throws away the table entry for that connection. Unless otherwise configured by you, connections have to originate behind the router. That's because a NAT router ignores any incoming data that doesn't match a port and IP that are currently in its table. The router really doesn't have a choice in this case, because where would it send that data? The result of this is that your NAT router protects you from all the crap flying around the internet. Even if you only run one computer, a NAT router is a good investment if only for the protection it gives you.

Most NAT routers have something called DMZ (demilitarized zone). When you put an IP address in the DMZ, any unrecognized traffic is sent to that address. There are two downsides to this: Only one computer can be put into the DMZ at a time and any computer in the DMZ might as well be connected directly to the internet. If that computer doesn't have a very good software firewall, it will quickly be compromised. Windows leaves certain ports open for file sharing, messages, etc. Some of these can be exploited by hackers. Stay away from the DMZ if you can.

There might be a legitimate reason for people from the internet to connect to one of your machines. You could be running a web, FTP or mail server for example. And of course you want to be "connectable" on BitTorrent. To meet this need, most routers allow you to open or forward ports. What this means is that a packet arriving addressed to a certain port on your router would always be sent to a specific IP address and port in your network. This is independent of whether that computer is actually waiting for traffic on that port. If the computer is not expecting any traffic, the packet is rejected by the computer. At most, the originating computer on the internet would receive a reply saying that the port was closed.

It's possible to have different ports forwarded to different computers. There might be two people running FTP servers. To the outside world, they'd be on different ports. Inside your network they could each be on the default port 21. The router would send data to the IP address associated with each forwarded port. You can run BitTorrent simultaneously on several computers behind the same NAT router if the router is properly configured.

How the BitTorrent protocol works

You download a .torrent file from somewhere. In that file is the name of the tracker, a port number and a 20-byte ID that identifies the torrent within that tracker. Your BT client connects with the tracker (since you initiate this connection, it always works properly with your router). You tell the tracker the ID as well as the port number that your BT client is listening on. The tracker looks at who else is using that torrent and gives you a random subset of those users' IP addresses and listening ports. This random set of users is called your swarm. The tracker also tells your swarm about you, giving your IP address and port number. Your BT client attempts to contact swarm members directly and starts negotiating for "pieces" of the files in the torrent. Swarm members are also free to try to contact you.

Now your BT client has a list of IP addresses that it is trying to contact. The objective for BT is to open a connection between your computer and each computer in the swarm. Once that connection is made data starts flowing both into and out of your computer. It makes no difference which computer initiates the connection so long as you do connect. If both users are behind routers then that connection can't be completed. That is, not unless at least one router has been told how to forward data to the computer running BT.

Port Forwarding

There are two ways to forward ports. Let's talk about the pain-free way first. Many routers support something called uPnP. As far as I can tell, this means that computers behind the router can tell the router to open ports as needed. I use the BitTornado program for my BT needs. In it's default configuration BitTornado uses a random port between 10000 and 60000 and uses uPnP to automatically make sure that port is forwarded by the router. When you close BitTornado it should close that port. If your BT client and router both support uPnP, this is certainly the easiest way to go. Multiple computers running BT simultaneously behind the same firewall will also work properly, unless they happen to pick the same port number. It's easy to change the port number range in any BitTorrent client so that two computers' port numbers will never overlap. You don't even need a static IP address in this case, as the router will always know where to forward packets.

  • The not-so-easy way to forward ports is to use your router's web interface and specifically tell it what ports to forward where. You need several things for this to work. They are:
  1. A static IP address for your computer
  2. Your BT client configured for a known port or small range of ports
  3. Your router configured to forward those ports to your static IP address
  4. Any software firewall must be disabled or configured to let traffic on BT ports through.

Establishing a static IP address

Directions can be found in almost any router manual that I've seen. You can also look at http://www.portforward.com/networking/staticip.htm

What ports to use

Pick something above 10000. The highest possible port number is 65535. If your BT client can have multiple torrents open using a single port (Azureus, BitComet, etc.) then you only need to open a single port. If you need a separate port for every torrent, figure out how many you'll have open and use a range of at least that many ports.

Forwarding the necessary port numbers

Once you have a static IP address and know which ports you're using, you want to set up your router to forward incoming traffic on those ports to your static IP address (and those same port numbers). Again see http://www.portforward.com for specific instructions regarding your make and model of router.

Software Firewalls

You probably want to shut these off at least temporarily to see if you can become clever. Then if you've got yourself clever you can re-enable the firewall and create exceptions for your BT client.

Lexie's sidenote for the non-computer savvy

I had to do a few extra things to solve NAT issues, which I think might be caused by my router in theory being able to use UPnP but in reality it was struggling. Go to Settings --> Windows Firewall --> Exceptions tab and make sure there is an exception for Azureus, or create one if it doesn't already exist. I may have done extra by adding the ports as well, but this is what I did and I finally have everything working:

  • Add a program --> specify where you have Azureus installed on your computer
  • Add a port --> open the listening port Azureus uses, for example:
  1. Azur1 - 12345 TCP (12345 being whatever you chose as your listening port)
  2. Azur2 - 12345 UDP

This may be where I did extra work, but it certainly can't hurt and I couldn't get Azureus to work by just allowing an exception for Azureus as a program; more information available in the Useful Links section below

Now, even after all of that, I still couldn't get my NAT test to work on Azureus! I think it may be caused by the fact that we have multiple instances of Azureus running on our network, including one that shares massive amounts of data all day long. If you have that problem, you may want to try this:

  1. Open Azureus --> Tools --> Configuration Wizard
  2. Select language
  3. Select advanced user
  4. Don't change anything else about your modem info, etc. (unless it's wrong)
  5. Go back to Azureus --> Tools --> Options
  6. Expand Connection --> Advanced Network Settings
  7. Enter the static IP address you set up in the "Bind to local IP address or interface" field
  8. Save your settings --> close tools --> open Configuration Wizard again and reset whatever user type you had originally set it as, because I'm assuming if you're an advanced user you're probably not reading "Lexie's Azureus Guide for Dummies" :)

If that doesn't work, I can't help you any more than this so try posting in the forums or begging a computer-literate friend to help you out.

Useful Links