Wiki DE Start in the browser

Wiki › Basics

OSI model and encapsulation

Seven layers that describe every network connection, and why a packet is built like a Russian doll.

Layer
1 bis 7
See an example
See demo

The seven layers

The OSI model divides communication into layers. Each layer solves one task and uses the layer below for it. In class one usually works with five: in everyday networking layers 5 and 6 are part of the application (as in the TCP/IP model).

Every layer has a fixed colour in leyoNET – in the packet list, in single step mode and here in the wiki. The tags show the protocols leyoNET simulates on that layer, in the same colours as in the packet list.

  1. 7ApplicationdataHTTPDNSDHCPDHCPv6SMTPPOP3IMAPSSHRIPRIPngBGPIKEv2
  2. 6Presentationdatapart of the application in TCP/IP
  3. 5Sessiondatapart of the application in TCP/IP
  4. 4Transportsegment / datagramTCPUDP
  5. 3NetworkpacketIPv4IPv6ICMPICMPv6OSPFESP
  6. 2Data linkframeEthernet II802.1QARPSTPLACPPPPPPPoE802.11
  7. 1Physicalbits1000BASE-T1000BASE-SX/LX802.11 PHYDSLDOCSISGPONLTE
LayerNameTaskExamplesDevice
7Applicationservices for programsHTTP, DNS, DHCP, SMTPserver, PC
4Transportconnection between programs (ports)TCP, UDP–
3Networkpath through several networks (IP addresses)IPv4, IPv6, ICMP, OSPFrouter, layer 3 switch
2Data linkframes in the local network (MAC addresses)Ethernet, ARP, VLAN, STPswitch, access point
1Physicalsignals on the mediumcopper, fibre, radio, DSLcable, modem

Encapsulation

When a browser requests a web page, an HTTP request is created (layer 7). TCP puts a header with the ports in front (layer 4), IP a header with source and destination address (layer 3), Ethernet a header with the MAC addresses and the checksum FCS at the end (layer 2). On the cable (layer 1) there are only bits in the end, led by preamble and SFD.

Real frame from the demo “DNS, TCP and HTTP” (no. 36, 158 bytes), exactly as the packet list in leyoNET shows it.

How every header is built field by field is shown in Structure of frames and packets.

On the way, every device only unpacks as far as it needs to: a switch looks up to layer 2 (MAC address), a router up to layer 3 (IP address) and puts a new Ethernet header on for the next network. Only the destination unpacks everything.

Seeing it in leyoNET

The packet list shows every frame by layer, each in its colour. In single step mode frames travel across the cables as coloured dots, and every device visibly unpacks as far as its layer requires. The demo “Default gateway” shows it particularly clearly: the IP addresses stay the same from PC to PC, the MAC addresses change at the router.

How to do it in leyoNET

The same text as in the app’s help (F1 key).

OSI model

Each frame is encoded into real bytes and broken down by layer: application (7) at the top, wire (1) at the bottom. Each layer wraps the one above: HTTP inside TCP, TCP inside IP, IP inside Ethernet. Ethernet adds a header in front and the checksum FCS (CRC-32) at the end; preamble and SFD belong to layer 1.

  • Empty layers are greyed out (e.g. ARP has no layer 3 or 4)
  • Clicking a field highlights its bytes in the hex view
  • Structure per standard below a layer draws its header as in the RFC or IEEE standard, with the values of this frame; point at a field for an explanation
  • Nesting shows how the layers fit inside each other: header, payload and FCS with their lengths
  • Checksums are computed for real

The same with explanations of every field is in the wiki under «Aufbau von Rahmen und Paketen».

See an example

  • Demo “Default gateway” in leyoNETDemo “Default gateway” in leyoNET
    Slow motion This is how it looks in the simulation: every dot is a frame on the cable.
    Default gateway

    Two subnets connected by a router.

    PC 1 sees that the target is in another network and sends the packet to its router. The TTL drops by one.

    Watch live Project file

“Watch live” opens the network in leyoNET, the simulation runs in a loop. In the app you find it under File → Demo networks, with a step-by-step tour.

Practise

  • ★★★★☆ Protocol analysis – Task 3: ARP, DNS and HTTP · 7 goals · Worksheet (German)

In leyoNET under Tools → Exercise catalogue. Every exercise checks itself.

Read on

Found a mistake or have an idea? Source of this page on GitHub.