Internet Protocol (IP)

This chapter is a précis of Chapters 18 and 20 of Doug Comer's book [Comer 2004] with additional material from Chapter 5 of Andy Tanenbaum's book [Tanenbaum 2003] . It explains the concepts of network addresses, network addressing, and IP datagrams.

IP Addresses

The Internet is a large virtual network, an abstraction created in software, sitting on top of the underlying physical networks. It provides a uniform addressing scheme for all hosts which helps give the illusion of a large, seamless network. The IP standard specifies that each host is assigned a unique 32-bit IP address which is used for all communications with that host.

Conceptually, each 32-bit address is divided into two parts: a network prefix and a host suffix. Physical networks on the Internet have unique network addresses and all hosts attached to a particular physical network have unique host addresses.

The Internet includes arbitrary network technologies and both large and small physical networks. In order to accommodate this diversity, IP addresses are divided into classes, known as classful IP addressing, as illustrated in Figure 1.

IP address classes
Figure 1: IP address classes

The first four bits determine the class of the address. The first three classes, A, B, and C are called unicast addresses because they identify a single host. Class D is used for multicasting where a set of hosts share a common multicast address.

Classful IP addresses are called self-identifying because the class of the address can be computed from the address itself. The first four bits of the address can be extracted and used as an index into a table to determine the address class. This is illustrated in Figure 2.

Computing an address class
Figure 2: Computing an address class

Note than an address that begins with 1111 is reserved and currently not used.

Dotted Decimal Notation

Although IP addresses are 32-bit numbers, humans use a dotted decimal notation which is easier to comprehend. Each 8-bit octet is written in decimal and the four octets have periods (dots) between them. Figure 3 illustrates some example 32-bit addresses and their equivalent dotted decimal forms.

Example addresses
Figure 3: Example addresses

The range of possible dotted decimal addresses goes from 0.0.0.0 through 255.255.255.255.

Dotted decimal notation works well with classful IP addresses because IP uses octet boundaries to separate the network prefix from the host suffix. The class must be recognised from the decimal value of the first octet. This is illustrated in Figure 4.

Classes and ranges
Figure 4: Classes and ranges

From Figure 4, it can be seen that the IP class scheme does not divide the 32-bit address space into equal size classes. This is illustrated in Figure 5, together with the maximum number of hosts per network.

Network sizes
Figure 5: Network sizes

The total number of hosts for each class also differ because of the number of bits required to identify the class; class A can contain 2,147,483,648 hosts, class B half of that, and class C half again.

A Classful Addressing Example

Network numbers are managed by the Internet Corporation for Assigned Names and Numbers (ICANN) to avoid conflicts. Public networks are usually assigned a class C address unless they can justify a class B address. Class A is seldom justified.

Private networks (internets) select the appropriate class for their needs. Figure 6 illustrates a private internet containing one large network, two medium networks, and one small network.

Example internet
Figure 6: Example internet

The size of the cloud used to represent a physical network corresponds to the number of hosts expected on the network.

Subnet Addressing

As the Internet grew, it became apparent that classful addressing was insufficiently flexible for certain situations. The solution to allow the boundary between the network prefix and the host suffix to occur on an arbitrary bit boundary is called subnet addressing or classless addressing.

Subnet addressing is implemented by storing a 32-bit address and an additional 32-bit subnet mask specifying where the boundary occurs. This subnet mask consists of ones corresponding to the network prefix and zeros corresponding to the host suffix. For humans, this pair is written using Classless Inter-Domain Routing (CIDR) notation. For example, the class B network 128.10.0.0 would be written as 128.10.0.0/16 to denote a 16-bit network prefix. Another example is illustrated in Figure 7.

Example CIDR addressing
Figure 7: Example CIDR addressing

The network address 128.211.0.16/28 allows four bits for host suffixes. A host suffix of all-zeros or all-ones is special (see below), so only 14 hosts can exist.

An ISP can now allocate network addresses according to demand. For example, the class B network 128.211.0.0 could be subdivided into 128.211.0.16/28 for one customer and 128.211.0.32/28 for another. The ISP retains most of the original address for other customers.

Special IP Addresses

In addition to assigning a unique address to each host, the IP addressing scheme defines a set of special addresses that are reserved and never assigned to hosts. These addresses are illustrated in Figure 8.

Special IP addresses
Figure 8: Special IP addresses

The loopback address is usually 127.0.0.1 and can be used for more than testing. It enables a user to run both a client and a server on the same machine. Moreover, packets sent to the loopback address never appear "on the wire", but are handled internally by the IP software.

Router Addresses

Each router on an internet will have two or more IP addresses assigned to it. This is because a router connects two or more networks together. Therefore, there will be a different IP network prefix for each physical network. This is illustrated in Figure 9.

Routers with IP addresses
Figure 9: Routers with IP addresses

Note that no hosts are shown connected to any of the networks. In reality, an IP address does not identify a specific host. Instead, it identifies a connection between a host and a network.

IP Datagrams

The designers of TCP/IP decided to make the fundamental delivery service, i.e. the network layer, a connectionless service with virtual packets created by a source host travelling from router to router until they reach a router that can deliver the packets.

Physical networks may use incompatible frame formats so, to overcome heterogeneity, IP software defines a virtual packet format that is independent of the underlying hardware. This packet is called an IP datagram, whose format is illustrated in Figure 10.

IP datagram
Figure 10: IP datagram

The header contains information that controls where and how the datagram is sent. The size of a datagram is determined by the application that uses it, thereby making IP adaptable to a variety of applications.

Datagrams traverse the Internet by following a path from the source, through routers, to the destination. Each router examines the destination address (in the header) and uses a routing table to determine the next hop. This is illustrated in Figure 11.

Conceptual routing
Figure 11: Conceptual routing

In (a), we have an internet with three routers connecting four physical networks. In (b), we have the conceptual routing table for router R2. Each entry in the table lists a destination network and the next hop to that network.

In practice, the routing table also needs a subnet mask associated with each destination network and the address of a router for each destination network. A practical example is illustrated in Figure 12.

Actual routing
Figure 12: Actual routing

In (a), we have four networks and three routers with the addresses assigned to each router interface. In (b), we have the routing table for the central router. In practice, most internets have more than four networks and a typical routing table would also contain a default route, as discussed above.

The router will first scan the routing table for an exact match, i.e. a 32-bit address; failing that, it will scan the table applying each subnet mask to the destination address in order to find a next hop router; failing that, it will use the default route, or cause an error if there is no default route.

Best-Effort Delivery

Interestingly, the standard states that IP will make a best-effort attempt to deliver a datagram because there are a number of problems out of its control.

The underlying physical networks can cause such problems, so higher layers of protocol software are required to handle such these errors.

Header Format

Figure 13 illustates the fields in the IP datagram header.

IP datagram header
Figure 13: IP datagram header

To keep the headers of most datagrams small, a variable-length list of options may also be present. Padding is required to expand the options to a 32-bit word boundary.

References

  1. Douglas Comer, Computer Networks and Internets with Internet Applications (fourth edition), Prentice Hall, Upper Saddle River, NJ, 2004, ISBN 0-13-143351-2. http://netbook.cs.purdue.edu
  2. Andrew Tanenbaum, Computer Networks (fourth edition), Prentice Hall, Upper Saddle River, NJ, 2003, ISBN 0-13-038488-7. http://www.phptr.com/tanenbaumcn4/


Last modified: Thu Nov 24 10:40:11 2005