Network Models and Protocols
OSI Reference Model
The Open Systems Interconnection (OSI) model is a conceptual framework that standardizes the functions of a telecommunication or computing system in terms of abstraction layers. It was developed by the International Organization for Standardization (ISO). The OSI model consists of seven layers, each performing a specific function to enable communication between different systems. It provides a structured way to understand how data is transmitted across a network.
Layer 7: Application Layer
This is the layer closest to the end user. It provides network services directly to the end-user applications. It handles issues such as network transparency, resource sharing, and remote synchronization. Examples of protocols at this layer include HTTP (Hypertext Transfer Protocol), FTP (File Transfer Protocol), SMTP (Simple Mail Transfer Protocol), and DNS (Domain Name System).
Layer 6: Presentation Layer
This layer is responsible for translating, encrypting, and compressing data. It ensures that data sent from the Application layer of one system can be understood by the Application layer of another system. Common functions include data encryption/decryption, character code translation (e.g., ASCII to EBCDIC), and data compression.
Layer 5: Session Layer
The Session layer establishes, manages, and terminates connections (sessions) between applications. It controls the dialogue between two communicating hosts. It handles tasks like dialogue control (determining whether communication is two-way or half-duplex) and synchronization (adding checkpoints to a data stream so that if a failure occurs, only the data after the last checkpoint needs to be retransmitted).
Layer 4: Transport Layer
This layer provides reliable or unreliable data transfer services from the system to the network. It is responsible for end-to-end communication and data integrity. Key functions include segmentation and reassembly of data, connection control, error control, and flow control. The two most common protocols at this layer are TCP (Transmission Control Protocol) for reliable, connection-oriented service and UDP (User Datagram Protocol) for unreliable, connectionless service.
Layer 3: Network Layer
The Network layer is responsible for logical addressing (IP addresses) and routing of data packets from source to destination across multiple networks. It determines the best path for data to travel across the network. Key functions include logical addressing, routing, and packet forwarding. IP (Internet Protocol) is the primary protocol at this layer.
Layer 2: Data Link Layer
This layer provides node-to-node data transfer (between two directly connected nodes). It handles physical addressing (MAC addresses), error detection and correction on the physical link, and flow control. It defines how data is formatted into frames. Examples of protocols include Ethernet and PPP (Point-to-Point Protocol). It is often divided into two sub-layers: Logical Link Control (LLC) and Media Access Control (MAC).
Layer 1: Physical Layer
This layer defines the physical and electrical specifications for devices. It is responsible for the actual transmission and reception of raw bit streams over a physical medium. This includes specifications for cables, connectors, voltages, data rates, and transmission modes (simplex, half-duplex, full-duplex). Examples include Ethernet cables, fiber optic cables, and wireless radio frequencies.
To remember the order of the OSI layers from top to bottom (Application to Physical), you can use this mnemonic: All People Seem To Need Data Processing.
For the order from bottom to top (Physical to Application): Please Do Not Throw Sausage Pizza Away.
TCP/IP Suite
The TCP/IP (Transmission Control Protocol/Internet Protocol) suite is a set of communication protocols used in the Internet and similar computer networks. It is the de facto standard for internetworking. Unlike the OSI model, which is a conceptual model, TCP/IP is a practical implementation that evolved over time. It is often described as a four-layer model, though sometimes a five-layer model is used for better comparison with OSI.
TCP/IP Four-Layer Model
The four-layer TCP/IP model is a more practical representation of how the internet works.
Application Layer
This layer combines the functions of the OSI Application, Presentation, and Session layers. It provides protocols that support user applications. Examples include HTTP, FTP, SMTP, DNS, Telnet, and SNMP.
Transport Layer
This layer corresponds to the OSI Transport layer. Its primary goal is to provide end-to-end communication services. The two main protocols are:
- TCP (Transmission Control Protocol): Provides reliable, ordered, and error-checked delivery of a stream of octets (bytes). It is connection-oriented.
- UDP (User Datagram Protocol): Provides a simpler, connectionless datagram service. It is faster but less reliable than TCP, as it does not guarantee delivery or order.
Internet Layer
This layer corresponds to the OSI Network layer. Its main function is to move packets from source to destination across one or more networks. The primary protocol is IP (Internet Protocol), which handles logical addressing and routing. Other protocols in this layer include ICMP (Internet Control Message Protocol) and ARP (Address Resolution Protocol).
Network Access Layer (or Link Layer)
This layer combines the functions of the OSI Physical and Data Link layers. It is concerned with all the aspects of physically transmitting the data, including hardware addressing (MAC addresses), the physical medium, and the protocols used to transmit data over that medium. Examples include Ethernet, Wi-Fi, and PPP.
While the OSI model is a theoretical reference, the TCP/IP model is the practical foundation of the internet. Many network functions are combined in TCP/IP layers compared to the more granular OSI layers.
| OSI Layer | TCP/IP Layer |
|---|---|
| Application | Application |
| Presentation | |
| Session | |
| Transport | Transport |
| Network | Internet |
| Data Link | Network Access |
| Physical |
Switching Techniques
Switching is the process of connecting different network segments to allow communication between devices on those segments. In modern networks, particularly local area networks (LANs), switches are used to forward data frames. There are several switching techniques:
Circuit Switching
In circuit switching, a dedicated physical path (a circuit) is established between the sender and receiver before data transmission begins. This path remains reserved for the entire duration of the communication session, even if no data is being sent. Once the communication is complete, the circuit is released.
- Analogy: Like making a direct phone call; the line is dedicated to you until you hang up.
- Pros: Guaranteed bandwidth, low latency, no data collisions.
- Cons: Inefficient use of network resources (line is busy even if idle), setup time can be long.
- Example: Traditional telephone networks (PSTN).
Packet Switching
Packet switching is the dominant technique used in data networks like the internet. Data is broken down into smaller units called packets. Each packet contains a portion of the data along with header information (source address, destination address, sequence number, etc.). These packets are then routed independently across the network and reassembled at the destination.
- Analogy: Sending a letter through the postal service; the letter is broken into pages (packets), each addressed, and they might take different routes to reach the destination.
- Types:
- Datagram Switching: Each packet is treated independently and routed based on its destination address. The network does not maintain connection information. Packets may arrive out of order. This is how IP works.
- Virtual Circuit Switching: A logical connection (virtual circuit) is established between the sender and receiver before data transfer. All packets for that connection follow the same path. This provides some benefits of circuit switching (like ordered delivery) while using packet switching principles. Examples include Frame Relay and ATM.
- Pros: Efficient use of network bandwidth, robust (if one path fails, packets can be rerouted), cost-effective.
- Cons: Variable delay (jitter), potential for packet loss, requires reassembly and error checking at the destination.
Message Switching
This is an older technique where an entire message is sent from source to destination. Unlike packet switching, the message is not broken down into smaller packets. Each message is stored at intermediate nodes (routers or switches) and then forwarded to the next node. This is a store-and-forward technique.
- Pros: Can handle messages of varying lengths efficiently.
- Cons: High latency due to storage and forwarding at each hop, not commonly used in modern data networks.
- Example: Early email systems, telegraph systems.
The choice of switching technique impacts network performance, efficiency, and cost. Packet switching is the foundation of the internet due to its flexibility and efficient resource utilization.
Addressing
Addressing is crucial for identifying devices and locations on a network so that data can be sent to the correct destination. Different layers of network models use different types of addresses.
Physical Addressing (MAC Address)
A Media Access Control (MAC) address is a unique hardware identifier assigned to network interface controllers (NICs) by the manufacturer. It operates at the Data Link Layer (Layer 2) of the OSI model.
- Format: Typically a 48-bit (6-byte) hexadecimal number, written as 12 hexadecimal digits separated by colons or hyphens (e.g., 00:1A:2B:3C:4D:5E).
- Uniqueness: The first 24 bits (Organizationally Unique Identifier - OUI) identify the manufacturer, and the last 24 bits are assigned by the manufacturer to uniquely identify the device.
- Purpose: Used for local network communication (within a single network segment or LAN). Switches use MAC addresses to forward frames to the correct device on the local network.
Logical Addressing (IP Address)
An Internet Protocol (IP) address is a numerical label assigned to each device connected to a computer network that uses the Internet Protocol for communication. It operates at the Network Layer (Layer 3) of the OSI model. IP addresses are used for routing packets across different networks (internetworking).
- IPv4: A 32-bit address, typically represented in dotted-decimal notation (e.g., 192.168.1.1). It has a limited number of addresses (about 4.3 billion).
- IPv6: A 128-bit address, represented in hexadecimal notation separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334). Designed to overcome the limitations of IPv4 and provide a much larger address space.
- Purpose: Used to identify a device and its network globally, enabling end-to-end communication across the internet. Routers use IP addresses to determine the best path for packets.
Port Addressing
Port addresses are used at the Transport Layer (Layer 4) to identify specific applications or services running on a host. When data arrives at a host, the port number tells the operating system which application should receive that data.
- Format: A 16-bit number (0 to 65535).
- Types of Ports:
- Well-Known Ports (0-1023): Reserved for standard services like HTTP (port 80), FTP (port 21), SMTP (port 25), DNS (port 53).
- Registered Ports (1024-49151): Can be registered with IANA (Internet Assigned Numbers Authority) for specific applications.
- Dynamic/Private Ports (49152-65535): Used for temporary or private client-side connections.
- Purpose: Allows a single host with a single IP address to run multiple network applications simultaneously and deliver data to the correct one.
Other Addresses
- Physical Addresses (Ethernet, Wi-Fi): MAC Addresses.
- Logical Addresses (Internet): IP Addresses (IPv4, IPv6).
- Port Addresses (Transport): TCP/UDP Port Numbers.
- Application-Specific Addresses: Such as URLs (Uniform Resource Locators) used in web browsing, which combine protocol, domain name, and path.
Think of it like sending a package:
- MAC Address: The specific house number on a street (local delivery).
- IP Address: The street address and city (getting the package to the right neighborhood/network).
- Port Number: The name of the person or department within the house/building (delivering to the right application).
Ports
Ports are a fundamental concept in network communication, particularly at the Transport Layer. They act as endpoints for communication, allowing multiple applications on a single device to share the network connection. A port number, combined with an IP address, forms a socket, which is a unique endpoint for network communication.
How Ports Work
When a client application wants to communicate with a server application, it needs to know the server's IP address and the port number the server application is listening on. The client uses a dynamically assigned port number for its end of the connection, while the server listens on a well-known or registered port.
For example, when you browse a website, your browser (client) sends a request to the web server's IP address on port 80 (for HTTP) or port 443 (for HTTPS). Your browser uses a temporary, high-numbered port (e.g., 50000) for its source port. The server receives the request, processes it, and sends the response back to your browser's IP address and the source port (50000).
Well-Known Ports
These ports are assigned by IANA and are used by popular network services. They are standardized and generally require administrator privileges to use on the server side.
| Port Number | Protocol | Service |
|---|---|---|
| 20, 21 | TCP | FTP (File Transfer Protocol) |
| 22 | TCP | SSH (Secure Shell) |
| 23 | TCP | Telnet |
| 25 | TCP | SMTP (Simple Mail Transfer Protocol) |
| 53 | TCP/UDP | DNS (Domain Name System) |
| 67, 68 | UDP | DHCP (Dynamic Host Configuration Protocol) |
| 80 | TCP | HTTP (Hypertext Transfer Protocol) |
| 110 | TCP | POP3 (Post Office Protocol version 3) |
| 143 | TCP | IMAP (Internet Message Access Protocol) |
| 443 | TCP | HTTPS (HTTP Secure) |
| 3389 | TCP | RDP (Remote Desktop Protocol) |
Registered Ports
These ports are used by specific applications and services that are not part of the standard internet protocols. Any company or developer can register a port number for their application with IANA. Examples include database services like MySQL (port 3306) or Oracle (port 1521).
Dynamic/Private Ports
These ports are used for ephemeral (short-lived) connections. When a client initiates a connection to a server, it often picks a random port from this range to use as its source port. This avoids conflicts with well-known or registered services.
A socket is the combination of an IP address and a port number. It uniquely identifies one end of a communication link. For example, 192.168.1.100:80 represents a socket on the web server listening for HTTP requests.