The Application Layer

Learn about the purpose of the application layer and the two main protocols that it follows.

The application layer relies on the transport layer for the data transfer and is responsible for defining the syntax and semantics of this data as well as the protocol of exchanges between the two sides.

This is probably the most crowded layer with a vast number of protocols. In this lesson, we will explore two of the protocols that form the foundation of the world wide web, namely: Domain Name System (DNS) protocol and the Hypertext Transfer Protocol (HTTP).

Domain name system

DNS is a system used to map human-friendly names, called domain names, to IP addresses. This is useful because these domain names are easier for humans to remember and use, and they can also be agnostic to the actual network topology of an application, making them a better addressing scheme for applications, unlike IP addresses.

Users of DNS

The users of the DNS system can be classified into two broad categories.

Clients that want to resolve a domain name into an IP address in order to send a data packet, and servers that store and serve this information to clients.

The DNS specifies a protocol, which defines the data structures that the servers can maintain and how clients can request the data they need. For example, one type of record is the so-called A record, which contains the IP address for the associated domain name.

For a client to find the IP address for a specific domain name, they need to send a DNS query message to a DNS server that contains the necessary information, such as the domain name that needs to be resolved and the record type that is requested (A).

The DNS servers form a hierarchy with three basic layers:

  • The root servers
  • The top-level domain servers
  • The authoritative servers

The client needs to know the IP addresses of the root servers, which are published by the Internet Corporation of Assigned Names and Numbers (ICANN) as the official “root zone file”.

Under normal conditions, DNS uses UDP as a transport protocol, and a resolution of a domain name consists of a single UDP request from the client followed by a single UDP reply from the server.

Hypertext Transfer Protocol

HTTP is an application layer protocol for distributed, collaborative, hypermedia information systems. In other words, it can be used for distributing various pieces of information throughout the Internet, where each piece of information can link to a different piece of information.

HTTP also functions as a request-response protocol between clients and servers. For example, the client can be a browser requesting a web page and the server can be a computer hosting this webpage.

HTTP makes use of TCP as the underlying transport layer protocol and uses its own headers to specify the size of a message.

Note: There are many versions of the HTTP protocol, and HTTP/3 uses UDP instead of TCP mostly for performance reasons. However, when talking about HTTP here, we refer to the first version of HTTP for simplicity.

HTTP request and response structure

The following illustration shows the structure of an HTTP request and the associated response.

Request message

The request message consists of the following parts that are separated by <CR><CR><LF><LF> (a carriage return character followed by a line feed character):

  • A request line that contains the request method (for example, GET) and the location of the resource that is requested (for example, /index.html)
  • Some header fields (for example, Host)
  • An empty line
  • An optional message body, populated in case the data needs to be submitted to the server (for example, when a request is made to update data, instead of a request to retrieve data)

Response message

The response message consists of the following parts (again separated by <CR><CR><LF><LF>):

  • A status line that includes the status code and a message, indicating the reason for success or failure (for example, 200 OK)
  • Some header fields (for example, Content-Type)
  • An empty line
  • An optional message body, which is populated when the servers need to send data associated with a resource as part of the response

Get hands-on with 1400+ tech skills courses.