0% found this document useful (0 votes)
10 views37 pages

Unit 4 - Computer Networks - 094520

This document provides an overview of computer networks, focusing on the network layer, including concepts like virtual circuits, datagrams, addressing, and subnetting. It explains the importance of internetworks, routing protocols, and packet switching methods, detailing advantages and disadvantages of virtual circuits and datagrams. Additionally, it covers IP addressing, subnetting techniques, and Dijkstra's routing algorithm for finding optimal paths in networks.

Uploaded by

Dinesh Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views37 pages

Unit 4 - Computer Networks - 094520

This document provides an overview of computer networks, focusing on the network layer, including concepts like virtual circuits, datagrams, addressing, and subnetting. It explains the importance of internetworks, routing protocols, and packet switching methods, detailing advantages and disadvantages of virtual circuits and datagrams. Additionally, it covers IP addressing, subnetting techniques, and Dijkstra's routing algorithm for finding optimal paths in networks.

Uploaded by

Dinesh Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 37

ATMA RAM SANATAN DHARMA COLLEGE

B.A.(Programme) Computer Application (2022-25)

COMPUTER NETWORKS
Unit 4 – Network Layer

Semester – 6
Group:- Raishav Kumar (20121)
Pari (20119)
Lakshya Anand
INTRODUCTION

 Networks and Internetworks


 Virtual Circuits and Datagrams
 Addressing
 Subnetting
 Dijkstra Routing Algorithm
 Distance Vector Routing
 Overview of Network Layer Protocols (ARP, IPv4, ICMP, RARP, IPv6, DHCP)
Networks: An Overview
 A network is a collection of two or more interconnected devices (such as computers,
printers, routers, switches, etc.) that can communicate and share resources (data, files,
internet, etc.). The primary goal is communication and resource sharing.
 Types of Networks (based on size and coverage)
1. LAN (Local Area Network):
1. Covers a small geographical area (like a room, building, or campus).
2. High-speed and low latency.
3. Example: Computer lab in a college. Network Components
2. MAN (Metropolitan Area Network): •Hosts: Devices like computers and
1. Spans a city or large campus. phones that send/receive data.
2. Typically used by cities or large organizations. •Networking Devices: Routers,
3. WAN (Wide Area Network): switches, hubs, modems.
1. Covers large geographical areas (like
•Transmission Media: Wired
(Ethernet, fiber) or wireless (Wi-Fi,
2. countries or continents).
radio waves).
3. The Internet is the largest example of a WAN.
4. PAN (Personal Area Network):
1. Very short-range, usually around a person.
2. Example: Bluetooth between phone and earbuds.
Internetworks (Interconnected Networks)

 An internetwork is a combination of multiple different networks connected


together using devices like routers and gateways. These networks may be of
different types or technologies but are made to work together as a unified system.
 Why Do We Need Internetworks?
• Not all devices are on the same physical or logical network.
• Organizations often have multiple LANs in different buildings or cities.
• Internetworking allows these separate networks to communicate seamlessly.
 How Are Internetworks Built?
 Internetworks are built using networking devices:
• Routers: Connect different networks and route data between them.
• Gateways: Connect networks that use different protocols (e.g., TCP/IP vs.
AppleTalk).
• Switches (Layer 3): Sometimes used to route between VLANs (Virtual LANs).
Key Concepts in Internetworks

 1. Routing
• Determines the best path for data to travel across multiple networks.
• Routers use routing tables and protocols (like OSPF, RIP, BGP) to decide paths.
 2. Protocols
• Rules that devices follow to communicate.
• Common internetworking protocol: IP (Internet Protocol).
• TCP/IP is the backbone of the internet and most internetworks.
 3. Packet Switching
• Internetworks use packet switching where data is broken into small packets.
• Each packet is sent independently and may take different routes.
Examples to Understand Better

 Example 1: College Network


