ISO-OSI Model and TCP-IP Stack
In questa pagina 5
The communication system and the protocol
A data exchange between two devices over a transmission medium has three ingredients: a sender, a receiver and a medium (cable, fibre, air). The message does not pass directly: each side has a set of rules, the protocol stack, that turns the message into signals and back.
Between people it is natural: "Hello!" is answered by "Hello!", then a question is asked and the answer awaited. Between computers the same happens, but everything must be fixed in advance: TCP connection request, reply, page request (GET https://www.google.it), file transfer, confirmation (ACK).
Definition (protocol). A protocol is a series of steps, involving two or more parties, designed to accomplish a task. It must be known to all nodes and accepted by all, unambiguous (no room for misunderstanding) and complete (an action is foreseen for every situation).
A protocol specifies three things: the address (how the counterpart is identified), the format of messages and the rules of behaviour (what to do when something happens).
Why layers
A single protocol would have to solve: electrical/optical signals and noise, error detection and recovery, medium access (MAC), message delimitation, routing and fragmentation, flow and congestion control, losses and duplicates, synchronization, data representation, application constraints. It can be done, but at very high cost in development, complexity, energy and delay.
The divide and conquer (layered approach) principle is applied: software is divided into layers, each with clear programming interfaces and responsible for a limited set of problems (one for error control, one for medium access, one for flow control, ...). Each layer encapsulates its own details, so the others need not care.
- Pros: less complexity, isolated changes (change the cable without touching the web browser), each layer handles a class of functions.
- Cons: some efficiency lost (headers, copies), widely compensated.
The ISO/OSI model
ISO (International Organization for Standardization) defined at the end of the 1970s the OSI model (Open System Interconnection), with seven layers, each with its own function and protocol.
| # | Layer | Function | Examples |
|---|---|---|---|
| 7 | Application | user-level processing, high-level APIs | HTTP, FTP, e-mail, Telnet |
| 6 | Presentation | data representation and syntax: character coding, compression, encryption | ISO Presentation |
| 5 | Session | management of continuous exchanges of many messages back and forth (synchronization points and dialogues) | ISO Session |
| 4 | Transport | reliable end-to-end channel between the two ends | TCP, UDP |
| 3 | Network | unreliable delivery across a multi-node network: routing and forwarding | IP, ICMP, routing protocols |
| 2 | Data Link | reliable (in intent) delivery over a single link between adjacent nodes | ARP, ARQ, HDLC, PPP, LLC; MAC: ALOHA, CSMA... |
| 1 | Physical | transport of bits on the medium (unreliable line) | RS232, T1, 802.x |
Layer functions, one by one
Physical (PHY). Turns the 1s and 0s coming from the link layer above into a signal that can travel on the medium (electric current, light pulses, radio waves), and does the opposite at the receiver. Provides bit synchronization (same bit duration and timing for TX and RX). The message has a beginning and an end; what lies between is passed to the link layer.
Data Link (DLL). Delivers a packet from a node to a physically adjacent node over a link: limited to a single hop. It splits into two sublayers: MAC (Medium Access Control), managing the presence of several users on the same medium (avoiding collisions), and LLC (Logical Link Control), doing local flow and error control. MAC addresses are local (valid only on the link), fixed for each network interface card (NIC) and unique worldwide (assigned by the manufacturer). Details: Data Link Layer and FramingThe data link layer (DLL) delivers a frame from a node to an adjacent node over a link. Services: framing, medium access (MAC) with 48-bit MAC addresses, flow control, error detection and correction. It splits into DLC (framing, error and flow control) and MAC (shared medium access). Framing delimits frames with a flag: byte-oriented protocols (8-bit flag, ESC) use byte stuffing, bit-oriented ones (flag 01111110) use bit stuffing, which inserts a 0 after every five consecutive 1s.Data Link Layer and Framing →.
Network. Responsible for host-to-host delivery of datagrams (routing: finding the best path; forwarding: moving data across a multi-node network, multi-hop). While the link layer has a local view, the network layer has a global one. It does no error recovery: data can be lost (unreliable service). Addresses are IP: unique (each address identifies a single Internet connection) and universal (accepted by any host). An IP address identifies a connection, not a device.
Transport. Creates a transparent one-to-one virtual channel between the two communication ends, regardless of topology: offers flow control as if only the two entities existed. Offers reliability: error control, retransmission of corrupted packets, flow control (prevents the sender going faster than the receiver can handle).
Upper layers. Session: management of continuous exchanges with several transmissions back and forth. Presentation: translation of data between network and application (character coding, compression, encryption/decryption). Application: high-level functions and APIs.
Property (MAC and IP addresses, not to be confused). MAC: 48 bits, identifies the device (the card) on the local link and is not routable. IP: identifies the connection and is used for routing; its validity spans several hops. A network-layer packet may travel through many networks; a link-layer frame stays local. Example: IP
131.175.21.1, MACA3:34:45:11:92:F1.
Every address answers a different question. At transport a third address is added, the port: a remote host can run several server programs at once, and the port number says to which process the data must be delivered. The pair IP address + port number is a socket, e.g. <158.108.33.3, 3000> or <113.23.30.0, 80>.
| Address | Layer | Answers the question |
|---|---|---|
| MAC | link | which device? (on the local link) |
| IP | network | which network? (and which connection, globally) |
| port | transport | which process? (on the destination host) |
Layered terminology: PDU, SDU, PCI
An entity of layer offers a service to the entity of layer . The dialogue takes place only between two entities of the same layer (peers), but the real communication goes through the whole stack: down to the medium at the sender and up at the receiver.
Definition (PDU, SDU, PCI). The PDU (Protocol Data Unit) is the data unit exchanged between two entities of the same layer. The PDU of layer becomes the SDU (Service Data Unit) for layer below. Layer does not simply forward it: it adds its own control information, the PCI (Protocol Control Information, the header, sometimes also a trailer), and the result is the new PDU of layer :
Example. The transport layer receives a B message from the application and adds a B TCP header: transport PDU B. The network layer adds a B IP header: B. The link layer adds B of Ethernet header and trailer: B. The physical layer sends bits. Useful ratio (overhead ). The B of Ethernet are B of header (destination MAC , source MAC , type ) plus B of trailer (error check, FCS); the preamble, which only serves receiver synchronization, is not counted. In general, with a payload of bytes and total header bytes, the useful fraction is : low for small messages (for it is , for it is ) and tends to 1 for large ones, since the header has fixed size. Hence data are sent in pieces as large as the MTU allows.
Encapsulation and decapsulation
Definition (encapsulation). At the sender, each layer packs the data of the upper layer together with its own PCI (encapsulation), going down the stack. At the receiver, each layer separates the upper-layer data from its own PCI and passes them up (decapsulation).
Intermediate routers go up only to the network layer: they read the IP header and build a new frame for the next hop (Network Devices - Hub, Switch and RouterDevices that interconnect networks differ by the highest layer of the stack they read. Hub (layer 1): a repeater, regenerates the signal and sends it out of all ports, all stations share the capacity. Bridge and switch (layer 2): read the MAC address and forward only to the right port, learning the table (FDB) from source addresses. Router (layer 3): reads the IP address and joins independent networks (internetwork). Switches and bridges isolate traffic and are plug and play; the router gives optimal routing but must be configured.Network Devices - Hub, Switch and Router →).
The TCP/IP stack
The stack actually used on the Internet is the TCP/IP suite. It has five layers: the session and presentation layers of OSI do not exist as separate layers and their functions are absorbed by the application layer.
| OSI | TCP/IP | Protocols |
|---|---|---|
| Application, Presentation, Session | Application | HTTP, FTP, e-mail, DNS |
| Transport | Transport | TCP, UDP |
| Network | Network (Internet) | IP and auxiliary protocols (ICMP, routing, DHCP) |
| Data Link | Data Link | underlying LAN and WAN technologies (Ethernet, Wi-Fi, PPP) |
| Physical | Physical |
Protocols of the course, by layer: link ARP, ARQ, HDLC, PPP, LLC and, for medium access, ALOHA, slotted ALOHA, CSMA, CSMA/CD, CSMA/CA (and TDMA, FDMA, SDMA, CDMA, OFDMA); network IP, ICMP and routing protocols, with BOOTP/DHCP; transport UDP and TCP; application HTTP, FTP, e-mail. A host has all layers; a router only the first three; a switch the first two; a hub only the physical.
The three addresses of one host: name (giordani.dei.unipd.it, resolved by DNS), IP address (147.162.97.17, network layer) and MAC address (0:0:c:6:13:4a, link layer). The IP-to-MAC mapping is done by ARP.
The following notes descend the stack: Data Link Layer and FramingThe data link layer (DLL) delivers a frame from a node to an adjacent node over a link. Services: framing, medium access (MAC) with 48-bit MAC addresses, flow control, error detection and correction. It splits into DLC (framing, error and flow control) and MAC (shared medium access). Framing delimits frames with a flag: byte-oriented protocols (8-bit flag, ESC) use byte stuffing, bit-oriented ones (flag 01111110) use bit stuffing, which inserts a 0 after every five consecutive 1s.Data Link Layer and Framing →, then the performance of a link in Network Performance AnalysisNetwork performance is measured by traffic metrics (bitrate R0, the link maximum; throughput S <= R0, data delivered successfully; goodput at the application layer), delay (end-to-end d = d_proc + d_queue + d_trans + d_prop with d_trans = L/R and d_prop = d/v; jitter; RTT), pipe capacity (BDP = rate times delay) and reliability (PER, PDR, PLR). The throughput of a path is that of its bottleneck link, the minimum bitrate, remembering that shared links split their capacity.Network Performance Analysis →.
Versione ripasso
Protocol. A series of steps between two or more parties, designed for a task. It must be known to all, unambiguous and complete (an action for every situation). Specifies address, message format and rules of behaviour.
Why layers. A communication needs signals, error detection and recovery, medium access, message delimitation, routing, fragmentation, flow and congestion control, synchronization, data representation. One protocol would be too complex. Divide and conquer: software divided into layers, each with a limited set of problems.
- Pros: less complexity, isolated changes (change the cable without touching the browser).
- Cons: some efficiency lost (headers, copies).
ISO/OSI model, 7 layers.
- Physical: carries bits on the medium (current, light, radio) and provides bit synchronization.
- Data Link: delivers a frame to a physically adjacent node (one hop). Sublayers MAC (medium access, avoids collisions) and LLC (local flow and error control). MAC addresses are local, 48 bit, fixed by the card.
- Network: host-to-host delivery across several nodes (routing to choose the path, forwarding to move data). Unreliable delivery. IP addresses, global.
- Transport: reliable end-to-end channel (TCP, UDP): error control, retransmission, flow control.
- Session: management of continuous exchanges back and forth, with synchronization points.
- Presentation: character coding, compression, encryption.
- Application: high-level functions and APIs (HTTP, FTP, e-mail, Telnet).
PDU, SDU and PCI. The PDU is the unit exchanged between two peer entities of the same layer. The PDU of layer becomes the SDU of layer , which adds its own PCI (header):
- Encapsulation at the sender, going down; decapsulation at the receiver, going up.
- Example: B message, TCP header B, IP B, Ethernet B (header and trailer): B. The physical layer gets bits. Overhead , useful .
TCP/IP stack, 5 layers. Session and presentation do not exist as layers: their functions are in the application layer.
| OSI | TCP/IP | Protocols |
|---|---|---|
| Application, presentation, session | Application | HTTP, FTP, e-mail, DNS |
| Transport | Transport | TCP, UDP |
| Network | Network (Internet) | IP, ICMP, routing, DHCP |
| Data Link | Data Link | Ethernet, Wi-Fi, PPP, ARP |
| Physical | Physical |
- Devices: host with all layers; router up to the network layer (); switch and bridge up to the link (); hub only the physical () (Network Devices - Hub, Switch and RouterDevices that interconnect networks differ by the highest layer of the stack they read. Hub (layer 1): a repeater, regenerates the signal and sends it out of all ports, all stations share the capacity. Bridge and switch (layer 2): read the MAC address and forward only to the right port, learning the table (FDB) from source addresses. Router (layer 3): reads the IP address and joins independent networks (internetwork). Switches and bridges isolate traffic and are plug and play; the router gives optimal routing but must be configured.Network Devices - Hub, Switch and Router →).
- The router reads the IP header and builds a new frame for the next hop.
Addresses of the same host.
- Name (
giordani.dei.unipd.it): resolved by DNS. - IP (
147.162.97.17, network layer): which network, routable across hops. - MAC (
0:0:c:6:13:4a, link layer): which device, only on the local link. IP-to-MAC is done by ARP. - Port (transport layer): which process. IP port is the socket, e.g.
<158.108.33.3, 3000>.
| Address | Layer | Answers the question |
|---|---|---|
| MAC | link | which device, on the local link |
| IP | network | which network or connection, globally |
| port | transport | which process, on the destination host |
Typical mistakes:
- confusing the MAC, which identifies the device and is only local, with the IP, which identifies the connection and is routable;
- saying TCP/IP has seven layers (it has five);
- saying the network layer is reliable (it is not, transport is);
- forgetting that the dialogue is only between peers, while data cross the whole stack.
Teoria collegata
- Client-Server Programming
- Internet Structure, Packet Switching and the TCP-IP Stack
- Network Key Performance Indicators
- Data Link Layer and Framing
- History and Structure of the Internet
- LAN - Ethernet and Wi-Fi
- Network Devices - Hub, Switch and Router
- Network Layer and IPv4 Addressing
- Network Security - Threats and Attacks