25. Introduction to TCP/IP
Introduction to FreeBSD
25.1.  IP - Internet Protocol
25.2.  TCP - Transmission Control Protocol

TCP/IP is the protocol used for network communications by FreeBSD. Of course, TCP/IP is also the protocol used to communicate over the Internet, meaning FreeBSD can be used on the Internet ``out of the box''. This chapter will attempt to give you a brief overview of the TCP/IP protocol, and what you need to understand in order to configure your FreeBSD machine for use on a TCP/IP network.

While we are going to give you enough of an introduction to TCP/IP in this book to get you up and running, if you're in the position of maintaining a FreeBSD network (or any TCP/IP network for that matter) you'll almost certainly need a better understanding of the TCP/IP protocol. TCP/IP is a large enough protocol that one could devote an entire book to it, and indeed many people have! An excellent book on the subject (IMHO) is TCP/IP Network Administration by Craig Hunt. Published by O'Reilly and Associates. This book gives a more in depth overview of TCP/IP and covers many of the common Unix services that we touch upon in this book. While the material is somewhat out of date when it concerns configuration files and so on, you'll find that the concepts are still perfectly conveyed. If you're interested in the guts of the protocol itself, Richard Stevens has three entire volumes written about TCP/IP starting with the theoretical and moving towards more practical knowledge. TCP/IP Illustrated is published by Addison Wesley.


Although FreeBSD can also use the Apple-talk and IPX/SPX (Novell) protocols, this isn't the norm and for this reason we'll focus on TCP/IP as the protocol of choice for FreeBSD. The Applications section of this book will look at using FreeBSD as a replacement Apple and Novell File/Print server - we'll discuss how to turn on the appropriate protocols there.

The first thing you need to know about TCP/IP is that it is actually a suite of protocols. Together, this suite of protocols lets us send data from one computer to another -- a source to a destination -- without having to specifically know the exact path the data will take on its journey. There are three important components that you need to know: IP, TCP, and UDP.

25.1.   IP - Internet Protocol

Essentially, IP makes packets. What's a packet? A packet is a small ``unit'', or ``package'' of data. The easiest way to understand what a packet is, and how IP makes packets, is to look at an example. Let's say you have a 200K file you wish to send over the Internet to a friend. You can think of this file as a ``stream'' of data - the file has a beginning, and a sequential set of bytes (200 thousand of them in this case) all the way up to the end of the file. Any continuous set of data like this is called a stream, due to the directional nature of the data. The most important thing to realize about a data stream is that the order that the bytes are in is critical. What IP does is break this continuous stream of data up into discrete packages (``packets'') that can be delivered independently. IP chops this data stream up into packets, wraps each packet to make it suitable for delivery over the Internet, and labels the packet with a source and destination address.

25.2.   TCP - Transmission Control Protocol

What I didn't tell you before about IP is that, oddly enough, IP is not reliable. IP doesn't guarantee that a packet will reach its destination, or that a collection of packets that represent a single coherent data stream will arrive in the correct sequential order. That's where TCP comes in. TCP puts the packets in their correct order and makes sure all the packets arrived at the destination. Without TCP, IP would be nearly useless! I guess that's why they call the suite TCP/IP!! :-)

Hidden in the address information of each packet is a sequence number. IP increments the sequence number as it sends each packet out, and TCP uses these sequence numbers to reassemble the packets in the correct order when they arrive at the destination. TCP also uses the sequence number to determine if any packets are missing. If a particular packet does not show up (it was incorrectly routed, etc.) TCP requests the packet from the source again. It will keep trying until it has all the packets that make up a data stream. Hence, TCP makes the TCP/IP packet delivery mechanism ``reliable''.

TCP adds another layer of functionality that IP itself doesn't provide: ports. IP numbers specify individual computers on the network, whereas TCP port numbers specify services on that particular computer. Port numbers allow you to have many services running at once, and have a mechanism for making sure requests get to the correct service. The example you are perhaps most familiar with is a web server. WWW servers typically run on port 80. The standard notation for representing a IP number and Port number combination is ip:port - for example, . TCP lets us send a packet intended for the web server, and a packet intended for the telnet server (port 23) to the same host IP number simultaneously. Great! For the record, port numbers range from 0 - 65000. All ports below 1024 are restricted, meaning that only root has the privilege of starting a service which listens on a port less than 1024. Anything above 1024 is fair game for any user process to use - no root privileges are required.


Return to Table of Contents

Visit the Gifcom