• A college may have:
• A LAN in the computer lab.
• A LAN in the library.
• A LAN in the administration block.
• All these LANs can be connected using routers to form a campus internetwork.
 Example 2: The Internet
• Billions of networks around the world (corporate, academic, personal).
• All connected to each other using routers and governed by the Internet
Protocol.
• This global system of internetworked devices is what we call the Internet.
What Is Packet Switching?

 Before diving into virtual circuits and datagrams, let's quickly understand
packet switching:
• In packet-switched networks, data is divided into small units called packets.
• These packets are sent independently and may take different routes to the
destination.
• Once all packets arrive, they are reassembled into the original message.
 Now, there are two primary approaches to how these packets are transmitted:
1. Virtual Circuits
2. Datagrams
1. Virtual Circuits
 A Virtual Circuit is a connection-oriented packet switching method. It simulates a
dedicated connection between sender and receiver.
 How It Works
• Phase 1 – Setup: A path is established between the sender and receiver before
any data is sent. This path is called a virtual circuit.
• Phase 2 – Data Transfer: All packets follow the same predefined path in order.
• Phase 3 – Teardown: After data transfer is complete, the circuit is terminated.
 Key Features
• Connection-oriented: Like a phone call; connection first, then communication.
• Fixed path: All packets travel through the same path.
• Ordered delivery: Packets arrive in the correct order.
• Resource reservation: Bandwidth and buffers may be reserved along the path.
Advantages & Disadvantages

 Advantages
• Reliable and organized data delivery.
• Low variation in delay (good for real-time traffic like voice).
• Easier error control and flow control.
 Disadvantages
• Setup time introduces delay.
• Less flexible—if a link fails, the whole virtual circuit fails.
• Not efficient for bursty data.
 Examples of Virtual Circuit Networks
• ATM (Asynchronous Transfer Mode)
• Frame Relay
• X.25
2. Datagrams
 A Datagram is a connectionless packet switching method, used by the IP
protocol on the internet.
 How It Works
• Each packet is treated as an independent unit.
• Packets may take different paths to the destination.
• No need to set up a path in advance.
• Each packet contains the complete destination address.
 Key Features
• Connectionless: Like sending letters in mail; each letter is sent separately.
• Dynamic routing: Packets may be routed differently depending on network
conditions.
• No guaranteed order: Packets may arrive out of order or get lost.
• Stateless: Routers don’t keep track of connections.
Advantages & Disadvantages
 Advantages
• Fast and flexible.
• No setup delay.
• Efficient use of network resources.
• Scales well for large networks like the Internet.
 Disadvantages
• Unreliable by nature—packets can be lost, duplicated, or arrive out of order.
• More complex reassembly at the receiver’s end.
• Requires additional mechanisms for reliability (like TCP).
 Examples of Datagram Networks
• Internet (IP protocol)
• UDP (User Datagram Protocol)
Analogy
• Virtual Circuit: Like a phone call – you dial a number, connect, talk in order,
and then hang up.
• Datagram: Like postal mail – you send each letter separately; they may
take different routes and arrive at different times.
Addressing in Network Layer

 Addressing refers to the method of assigning unique identifiers to devices


on a network so that data can be sent and received correctly. In computer
networks, this is mainly done through IP addresses at the network layer
(Layer 3).
 There are mainly two types of addresses:
1. Physical Address (MAC Address) – used at the Data Link Layer.
2. Logical Address (IP Address) – used at the Network Layer (our chapter).
IP (Internet Protocol) Address

 An IP address is a logical address that identifies a device on a network


uniquely. It’s assigned by the network or manually configured.
 An IP address is a 32-bit number (for IPv4) or 128-bit number (for IPv6).
 It is typically represented in dotted decimal notation (e.g., 192.168.0.1).
 There are two versions of IP addresses:
• IPv4 (Internet Protocol version 4)
• IPv6 (Internet Protocol version 6)
IPv4 Addressing
 It’s a 32-bit number, usually written in dotted decimal format.
 Divided into 4 octets (each of 8 bits)
 Each IPv4 address has two parts (structure):
