Computer Networks
Subject 1 of 10 · Exact transcription of the original notes, Chapters 1 to 9.
1. Network Basics
1.1 OSI Reference Model
Overview
This content appears to be just a chapter divider page with minimal information. Since there's no substantial technical content to enhance, here's a brief overview of what this chapter covers: Chapter 1: ISO/OSI Stack and LAN Technologies This chapter covers fundamental networking concepts including:
- ISO/OSI 7-layer model - Standard framework for network communication
- Ethernet - Most common LAN technology using CSMA/CD
- Token Ring - Ring-based LAN with token-passing protocol
These topics form the foundation for understanding how data moves through networks, from physical transmission to application-level communication. Key focus areas:
- Layer functions and interactions in the OSI model
- Ethernet frame structure and collision handling
- Token Ring operation and performance characteristics
- Comparison between different LAN technologies
OSI Model
The OSI (Open Systems Interconnection) model is a 7-layer framework developed by ISO in 1984 for network communication design. Purpose: Standardizes how different network devices and protocols communicate by dividing complex networking functions into manageable layers. Layer Structure: Each layer provides services to the layer above and uses services from the layer below.
| Layer | Name | Function |
|---|---|---|
| 7 | Application | User interface, network services |
| 6 | Presentation | Data formatting, encryption |
| 5 | Session | Connection management |
| 4 | Transport | Reliable data transfer |
| 3 | Network | Routing, addressing |
| 2 | Data Link | Frame formatting, error detection |
| 1 | Physical | Electrical signals, hardware |
Layer Categories:
- Upper Layers (5-7): Handle user-oriented functions like data formatting and application interfaces
- Lower Layers (1-4): Handle network-oriented functions like routing and physical transmission
Key Benefit: Enables interoperability between equipment from different manufacturers by providing common design standards. Remember: Data flows down the stack when sending (7 → 1) and up the stack when receiving (1 → 7).
1.2 Network Topologies
Types of Infrastructure Mode
Wireless networks are classified based on their infrastructure requirements and communication patterns:
Infrastructure-Based Networks
Single-hop Infrastructure
- Uses a central base station connected to the wired network
- All wireless devices communicate directly with the base station in one hop
- No device-to-device communication - all traffic goes through the base station
- Example: Traditional Wi-Fi access point where laptops connect directly to the router
Multi-hop Infrastructure
- Base station still connects to the wired network
- Some wireless nodes act as relays to extend coverage
- Distant devices route through intermediate nodes to reach the base station
- Example: Wireless mesh network where some nodes forward traffic for others
Ad Hoc Networks
Infrastructure-free Communication
- No central base station or wired backbone
- Wireless devices communicate directly with each other
- Each node can act as both client and router
- Network forms spontaneously when devices come within range
Key characteristics:
- Self-organizing and self-healing
- Dynamic topology as nodes join/leave
- Distributed routing protocols required
- Example: Bluetooth device pairing, emergency response networks
Remember: Infrastructure mode = centralized control, Ad hoc = peer-to-peer communication.
2. Physical Layer
2.1 Transmission Media (Guided, Unguided)
Physical Layer
The Physical Layer operates at the lowest level of the OSI model, handling the actual transmission of raw bits across physical media.
Primary Functions:
- Converts digital bits into electrical, optical, or radio signals
- Manages the physical connection between network devices
- Controls how data moves through cables, wireless channels, or fiber optics
Key Specifications:
- Electrical: Voltage levels (+V for binary 1, 0V for binary 0)
- Mechanical: Connector types, pin configurations, cable specifications
- Timing: Signal duration, synchronization between sender and receiver
- Functional: Data transmission rates, maximum cable distances
Signal Characteristics:
- Defines how long each bit should be transmitted
- Sets voltage thresholds for distinguishing between 0 and 1
- Specifies signal encoding methods (NRZ, Manchester, differential)
Physical Media Examples:
- Copper cables (twisted pair, coaxial)
- Fiber optic cables (single-mode, multi-mode)
- Wireless frequencies (2.4 GHz, 5 GHz bands)
Note: The Physical Layer doesn't understand data meaning - it only knows how to push bits from one end to another. Error detection and correction happen at higher layers.
3. Data Link Layer
3.1 Framing
Data Link Layer
The Data Link Layer (Layer 2) manages reliable transmission of data frames between directly connected nodes.
Primary Functions:
- Frame Formation: Converts packets from Network Layer into frames with headers and trailers
- Error Detection: Adds checksums to detect transmission errors
- Flow Control: Manages data transmission rate between sender and receiver
- Access Control: Coordinates shared medium access in multi-node networks
Key Responsibilities:
- Encapsulates network packets into frames with addressing information
- Provides node-to-node delivery across a single link
- Handles retransmission of corrupted or lost frames
- Manages MAC (Media Access Control) addresses for local identification
Frame Structure:
Header + Data Payload + Trailer
The header contains source/destination MAC addresses and control information. The trailer typically includes error detection codes like CRC. Example: When your computer sends data to a router, the Data Link Layer adds Ethernet headers with MAC addresses, ensuring the frame reaches the correct device on the local network segment. Note: This layer only handles hop-to-hop delivery - getting data from one directly connected device to the next. End-to-end delivery across multiple hops is handled by higher layers.
Framing and Error Detection
The data link layer handles frame transmission through three key steps:
Frame Creation
Break the continuous bit stream from the network layer into discrete frames. Each frame contains:
- Header with control information
- Data payload
- Trailer with error detection codes
Error Detection
Compute error-detection codes for each frame using methods like:
- Checksum: Simple addition-based verification
- CRC (Cyclic Redundancy Check): Polynomial division for robust detection
- Parity bits: Single-bit error detection
Frame Transmission
Send each frame individually across the physical medium. The receiving end:
- Extracts frames from the bit stream
- Verifies integrity using the error detection code
- Requests retransmission if errors are detected
Example: Ethernet frame structure
- Preamble (8 bytes) for synchronization
- Header (14 bytes) with source/destination addresses
- Data (46-1500 bytes) actual payload
- CRC (4 bytes) for error detection
Remember: Framing solves the fundamental problem of where one message ends and another begins in a continuous bit stream.
Ethernet (IEEE 802.3)
Ethernet (IEEE 802.3) is a widely used LAN technology that defines both physical and data link layer specifications.
Key Characteristics:
- Connectionless: No connection establishment required before data transmission
- Best-effort delivery: No acknowledgments, flow control, or error recovery at this layer
- Bus topology: Originally designed for shared medium access
- CSMA/CD: Uses Carrier Sense Multiple Access with Collision Detection for medium access
Frame Structure
Ethernet frames follow a standardized format for data transmission:
| Field | Preamble | SFD | DA | SA | Length/Type | Data | CRC |
|---|---|---|---|---|---|---|---|
| Size (bytes) | 7 | 1 | 6 | 6 | 2 | 46-1500 | 4 |
| Content | 1010...10 shown as "1010...10" | 10101011 |
Field descriptions:
- Preamble: Synchronization pattern for receiver clock recovery
- SFD: Start Frame Delimiter marks actual frame beginning
- DA/SA: Destination and Source MAC addresses (48-bit each)
- Length: Size of data field in bytes
- Data: Actual payload (padded to minimum 46 bytes if needed)
- CRC: 32-bit error detection code
Frame Size Limits
Minimum frame size: 64 bytes total
6 + 6 + 2 + 46 + 4 = 64 bytes
Maximum frame size: 1518 bytes total
6 + 6 + 2 + 1500 + 4 = 1518 bytes
The minimum ensures collision detection works properly across maximum cable length.
CSMA/CD Performance
Collision detection timing: Maximum collision detection time equals twice the propagation delay across the network.
Slot time = 2 × Propagation delay
Network utilization depends on the ratio of transmission time to propagation delay:
η = 1 / (1 + 5.44a)
- d: Cable length, v: Signal propagation speed
- L: Frame length in bits, B: Bandwidth in bps
Key insight: Longer frames improve efficiency by reducing the relative impact of collision overhead.
Collision Handling
When n stations compete for access, the probability that exactly one station successfully transmits is:
P_success = nP(1 - P)^(n-1)
where P is the probability that any given station attempts transmission. Contention period: Average time spent resolving collisions before successful transmission:
Contention period = x × 2 × (d/v)
where x = e (≈ 2.718) represents the expected number of collision slots. Note: Modern Ethernet uses switches and full-duplex operation, eliminating collisions in most deployments. CSMA/CD remains relevant for understanding shared medium behavior and legacy installations.
ARP (Address Resolution Protocol)
Address Resolution Protocol (ARP) maps IP addresses to MAC addresses when devices need to communicate on the same network.
ARP Process
When ARP is needed: A device knows the destination IP address but needs the corresponding MAC address to send frames at the data link layer. ARP Request: Broadcast message containing:
- Sender's IP and MAC addresses
- Target IP address (MAC unknown)
ARP Reply: Unicast response containing:
- Target's IP and MAC addresses
- Sent directly back to the requesting device
ARP Caching
Devices store ARP mappings in cache memory for 20-30 minutes to avoid repeated requests for frequently contacted destinations. Cache lookup: Before sending an ARP request, the system first checks its local ARP cache for existing mappings. Benefits: Reduces network traffic since multiple packets to the same destination don't require separate ARP requests.
ARP Encapsulation
ARP packets are encapsulated directly into Ethernet frames with a special type field indicating ARP content (no IP header needed).
ARP Use Cases
- Host-to-host (same network): Direct communication between devices on the same subnet
- Host-to-host (different networks): Host needs MAC address of default gateway router
- Router forwarding: Router needs MAC address of next-hop router from routing table
- Router-to-host: Router delivering packet to final destination on directly connected network
Reverse ARP (RARP)
Purpose: Discovers IP address when only MAC address is known (typically for diskless workstations). Process:
- Client broadcasts RARP request with its MAC address
- RARP server responds with corresponding IP address
- Requires dedicated RARP server on each network segment
Limitation: RARP broadcasts don't cross network boundaries, requiring a RARP server on every subnet. This scalability issue led to RARP being largely replaced by DHCP. Remember: ARP goes from logical (IP) to physical (MAC), while RARP goes from physical (MAC) to logical (IP).
3.2 Stop-and-Wait ARQ
Stop and Wait ARQ
Stop and Wait ARQ sends only one frame at a time, waiting for acknowledgment before transmitting the next frame. This leads to poor link utilization.
Efficiency Formula:
η = 1 / (1 + 2a)
where a = T_propagation / T_transmission is the ratio of propagation delay to transmission time. Derivation:
- Transmission time: T_t = L / B (frame length ÷ bandwidth)
- Total cycle time: T_t + RTT
- Efficiency: T_t / (T_t + RTT) = 1 / (1 + 2a)
Key Characteristics:
- Closed-loop flow control protocol
- Window size = 1 (special case of Sliding Window Protocol)
- Positive ACKs are numbered (sequence numbers)
- Negative ACKs (NAKs) are not numbered
- Throughput = 1 packet per RTT
Performance Impact: When a is large (long distance or high bandwidth), efficiency drops significantly. For satellite links where a is very large , efficiency can be less than 1%. Example: If propagation delay = 10ms and transmission time = 1ms, then a = 10 and η = 1/21 ≈ 4.7% Remember: Stop and Wait is simple but inefficient for high bandwidth-delay product networks.
3.3 Go-Back-N ARQ
Go-Back-N (GBN) ARQ
Go-Back-N (GBN) is a sliding window ARQ protocol where the receiver accepts frames only in order.
Window Sizes:
- Receiver window size: W_R = 1 (accepts only next expected frame)
- Sender window size: W_S = 2^k - 1, where k = bits allocated for sequence numbers
Efficiency Formula:
Efficiency = (2^k - 1) / (1 + 2a)
where:
- T_transmission = time to transmit one frame
- RTT = round-trip time for acknowledgment
Key Constraints:
- Total window sizes: W_S + W_R ≤ 2^k (available sequence numbers)
- Since W_R = 1: W_S ≤ 2^k - 1
Protocol Characteristics:
- Uses cumulative acknowledgments - ACK(n) confirms all frames up to n
- Supports piggybacking - data and ACK in same frame
- Conservative approach - discards out-of-order frames at receiver
Operation:
- Sender transmits frames within window
- On timeout/NAK, retransmits from error point onwards
- Receiver accepts only in-sequence frames, discards others
- ACK confirms highest correctly received frame
Note: Called "conservative" because receiver doesn't buffer out-of-order frames, requiring retransmission of correctly received but out-of-sequence data.
3.4 Selective Repeat ARQ
Selective Repeat (SR)
Selective Repeat (SR) is a sliding window protocol that allows out-of-order packet acceptance for better efficiency.
Window Sizes:
W_S = W_R = N / 2
where N is the maximum sequence number space (2^k for k-bit sequence numbers). Both sender and receiver maintain equal window sizes to prevent sequence number confusion.
Key Features:
- Uses independent acknowledgments (each packet ACKed individually)
- Accepts packets out of order at receiver
- Supports piggybacking for bidirectional data flow
- Retransmits only the specific packets that are lost or corrupted
Efficiency Formula:
Efficiency = 2^(k-1) × (T_trans / (T_trans + RTT))
This accounts for the maximum usable window size and the ratio of transmission time to total round trip cycle.
Throughput with Piggybacking:
Throughput = (2 × Packet Size) / RTT
Bidirectional communication doubles effective throughput compared to simplex transmission.
Timing Parameters:
- RTT (Round Trip Time): Minimum time to receive acknowledgment = 2 × Propagation Delay
- Timeout: Maximum waiting time before retransmission (typically set to RTT + margin)
Example: With 3-bit sequence numbers (k = 3), N = 8, so W_S = W_R = 4. This prevents the receiver from confusing new packets with retransmissions.
3.5 Sliding Window Protocol
Flow Control
Flow control manages the rate of data transmission between sender and receiver to prevent buffer overflow and ensure reliable communication. Purpose: Prevents fast senders from overwhelming slow receivers by regulating transmission speed.
Two Main Approaches:
1. Stop-and-Wait Protocol
- Sender transmits one frame and waits for acknowledgment
- Only sends next frame after receiving ACK for current frame
- Simple but inefficient due to idle waiting time
- Often combined with error control (Stop-and-Wait ARQ)
2. Sliding Window Protocol (SWP)
- Sender can transmit multiple frames before receiving acknowledgments
- Uses a "window" of frames that can be sent without waiting
- Window slides forward as ACKs are received
- Much more efficient than stop-and-wait
Key difference: Stop-and-wait sends one frame at a time, while sliding window allows multiple outstanding frames, improving channel utilization. Note: Flow control is separate from error control, though they're often implemented together in protocols like ARQ (Automatic Repeat Request).
4. MAC Sublayer
4.1 CSMA/CA
Wireless IEEE 802.11
Wireless Network Components
A wireless network consists of three key elements that enable mobile communication:
Wireless Hosts
Mobile devices (laptops, smartphones, tablets) that run applications and need network connectivity. Unlike wired networks where hosts connect via cables, wireless hosts communicate through radio signals.
Wireless Links
Radio communication channels that connect wireless hosts to the network infrastructure. Two connection types:
- Host to base station (infrastructure mode)
- Host to host directly (ad-hoc mode)
Base Station
Central coordination point that manages wireless communication in a coverage area. Functions include:
- Forwarding packets between wireless hosts and the wired network
- Managing host associations and handoffs
- Controlling access to the wireless medium
Example: In IEEE 802.11 networks, the base station is called an Access Point (AP). When your laptop connects to WiFi, it associates with an AP that bridges your wireless traffic to the wired network infrastructure. Remember: Base stations act as translators between the wireless and wired worlds, handling the complexity of radio communication while presenting a standard network interface.
Two Types of Mode
Infrastructure Mode: All network services are provided through a centralized base station (access point). Mobile devices connect to the network infrastructure via this base station, which handles routing, security, and network management. Ad Hoc Mode: Devices communicate directly with each other without requiring a central access point. Each device acts as both client and router, forming a peer-to-peer network.
| Mode | Connection |
|---|---|
| Infrastructure | Via base station |
| Ad Hoc | Direct device-to-device |
Key Difference: Infrastructure mode requires existing network infrastructure, while ad hoc mode creates temporary networks between devices. Note: Most WiFi networks operate in infrastructure mode for better security and management control.
Types of Adhoc Mode
Ad Hoc Network Modes
Wireless networks can operate without infrastructure in two configurations:
Single-hop, Infrastructure-less: Direct communication between wireless devices without any base station or access point. All nodes communicate directly within transmission range.
Multi-hop, Infrastructure-less: Nodes relay messages through intermediate devices to reach destinations beyond direct transmission range. No central infrastructure required.
Basic Service Set (BSS)
A BSS consists of wireless stations connected through a central access point (AP). Each wireless station and AP has a unique 6-byte MAC address for identification.
IEEE 802.11 Frequency Bands
| Standard | Frequency Band | Non-overlapping Channels |
|---|---|---|
| 802.11b | 2.4 GHz ISM | 3 |
| 802.11g | 2.4 GHz ISM | 3 |
| 802.11a | 5 GHz ISM | 23 |
| 802.11n | 2.4 or 5 GHz | Varies by channel width |
| 802.11ac | 5 GHz only | 25 |
WiFi Jungle: Location where a wireless device receives strong signals from multiple APs simultaneously, requiring selection of the best connection.
AP Discovery Methods
Passive Scanning
- APs broadcast beacon frames periodically
- Host sends association request to selected AP
- Selected AP responds with association response
Active Scanning
- Host broadcasts probe request frame
- All APs in range send probe response frames
- Host sends association request to chosen AP
- Selected AP responds with association response
Active scanning provides faster discovery but consumes more bandwidth.
802.11 MAC Protocol Features
Collision Avoidance: Uses CSMA/CA instead of collision detection due to wireless medium limitations.
Link-layer ARQ: Implements acknowledgment and retransmission scheme to handle high bit error rates in wireless channels.
Timing Intervals:
- SIFS (Short Inter-Frame Space): Brief gap between frame exchanges
- DIFS (Distributed Inter-Frame Space): Longer gap for channel access
Binary Exponential Backoff: Doubles contention window after each collision to reduce network congestion.
Hidden Terminal Solution: RTS (Request to Send) and CTS (Clear to Send) frames prevent collisions from hidden nodes.
802.11 Frame Structure
| Field | Size | Purpose |
|---|---|---|
| Frame Control | 2 bytes | Protocol version, type, and control information |
| Duration | 2 bytes | Channel reservation time |
| Address 1-4 | 6 bytes each | Source, destination, transmitter, and receiver addresses |
| Sequence Control | 2 bytes | Fragment and sequence numbering |
| Frame Body | 0-2312 bytes | Actual data / payload |
| FCS | 4 bytes | Frame check sequence for error detection |
Frame Control Subfields
| Field | Bits | Function |
|---|---|---|
| Protocol Version | 2 | 802.11 version |
| Type | 2 | Management, Control, or Data |
| Subtype | 4 | Specific frame function |
| To/From DS | 1 each | Distribution system direction |
| More Fragments | 1 | Additional fragments follow |
| Retry | 1 | Retransmitted frame |
| Power Management | 1 | Station power save mode |
| More Data | 1 | Additional data buffered |
| WEP | 1 | Encryption enabled |
| Order | 1 | Strict ordering / reserved for future use |
4 / Token Ring
Token Ring (IEEE 802.5)
Token Ring (IEEE 802.5) is a deterministic LAN technology using ring topology and token passing for media access control.
Key Characteristics
- Connectionless communication with ring topology
- Token passing access control method
- Collision-free operation with priority support
- Deterministic service - predictable access times
Token Holding Time (THT)
Maximum time a station can hold the token before releasing it.
- Default value: 10 milliseconds
- Purpose: Prevents token monopolization by any single station
- Enforcement: No station can exceed THT limit
Monitor Station
The station with highest MAC address that generates and manages the token.
Responsibilities:
- Maintains ring timing parameters
- Generates initial token
- Monitors ring health
Timing Parameters:
Min TRT = Propagation delay + (Stations x Station delay)
Max TRT = Propagation delay + (Stations x THT)
Data Rates and Ring Length
| Data Rate | Minimum Ring Length |
|---|---|
| 4 Mbps | 1200 meters |
| 16 Mbps | 300 meters |
Higher speeds require shorter rings to maintain signal integrity.
Frame Formats
Data Frame Structure
| Field | SD | AC | FC | DA |
|---|---|---|---|---|
| Bytes | 1 | 1 | 1 | 2-6 |
Key Fields:
- SD (Starting Delimiter): JK0JK000 (J,K are non-data symbols)
- AC (Access Control): PPPTMRRR where T=1 for data, T=0 for token
- FC (Frame Control): 2 bits for frame type + 6 bits for control type
- ED (Ending Delimiter): JK1JK1IE (I=Intermediate, E=Error bit)
- FS (Frame Status): AC00AC00 (A=Address recognized, C=Frame copied)
Frame Status Interpretation
| A (Address) | C (Copied) | Meaning |
|---|---|---|
| 0 | 0 | Destination not present |
| 0 | 1 | Invalid combination |
| 1 | 0 | Destination present, frame not copied |
| 1 | 1 | Destination present, frame copied |
Token Frame
| Field | SD | AC | ED |
|---|---|---|---|
| Bytes | 1 | 1 | 1 |
Abort Frame
| Field | SD | ED |
|---|---|---|
| Bytes | 1 | 1 |
Ring Latency
Time for a bit to complete one ring traversal:
RL = d/v + Mb/R (seconds) = dR/v + Mb (bits)
where:
- d = physical ring length (meters)
- v = signal velocity (m/s)
- M = number of stations
- b = bits buffered per station
- R = data rate (bps)
Performance Metrics
Data Transfer Rate:
Rate = F / (t_l + t_o + F/B)
Link Length in Bits:
Link bits = R x (d/v)
Utilization:
U = 1 / (1 + a/N), if a < 1; U = 1 / (a(1 + 1/N)), if a > 1
Control Frame Types
Control frames use 6-bit type field in Frame Control:
- 000000: Duplicate Address Test - detects address conflicts
- 000010: Beacon Frame - localizes major ring faults
- 000011: Claim Token - used in monitor election process
- 000100: Purge - clears unwanted ring signals
- 000101: Active Monitor Present - monitor health announcement
- 000110: Standby Monitor Present - neighbor identification
Token Reinsertion Strategies
| Aspect | Delay Token Reinsertion (DTR) |
|---|---|
| Token Release | After receiving entire transmitted frame |
| Efficiency | Lower - one frame on ring at a time |
| Reliability | Higher - THT enforced (10ms) |
| Usage | Light load conditions |
| Cycle Time | a x b + c x d formula shown as symbol glyphs |
where: a = transmission time, b = ring latency, c = token transmission time, d = inter-station delay
Note: ETR allows better ring utilization but requires careful flow control to prevent congestion.
5. Network Layer
5.1 IPv4 Addressing
Network Layer
The Network Layer (Layer 3) handles logical addressing and routing between different networks.
Primary Functions:
- Logical Addressing: Assigns IP addresses to identify devices across networks
- Routing: Determines the best path for data packets to reach their destination
- Packet Forwarding: Moves packets from source to destination through intermediate routers
- Fragmentation: Breaks large packets into smaller units when needed for transmission
- Reassembly: Reconstructs original packets at the destination
Key Responsibilities:
- Path determination using routing algorithms (OSPF, RIP, BGP)
- Managing network congestion through traffic control
- Handling packet switching between different network segments
- Providing network-to-network communication
Address Translation:
Converts logical addresses (IP addresses) to physical addresses (MAC addresses) using protocols like ARP (Address Resolution Protocol).
Example: When sending data from 192.168.1.10 to 203.0.113.89 :
- Network layer determines routing path through intermediate routers
- Each router forwards packet based on destination IP
- Final router delivers packet to destination network
Abstraction: Shields upper layers from physical network details - applications don't need to know the actual path data takes through the internet.
Note: This layer enables internetworking - connecting different types of networks (Ethernet, Wi-Fi, etc.) into one logical network.
IP Address
IP addresses provide globally unique identification for devices on the internet. Each device needs a distinct address to enable proper routing and communication across networks.
IP Versions
The Internet Protocol has evolved through two main versions:
IPv4 (Internet Protocol version 4)
- 32-bit addressing scheme
- Supports approximately 4.3 billion unique addresses
- Uses dotted decimal notation: 192.168.1.1
- Currently the dominant protocol despite address exhaustion
IPv6 (Internet Protocol version 6)
- 128-bit addressing scheme
- Provides 2^128 possible addresses (virtually unlimited)
- Uses hexadecimal notation: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
- Designed to replace IPv4 as addresses become scarce
IPv4 Addressing Methods
IPv4 addressing has evolved from simple class-based systems to flexible routing schemes:
Classful Addressing
Traditional method dividing addresses into fixed classes:
- Class A: 1.0.0.0 to 126.255.255.255 (large networks)
- Class B: 128.0.0.0 to 191.255.255.255 (medium networks)
- Class C: 192.0.0.0 to 223.255.255.255 (small networks)
Limitation: Wasteful allocation - many addresses remained unused within assigned classes.
Classless Inter-Domain Routing (CIDR)
Modern approach allowing flexible network size allocation:
- Uses subnet masks to define network boundaries
- Notation: 192.168.1.0/24 (where /24 indicates 24-bit network prefix)
- Eliminates rigid class boundaries for efficient address utilization
CIDR Techniques
Subnetting
Dividing a large network into smaller subnetworks:
- Fixed Length: All subnets have identical size
- Variable Length (VLSM): Subnets can have different sizes based on requirements
Example: Network 192.168.1.0/24 can be split into:
- 192.168.1.0/26 (64 hosts)
- 192.168.1.64/26 (64 hosts)
- 192.168.1.128/25 (128 hosts)
Supernetting
Combining multiple smaller networks into one larger network:
- Reduces routing table entries
- Improves routing efficiency
- Also called route aggregation or summarization
Example: Networks 192.168.0.0/24, 192.168.1.0/24, 192.168.2.0/24, 192.168.3.0/24 can be summarized as 192.168.0.0/22
Remember: CIDR enables efficient address allocation by removing the constraints of traditional class boundaries.
IPv4 Address
IPv4 addresses use a 32-bit format divided into four 8-bit octets (e.g., 192.168.1.1) for better readability. Each address contains two parts: Network ID (identifies the network) and Host ID (identifies the specific device).
Classful Addressing
IPv4 addresses are categorized into classes based on their first octet value:
| Class | Range | Binary Pattern | Purpose |
|---|---|---|---|
| A | 0-127 | 0xxxxxxx | Large networks |
| B | 128-191 | 10xxxxxx | Medium networks |
| C | 192-223 | 110xxxxx | Small networks |
| D | 224-239 | 1110xxxx | Multicast |
| E | 240-255 | 1111xxxx | Experimental / reserved |
Read as: Class determines how many octets are used for Network ID vs Host ID identification.
Address Calculations
Class A: 7 network bits, 24 host bits
- Networks: 2^7 - 2 = 126 (excluding 0 and 127)
- Hosts per network: 2^24 - 2 = 16,777,214
Class B: 14 network bits, 16 host bits
- Networks: 2^14 = 16,384
- Hosts per network: 2^16 - 2 = 65,534
Class C: 21 network bits, 8 host bits
- Networks: 2^21 = 2,097,152
- Hosts per network: 2^8 - 2 = 254
Note: Subtract 2 from host count because all-zeroes (network address) and all-ones (broadcast address) are reserved.
Special Purpose Addresses
Network Address: Host bits set to 0, identifies the network itself.
Example: 192.168.1.0 for network 192.168.1.0/24
Broadcast Address: Host bits set to 1, sends packets to all devices in the network.
Example: 192.168.1.255 for network 192.168.1.0/24
Loopback (127.0.0.x): Tests local TCP/IP stack and enables inter-process communication. Range 127.0.0.0 to 127.255.255.254 (excluding network and broadcast addresses)
Default Route (0.0.0.0): Used in routing tables when destination network is unknown. Forwards packets to a default gateway.
Direct Broadcast: Sends packets to all hosts in a remote network.
- Class A: N.255.255.255
- Class B: N.N.255.255
- Class C: N.N.N.255
Limited Broadcast (255.255.255.255): Sends packets to all hosts in the local network only.
Private Address Ranges
These addresses are not routable on the Internet, only within private networks:
- Class A: 10.0.0.0 to 10.255.255.255
- Class B: 172.16.0.0 to 172.31.255.255
- Class C: 192.168.0.0 to 192.168.255.255
Router Deployment Rules
- Different Networks: Each router interface must belong to a different network
- LAN Separation: Interconnected LANs must use different network addresses
- Interface Matching: Router's ethernet interface and connected LAN must share the same network
- Shared Links: Routers on the same physical link must belong to the same network
Subnetting vs Supernetting
| Aspect | Subnetting | Supernetting |
|---|---|---|
| Purpose | Divide one network into smaller subnetworks | Combine multiple networks into one larger network |
| Bit Borrowing | From host bits | From network bits |
| Application | Single large network | Multiple small networks |
| Subnet Mask | More 1s than default mask | Fewer 1s than default mask |
| Routing Impact | Increases table entries | Decreases table entries |
| Network Requirement | One network | Multiple networks |
Remember: Classful addressing has limitations including inflexibility, no built-in security, and addresses not permanently tied to systems. Modern solutions include CIDR (Supernetting), VLSM (Subnetting), and NAT.
5.2 IPv4 Header Format
IPv4
IPv4 is a best-effort, connectionless network protocol. Packets are delivered without guarantees of delivery, order, or error correction.
IP Datagram Structure
An IP datagram consists of:
- Header: Control information (20-60 bytes)
- Data: Transport layer header + application data
IPv4 Header Format
| Field | Size | Field | Size |
|---|---|---|---|
| Version | 4 bits | Header Length (IHL) | 4 bits |
| Type of Service | 8 bits | Total Length | 16 bits |
| Identification | 16 bits | Flags | 3 bits |
| Fragment Offset | 13 bits | TTL | 8 bits |
| Protocol | 8 bits | Header Checksum | 16 bits |
| Source IP Address | 32 bits | ||
| Destination IP Address | 32 bits | ||
| Options + Padding | Variable |
Key Fields:
- Version: Always 4 for IPv4
- Header Length: Header size in 32-bit words
- TTL: Maximum hops before packet is discarded
- Protocol: Next layer protocol (TCP = 6, UDP = 17)
- Flags: Control fragmentation behavior
IPv6 Header Format
| Field | Size |
|---|---|
| Version | 4 bits |
| Traffic Class | 8 bits |
| Flow Label | 20 bits |
| Payload Length | 16 bits |
| Next Header | 8 bits |
| Hop Limit | 8 bits |
| Source Address | 128 bits |
| Destination Address | 128 bits |
Simplified Design: Fixed 40-byte header, no fragmentation at routers, no checksum
Header Length Encoding
IPv4 Header Length Field:
- At source: Actual header bytes / 4
- At destination: Field value x 4 = actual bytes
Example: 24-byte header -> Header Length = 6 -> Receiver calculates 6 x 4 = 24 bytes
Fragmentation Rules
When a packet exceeds Maximum Transmission Unit (MTU):
- Fragment size: Must be divisible by 8 bytes (except last fragment)
- Fragment Offset: Position in original packet / 8
Example: 1500-byte packet fragmented into 800 + 700 bytes:
- Fragment 1: Offset = 0, size = 800 (divisible by 8)
- Fragment 2: Offset = 100 (since 800 / 8 = 100), size = 700
Remember: The constant factor 8 ensures efficient reassembly at the destination.
Options
IPv4 headers contain an optional variable section (0-40 bytes) after the fixed 20-byte header. These options enable network testing, debugging, and specialised routing control.
Common Option Types
End of Option (Type 0)
- Single byte: '00000000'
- Marks end of options field
- Used for padding when options don't fill complete 4-byte boundary
- Must be the final option if present
No Operation (Type 1)
- Single byte: '00000001'
- Acts as filler between other options
- Ensures proper alignment without affecting functionality
Record Route (Type 7)
- Records IP addresses of routers handling the datagram
- Maximum capacity: 9 router addresses
- Format: [Type][Length][Pointer][Router IPs...]
- Use case: Tracing actual path taken by packets for network diagnosis
Strict Source Route (Type 9)
- Source specifies exact router sequence for packet delivery
- Routers must forward only to the next specified address
- Packet discarded if any specified router is unreachable
- Example: Force packet through specific security gateways
Loose Source Route (Type 3)
- Source lists routers that must be visited
- Packet can traverse additional routers between specified ones
- More flexible than strict routing
- Example: Ensure packet passes through particular geographic regions
Timestamp (Type 4)
- Records processing time at each router
- Can store timestamps only or timestamp-address pairs
- Useful for measuring network delays and performance analysis
Note: Options increase header size and processing overhead. Most modern networks rely on other protocols (MPLS, SDN) for advanced routing control.
5.2 IPv6 Basics section number
IPv6
IPv6 uses a modular packet structure with a fixed header followed by optional extension headers.
IPv6 Packet Structure Fixed Header: Always 40 bytes (compared to IPv4's variable 20-60 bytes) Extension Headers: Optional, variable-length headers that provide additional functionality
- Each header contains a Next Header field pointing to the following header
- Chain continues until reaching the upper layer protocol (TCP, UDP, ICMPv6)
Payload: Extension headers + upper layer protocol data unit
- Standard limit: 65,535 bytes
- Larger payloads possible using Jumbo Payload option in Hop-by-Hop header
Next Header Field Values The Next Header field identifies what follows the current header:
| Value | Protocol/Header |
|---|---|
| 0 | Hop-by-Hop Options |
| 6 | TCP |
| 44 | Fragment Header |
| 50 | Encapsulating Security Payload |
| 51 | Authentication Header |
| 58 | ICMPv6 |
| 59 | No Next Header |
| 60 | Destination Options |
Goal: an Next Header value indicates the type of header or protocol that follows.
Required Extension Headers All IPv6 implementations must support:
- Hop-by-Hop Options
- Destination Options
- Routing Header
- Fragment Header
- Authentication Header
- Encapsulating Security Payload
Alignment rule: Extension headers must align on 8-byte boundaries. Variable-length headers include padding to ensure proper alignment.
Recommended Header Order When multiple extension headers are present:
- Hop-by-Hop Options
- Destination Options (for intermediate nodes)
- Routing Header
- Fragment Header
- Authentication Header
- Encapsulating Security Payload
- Destination Options (for final destination)
IPv6 Fragmentation When a packet exceeds the path MTU, it splits into two parts:
Unfragmentable Part (processed by intermediate routers):
- IPv6 header
- Hop-by-Hop Options
- Destination Options for intermediate destinations
- Routing header
Fragmentable Part (processed only at destination):
- Authentication Header
- Encapsulating Security Payload
- Destination Options for final destination
- Upper layer data (TCP/UDP payload)
Note: Only the source node can fragment IPv6 packets. Routers cannot fragment, unlike IPv4.
5.4 ICMP Protocol section number
Internet Control Messaging Protocol (ICMP)
ICMP (Internet Control Message Protocol) handles error reporting and network diagnostics. It operates at the network layer alongside IP.
Encapsulation: ICMP messages are wrapped inside IP datagrams with protocol field = 1 Transport: ICMP operates directly over IP, not through TCP/UDP. The ping utility uses ICMP Echo messages.
Message Types
Error Reporting Messages:
- Destination Unreachable: Host, network, or port cannot be reached
- Source Quench: Congestion control - tells sender to slow down transmission
- Parameter Problem: Invalid header field detected in IP packet
- Time Exceeded: TTL expired or fragment reassembly timeout
- Redirection: Informs host of better route to destination
Query Messages:
- Echo Request/Reply: Used by ping command for connectivity testing
- Timestamp Request/Reply: Measures round-trip time and clock synchronization
- Address Mask Request/Reply: Obtains subnet mask information
- Router Solicitation/Advertisement: Discovers available routers on network
Example: When you ping 192.168.1.1 IP address, your host sends ICMP Echo Request. If reachable, target responds with Echo Reply containing same data.
Note: ICMP errors are never generated for ICMP error messages themselves, preventing infinite loops.
6. Routing Algorithms
6.1 Distance Vector Routing
Routing Algorithms
Routing algorithms determine how packets travel through networks. Each algorithm has specific use cases and trade-offs.
Basic Routing Types
Flooding: Every incoming packet is forwarded to all outgoing interfaces except the arrival interface. Simple but inefficient due to packet duplication.
Broadcast Routing: Sends packets from one host to all other hosts simultaneously. Methods include:
- Flooding (simple but wasteful)
- Multidimensional routing
- Spanning tree approach
- Reverse path forwarding
Multicast Routing: Delivers packets to specific host groups rather than all hosts. Uses:
- Shared tree structures
- Source-based trees
- Least cost path trees
- Reverse path multicasting with pruning
Dynamic Routing Protocol Classification Dynamic routing protocols are organized into two main categories:
Interior Gateway Protocols (IGP) - operate within a single autonomous system:
- Distance Vector: RIP (v1, v2), IGRP, EIGRP protocol list
- Link State: OSPF, IS-IS
Exterior Gateway Protocols (EGP) - operate between autonomous systems:
- Path Vector: BGP
Distance Vector Routing
Routers share routing information only with direct neighbors but maintain knowledge about the entire network. Each router knows the distance and direction to reach destinations.
Key protocols: RIP, IGRP Technique used: Split horizon to prevent routing loops
Common problems:
- Two-node loop instability
- Slow convergence
- Count-to-infinity problem
Solutions:
- Split horizon: Don't advertise routes back to their source
- Poison reverse: Advertise unreachable routes as infinite distance
- Define infinity (typically 16 hops) to limit loop duration hop count
Link State Routing (OSPF)
Uses Dijkstra's algorithm to build complete network topology. Each router:
- Discovers all neighbors and their network addresses
- Measures cost to reach each neighbor
- Floods link state information to all routers
- Builds shortest path tree
OSPF link types:
- Point-to-point: Direct connection between two routers
- Transient: Multi-access networks (Ethernet, WiFi)
- Stub: Networks with only one router connection
- Virtual: Logical connections through intermediate areas
Path Vector Routing (BGP)
Designed for interdomain routing between autonomous systems. Maintains the complete path (list of autonomous systems) to reach each destination network.
Advantage: Path information prevents routing loops between autonomous systems Use case: Internet backbone routing
Hierarchical Routing
Organizes networks into regions to reduce routing table size and complexity.
Two routing tables maintained:
- Full table: Contains all routers within the local region
- Hierarchical table: Contains summary information about other regions
Benefits: Scales better for large networks by reducing routing overhead.
RIP Protocol Details
- Metric: Hop count (number of network links)
- Maximum hops: 15 (Infinity = 16)
- Type: Intradomain distance vector protocol
- Limitation: Cannot handle networks requiring more than 15 hops
Example: If destination requires 8 router hops, RIP metric = 8. If any path exceeds 15 hops, destination is considered unreachable.
7. Transport Layer
The Transport Layer manages reliable data transmission between applications across a network.
Core Functions:
- Segmentation: Breaks application data into smaller packets for transmission
- Reassembly: Reconstructs original messages from received packets at destination
- Error Detection: Verifies packet integrity using checksums and sequence numbers
- Acknowledgment: Confirms successful packet delivery to sender
- Retransmission: Automatically resends lost or corrupted packets
- Flow Control: Manages data transmission rate to prevent receiver overflow
- Error Recovery: Handles packet loss, duplication, and out-of-order delivery
Key Mechanisms:
Reliable Delivery: Ensures all data arrives correctly through acknowledgment and retransmission protocols. Flow Control: Prevents fast senders from overwhelming slow receivers by controlling transmission windows. Error Handling: Detects transmission errors and coordinates recovery without involving upper layers. Connection Management: Establishes, maintains, and terminates communication sessions between applications.
Note: The Transport Layer abstracts network complexities, providing applications with a reliable communication interface regardless of underlying network conditions.
Transmission Control Protocol
TCP is a reliable, connection-oriented transport layer protocol that provides byte-stream delivery between application ports. It guarantees data delivery through acknowledgments and retransmission.
Key Characteristics:
- Full-duplex communication (bidirectional data flow)
- Connection-oriented with cumulative acknowledgments
- Point-to-point only (no broadcast/multicast support)
- Slow start congestion control
- Sliding window flow control (receiver sets window size)
TCP Connection Lifecycle
- Connection Establishment - Three-way handshake
- Data Transmission - Reliable data transfer with flow control
- Connection Termination - Four-way handshake to close connection
TCP Header Structure
| Field | Size (bits) | Function |
|---|---|---|
| Source Port | 16 | Identifies the sending port |
| Destination Port | 16 | Identifies the receiving port |
| Sequence Number | 32 | Sequence number of the first data byte in this segment |
| Acknowledgment Number | 32 | Next sequence number the sender expects to receive |
| Header Length | 4 | Length of the TCP header |
| Reserved | 6 | Reserved for future use, must be zero |
| Control Flags | 6 | URG, ACK, PSH, RST, SYN, FIN control bits |
| Window Size | 16 | Size of the receive window |
| Checksum | 16 | Error-checking of header and data |
| Urgent Pointer | 16 | Points to urgent data |
| Options | Variable | Optional additional fields |
Control Flags:
- SYN: Synchronize sequence numbers (connection setup)
- ACK: Acknowledgment field is valid
- FIN: Finish connection (graceful close)
- RST: Reset connection (immediate close)
- PSH: Push data to application immediately
- URG: Urgent pointer field is valid
Sequence Numbers TCP uses 32-bit sequence numbers starting from a random initial value for security. When all 2^32 numbers are used, they wrap around and repeat. Collision probability for initial sequence number: 1 / 2^32 = 2.33 x 10^-10 formula
Common TCP Applications
| Protocol | Port | Purpose |
|---|---|---|
| HTTP | 80 | Web browsing |
| FTP Control | 21 | File transfer command |
| Telnet | 23 | Remote terminal access |
| SMTP | 25 | Email sending |
| POP3 | 110 port number | Email retrieval |
Remember: TCP's reliability comes at the cost of overhead - use UDP when speed matters more than guaranteed delivery.
7.2 TCP Congestion Control section number
Congestion Control
Congestion control manages network traffic to prevent or resolve congestion through proactive and reactive mechanisms.
Open-Loop Congestion Control Prevents congestion before it occurs through policies applied at source or destination.
Retransmission Policy
- Lost or corrupted packets require retransmission, potentially increasing network congestion
- Retransmission timers must balance efficiency with congestion prevention
Window Policy
- Selective Repeat ARQ performs better than Go-Back-N for congestion control
- Reduces unnecessary retransmissions
Acknowledgment Policy
- Receiver-imposed policy controlling ACK frequency
- Delayed ACKs can reduce network traffic
Discarding Policy
- Router-based packet dropping strategy
- Prevents congestion while maintaining transmission integrity
Admission Policy
- Quality-of-service mechanism for virtual-circuit networks
- Controls new connection establishment during high traffic
Closed-Loop Congestion Control Alleviates congestion after detection through feedback mechanisms.
Backpressure
- Node-to-node congestion signaling
- Warning propagates upstream opposite to data flow direction
- Each congested node warns its immediate upstream neighbor
Choke Packet
- Direct congestion notification from router to source
- Bypasses intermediate nodes for faster response
- Congested router sends special packet to original sender
Implicit Signaling
- Source detects congestion from symptoms like timeouts or packet loss
- No explicit communication from congested nodes
- Relies on inference from network behavior
Explicit Signaling
- Direct congestion notification between nodes and endpoints
- Backward Signaling: Bit set in reverse-direction packets to warn source
- Forward Signaling: Bit set in forward-direction packets to warn destination
Traffic Shaping Converts bursty input traffic into regulated, smooth output flow.
Leaky Bucket Algorithm
- Fixed output rate regardless of input burst size
- Smooths traffic to constant rate
Token Bucket Algorithm
- Allows controlled bursts while maintaining average rate
- Bucket capacity formula:
C + ρt = Mt formula
where:
- M = maximum regulated output rate
- C = bucket capacity
- ρ = token generation rate
- t = time period
TCP Congestion Control
Slow Start and Additive Increase
- Congestion window starts at 1 MSS (Maximum Segment Size)
- Exponential growth until threshold, then linear increase
- Reaches Sender Window Size (SWS) limit wording
Multiplicative Decrease
- On timeout: congestion window resets to 1 MSS
- Threshold becomes half of previous congestion window size
- Provides aggressive backoff during congestion
TCP Error Control Uses three mechanisms for reliable data transfer:
Checksum
- Detects transmission errors in segments
- Corrupted segments are silently discarded
Acknowledgments
- No negative ACKs in TCP
- No ACKs for received ACKs
- Only error-free segments are acknowledged
Timeouts
- Dynamic RTT calculation for adaptive timeout values
- Multiple timer types: Retransmission, Keep-Alive, Persistence, Time-Wait timer list
Pseudoheader Purpose
- Verifies packet delivery to correct destination
- Created at source with sender values, recreated at destination for comparison
TCP State Transition State diagram represents connection lifecycle phases:
- Connection establishment (3-way handshake)
- Data communication
- Connection termination (4-way handshake)
Limitations:
- Error control procedures not shown in basic diagram
- Retransmission scenarios not depicted
Sockets Software abstraction representing communication endpoints between networked machines.
Key Characteristics:
- Endpoints of logical communication channels over TCP/UDP
- Both client and server must create sockets for communication
- Sockets must bind to specific network addresses
- Client initiates connection to listening server socket
Communication Process:
- Both processes create sockets
- Server socket enters listening state
- Client attempts connection to server
- Bidirectional communication established
Remember: Sockets provide the programming interface between applications and the transport layer protocols.
7.3 UDP Protocol section number
User Datagram Protocol
User Datagram Protocol (UDP) is a connectionless transport protocol that prioritizes speed over reliability.
Key Characteristics:
- Connectionless: No connection establishment or acknowledgment required
- Unreliable: No guarantee of packet delivery or ordering
- Message-oriented: Treats data as discrete messages, not continuous streams
- No flow control: Sender transmits at any rate without receiver feedback
UDP vs TCP UDP uses an iterative approach compared to TCP's concurrent model:
- TCP maintains multiple simultaneous connections
- UDP processes one request at a time per socket
Common Use Cases Real-time applications where speed matters more than perfect delivery:
- Video conferencing and live streaming (with RTP)
- Online gaming
- DNS lookups
- Broadcasting and multicasting
Bulk data transfer applications prioritizing speed:
- File transfers where occasional packet loss is acceptable
- Network monitoring tools
Header Structure UDP has a simple 8-byte header:
Fields explained:
- Length: Total UDP header + data size in bytes
- Checksum: Optional error detection (mandatory in IPv6)
Pseudoheader for Checksum UDP uses the same pseudo-header concept as TCP for checksum calculation:
- Source IP address
- Destination IP address
- Protocol field from IP header
- UDP segment length
This ensures the packet reached the correct destination.
Protocols Using UDP
| Protocol | Port | Purpose |
|---|---|---|
| DNS | 53 | Domain name resolution |
| TFTP | 69 | Trivial file transfer |
| SNMP | 161 | Network management |
| RIP | 520 | Routing information |
| NFS | 2049 | Network File System |
Note: ICMP (ping) operates at the network layer, not transport layer, so it doesn't use UDP port any UDP port.
8. Application Layer
8.1 DNS (Domain Name System)
BOOTP (Bootstrap Protocol)
BOOTP (Bootstrap Protocol) enables network devices to obtain their IP configuration during startup.
Purpose: Maps physical addresses (MAC) to logical addresses (IP) for diskless workstations and network devices that need initial configuration.
Key Characteristics:
- Application layer protocol using UDP transport
- Static configuration (not dynamic like DHCP)
- Client-server architecture
- Can operate across different network segments
Message Flow:
- Client broadcasts BOOTP request using:
- Source IP: 0.0.0.0 (unknown)
- Destination IP: 255.255.255.255 (broadcast)
- Server responds with client's assigned IP configuration
- Messages encapsulated as: BOOTP -> UDP -> IP
Cross-Network Operation:
Since broadcast packets cannot traverse routers, BOOTP uses relay agents:
- Relay agent receives broadcast BOOTP request on local network
- Converts broadcast to unicast and forwards to BOOTP server
- Server response is relayed back to requesting client
Advantage over RARP:
RARP (Reverse ARP) requires a server on each network segment because ARP broadcasts don't cross routers. BOOTP's relay mechanism allows centralized servers to serve multiple network segments.
Example Scenario:
Diskless workstation boots up -> broadcasts BOOTP request -> relay agent forwards to central BOOTP server -> server provides IP, subnet mask, gateway, and boot file location.
Remember: BOOTP provides static mappings configured by administrators, unlike DHCP's dynamic allocation.
DHCP (Dynamic Host Configuration Protocol)
DHCP (Dynamic Host Configuration Protocol) automates IP address assignment in networks, supporting both static and dynamic allocation methods.
Address Allocation Types
Static Allocation
- DHCP maintains a database that permanently maps physical addresses (MAC) to specific IP addresses
- Functions like BOOTP protocol and maintains backward compatibility
- Each device always receives the same IP address
Dynamic Allocation
- DHCP maintains a pool of available IP addresses
- Assigns addresses temporarily from this pool as needed
- Addresses are recycled when no longer in use
Dynamic Features
Lease System:
DHCP uses a lease mechanism for temporary address assignment:
- Lease Duration: Server assigns IP address for a specific time period
- Lease Renewal: Client must renew before expiration or stop using the address
- Server Control: Server can approve or deny renewal requests
Use Cases for Dynamic Assignment:
- Mobile devices moving between networks
- Devices that connect/disconnect frequently
- Networks with more devices than available IP addresses
Advantages Over BOOTP
| Feature | BOOTP | DHCP |
|---|---|---|
| Configuration | Manual only | Manual and automatic |
| Address Type | Static only | Static and dynamic |
| Lease Management | None | Built-in |
Key Improvement: DHCP eliminates the need for manual IP-to-MAC address mapping that BOOTP requires, enabling automatic network configuration.
Remember: DHCP = BOOTP + dynamic allocation + automatic configuration
Domain Name System (DNS)
DNS (Domain Name System) translates human-readable domain names into IP addresses, enabling users to access websites using memorable names instead of numeric addresses.
Primary Functions:
- Maps URLs to IP addresses (e.g., google.com -> 172.217.164.110)
- Tracks computers and services across both LAN and WAN networks
- Maintains distributed database of domain information
Transport Protocols:
- Uses port 53 for all communications
- UDP for standard queries (faster, smaller overhead)
- TCP for zone transfers and large responses (reliable delivery)
DNS Server Hierarchy:
- Root Servers - Top level servers that direct queries to appropriate TLD servers
- Top-Level Domain (TLD) Servers - Handle domains like .com, .org, .edu
- Authoritative Servers - Store actual DNS records for specific domains
- Local DNS Servers - ISP servers that cache responses and forward queries
Core Services:
- Name Translation - Convert domain names to IP addresses
- Host Aliasing - Multiple names for same host (www.example.com and example.com)
- Mail Aliasing - Route email using domain names instead of server IPs
- Load Balancing - Distribute traffic across multiple servers with same domain
Query Process Example:
User types "example.com" -> Local DNS checks cache -> Queries root server -> Directed to .com TLD server -> Directed to authoritative server -> Returns IP address
Remember: DNS uses distributed storage across multiple servers to ensure reliability and reduce single points of failure.
HTTP Protocol
Application Layer
The Application Layer is the topmost layer of the OSI model that provides network services directly to end-user applications.
Purpose:
- Enables applications to access network resources and services
- Provides the interface between user applications and the network
- Handles high level protocols that support user tasks like file transfer, email, and web browsing
- Represents what users actually interact with when using network applications
Key Functions:
- Service Advertisement: Makes network services discoverable to applications
- Application Interface: Provides APIs for applications to communicate over the network
- Data Formatting: Ensures data is in the correct format for the receiving application
- User Authentication: Handles login credentials and access control
Common Application Layer Protocols
Web and File Services:
- HTTP/HTTPS - Web page transfer
- FTP - File transfer
- DNS - Domain name resolution
- NFS - Network file system
Email and Messaging:
- SMTP - Email sending
- NNTP - Network news transfer
- SIP - Voice over IP signaling
Read as: Each layer handles specific types of protocols for different network functions.
| Layer | Primary Protocols |
|---|---|
| Application | HTTP, FTP, SMTP, DNS, DHCP |
| Presentation | TLS, SSL, MIME, XDR |
| Session | NetBIOS, L2TP, PPTP |
| Transport | TCP, UDP, SCTP |
| Network | IP, ICMP, IGMP |
| Data Link | Ethernet 802.3, PPP, Frame Relay |
| Physical | Ethernet, Wi-Fi 802.11, Bluetooth |
Remember: Application layer protocols are what users directly interact with - if you can name the service (like "web browsing" or "email"), it likely uses an application layer protocol.
Hyper Text Transfer Protocol (HTTP)
HTTP (Hyper Text Transfer Protocol) is an application layer protocol that enables web communication between clients and servers.
Basic Properties:
- Uses TCP on port 80 for reliable data transfer
- Stateless protocol - each request-response pair is independent
- No memory of previous transactions between client and server
Security: HTTPS uses SSL/TLS encryption to secure HTTP communication over port 443.
Primary Function: Retrieval and transfer of web resources (HTML pages, images, files) from web servers.
HTTP Methods:
- GET - Retrieve data from server
- POST - Send data to server (form submissions)
- PUT - Upload/update resource on server
- DELETE - Remove resource from server
- HEAD - Get headers only (no body content)
- OPTIONS - Check supported methods for a resource
- TRACE - Echo request back for debugging
- CONNECT - Establish tunnel (used for HTTPS proxying)
Connection Types:
| Type | Behavior |
|---|---|
| Non-Persistent | New TCP connection per request |
| Persistent | Single TCP connection for multiple requests |
Non-Persistent: Client opens new TCP connection for each HTTP request, then closes it after receiving response.
Persistent: Client maintains one TCP connection and sends multiple requests through it, reducing connection establishment overhead.
Note: Modern browsers default to persistent connections (HTTP/1.1) for better performance.
FTP (File Transfer Protocol)
File Transfer Protocol (FTP)
File Transfer Protocol (FTP) operates over TCP using two separate connections:
Data Connection: Port 20 | Control Connection: Port 21
Control connection handles commands and responses, while data connection transfers actual files.
Status and Error Codes:
FTP uses standardized response codes:
- 1xx: Positive preliminary (action initiated)
- 2xx: Positive completion (action successful)
- 3xx: Positive intermediate (need more information)
- 4xx: Transient negative (temporary failure)
- 5xx: Permanent negative (command failed)
Operation Modes
Active Mode: Server initiates data connection back to client
- Client opens random port and tells server via PORT command
- Server connects from port 20 to client's specified port
- Problem: Blocked by client firewalls
Passive Mode: Client initiates both connections
- Server opens random port and tells client via PASV command
- Client connects to server's specified port for data transfer
- Firewall friendly for clients
Extended Passive Mode: Enhanced version of passive mode
- Uses EPSV command instead of PASV
- Supports IPv6 and provides better NAT traversal
Access Modes:
ASCII Mode: For text files
- Performs character set conversion between systems
- Handles line ending differences (CRLF vs LF)
Binary Mode: For non-text files
- Raw byte transfer without any conversion
- Used for images, executables, compressed files
Note: Wrong mode selection can corrupt files during transfer.
Two Modes of Access
FTP vs TFTP Comparison
| Feature | FTP | TFTP |
|---|---|---|
| User Access | Authorized users only | |
| Authentication | Username and password | none |
| Operations | Full upload and download | simple upload and download only |
| Transport Protocol | TCP (ports 20, 21) | UDP (port 69) |
| Security | More secure with authentication | less secure, no authentication |
| Reliability | Reliable delivery via TCP | no reliable delivery, runs over UDP |
FTP (File Transfer Protocol)
- Establishes two connections: control (port 21) and data (port 20)
- Supports both active and passive modes
- Provides complete file management capabilities
TFTP (Trivial File Transfer Protocol)
- Simple UDP connection on port 69
- Designed for simple file transfers
- Commonly used for network booting and firmware updates
- No directory listing or file management features
Use Cases:
- FTP: Web development, secure file sharing, remote file management
- TFTP: Router configuration backup, diskless workstation booting, simple file retrieval
SMTP (Email Protocol)
Presentation
The Presentation Layer (Layer 6) handles data format translation and standardization across different systems.
Primary Function: Converts data between application-specific formats and standardized network formats that all OSI layers can process.
Key Responsibilities:
- Protocol conversion - translation between different data representation protocols
- Character encoding - converts between ASCII, EBCDIC, Unicode formats
- Data encryption/decryption - secures data before transmission, decrypts on receipt
- Data compression - reduces data size for efficient transmission
- Graphics processing - converts compressed graphics commands into displayable formats
Why it Matters: Different systems use different data formats (Windows vs Unix, Intel vs ARM processors). The presentation layer ensures a file created on one system can be properly interpreted on another.
Example: When sending an email with an image attachment:
- Compresses the image file
- Encrypts the entire message
- Converts text encoding if sender uses UTF-8 and receiver expects ASCII
- Packages everything in a standard format for network transmission
Remember: Think of it as a universal translator that makes sure data "looks the same" to both sender and receiver, regardless of their underlying system differences.
Simple Mail Transfer Protocol (SMTP)
SMTP (Simple Mail Transfer Protocol) handles email transmission between mail servers using port 25 over TCP connection.
Core Components
User Agent (UA)
- Email client software (Gmail, Outlook, Thunderbird)
- Composes, sends, and receives email messages
- Provides user interface for email management
Mail Transfer Agent (MTA)
- Server software that routes emails between domains
- Handles the actual transmission using SMTP protocol
- Examples: Postfix, Sendmail, Exchange Server
MIME (Multipurpose Internet Mail Extensions)
- Extends basic email to support multimedia content
- Enables attachments, HTML formatting, and non-ASCII text
- Defines content types and encoding methods
Mail Access Protocols (MAP)
- Allow users to retrieve emails from mail servers
- Two main protocols:
| Protocol | Full Name |
|---|---|
| POP3 | Post Office Protocol v3 |
| IMAP4 | Internet Message Access Protocol v4 |
Protocol Differences:
POP3: Downloads messages to local device and typically deletes from server. Good for single-device access.
IMAP4: Synchronizes emails across multiple devices. Messages remain on server for universal access.
Note: SMTP only handles sending emails. Receiving requires POP3 or IMAP4 for the final delivery to user's mailbox.
8.5 POP3 and IMAP
Post Office Protocol Version 3 (POP3)
Post Office Protocol Version 3 (POP3) is an email retrieval protocol that operates as a pull protocol, meaning the client initiates requests to fetch emails from the server.
Protocol Details:
- Uses TCP transport protocol on port 110
- Client downloads emails from server to local device
- Typically deletes emails from server after download (though configurable)
POP3 Operation:
- Client connects to mail server on port 110
- User authentication (username/password)
- Client downloads all new messages
- Messages removed from server (default behavior)
- Connection terminated
Key Characteristics:
- Offline access: Once downloaded, emails available without internet
- Single device: Best suited for accessing email from one device
- Storage: Emails stored locally on client device
- Simple protocol: Minimal server-side processing required
POP3 vs IMAP Comparison:
| Feature | POP3 | IMAP |
|---|---|---|
| Storage | Local device | Server |
| Multi-device | Poor support | Full support |
| Offline access | Yes | Limited |
| Server storage | Minimal | High |
Current Usage: While POP3 is still supported, IMAP4 (Internet Message Access Protocol version 4) has become the preferred choice for modern email services due to its multi-device synchronization capabilities and server-side email management. Remember: POP3 = Pull protocol, Port 110, Downloads and deletes from server
8.6 SSH
Session Layer
The Session Layer manages communication sessions between applications across a network.
Primary Functions:
- Session Management: Establishes, maintains, and terminates communication sessions between network applications
- Participant Authentication: Ensures only authorized parties can join a session through name recognition and identification
- Data Flow Control: Manages which party can transmit data and for how long (half-duplex or full-duplex communication)
Synchronization Services: The layer provides checkpoint mechanisms to handle transmission failures:
- Places synchronization points (checkpoints) at regular intervals in the data stream
- If transmission fails, only data transmitted after the most recent checkpoint needs retransmission
- Prevents need to restart entire session from beginning
Example: During a large file transfer, checkpoints are placed every 1MB , if connection drops at 7.3MB , transmission resumes from the 7MB checkpoint, not from the start.
Session Control Types:
- Simplex: One-way communication only
- Half-duplex: Two-way communication, but only one direction at a time
- Full-duplex: Simultaneous two-way communication
Remember: Session layer is about managing the conversation, not the actual data transport.
9. Network Security
9.1 Symmetric Key Encryption (DES, AES)
Cryptography
Cryptography involves transforming readable messages into unreadable form and back again for secure communication.
Key Terms:
- Plaintext: The original, readable message before any transformation
- Ciphertext: The transformed, unreadable message after encryption
Basic Process:
Encryption Algorithm: Converts plaintext into ciphertext using a specific method and key Decryption Algorithm: Reverses the process, converting ciphertext back to original plaintext
Example:
- Plaintext: "HELLO"
- After Caesar cipher (shift by 3): "KHOOR" (ciphertext)
- Decryption with same key recovers: "HELLO"
Note: The strength of cryptography depends on the algorithm's complexity and key secrecy, not on hiding the method itself.
Types of Cryptography
Cryptography uses mathematical algorithms to secure data transmission. Two main approaches exist based on key usage.
Symmetric Key Cryptography Uses the same shared key for both encryption and decryption. The sender encrypts with the key, and the receiver decrypts with the same key.
Substitution Ciphers Replace one symbol with another according to a fixed system:
- Monoalphabetic: Each letter maps to exactly one other letter
- Polyalphabetic: Letters map to different substitutions based on position
Shift Cipher The simplest substitution where each letter shifts by a fixed number of positions. Example: with shift +1, "A" becomes "B" , "B" becomes "C" .
Transposition Ciphers Characters remain the same but their positions change according to a key pattern. The key defines how to rearrange character positions between plaintext and ciphertext.
Rotation Cipher Input bits rotate left or right by a specified amount:
- Keyed rotation: Key value determines rotation count. After k rotations on k-bit input, original data returns
- Keyless rotation: Fixed rotation amount
Decryption uses the same key with opposite rotation direction.
Block Ciphers Divide plaintext into fixed-size blocks and apply the same key to encrypt each block.
Data Encryption Standard (DES)
- Processes 64-bit plaintext blocks using 56-bit keys
- Contains 2 permutation boxes and 16 repeated round operations
- Initial and final permutations are keyless and inverse of each other
- DES function forms the algorithm's core
Triple DES (3DES) Uses three DES operations in sequence:
- Encryption: Encrypt-Decrypt-Encrypt combination
- Decryption: Decrypt-Encrypt-Decrypt combination
Two versions exist:
- Two-key 3DES: 112-bit effective key size, protects against man-in-the-middle attacks
- Three-key 3DES: Higher security with three distinct keys
Advanced Encryption Standard (AES) Designed to replace DES due to its small key size. Triple DES was too slow despite larger keys.
- Complex round cipher structure
- Three key sizes available: 128, 192, or 256 bits
- Much faster than Triple DES
Asymmetric Key Cryptography Uses two mathematically related keys: a private key (kept secret) and a public key (shared openly).
RSA Algorithm Named after Rivest, Shamir, and Adleman. Uses numbers e and d as public and private keys.
Key Generation Process:
- Choose two large prime numbers p and q
- Calculate modulus: n = p × q
- Compute: φ(n) = (p - 1)(q - 1)
- Select random integer e, then find d where d × e ≡ 1 mod φ(n)
Public information: e and n Private information: d and φ(n)
Usage: RSA works best for short messages like symmetric keys or message digests. For long messages, use RSA to exchange symmetric keys, then use symmetric encryption for the actual data. Applications: Digital signatures, authentication, secure key exchange
Diffie-Hellman Key Exchange Designed specifically for establishing shared symmetric keys between parties without prior key exchange. Process: Two parties create a session key k using the mathematical relationship:
K = g^(ab) mod p
where both (g^a mod p)^b mod p and (g^b mod p)^a mod p produce the same result . Vulnerability: Man-in-the-middle attacks where an attacker intercepts and modifies communications. Solution: Authenticate parties before key exchange to prevent interception.
Message Integrity and Authentication Encryption provides confidentiality but not integrity verification.
Message Digest Functions Create fixed-size hash values from variable-length input data. Key properties:
- Every output bit depends on every input bit
- Changing any input bit has 50% probability of changing each output bit
- Computationally impossible to find two inputs producing the same digest
Common Hash Algorithms
| Algorithm | Digest Size | Notes |
|---|---|---|
| MD2 | 128 bits | Most secure but slowest |
| MD4 | 128 bits | Fast alternative |
| MD5 | 128 bits | Enhanced MD4 |
| SHA-1 | 160 bits | Processes 512-bit blocks |
SHA-1 Details: Creates 160-bit digest (5 words of 32 bits each) from 512-bit message blocks.
Message Authentication Code (MAC)
- MDC (Modification Detection Code): Uses keyless hash function, detects changes only
- MAC: Uses keyed hash function with shared symmetric key between sender and receiver
MAC provides both integrity checking and sender authentication. Identical MACs confirm message integrity and sender identity.
Digital Signatures Uses asymmetric key pairs for authentication:
- Sender signs message digest with private key
- Receiver verifies signature with sender's public key
Provides: Message integrity, authentication, and non-repudiation (sender cannot deny sending the message). Note: For long messages, symmetric cryptography is much more efficient than asymmetric methods.
Eavesdropping
Eavesdropping is a passive attack where an attacker intercepts and monitors network communications without the sender or receiver knowing.
How it works:
- Attacker "taps into" network transmission lines
- Captures data packets as they travel between systems
- Reads unencrypted information in transit
Common targets:
- Serial communication lines
- Ethernet network traffic
- Wireless transmissions
- Unencrypted protocols (HTTP, Telnet, FTP)
Example: On a shared Ethernet segment, an attacker can use packet sniffing tools to capture all network traffic, including passwords, emails, and file transfers sent in plain text. Vulnerability: Most network protocols transmit data without encryption by default, making eavesdropping trivial with readily available tools. Defense: Use encrypted protocols (HTTPS, SSH, VPN) and secure network infrastructure to prevent unauthorized access to transmission media. Note: Unlike active attacks, eavesdropping leaves no trace since the attacker only observes traffic without modifying it.
9.2 Firewalls
Denial-of-service Attack
A Denial-of-Service (DoS) attack targets system availability by overwhelming resources to prevent legitimate users from accessing services.
Attack mechanism:
- Flood the target with excessive network traffic
- Consume system resources (CPU, memory, bandwidth)
- Make the system unresponsive to legitimate requests
Distributed DoS (DDoS):
- Uses multiple compromised machines (botnet)
- Coordinates simultaneous attacks from different sources
- Much harder to defend against than single-source attacks
Common attack vectors:
- Network flooding (TCP SYN flood, UDP flood)
- Application layer attacks (HTTP request flooding)
- Resource exhaustion (memory, disk space)
Example: A botnet of 1000 machines each sending 100 requests/second can generate 100,000 requests/second, overwhelming most web servers.
Defense strategies:
- Rate limiting and traffic filtering
- Load balancing across multiple servers
- DDoS protection services and firewalls
Note: Unlike other security attacks that aim to steal data, DoS attacks focus purely on disrupting service availability.