This appendix provides an overview of IP routing. The chapter describes the following topics:
Internet protocol (IP) addresses are 32 bits long. Thus, there is a possibility of approximately a total 4 billion addresses for the entire Internet. An IP address is expressed as a series of octets separated by dots. For example, the address 11111111 00000001 00000101 00001010 is written as 127.1.5.10, or using hexadecimal notation, 7f.1.5.a0.
Because of this vast number of addresses, the network is organized hierarchically into administrative domains. This organization led to the definition of name administrative domains and network classes. Since each site can vary in size, IP addresses are divided into three main types or classes. A large site can reserve a class A address and receive 224 individual addresses. A small site can reserve a class C address and receive 28 individual addresses.
Class A uses the first octet for the network address, and the rest for host addresses within this network. For example, a site whose network address is 129.0.0.0 would own the 224 addresses between 129.0.0.0 and 129.255.255.255.
Network |
Host |
|
|
---|---|---|---|
0xxxxxxx |
xxxxxxxx |
xxxxxxxx |
xxxxxxxx |
Class B uses two octets for the network address, and two for the host address. For example, a site whose network address is 129.123.0.0 would own the 216 addresses between 129.123.0.0 and 129.123.255.255.
Network |
Host |
|
|
---|---|---|---|
10xxxxxx |
xxxxxxxx |
xxxxxxxx |
xxxxxxxx |
Class C uses three octets for the network address, and one octet for the host address. For example, a site whose network address is 129.123.56.0 would own the 28 addresses between 129.123.56.0 and 129.123.56.255.
Network |
Host |
|
|
---|---|---|---|
110xxxxx |
xxxxxxxx |
xxxxxxxx |
xxxxxxxx |
Subnetting divides a network into smaller segments, or subnets. This technique is imperative for Class A and B networks. Routers do not forward packets outside a subnet if the destination address is within the same subnet. Thus, network traffic is decreased dramatically by segmenting a large network. For example, suppose a class B network is segmented into 255 subnets. Unless a packet destination is a host outside the subnet, a local packet is sent to 255 hosts instead of 256,000.
The format of the netmask is a series of 1s followed by a series of 0s. By ANDing an IP address with a netmask, you can get the address of the subnet.
Routers use netmasks to decide whether to forward a packet to an external subnet. For example, suppose a machine with an IP address of 129.123.56.95 sends an email to another machine whose IP address is 129.123.56.100. By ANDing both IP addresses with a netmask (255.255.255.0), the result is 129.123.56.0 for both machines. The router then concludes that the source machine and the destination machine are in the same subnet. Therefore, the router does not forward the email to external subnets.
On the other hand, if the destination address is 129.123.67.100, then the resulting subnet address is 129.123.67.0. The router forwards the email to the external subnet (129.123.67.0).
Although some of these examples only apply to Ethernet links, the principles apply regardless of the network type.