BSD DevCenter
oreilly.comSafari Books Online.Conferences.


FreeBSD Basics

Networking with TCP/IP


When you install FreeBSD, you are plunged into the wonderful world of TCP/IP. You may have heard about DNS, ports, RFCs, private ranges, and subnet masks but may be foggy on what these are and why you should care. This article will be a primer on the TCP/IP protocol for the novice and a refresher with some interesting links for those more seasoned FreeBSD users.

First off, let's make sure you are clear on what a protocol is. By definition, a protocol is the rules of communication. If you are travelling in a foreign country, you need to be aware of the customs of that country. A gesture that may seem friendly or insignificant to you may actually be considered an insult in other parts of the world. Awareness of protocol can save you the embarassment of miscommunication.

Protocols are even more important if two computers wish to exchange information. Amazingly, computers communicate by subtly changing millions of electrical pulses, light pulses, or radio waves per second. Both computers need to be using the same protocol, or set of rules, to correctly interpret which of these pulses represent the address of the computer to receive the data, the address of the computer that sent the data, the data itself, and confirmation that the data received was the same data that was sent.

TCP/IP is more than a protocol; it is a protocol suite, or collection of protocols. TCP/IP was designed to allow any operating system on any type of hardware to talk to any other computer in the world. This is something we take for granted in the age of the Internet, but before TCP/IP changed all of the rules, operating systems, hardware, and protocols were proprietary. Proprietary means that in order to exchange information with another computer, it has to be running the same hardware and the same version of the same operating system, which was provided by the vendor of the hardware.

Because TCP/IP is a collection of protocols, new protocols can be added as the capabilities of networking evolve. The designers of TCP/IP left room for the creation of up to 65,535 application protocols. To keep track of all of these application protocols (or rules for how an application expects to receive data), each is assigned a number known as a port number. For example, the port number for Telnet is 23 and the port number for http is 80. If I wish to Telnet into a computer, TCP/IP will send out packets that contain (among other information we'll ignore for the moment) the port number 23. The other computer will realize that I wish to use the rules for Telnet, which are very different than, say, the rules for surfing or checking my e-mail.

Since TCP/IP is non-proprietary, anyone can add new functionality to TCP/IP, pending a review process of their peers known as the RFC or Request For Comments. RFCs were started before the actual development of TCP/IP and have become a fascinating record of each step in the evolution of TCP/IP and the Internet. Ever wonder about who invented DNS and why and all the nitty-gritty details of how DNS actually works? The answer lies in the associated RFCs, which are available for anyone to read via the Internet.

There are many good sites on the Internet where you can search for and read RFCs. Two of these are:

  • The RFC Database - sometimes slow due to its popularity. If it is too slow, do a Yahoo search for "rfc search" to find other RFC sites.
  • Internet Requests for Comments - be sure to read the Hitchhiker's Guide to the Internet and the Twelve Networking Truths.

Perhaps you've been told that reading RFCs is as much fun as reading manpages. Admittedly, RFCs can be written by anyone, so writing styles will differ. Some good RFCs to start with are:

  • RFCs 1000, 1251, 2235, and 2468 - if you're interested in hearing about the history of the Internet from some of the people who made it happen
  • RFCs 968, 1121, and 1882 - just in case you thought computer geeks had no sense of humor. If you enjoy humorous RFCs, see this list.

Anyway, back to ports. Your FreeBSD system contains a database file of port numbers and associated TCP/IP applications in /etc/services. If you need to know the port number for an application or vice-versa, a quick grep of this file will reveal the information:

grep ssh /etc/services
ssh		 22/tcp    #Secure Shell Login
ssh		 22/udp    #Secure Shell Login
grep -w 69 /etc/services
tftp		 69/tcp	   #Trivial File Transfer
tftp		 69/udp	   #Trivial File Transfer

With these two commands, I've determined that the port number used by ssh is 22 and that port 69 is used by the tftp application. Note that I used -w for the second grep; if you try the same command without the switch, grep will return all port numbers with a 69 in them.

Also note that each application has two port numbers: one for TCP and one for UDP. TCP and UDP are known as transport protocols. While there are thousands of TCP/IP applications, there are only two ways of "transporting" an application's data between computers. UDP is the connectionless transport, meaning that it just sends out data without double-checking that the other computer is ready to receive the data. This is similar to you just showing up at a friend's house in the hope that he may be home. TCP is the connection-oriented transport; it will not send out any data until it has contacted the other computer to ensure that it is ready to receive data. This would be similar to you phoning your friend first to see if he is home and willing to have you come over for a visit.

Pages: 1, 2, 3

Next Pagearrow

Sponsored by: