[Networking] the TCP/IP Model

The Open System Interconnection model (OSI), introduced in the last post, is a seven-layered network structure that groups different protocols/elements into well-defined categories. Idealized as the OSI model is, in reality, we use a different model–the TCP/IP model in implementation.

The TCP/IP model predates the OSI model. While the OSI model is developed based on a predefined architecture, and serves as a more comprehensive framework, the TCP/IP model has clearer/more practical boundaries, because the TCP/IP model is built upon existing protocols, and uses these protocols as boundaries.

In this post, besides introducing the TCP/IP model, we will also look at the principles behind both the TCP/IP and the OSI model, so that we can better understand how they are constructed as so.

TCP/IP (or Internet Protocol Suite)

The official name of TCP/IP is the Internet Protocol Suite. It is a model that includes a set of communication protocols used in computer networks like the Internet. The name TCP/IP comes from the two foundational protocols in this model: the Transmission Control Protocol (TCP) and the Internet Protocol (IP). Like the OSI model, TCP/IP provides end-to-end data communication specifying how data should be packetized, addressed, transmitted, routed, and received. Unlike the OSI model, which has seven abstraction layers, TCP/IP has four layers–the Link layer, the Internet layer, the Transport layer, and the Application layer.

note: according to the RFC 1122, this TCP/IP model has four layers. There are other versions that has five layers, which break the Link layer into Data Link layer and Physical/Hardware layer.

Principles of TCP/IP and the OSI Model

The End-to-End Principle

The end-to-end principle ensures that the Internet who connects the edges retains no state–any specific information on the edges–and focuses instead on the action of connecting. The idea is to separate the data and the function: the maintenance of states and the overall intelligence should be kept within the edges. Each request is considered new because there is no "state" saved in the function. In reality, however, this is hard to realized because of the needs for firewalls, web content caches, etc.

This stateless-ness has an exception in the transport layer, where the connection remains in place until all the packets in a message have been received and reassembled at the destination.

The Robustness Principle

Be conservative in what you send, be liberal in what you accept. –reworded from Jon Postel

The robustness principle, or Postel's law, states that programs that send messages to other machines (or to other programs on the same machine) should conform completely to the specifications, but programs that receive messages should accept non-conformant input as long as the meaning is clear.

RFC 1122 recommends programmers "assume that the network is filled with malevolent entities that will send in packets designed to have the worst possible effect".

In general, an implementation must be conservative in its sending behavior, and liberal in its receiving behavoir. It must be careful to send well-formed datagrams, but must accept any datagam that it can interpret (not object to technical errors where the meaning is still clear.)

Encapsulation

Encapsulation refers to the act that takes data from one protocol to another, with a process of translation, so the data can continue across a network. In reality, it's accomplished by adding headers & trailers around the data.

In the OSI model, each layer builds a protocol data unit (PDU). Each layer provides a service to the layer above it (adjacent-layer interaction), while at the same time each layer communicates with its corresponding layer on the receiving node (same-layer interaction).

Now let's look at the four layers in the TCP/IP model.

Application Layer

corresponding OSI layers: Application + Presentation + Session related protocols: HTTP/HTTPS, FTP, Telnet, DNS data format: data

TCP/IP model corresponds to the top three layers (application, presentation, session) in the OSI model. It does not consider the specifics of formatting and presenting data: such functions are the realm of libraries and application programming interfaces.

In this layer, applications, or processes, create and transport data to other applications/processes on the same/another host. Processes are addressed via ports, which represent services.

Application layer protocols do not care about the layers below. They only know (and expect) that these layers provide a stable connection across which to communicate. In reality, though, the applications are usually aware of some key qualities of the transport layer connection, such as the endpoint IP addresses and port numbers.

Application layer protocols are often associated with particular client-server applications. Some port numbers are reserved (by the Internet Assigned Numbers Authority) for common services, like port 80 for the HyperText Transfer Protocol server and port 23 for the Telnet server. Clients connecting to a service usually use ephemeral ports, that is, the port numbers are assigned at random and last only for the duration of the transaction in the application.

Transport Layer

corresponding OSI layers: Transport related protocols: TCP, UDP data format: segments

The transport layer perform host-to-host communications, either on local network or remote network separated by routers. Two important protocols here are TCP: Transmission Control Protocol and UDP: User Datagram Protocol. They are explained in detail in the last post. The biggest difference between them is that UDP provides unreliable (connectionless) but fast data transmission, while TCP provides reliable (connection-oriented) but slower transmission.

Internet Layer

corresponding OSI layers: Networking related protocols: IPv4, IPv6 data format: packets

In the Internet layer, datagrams are exchanged across network boundaries, based on the Internet Protocol (IP). The Internet Protocol performs two basic functions: host addressing and identification. Its routing function (sending packets of data from source to destination by forwarding them to the next network router closer to the final destination) enables internetworking, and essentially establishes the Internet.

IP address

An IP address is a 32-bit number that uniquely identifies a host (computer or other device, such as a printer or router) on a TCP/IP network. A typical IP address looks like this: 192.168.123.132. The Internet Protocol can deliver packets from the source host to the destination host solely based on the IP addresses.

corresponding OSI layers: Datalink + Physical related protocols: Ethernet, Frame Relay data format: frames

The link layer is the lowest component layer of the Internet protocols, as TCP/IP is designed to be hardware independent. That is, TCP/IP assumes a working network infrastructure that can deliver media level frames on the link, and can be implemented on top of any hardware networking technology.

The link layer has a group of communication protocols that only operate on a link a host is physically connected to. It is responsible for physical addressing and access control at MAC sub layer.

Now that we have seen both the OSI model and the TCP/IP model, surely we'd know better how to debug if any (unfortunate) network-related situations arise.


  • Find me at