Networking Interfaces
To hide the diversity of equipment that may be used in a networking environment,
TCP/IP defines an abstract interfacethrough which the hardware is accessed. This
interface offers a set of operations that is the same for all types of hardware and
basically deals with sending and receiving packets.
For each peripheral networking device, a corresponding interface has to be present
in the kernel. For example, Ethernet interfaces in Linux are called by such names
as eth0and eth1; PPP (discussed in Chapter 8, The Point-to-Point Protocol)
interfaces are named ppp0and ppp1; and FDDI interfaces are given names like
fddi0and fddi1. These interface names are used for configuration purposes when
you want to specify a particular physical device in a configuration command, and
they have no meaning beyond this use.
Before being used by TCP/IP networking, an interface must be assigned an IP
address that serves as its identification when communicating with the rest of the
world. This address is different from the interface name mentioned previously; if
you compare an interface to a door, the address is like the nameplate pinned on it.
Other device parameters may be set, like the maximum size of datagrams that can
be processed by a particular piece of hardware, which is referred to as Maximum
Transfer Unit(MTU). Other attributes will be introduced later. Fortunately, most
attributes have sensible defaults.
IP Addresses
As mentioned in Chapter 1, Introduction to Networking, the IP networking
protocol understands addresses as 32-bit numbers. Each machine must be assigned
a number unique to the networking environment.[1] If you are running a local
network that does not have TCP/IP traffic with other networks, you may assign
these numbers according to your personal preferences. There are some IP address
ranges that have been reserved for such private networks. These ranges are listed
in Table 2.1. However, for sites on the Internet, numbers are assigned by a central
authority, the Network Information Center(NIC).[2]
[1] The version of the Internet Protocol most frequently used on the
Internet is Version 4. A lot of effort has been expended in designing a
replacement called IP Version 6. IPv6 uses a different addressing
scheme and larger addresses. Linux has an implementation of IPv6,
but it isn't ready to document it in this book yet. The Linux kernel
support for IPv6 is good, but a large number of network applications
need to be modified to support it as well. Stay tuned.
[2] Frequently, IP addresses will be assigned to you by the provider
from whom you buy your IP connectivity. However, you may also
apply to the NIC directly for an IP address for your network by
sending email to hostmaster@internic.net, or by using the form at
http://www.internic.net/.
IP addresses are split up into four eight-bit numbers called octetsfor readability.
For example, quark.physics.groucho.eduhas an IP address of 0x954C0C04, which
is written as 149.76.12.4. This format is often referred to as dotted quad notation.
Another reason for this notation is that IP addresses are split into a network
number, which is contained in the leading octets, and a hostnumber, which is the
remainder. When applying to the NIC for IP addresses, you are not assigned an
address for each single host you plan to use. Instead, you are given a network
number and allowed to assign all valid IP addresses within this range to hosts on
your network according to your preferences.
The size of the host part depends on the size of the network. To accommodate
different needs, several classes of networks, defining different places to split IP
addresses, have been defined. The class networks are described here:
Class A
Class A comprises networks 1.0.0.0through 127.0.0.0. The network number
is contained in the first octet. This class provides for a 24-bit host part,
allowing roughly 1.6 million hosts per network.
Class B
Class B contains networks 128.0.0.0through 191.255.0.0; the network
number is in the first two octets. This class allows for 16,320 nets with
65,024 hosts each.
Class C
Class C networks range from 192.0.0.0through 223.255.255.0, with the
network number contained in the first three octets. This class allows for
nearly 2 million networks with up to 254 hosts.
Classes D, E, and F
Addresses falling into the range of 224.0.0.0through 254.0.0.0are either
experimental or are reserved for special purpose use and don't specify any
network. IP Multicast, which is a service that allows material to be
transmitted to many points on an internet at one time, has been assigned
addresses from within this range.
If we go back to the example in Chapter 1, we find that 149.76.12.4, the address of
quark, refers to host 12.4on the class B network 149.76.0.0.
You may have noticed that not all possible values in the previous list were allowed
for each octet in the host part. This is because octets 0and 255are reserved for
special purposes. An address where all host part bits are 0 refers to the network,
and an address where all bits of the host part are 1 is called a broadcast address.
This refers to all hosts on the specified network simultaneously. Thus,
149.76.255.255is not a valid host address, but refers to all hosts on network
149.76.0.0.
A number of network addresses are reserved for special purposes. 0.0.0.0and
127.0.0.0are two such addresses. The first is called the default route, and the latter
is the loopback address. The default route has to do with the way the IP routes
datagrams.
Network 127.0.0.0is reserved for IP traffic local to your host. Usually, address
127.0.0.1will be assigned to a special interface on your host, the loopback
interface, which acts like a closed circuit. Any IP packet handed to this interface
from TCP or UDP will be returned to them as if it had just arrived from some
network. This allows you to develop and test networking software without ever
using a "real" network. The loopback network also allows you to use networking
software on a standalone host. This may not be as uncommon as it sounds; for
instance, many UUCP sites don't have IP connectivity at all, but still want to run
the INN news system. For proper operation on Linux, INN requires the loopback
interface.
Some address ranges from each of the network classes have been set aside and
designated "reserved" or "private" address ranges. These addresses are reserved for
use by private networks and are not routed on the Internet. They are commonly
used by organizations building their own intranet, but even small networks often
find them useful. The reserved network addresses appear in Table 2.1.
Table 2.1: IP Address Ranges Reserved for
Private Use
ClassNetworks
A 10.0.0.0 through 10.255.255.255
B 172.16.0.0 through 172.31.0.0
C 192.168.0.0 through 192.168.255.0
No comments:
Post a Comment