• Network ID: Identifies the network.
• Host ID: Identifies the device (host) on that network.
 Classes of IPv4 Addresses
 Originally, IP addresses were divided into classes:

 Note: Modern networking uses CIDR (Classless Inter-Domain Routing) instead of


fixed classes.
IPv6 Addressing

 It’s a 128-bit address, written in hexadecimal.


 Example: 2001:0db8:85a3:0000:0000:8a2e:0370:7334
 Provides a much larger address space to solve IPv4 exhaustion.
 IPv6 simplifies headers and removes fragmentation at routers.
 Supports hierarchical addressing and auto-configuration.
Public vs Private IP Addresses

• Private IP: Used within private networks, not routable on the internet.
• Ranges:
• 10.0.0.0 – 10.255.255.255
• 172.16.0.0 – 172.31.255.255
• 192.168.0.0 – 192.168.255.255

• Public IP: Assigned by ISPs and used to identify your network on the Internet.
Some important points:
 Interfaces and Addressing:
• An interface is the boundary between a host/router and the link.
• IP addresses are assigned per interface, not per device.
• A host with multiple interfaces (e.g., WiFi and Ethernet) will have multiple IP
addresses.
 Subnets:
• A subnet is a portion of the IP address space where all devices can directly
communicate without routing.
• Devices in the same subnet share a common prefix in their IP addresses.
• Determining subnets involves using subnet masks (e.g., /24 means the first 24 bits
are the subnet)
 CIDR (Classless Inter-Domain Routing):
• CIDR allows more flexible division of IP address space.
• Instead of fixed class-based IPs (Class A, B, C), CIDR uses prefix notation
like192.168.1.0/24 .
Subnetting
 Subnetting is the process of dividing a large network into smaller, more
manageable subnetworks (subnets). It enhances routing efficiency, security,
and network performance.

 Why Subnet? {1.To reduce broadcast traffic. 2. To improve network


management and security. 3. To better utilize IP addresses.}
 Subnet Mask :- A subnet mask helps to identify the network and host portion of
an IP address. It works hand-in-hand with the IP address.
 Example:
• IP Address: 192.168.1.10
• Subnet Mask: 255.255.255.0
 This means:
• First 3 octets (192.168.1) = Network part
• Last octet (.10) = Host part
 Advantages of Subnetting
• Efficient IP usage: Prevents wastage of IPs.
• Improved performance: Limits broadcast domains.
• Enhanced security: Easier to isolate and manage.
• Simplifies management: Better control over different departments.

 Formula for Total hosts: 2^(32 - CIDR)


 Formula for usable hosts: 2^(32 - CIDR) – 2 (Subtract 2 for network address and broadcast address.)
How Subnetting Works (with Example)
 Say you’re given a Class C network: 192.168.1.0/24
 That gives you: 256 IPs (0 to 255), but only 254 usable (1 for network, 1 for
broadcast).
 Now you want to create 4 subnets.
 Step 1: Find how many bits you need to borrow: 4 = 2² → You need 2 extra bits from
the host portion.
 New subnet mask = /26 → 255.255.255.192 (11111111.11111111.11111111.11000000)
 Step 2: Find subnet ranges:
 Each subnet has:
• 64 IPs total
• 62 usable IPs-(excluding
network & broadcast
addresses)
Step-by-Step Subnetting Example
 You’re given the network: 192.168.10.0/24. You want 4 subnets.
 Step 1: Calculate how many bits to borrow
- 4=2² → You need to borrow 2 bits from host part.
 Step 2: New Subnet Mask
- Original: /24 = 255.255.255.0 (11111111.11111111.11111111.00000000)
- New: /26 = 255.255.255.192 (11111111.11111111.11111111.11000000)
 Step 3: Find Subnet Ranges
- Each subnet will have 2^(32-26) = 64 addresses (62 usable)
 Increment by 64:
CIDR for Class A addresses = /8 (255.0.0.0)
CIDR for Class B addresses = /16 (255.255.0.0)
CIDR for Class C addresses = /24 (255.255.255.0)
Practice Problems
 Question 1 :- You have network 10.0.0.0/8, and you need at least 1000 subnets.
What subnet mask should you use?
- Hint: How many bits do you need to borrow? Solve: 2ⁿ ≥ 1000 → n = 10 (because
2¹⁰ = 1024) New subnet mask: /8 + 10 = /18
- Answer: /18 = 255.255.192.0
 Question 2 :- Given IP address 192.168.1.50/28, what is the: Subnet address?
Broadcast address? Range of usable IPs?
- /28 = Block size = 16
- 192.168.1.50 falls in 192.168.1.48 – 63
 Subnet Address: 192.168.1.48
 Broadcast Address: 192.168.1.63
 Usable IP Range: 192.168.1.49 – 192.168.1.62
Dijkstra’s Routing Algorithm
 The Optimality Principle : The Optimality Principle, proposed by Bellman
(1957), states:
- If a router J is on the optimal path from router I to router K, then the optimal path from
J to K is also part of that same path.
 This principle implies that optimal paths exhibit a recursive property.
 As a result, the set of optimal routes from all sources to a given destination forms a
tree, called a sink tree, rooted at the destination.
 These trees help visualize how routers find shortest paths.
 While multiple such trees may exist (especially with equal cost paths), routing
algorithms aim to discover and use these sink trees.

Dijkstra’s Shortest Path Algorithm : Dijkstra’s algorithm is a graph-


based algorithm that computes the shortest path from a single source node to all
other nodes.
 Key Concepts:
- Graph Representation: Nodes are routers, edges are links with weights (e.g., delay,
hops, cost).
- Labels : Each node is assigned a tentative label (initially infinity). When the shortest
path to a node is found, its label becomes permanent.
- Selection Rule: At each step, the algorithm selects the tentatively labeled node with
the smallest distance, updates neighbors, and repeats until all nodes are labeled
permanently.
 Steps :
1. Label the source node with distance 0 and make it permanent.
2. For each neighbor of the current node:
1. Compute distance via this node.
2. If this distance is less than the current label, update it.
3. Select the tentatively labeled node with the smallest distance.
4. Repeat until the destination is reached or all nodes are permanent.
 Advantages:
• Finds optimal paths based on metrics (delay, bandwidth, cost).
• Guarantees loop-free paths.
Example:
 Let’s consider a simple network graph with the following nodes and link weights:
 Goal: Find the shortest path from A to all other nodes
using Dijkstra's algorithm.

 Shortest Paths from A:


 A to B: 1 hop via A
 A to E: 2 hops via A
 A to C: 3 hops via A
 A to D: 5 hops via C
 This demonstrates how each step permanently selects the shortest tentative path and
updates neighbors.
Distance Vector Routing
 Also known as the Bellman-Ford algorithm, Distance Vector Routing is distributed
and dynamic.
 Working:
(1) Each router maintains a routing table (distance vector) with:
- Best known distance to every destination.
- Which neighbor to use (next hop).
(2) Routers exchange tables periodically with their neighbors.
(3) Upon receiving a neighbor's vector, the router recalculates the shortest paths:
- For each destination, it checks:
New distance = distance to neighbor + neighbor's distance to destination
- Chooses the smallest such distance and updates its table.
 Key Points:
• Distance metric can be hops, delay, etc.
• Used in RIP (Routing Information Protocol).
• Count-to-infinity problem: When bad news (e.g., link failure) spreads slowly and
routers increment distance values indefinitely before correcting.
• Solutions: Split horizon, poisoned reverse (partial fixes).
 Strengths:
• Simple to implement.
• Requires little information (just neighbor’s vectors).
 Weaknesses:
• Convergence is slow, especially in large networks.
• Vulnerable to routing loops and incorrect routes during convergence.
Example:
 Assume a network like this:
