Network Layers

What are service layers?

In networking, a service layer offers defined services to the layer above it and relies on the layer below. Here is how that works in OSI and TCP/IP models.

On this page
  1. The short answer
  2. Services and protocols
  3. Following a message down the stack
  4. Service layers in software design
  5. Checking a service layer by layer

The short answer

In networking, a service layer is one layer of a layered model. It provides a defined set of services to the layer directly above it, and it uses the services of the layer directly below it. The OSI and TCP/IP models are built this way, so each layer can change its internal workings without the other layers needing to change.

Services and protocols

Two terms are used together:

  • A service is what a layer offers to the layer above it. It describes the functions and the interface, not how they are carried out.
  • A protocol is the set of rules a layer uses with its matching layer on another machine to provide that service.

Take TCP as an example. TCP offers reliable, ordered delivery to the programs above it. It does this with its own rules between two TCP endpoints, including how lost data is resent. The application above does not need to know how retransmission works.

In the OSI reference model, the handoff between layers happens at service access points, the places where one layer passes data to the layer above it.

Following a message down the stack

When you send an email, the message passes down through the layers on the sending machine. Each layer adds its own header, and sometimes a trailer, around the data it received from above. At the application layer, SMTP hands the message to TCP. TCP hands its segments to IP, and IP hands its packets to the link layer. On the receiving machine, each layer reads and removes its own header and passes the rest upward.

Service layers in software design

The phrase has another common meaning. In application architecture, a service layer is the part of a program that holds business logic between the user interface and the code that reads and writes data. That is a software design pattern, not a networking layer. If your question came from a developer’s architecture diagram, the answer is different from the networking meaning described above.

Checking a service layer by layer

Testing from the bottom up is a practical way to find which layer is failing.

Start with the network layer. Ping a public address that usually answers, such as 1.1.1.1:

ping -c 4 1.1.1.1

Next, test the transport layer by checking whether a TCP port accepts a connection. The nc command comes from the netcat package, which may need to be installed:

nc -vz example.com 443

Then test the application layer by requesting the headers from the web server:

curl -I https://example.com

On Windows, PowerShell can run the transport-layer check with a built-in command:

Test-NetConnection -ComputerName example.com -Port 443

The output includes TcpTestSucceeded, which is True when the port accepts a connection.

If ping fails but the port test succeeds, a firewall may be blocking ICMP, the protocol ping uses, while the service itself is reachable. If the port test fails, look at the firewall, the service’s listening state and the server’s routing before you blame the application.

The complete guide to network layers

Services Provided by the Application Layer
Read the guide

Keep exploring

Guides from other topics

All topics →