|
|
3.2. The Network Layer In The Internet
At the network layer, the Internet can be viewed as a collection of subnetworks or Autonomous Systems (ASes) that are connected together. There is no real structure, but several major backbones exist. These are constructed from high-bandwidth lines and fast routers. Attached to the backbones are regional (midlevel) networks, and attached to these regional networks are the LANs at many universities, companies, and Internet service providers (Fig. 5-44).
Fig. 5-44. The Internet is an interconnected collection of many networks.
The glue that holds the Internet together is the network layer protocol, IP (Internet Protocol).
Communication in the Internet works as follows: The transport layer
takes data streams and break them up into datagrams usually around
1500 bytes long (in theory, they can be up to 64 Kbytes). Each datagram
is transmitted through the Internet, possibly being fragmented into
smaller units. When all pieces finally get to the destination machine,
they are reassembled by the network layer into the original
datagram. This datagram is then handed to the transport layer, which
inserts it into the receiving process' input stream.
3.2.1. The IP Protocol
An IP datagram consists of a header part and a text part. The header has a 20 byte fixed part and a variable length optional part (Fig. 5-45). It is transmitted from left to right, with the high-order field of the Version field going first (big endian order).
Fig. 5-45. The IP (Internet Protocol) header.
Meanings of single fields in the IP header:
Fig. 5-46. IP options.
Every host and router on the Internet has an IP address, which encodes its network number (prefix part of the address) and host number (suffix part of the address). The combination is unique.
All IP addresses are 32 bits long. The format of IP address is in Fig. 5-47. Those machines connected to multiple networks have a different IP address on each network.
Fig. 5-47. IP address formats.
IP addresses can be divided into 5 classes. There are 3 primary classes, A, B, and C, used for host addresses. Class D is used for multicasting which allows delivery to a set of computers. Class E is reserved for future use. The first four bits of an address determine the class to which the address belongs.
The class A format allows for up to 126 networks with 16 million hosts each.
The class B format allows for up to 16382 networks with 64 K hosts each.
The class C format allows for up to 2 million networks with 254 hosts each.
Network numbers on the top level are assigned by the NIC (Network Information Center). For single organizations, the network number are assigned by Internet service providers.
Network addresses are usually written in dotted decimal notation. In this format, each of the 4 bytes is written in decimal, from 0 to 255.
Some addresses have special meaning (Fig. 5-48).
Fig. 5-48. Special IP addresses.
The IP address 0.0.0.0 is used by hosts when they are being booted but is not used afterwards.
All addresses of the form 127.xx.yy.zz are reserved for loopback
testing. Packets sent to that address are not put onto the wire; they
are processed locally and treated as incoming packets.
3.2.3. Subnets
All the hosts in a network must have the same network numbers. When the number of computers in an organization get bigger or the number of different LANs get bigger, this requirement can cause problems.
The solution to these problems is to allow a network to be split into several parts for internal use but still acts like a single network to the outside world. In the Internet literature, these parts are called subnets (different from subnets as a collections of routers).
The division is done in fact by splitting the host part of the address (e.g., 16 bits in case of B address) into a subnet number (e.g., 6 bits) and a host number (10 bits in our example). This split allows 62 LANs (0 and 255 are reserved), each with up to 1022 hosts (Fig. 5-49).
Fig. 5-49. One of the ways to subnet a class B network.
To see how subnets work, it is necessary to explain how IP packets are processed at a router.
Each router has a table listing some number of (network, 0) IP addresses and some number of (this-network, host) IP addresses. The first kind tells how to get to distant networks. The second kind tells how to get to local hosts. Associated with each table is the network interface to use to reach the destination, and certain other information.
When an IP packet arrives, its destination address is looked up in the routing table. If the packet is for a distant network, it is forwarded to the next router on the interface given in the table. If it is a local host (e.g., on the router LAN), it is sent directly to the destination. If the network in the destination address is not present in the router's table, the packet is forwarded to a default router with more extensive tables. So each router has to keep track of other networks and local hosts, not (network,host) pairs.
When subnetting is introduced, the routing tables are changed, adding
entries of the form (this-network, subnet, 0) and (this-network,
this-subnet, host). Thus a router on subnet k knows how to get to all
other subnets and also how to get to all the hosts on subnet k. In fact,
all that needs to be changed is to have each router do a Boolean AND with
the network's subnet mask (Fig. 5-49) to get rid of the host number and
look up the resulting address in its tables (after determining which
network class it is). Subnetting reduces router table space by creating
a three-level hierarchy.
3.2.4. Internet control protocols
In addition to IP, which is used for data transfer, the Internet has
several control protocols used in the network layer, including
ICMP and ARP.
3.2.5. The Internet Control Message Protocol
The operation of the Internet is monitored by the routers. When something unexpected occurs, the event is reported by the ICMP (Internet Control Message Protocol).
Each ICMP message is encapsulated in an IP packet. The most important messages are in Fig. 5-50.
Fig. 5-50. The principal ICMP message types.
The more detailed meaning of single messages are as follows:
The ICMP is defined in RFC 792.
3.2.6. The Address Resolution Protocol
The ARP (Address Resolution Protocol), defined in RFC 826, solves the following problem: A computer on a LAN has to send an IP packet with the destination IP address A to a computer on the same LAN (the fact that the computer with the address A is on the same LAN is known from the address A), but it does not know the LAN address of the computer necessary to send a packet directly. So it, using ARP, broadcast packet on the LAN asking: Who owns IP address A? The broadcast will arrive at every machine on the LAN and each one will check its IP address. The host with the IP address A will respond announcing its LAN address. An example is in Fig. 5-51.
Fig. 5-51. Three interconnected class C networks: two Ethernets
and an FDDI ring.