CodePark/ questions / Network layers & IP
START PRACTICINGPRACTICE
Backend question · OS, networking & Linux › Network layers & IP

Compare the OSI model and the TCP/IP model. Where do Ethernet, IP, TCP, UDP and HTTP fit?

The OSI model has seven layers:

  • physical
  • data link
  • network
  • transport
  • session
  • presentation
  • application

The TCP/IP model has four layers: link, internet, transport and application. The Internet actually runs on TCP/IP. OSI is mostly a shared vocabulary. Real protocols don't separate session and presentation cleanly. So TCP/IP puts them both inside the application layer.

Where common protocols fit:

  • Ethernet and Wi-Fi sit at the link layer (OSI layer 2).
  • IP and ICMP sit at the network or internet layer (layer 3).
  • TCP and UDP are the transport layer (layer 4).
  • HTTP, DNS and SSH are application protocols (layer 7).
  • TLS is usually described as sitting between transport and application.

Engineers use the layer numbers as short names. An L4 load balancer forwards traffic by IP and port only. An L7 load balancer reads the HTTP request, so it can route by path or header.

  • OSI has 7 layers. TCP/IP has 4 layers: link, internet, transport and application.
  • Ethernet is layer 2, IP is layer 3, TCP and UDP are layer 4, and HTTP and DNS are layer 7.
  • TCP/IP merges the OSI session and presentation layers into the application layer.
  • L4 and L7 load balancers are a practical use of the layer numbers.