Understanding TCP/IP Basics
TCP/IP, the acronym that has become a de facto name for a network communications protocol, stands for Transmission Control Protocol/Internet Protocol. TCP/IP has become so ubiquitous that many think of it, not just as a communications protocol, but as the only network communications protocol. Although not the only protocol out there (AppleTalk, covered later in this chapter, is one of the others), TCP/IP has proven flexible enough to support different types of data with a large range of requirements for delivery, timing, and reliability.
Basically, the TCP/IP protocol can be thought of as specifying the manner in which pieces of data should be transferred between two machines. This protocol includes the notion that the transmission of data can be broken down into a number of separate and abstract layers. Figure 7.1 shows the TCP/IP protocol stack, the conceptual breakdown of the protocol into layers. This is commonly referred to as the OSI (Open Systems Interconnect) model of networking. Because the functions of the layers are conceptually separate, the manner in which the function of any layer is accomplished does not matter, as long as it cooperates with the layers above and below it in the manner that each layer expects.
Figure 7.1. The OSI network model on which the TCP/IP stack is built.
For example, it doesn't matter whether the physical layer is carried by twisted-pair ethernet cabling, radio waves, or even with data written on slips of paper and handed back-and-forth between people sitting at terminals. As long as the data transmitted by the Physical layer gets retrieved from or inserted into data structures correctly at the Data Link layer, the rest of the TCP/IP stack functions identically.
This separation of functionality into independent and abstract pieces is typical of Unix technologies and allows the TCP/IP protocol to handle the transmission of a wide range of data types. Whether the data is equipment control where real-time transmission is critically important, or financial transactions where security and error-free transmissions are more important than speed, it is likely that the data can be fit into the TCP/IP model.
Going forward in the chapter, there are several TCP/IP-related terms you should be familiar with. These items define your connection to the Internet:
IP address The address that uniquely identifies your computer on the Internet. An IP address is typically represented in the form ###.###.###.###, such as 192.168.0.1. An IP address is assigned either by your network administrator or automatically via a DHCP (Dynamic Host Configuration Protocol) or BOOTP (Bootstrap Protocol) server.
The IP address shown in the preceding paragraph is for the IPv4 protocol (Internet Protocol Version 4). This protocol uses a 32-bit address space and has been around for the last 20 years. As the popularity of the Internet increases, the number of addresses available in the IPv4 address space decreases. To address the impending address shortage, NAT (Network Address Translation) is regularly implemented in businesses and at home. This creates a private internal network that uses addresses that the IPv4 protocol has already specified are acceptable to use for this purpose, whereas another machine with NAT software, or a NAT hardware device, has a unique IP that the outside world recognizes and handles the negotiations between the outside world and the private network. The dynamic IP addresses that your ISP serves also assist with coping with the address shortage by providing addresses for machines as they need them, rather than uniquely assigning an IP address for each customer's machine.
To also help fix this address space shortage, the IETF (Internet Engineering Task Force) has introduced the next version of the Internet Protocol, IPv6 (Internet Protocol Version 6). IPv6 uses a 128-bit address space, vastly increasing the number of addresses available. Additionally, it provides some improvements in routing and network configuration. It is expected that IPv4 and IPv6 will coexist for many years as the Internet transitions from one protocol to the other.
Hostname Typically, a hostname simply refers to the network name of your computer. Some people might use the term hostname to refer to the FQDN (fully qualified domain name) as well. This is the entire Internet name of your machine as registered with a DNS (domain name server), such as www.poisontooth.com. If you have a name registered with a DNS, your machine will use this as the hostname; otherwise, it will use the name configured as your Computer Name (from Sharing Preferences) by default. The default can be overridden by adding a HOSTNAME entry to /etc/hostconfig with whatever name you'd prefer your machine to use. If you have a name registered with a DNS, this name should be used because a number of important networking features will not work properly if this value appears to be misconfigured.
Subnet mask Similar in appearance to an IP address, a subnet mask tells your computer which part of the IP address identifies the network it is on and which is the individual computer. Most users will be part of a Class C network with the subnet mask 255.255.255.0. The last segment of the IP address identifies the computer, whereas the first three segments identify the network.
Gateway/router address The gateway address is an IP address of a network device that connects your local network to the rest of the Internet. A gateway handles any necessary translation between different types of networking media.
DNS Domain name servers are Internet servers that provide translation between IP addresses and fully qualified domain names. Each request for a machine using its FQDN requires an interaction with a DNS before a connection can take place.
Network interface The device that connects your computer to the network. This can be an ethernet port, AirPort card, and so on. Some computers might have multiple network interfaces. Mac OS X names its interfaces sequentially. The en0 interface is built-in ethernet, and en1 is typically AirPort.
In addition to the canonical TCP/IP terms common to all Unix networking configurations, it will be helpful to know a few Apple-specific networking terms for discussion and comparison:
AppleTalk AppleTalk is a network protocol with goals similar to those of TCP/IP but designed for less general-use applications, and with features to make it more friendly to nonexpert users. Instead of requiring each computer to have an assigned, distinct identification number, AppleTalk was designed to allow each computer to independently choose its own identification number, and to advertise its identification and services that it provides to the network. With only normal TCP/IP network methods, there is no convenient way for one computer to discover that another provides a service (such as a shared printer). The reason is that, although the service might be provided, there isn't any networkwide broadcast of this information. To use a remote printer in this networking model, you need to know the TCP/IP address of the machine to contact regarding the use of the printer. AppleTalk overcomes this problem by each computer continuously and repeatedly advertising all the services it provided, but this results in continuous traffic on your network. Because of this, it is usually limited to local networks only because you probably don't want to know about all the printers available on Macs all across the country.
Computer Name In the AppleTalk world, each computer can claim a name for itself and advertise this on the network. The names do not have to be different. This value is configured through the Sharing control pane or manually through the /etc/hostconfig file.
Bonjour Bonjour is an Apple product based on the Zeroconf project (http://www.zeroconf.org, a project of the Internet Engineering Task Force, http://www.ietf.org). Zeroconf is an attempt to provide AppleTalk-like networking simplicity with TCP/IP networking services. Although the ultimate goal of Zeroconf is fully automated network configuration, with Mac OS 10.2, Apple began promoting Bonjour, then Rendezvous (née Zeroconf), as a service-discovery protocol carried over TCP/IP. This provides an open-API method for computers to communicate in a manufacturer-agnostic manner about services that they provide or require. Using Bonjour services is as simple as using the Bonjour Computer Name as a URL in a web browser.
Bonjour Computer Name Yet another name for your computer. This parameter, configurable through the Sharing pane, defaults to a value similar (excluding illegal characters) to your Computer Name, with .local appended. The Bonjour Computer Name, also called your local hostname, is used by your computer when advertising services to the network and when trying to connect to your computer from others that want to use services you provide. The Bonjour Computer Name is also used, possibly incorrectly, in a number of other networking contexts, such as the name that Postfix (see Chapter 26, "Creating a Mail Server") attempts to report for the machine.
Using these pieces of information, you can configure your computer to access the Internet. Although most dial-in accounts automatically set these parameters for you, users connecting directly to a network via ethernet or AirPort need to know the appropriate settings for their network to continue.
If you want more information on the TCP/IP protocol and its use, I recommend Special Edition Using TCP/IP (ISBN: 0789718979).