Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Absolute BSD - The Ultimate Guide To FreeBSD (2002).pdf
Скачиваний:
26
Добавлен:
17.08.2013
Размер:
8.15 Mб
Скачать

Chapter 5: Networking

Overview

BSD is famous for its network performance. In fact, the TCP/IP network protocol itself was first developed on BSD. Many other operating systems have chosen to use the BSD network stack because of its high performance and liberal licensing.

If you're a system administrator, you must understand how networking works. If you're like most sysadmins, you're probably familiar with some of the basics, but not many people understand how all of that networking stuff hangs together. Knowings what an IP address really is, understanding how a netmask works, and comprehending the symbiotic relationship between IP and TCP is what separates a novice from a professional. We'll cover some of these issues here.

If you know what makes a /31 network mostly useless, you can skip this chapter. Otherwise, read on. There will be a test later–not in this book, but in the real world.

Network Layers

Network layers simplify the networking process. Each layer handles a specific part of the networking process, and information is said to travel down and up through these layers. New users often have trouble understanding this, but we'll go over it in detail. The important thing to remember is that each layer only communicates with the layer directly above it and the layer directly beneath it.

The classic ISO network protocol diagram has seven layers, is exhaustively complete, and covers any situation. The Internet isn't "every situation,"; however, and this isn't a book about networking. Since we'll limit our discussion to the Internet world, we can simplify this diagram somewhat and divide the network into four layers: the application, the logical protocol, the physical protocol, and the physical.

Note The descriptions in this chapter are necessarily generalizations, and very thick books have been written about this topic. My favorite is Stevens' TCP/IP Illustrated, volumes 1 through 3 (Addison−Wesley).

97

Figure 5.1: 4−layer network diagram

The Physical Layer

The bottom layer is the physical one, encompassing the network card and the wire (or other connection) running out of it. This layer also includes the switch (or network hub) and the wire running to the router, as well as the fiber that carries your packets from your ISP to one of the Internet switching points (network access points, or NAPs) and on to the destination. It may even include radio waves, if you're using wireless. Without this link, you have nothing. The physical protocol is the only thing that needs to recognize how this bottom layer works.

A piece of wire–it's really that simple. If your wire is intact and meets the specifications required by the physical protocol, you're in business. If not, you're hosed.

Some physical protocols have been implemented over many different physical layers and Ethernet has been transmitted over half a dozen different sorts of cable. With minor changes in the device drivers and major changes in the network card, you can change your physical layer and not alter any other layer.

Similarly, a single connection might travel over several different types of wire. One of the functions of Internet routers is to convert one sort of physical layer into another.

The physical layer has no decision−making abilities and no intelligence; everything it does is dictated by the physical protocol.

The Physical Protocol Layer

The physical protocol layer is where things get interesting. The physical protocol talks over the wire. It encodes transmissions in the actual ones and zeroes that are sent over the physical layer in the

98

appropriate manner for that sort of media. For example, Ethernet uses Media Access Control (MAC) addresses and the Address Resolution Protocol (ARP); dial−up uses the Point−to−Point Protocol (PPP, usually used for home connections). The physical protocol has to understand how to speak to these addresses, and to encode and decode messages for them.

Ethernet and PPP are the main physical protocols, though FreeBSD also supports a variety of other physical protocols, such as Asynchronous Transfer Mode (ATM) and Integrated Services Digital Network (ISDN), as well as combinations such as PPP over Ethernet (used by some home−broadband vendors). Each of these protocols has special requirements, and while we'll only discuss Ethernet in some detail, you should understand that other connection protocols exist.

The physical protocol passes information to and from the physical layer and the logical protocol layer.

The Logical Protocol Layer

Logical protocols, such as Internet Protocol (IP) and Transmission Control Protocol (TCP) handle things like IP addresses and port operations by exchanging information with the physical protocol and the application. You can use multiple logical protocols simultaneously.

There are many logical protocols. (See the /etc/protocols file for a mostly complete list.) The protocols we're most concerned with are IP and TCP (both already mentioned), Internet Control Message Protocol (ICMP), and User Datagram Protocol (UDP).

Logical protocols can work side by side, and can even depend upon one another. When a packet is transmitted, it includes a flag that identifies which protocol it belongs to.

Internet Protocol

The Internet Protocol (IP) is the baling wire that holds the Internet together, and every device on the Internet is expected to speak IP. IP provides very basic, core functions, such as network addresses and packet routing, as well as the fundamental infrastructure used by other logical protocols. You can live without TCP and other protocols, but if you don't have IP you don't have the Net.

Note In this book, we only discuss IP version 4; IP version 6 is fairly new. While FreeBSD includes excellent IPv6 support, it's not yet widespread enough to cover here. Hopefully, by the time a new edition of this book comes out, IPv6 will be widespread, because it fixes many problems found in IPv4, thus eliminating the gross hacks that have been implemented to work around them.

IP Addresses

An IP address is a 32−bit number, generally divided into four groups of 8 bits each. Translated into English, this means that you'll see four numbers, each from 0 to 255, separated by periods. For example, 192.168.1.87 is a valid IP address, while 192.259.0.87 is not–one of the numbers exceeds 255. 607.322.843.999 is Right Out.

Every device on the Internet has a unique IP address, unless it's using Network Address Translation (NAT) or some other ugly hack.

99