Imagine that John wants to invite Jane to go with him to the movies
on Sunday, sohe grabs the telephone and dials Jane’s number. John lives
in a city outside Jane’s area code, so he has to dial the area code
before her number. This combination of area code plus personal
telephone number makes Jane's number unique, and identifies her in the
local telephone system. IP addressing also work like this.
Why are there IP addresses?
Telephones need numbers so you can tell the telephone system which telephone to call. The Internet needs addresses for the same reason. Every computer needs it's own address. And therefore, the rules that run the Internet—called a protocol, because computer programmers like to use that term for rules they all agree on—define a simple but subtle addressing system. The protocol is called the Internet Protocol or IP, so the addresses are called IP addresses.
1. Telephones don't need to use the telephone system anymore. They can be connected to the Internet instead. In that case, they need IP addresses instead of telephone addresses. They can even have both: there's a system for translating between IP addresses and standard telephone numbers, so phones on the Internet can reach standard telephones and vice versa.
2. You can hide computers in a private network that shows just a single IP address to the rest of the Internet. If you have several computers in your home, school, or business, you probably do this. But each computer still needs its own IP address. As we'll see later, there are public addresses (which everyone in the Internet in the whole world can see) and private addresses (which are meaningful only within your home, school, or business.
What does an IP address look like?
An IP address is a combination of a network number plus a number associated with the computer connected to that network, called the host number. (Why host? Think of a computer as someone offering a home where applications to run on and users to store data.) which makes it unique. the area code in Jane's city is like the network number, and Jane's personal telephone number is like the host number.
Most computer users don't have to deal with IP addresses, thanks to the Domain Name System (see http://www.hackerteen.com/dns.php). But you might have had to enter some IP addresses while signing up for Internet service. When people deal with IP addresses, they are usually represented as four decimal numbers separated by dots The following is a typical IP address:
192.168.0.1
As we mentioned, this actually consists of two parts, one that identifies the network and another that identifies the host. To complete this information, we also need a number that tells Internet systems which part is which; that number is called the netmask. Here is the IP address again, now with its netmask:
192.168.0.1/255.255.255.0
In a minute, we'll explain why the number 255 appears. Just note that the last part of the network is 0. This means that the last part of the IP address (the 1 at the end of 192.168.0.1) is the host, whereas the rest is the network. In other words, this combination tells us that this computer belongs to a network numbered 192.168.0, and that it is the first computer connected to this network.
To summarize, Figure 1 shows a telephone number and an IP address, and shows how they are each divided into two parts:
Anatomy of an IP addresses and its classes
We previously showed the unusual way IP addresses normally look (four decimal numbers in the format 192.168.0.1) and showed 255 in the netmask. Now we can explain what lies behind this notation.
IP addresses are currently 32 bits. (This may change in the future, but the next version of the IP address standard is not in general use.) So inside the computer, our typical address is represented as:
1 1 0 0 0 0 0 0 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
That's easy for the computer to understand, but humans go a bit blurry when trying to read it. So instead they divide the address into four parts, each of which contains 8 bits. That's convenient because it corresponds to the familiar byte in computer talk (although the proper term in networking for an 8-bit number is an octet). The number then looks like this:
| 1 1 0 0 0 0 0 0 | . | 1 0 1 0 1 0 0 0 | . | 0 0 0 0 0 0 0 0 | . | 0 0 0 0 0 0 0 1 |
And in decimal, it's:
| 192 | . | 168 | . | 0 | . | 1 |
If you don't know binary arithmetic, don't worry. You can still understand the principles in this article with the help of the figures.
But the division into bytes (octets) also has a useful purpose. When the 32-bit IP address was standardized, the developers created four classes that divided the address differently. If you were a huge organization (such as a large government agency), you would need a lot of host addresses, so you would define just a few bits for the network part and leave a lot of bits for the host part. The opposite is true for a small organization, which needs just a few bits for the host part.
The most important classes are:
| A | 1 octet network | 3 octets host |
| B | 2 octets network | 2 octets host |
| C | 3 octets network | 1 octets host |
If you know any binary (bit) arithmetic, you know that the highest number an octet can contain is 255. This explains why the netmask contains 255 in some fields. What the netmask really means is, Any position occupied by a 1 is part of the network number, whereas any position occupied by a 0 is a host number. The netmask 255.255.255.0 looks like this in binary:
| 1 1 1 1 1 1 1 1 | . | 1 1 1 1 1 1 1 1 | . | 1 1 1 1 1 1 1 1 | . | 0 0 0 0 0 0 0 0 |
This netmask therefore represents a Class C network.
Nowadays, the division between network and host is much more flexible; the boundary can be anywhere. For instance, you could define 22 bits as the network number and 10 bits as the host. The new system is called Classless Inter-Domain Routing (CIDR). We'll look at routing next.
Routing
Sending a message from one computer to another is called routing. As you probably know, each message on the Internet is broken into many pieces called packets. Because each packet is routed separately, and a packet may have to pass through many computers to reach its destination, there are computers called routers whose main job is to help the packets from one computer reach a different computer.
The way in which packets get from a computer in Brazil to a laptop in San Francisco is extremely complicated. We can say a bit about routing and IP addresses here, though.
Think back to a phone number. If you dial an area code, the telephone system knows it has to go to a calling center located in that area code to deliver the call. If you dial a country code, the call is sent to a call center in that country.
In the same way, an Internet router looks at the network number to decide where to send a packet. If a packet is sent to address 192.168.0.1 (and the sender is not on that local area network), the sender looks for a router that handles the 192.168.0 network.
Finding the country code or area code is not hard for the telephone system, because it knows what part of the phone number each code is. Besides, a limited number of country codes and area codes are available.
In contrast, the Internet is less organized and less predictable. As we've seen, the difference between the network number and host number can be different on each local area network. Routers have an elegant solution: they keep a list of networks such as:
| 172.24/255.255.0.0 | (binary netmask 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1) |
| 172.30/255.255.0.0 | (binary netmask 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1) |
| . | |
| . | |
| . |
Routers find each other through an exchange of messages that can get quite complicated. And sometimes they find several possible routers covering the same network:
| 172.24/255.255.0.0 | (binary netmask 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1) |
| 172.24/255.128.0.0 | (binary netmask 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1.1) |
| 172.24/255.192.0.0 | (binary netmask 1 1 1 1 1 1 1 1.1 1 1 1 1 1 1 1.11) |
So where should packets for systems on the 172.24 network go? The router chooses the route with the longest netmask (the one with the 192), because it's the most specific. It covers fewer systems, so using it is more efficient. The routers with netmasks 255.255.0.0 and 255.255.128.0 will deliver the packet eventually too, but they'll take longer and probably have to send the packet through the one with the 192 along the way.
Public and private IP addresses
Public IP addresses can travel throughout the Internet, and are used by public servers such as Google, Yahoo! and other companies. Public IP addresses must be purchased or otherwise given out by an official organization that has the right to assign them. Your Internet provider got a block of public IP addresses from some such institution, and you can buy a public IP address from your provider. However, very few homes or small organizations hold public IP addresses.
Private IP addresses can be used by anyone, on any network. This makes it easy to set up a local area network (LAN) covering your home, a school building, or a business office. Because there's no control over who uses these addresses, there are millions of people using the same private addresses on their private networks. Therefore, the addresses do not have permission to travel on the Internet. In other words, they are non-routable addresses. Any address with 192 in the first octet, for instance, is a private address; this includes our example, 192.168.0.1. The 192 block is very common on local area networks,
IPv6
The version of the Internet Protocol we've discussed is version 4; it has been in use for most of the history of the Internet. Because 32 bits limits the number of addresses, and because of difficulties in routing, a newer version given the number 6 was designed many years ago. Although IPv6 may be necessary some day, it is still used mostly in experimental situations.