When sending data over a network, there must be some reliable way to get the data from one machine to another. In order to facilitate this complicated process, networks are organized in a series of layers, each layer offering a specific networking service to the next layer. The layers are independent and have clearly defined interfaces for supplying functions to the next layer. A high layer passes data and information to the layer below it, until the bottom layer is reached. At the bottom layer, two machines can physically communicate with each other. The rules and procedures used for one network layer on a machine to communicate with its counterpart network layer on another machine are called protocols. The most popular software networking protocols in UNIX are Ethernet, IP, TCP, and UDP.
The Ethernet layer is the physical layer of the network. Any host connected to the Ethernet bus has physical access to data sent over the network. The Ethernet protocol prepares the data for transmission across a wire. It organizes the data in frames using 48-bit Ethernet source and destination addresses. The Ethernet layer, the lowest layer, represents the transfer of data on the physical network.
The IP layer is above the Ethernet layer; it prepares the data for routing on independent networks. IP uses a 4-byte Internet protocol address (IP address), and data is organized in pieces of information called packets. A packet contains an IP header with source and destination addresses, a protocol type, and a data portion. Although the IP protocol is more complicated than the Ethernet protocol, it is connectionless and unreliable in delivering packets. It doesn't guarantee how or even that the data will be received, but if the data being sent is too large, IP will break it down into smaller units. The IP protocol hides the underlying differences among the different networks from the user.
Although the IP layer provides some flow control, it is not guaranteed to be reliable; that is, the data may not be received in the same order it was sent or it may never get to its destination at all. The TCP protocol provides a reliable end-to-end service and flow of control analogous to making a phone call. Once the connection is made, both sides can communicate with each other, and even if they talk at the same time, the messages are received in the same order they were sent. Programs that use TCP are rlogin, rsh, rcp, and telnet.
UDP is an alternative to TCP. It is used in applications that do not require a continuous connection and are sending short messages periodically with no concern whether some of the data is lost. A UDP datagram is similar to sending a letter in the mail: Each packet has an address, there is no guaranteed delivery time or sequencing, and duplicate packets may be sent.[1] This method prevents programs from hanging when a return is expected. Examples of programs that use this protocol are rwho and ruptime.
[1] Rieken, B., and Weiman, L., Adventures in Unix, Network Applications Programming, John Wiley & Sons, Wiley Professional Computing: New York, 1992, p. 7.