Introduction to the application layer
The application layer is the top layer of the TCP/IP stack.
This layer does not move bits across cables or handle the delivery of data.
Instead, it specifies the protocols that applications use to communicate over the network and the services they offer, such as web browsing and domain name resolution.
Network application architectures
Predominant architectural paradigms:
- client-server architecture
- a server handles requests from many other hosts
- peer-to-peer (P2P) architecture
- the application exploits direct communication between pairs of intermittently connected hosts (peers)
Processes
Programs use processes to communicate with each other:
- interprocess communication is how processes running on the same end system communicate
- exchanging messages across the computer network is how processes running on different hosts (with different OS) communicate
In a communication session between a pair of processes:
- the client is the process that initiates the communication (it initially contacts the other process at the beginning of the session)
- the server is the process that waits to be contacted to begin the session
Sockets
A socket is an operating-system-provided software abstraction that represents an endpoint for communication.
It allows a process to send and receive data through the networking stack.
A process communicates by creating sockets and using operations such as binding, connecting, sending, receiving, reading, and writing.
A socket is like a door through which data enters and leaves a process:
- the process is analogous to a house
- the socket is analogous to its door
The socket API provides the interface between an application and the operating system's networking stack. Through this API, applications can use transport-layer protocols.
The application developer:
- has control of everything on the application-layer side of the socket
- but has little control of the transport-layer side of the socket:
- he has only the choice of a transport-layer protocol (TCP or UDP)
- and the ability to fix a few transport-layer parameters (such as maximum buffer and maximum segment sizes)
Application-layer protocols
An application-layer protocol defines how processes on different devices send messages to each other:
- the types of messages exchanged (e.g. request and response messages)
- the syntax of the various message types, such as the fields in the message and how the fields are delineated
- the semantics of the fields, that is, the meaning of the information in the fields
- the rules for determining when and how a process sends messages and responds to messages
Some application-layer protocols are specified in RFCs and are therefore in the public domain (e.g., HTTP).
Many other application-layer protocols are proprietary and intentionally not available in the public domain (e.g., WhatsApp, Discord, Microsoft Teams, Signal).