- Each router maintains a distance vector table:
 Initial Distance Vectors:
• A: A(0), B(1), C(3), D(∞)
• B: B(0), A(1), D(2), C(∞)
• C: C(0), A(3), D(4), B(∞)
• D: D(0), B(2), C(4), A(∞)
 Exchange and Update:
• A learns from B that D is 3 away (B–D = 2 + B–A = 1)
• A updates D to 3 via B.
• A learns from C that D is 7 away (C–D = 4 + A–C = 3), but 3 via B is better.
 Each node repeatedly updates its table until convergence.
 Count-to-Infinity Problem:
• If link A–B fails, B tells A: “I reach D in 2.”
• A updates: “Then I reach D via B in 3,” despite the route no longer existing.
• Loop continues with each incrementing count.

 This is solved partially by:


• Split Horizon: Don’t tell a neighbor about routes learned from it.
• Poisoned Reverse: Tell neighbor route is unreachable if learned from them.
Overview of Network Layer protocols-
(ARP, IPV4, ICMP, RARP, IPV6, DHCP)

1. ARP (Address Resolution Protocol)


 Purpose: Resolves IP addresses to MAC (hardware) addresses.
 How it works:
• A host that wants to send an IP packet broadcasts an ARP request on the
network.
• The request includes the target IP address.
• The host with that IP responds with its MAC address.
• This mapping is then cached for future use.
 Special Case – Proxy ARP: A router can respond to ARP requests on behalf of
another device (e.g., a mobile device temporarily on a different network).
2. RARP (Reverse Address Resolution Protocol)
 Purpose: The inverse of ARP; it maps MAC addresses to IP addresses.
 Use Case: Used by diskless workstations to obtain an IP address when they only know
their MAC address.
 Note: RARP is obsolete and has been replaced by more robust protocols like BOOTP
and DHCP

3. IPv4 (Internet Protocol Version 4)


 Purpose: The primary protocol for routing and addressing packets across networks.
 Header Structure:
• 20-byte fixed part, optional extension fields.
• Includes fields like source/destination address, TTL, protocol, checksum, etc.
• Limited address space: Only ~4.3 billion addresses, which is insufficient for modern
needs.
 Challenges:
• Limited scalability
• No inherent security
• No built-in QoS or mobility features.
4. ICMP (Internet Control Message Protocol)
 Purpose: Used for error handling and diagnostics in network communication.
 Key ICMP Messages:
• Destination Unreachable – Packet couldn't be delivered.
• Time Exceeded – TTL reached 0; used in Traceroute.
• Echo Request/Reply – Used by Ping to check host availability.
• Redirect – Informs sender of a better route.
• Parameter Problem – Indicates malformed header issues.
 Usage: Essential for diagnosing network issues, e.g., unreachable hosts, loops.

5. IPv6 (Internet Protocol Version 6)


 Purpose: Successor to IPv4, designed to solve its limitations.
 Key Features:
• 128-bit addressing – Vast address space.
• Simplified header – Only 7 fields (vs. 13 in IPv4).
• Improved performance and security
• Extension headers – Flexible mechanism for additional options.
• Quality of Service (QoS) and mobility features are built-in.
• Flow label field for packet stream handling.
 Transition from IPv4: Supported by mechanisms like tunneling and dual-stack
setups.

6. DHCP (Dynamic Host Configuration Protocol)


 Purpose: Automatically assigns IP addresses and other configuration details to
hosts.
 Process:
1. Host sends DHCP DISCOVER broadcast.
2. Server replies with DHCP OFFER.
3. Host sends a REQUEST, and the server responds with an ACK.
 Leasing: IP addresses are assigned temporarily. Hosts must renew the lease
periodically.
 Advantage: Eliminates manual configuration, supports dynamic environments,
used widely by ISPs and enterprises.
 Replaces: BOOTP and RARP, offering more flexibility.

You might also like