0% found this document useful (0 votes)
5 views39 pages

Unit 5 - Network Layer

The document provides an overview of the Network Layer (Layer 3) functions, including logical addressing, routing, packetizing, fragmentation, and error reporting. It explains the concepts of IP addressing, subnetting, and various networking devices like hubs, switches, routers, and gateways. Additionally, it discusses routing types, algorithms, and protocols such as RIP and OSPF, along with their advantages and disadvantages.

Uploaded by

herbertrb22
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)
5 views39 pages

Unit 5 - Network Layer

The document provides an overview of the Network Layer (Layer 3) functions, including logical addressing, routing, packetizing, fragmentation, and error reporting. It explains the concepts of IP addressing, subnetting, and various networking devices like hubs, switches, routers, and gateways. Additionally, it discusses routing types, algorithms, and protocols such as RIP and OSPF, along with their advantages and disadvantages.

Uploaded by

herbertrb22
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

Unit 5- Network

Layer
The Network Layer (Layer 3) is primarily responsible for host-to-host delivery by moving data
packets across different networks.

Core Functions:
•Logical Addressing: Assigns a unique, hierarchical software address (like IPv4) to every device,
which is necessary for communication beyond the local network.
•Routing: Determines the best physical path for a packet to travel from the source to the
destination using routers and routing tables.
•Packetizing: Encapsulates data from the upper layer into "Packets" (Datagrams) by adding a
header containing source and destination IP addresses.
•Fragmentation and Reassembly: Breaks large packets into smaller fragments to fit the size limits
(MTU) of different network links and reassembles them at the destination.
•Internetworking: Connects diverse types of networks (e.g., WiFi, Ethernet, Fiber) to create a
single, seamless communication channel.
•Error Reporting: Uses protocols like ICMP to notify the sender if a destination is unreachable or
if a packet is dropped.
Addressing in Data Communication and Computer Network
Addressing provides a unique identity to every device on a network. There are two main levels
of addressing used in data communication:

•Physical (MAC) Addressing: Operates at the Data Link Layer and identifies a device within a
local network segment.

•Logical (IP) Addressing: Operates at the Network Layer. It is a software-based address that
allows communication between different, geographically separated networks.

•Hierarchical Structure: Unlike MAC addresses, logical addresses are hierarchical, meaning they
contain information about both the network and the specific host on that network, enabling
efficient routing.
Logical Addressing with IP (IPv4)

IPv4 (Internet Protocol version 4) is the most common form of logical addressing. It uses a 32-bit
binary string to uniquely identify a connection to the network.
Router uses the IP address to route packet to correct network segment

•Notation: For human readability, these 32 bits are divided into four 8-bit sections called octets,
separated by dots (e.g., [Link]). This is known as Dotted-Decimal Notation.

•Address Space: A 32-bit address provides a total of 2^32 (approximately 4.29 billion) unique
addresses.

•Components: Every IP address consists of two parts:


•Network ID (Netid): Identifies the network on the network.
•Host ID (Hostid): Identifies the specific device on that network.
Classful Addressing (IP Addressing)
Classful addressing is an old method of assigning IPv4 addresses where the address space is divided into
five classes (A, B, C, D, E) based on the first octet of the IP address.
In this scheme, the network part and host part are fixed for each class.

IPv4 Address Structure


An IPv4 address is 32 bits, written as 4 octets:

Example:
Network ID + Host ID
[Link]
11000000.10101000.00000001.00000001
Characteristics of the Classes:
Number of Hosts per
Class First Octet Range Network/Host Split Primary Use
Network

8-bit Netid / 24-bit 2^24 - 2 (approx.


Class A 1 – 126 Huge organizations
Hostid 16M)

16-bit Netid / 16-bit Medium-large


Class B 128 – 191 2^16 - 2(65,534)
Hostid organizations

24-bit Netid / 8-bit


Class C 192 – 223 2^8 - 2 (254) Small organizations
Hostid

Class D 224 – 239 No Hostid split N/A Multicasting

Experimental/Resear
Class E 240 – 255 No Hostid split N/A
ch
Networking Connecting Devices: Hub, Switch, Bridge, Router, Gateway

Hub
•Layer: Physical Layer (Layer 1).
•Function: A basic device that connects multiple computers in a LAN.
•Working: It is a "non-intelligent" device. When it receives a data
packet at one port, it broadcasts it to all other ports, regardless of the
intended destination. This often leads to network congestion and
collisions.

Switch
•Layer: Data Link Layer (Layer 2).
•Function: A more intelligent version of a hub used to connect devices
in a LAN.
•Working: It records the MAC addresses of connected devices in a
switch table. Unlike a hub, it sends data only to the specific port where
the destination device is connected, reducing traffic and improving
security.
Bridge
•Layer: Data Link Layer (Layer 2).
•Function: Used to connect two separate LAN segments to
make them act as a single network.
•Working: It filters traffic by checking the destination MAC
address to decide whether to pass the data to the other
segment or block it.

Router
•Layer: Network Layer (Layer 3).
•Function: Connects different networks together (e.g.,
your home network to the Internet).
•Working: It uses IP addresses and routing tables to
determine the most efficient path for data to travel across
the internet.
Gateway
•Layer: Operates at all layers (primarily Layers 4–7).
•Function: Acts as a "protocol converter" or translator between two networks with different
architectures.
•Working: It translates data from one set of protocols to another, allowing completely
different systems to communicate with each other.
Subnetting
Subnetting is the process of dividing a single physical network into two or more smaller logical
networks (subnets). It is a key strategy used in IP addressing to improve network performance and
security.
Purpose of Subnetting
•Reduce Network Traffic: By limiting the size of broadcast domains, it prevents unnecessary traffic
from flooding the entire network.
•Improve Security: It allows administrators to isolate specific departments or sensitive data within
their own subnets.
•Efficient Use of IP Space: Subnetting helps prevent the wasting of IP addresses, especially in
Classful Addressing schemes where large blocks of addresses might otherwise go unused.

How Subnetting Works


Subnetting works by "borrowing" bits from the Host ID portion of an IP address and assigning
them to the Network ID portion. This creates a third level of hierarchy: Network ID, Subnet ID,
and Host ID.
The Subnet Mask
A Subnet Mask is a 32-bit value that helps the router distinguish which part of the IP address
identifies the network and which part identifies the host.
•Binary 1s in the mask represent the network/subnet portion.
•Binary 0s represent the host portion.

Address Class Default Subnet Mask (Decimal) Default Subnet Mask (Binary)
11111111.00000000.00000000.
Class A [Link]
00000000
11111111.11111111.00000000.
Class B [Link]
00000000
11111111.11111111.11111111.
Class C [Link]
00000000
Network ID
Every subnet will always have its first IP/ Starting IP as network IP /ID with which it will connect
to the network.
Logical AND between IP and subnet mask.

Broadcast ID
Last IP address of subnet range
This Broadcast ID is utilized to talk to all your host within that particular network
First IP Network ID Usable host IP Last IP Broadcast ID
Basic Calculations
When you borrow n bits from the host portion:
•Number of Subnets Created: 2^n
•Number of Hosts per Subnet: 2^h - 2 (where h is the number of remaining host bits).
•Note: We subtract 2 because the first address is the Network Address and the last is the
Broadcast Address.

CIDR Notation (Classless Inter-Domain Routing)


Modern subnetting uses CIDR notation (or "slash notation") instead of traditional masks. It
represents the number of bits used for the network/subnet portion.
•Example: [Link]/24 means the first 24 bits are for the network, which is the same as a mask
of [Link].
•Example: [Link]/26 means 26 bits are for the network (borrowing 2 bits from Class C),
creating 4 subnets (2^2).
Question
From Given Ip [Link]/27 calculate:
1. No of subnet
2. No of host per subnet

Solution:
Subnet bits= 3
No. of Subnets = 2^3 = 8

Host bits = 5
No of hosts 2^5=32
Usable number of host = 32-2= 30
Question
A company is assigned the IP address [Link]/24. The network administrator needs to create 4 equal subnets.
[Link] the new subnet mask (CIDR notation).
[Link] the Network ID, Broadcast ID, and usable IP address range for each subnet.

Solution
Step 1: Given Information
•Given IP address: [Link]/24
•Number of required subnets: 4

Step 2: Determine number of subnet bits


To create 4 subnets:
2𝑛 = 4 ⇒ 𝑛 = 2
Borrow 2 bits from the host portion.
•Original CIDR: /24
•New CIDR: /24 + 2 = /26

Step 3: Find total and usable hosts per subnet


•Total IPs per subnet:
26 = 64
•Usable hosts per subnet:
64 − 2 = 62
Step 4: Subnet details
Block size = 64

Subnet 1
•Network ID: [Link]
•Broadcast ID: [Link]
•Usable IPs: [Link] – [Link]
Subnet 2
•Network ID: [Link]
•Broadcast ID: [Link]
•Usable IPs: [Link] – [Link]
Subnet 3
•Network ID: [Link]
•Broadcast ID: [Link]
•Usable IPs: [Link] – [Link]

Subnet 4
•Network ID: [Link]
•Broadcast ID: [Link]
•Usable IPs: [Link] – [Link]
Question
A company has been allocated the IP address range [Link]/16. The company needs to create
four subnets to accommodate 108 hosts, 83 hosts, 52 hosts, and 15 hosts respectively.
[Link] the appropriate CIDR notation for each subnet.
[Link] mention the network ID, broadcast ID, and usable IP address range for each subnet.

Solution (Using VLSM – Variable Length Subnet Masking)

Step 1: Arrange host requirements in descending order


In VLSM, largest subnet is allocated first.
Subnet Required Hosts
Subnet 1 108
Subnet 2 83
Subnet 3 52
Subnet 4 15

Step 2: Determine required block size and CIDR


Formula:
2𝑛 − 2 ≥ Number of hosts
Hosts Needed IPs Block Size CIDR
108 128 128 /25
83 128 128 /25
52 64 64 /26
15 32 32 /27
Step 3: Allocate subnets from [Link]
Subnet 1 (108 Hosts)
•CIDR: /25
•Block size: 128
Detail Address
Network ID [Link]
Broadcast ID [Link]
Usable IP Range [Link] – [Link]
Subnet 2 (83 Hosts)
•CIDR: /25
•Block size: 128
Detail Address
Network ID [Link]
Broadcast ID [Link]
Usable IP Range [Link] – [Link]
Subnet 3 (52 Hosts)
•CIDR: /26
•Block size: 64
Detail Address
Network ID [Link]
Broadcast ID [Link]
Usable IP Range [Link] – [Link]

Subnet 4 (15 Hosts)


•CIDR: /27
•Block size: 32
Detail Address
Network ID [Link]
Broadcast ID [Link]
Usable IP Range [Link] – [Link]
Routing
Routing is the process of selecting the best path for data packets to travel from a source to a destination across a
network.
Routers use routing algorithms and routing tables to make forwarding decisions.

Types of Routing
Routing algorithms are broadly classified into:
[Link]-Adaptive Routing
[Link] Routing
1. Non-Adaptive Routing (Static Routing)
Definition
Non-adaptive routing is a routing technique in which the route is fixed and does not change, regardless of
network conditions such as traffic load or link failure.
Characteristics
•Routes are predefined
•No real-time network information is used
•Simple to implement
•Not flexible
Advantages
•Low overhead
•Easy configuration
•Stable routing paths
Disadvantages
•Cannot handle congestion
•No response to link or node failures
•Poor performance in large or dynamic networks
Examples
•Static Routing
•Flooding
•Random Routing
2. Adaptive Routing (Dynamic Routing)
Definition
Adaptive routing is a routing technique in which the route changes dynamically based on current network
conditions such as traffic, delay, bandwidth, or failures.
Characteristics
•Routes are updated automatically
•Uses real-time network information
•More complex than non-adaptive routing
Advantages
•Efficient use of network resources
•Automatically adapts to failures
•Better performance in large networks
Disadvantages
•Higher overhead
•More complex algorithms
•Requires more processing power
Examples
•Distance Vector Routing (RIP)
•Link State Routing (OSPF)
•Path Vector Routing (BGP)
Routing Table
A routing table is a data structure maintained by a router that stores information about routes to
different networks.
It helps the router decide where to forward incoming packets.
A typical routing table contains:
•Destination Network, Subnet Mask, Next Hop, Interface, Metric (Cost)

Example of a Routing
Table
Destination Subnet Mask Next Hop Interface Metric
[Link] [Link] [Link] Eth0 1
[Link] [Link] [Link] Eth1 2
[Link] [Link] [Link] Eth0 10
[Link] represents the default route.
Functions of a Routing Table
•Determines the best path
•Helps in packet forwarding
•Supports dynamic route updates
•Reduces routing errors
Routing Protocols
A routing protocol is a set of rules used by routers to exchange routing information and determine the best
path for data packets in a network.
Common routing protocols include RIP, OSPF, and BGP.

1. RIP (Routing Information Protocol)


RIP is a distance vector routing protocol that uses hop count as its routing metric.
Features
•Maximum hop count: 15
•Updates every 30 seconds
•Uses Bellman-Ford algorithm
•Simple to configure
Advantages
•Easy to implement
•Low resource requirement
Disadvantages
•Slow convergence
•Not suitable for large networks
•Hop count is a weak metric
Use Case
•Small networks
2. OSPF (Open Shortest Path First)
OSPF is a link-state routing protocol that uses cost as its metric and calculates shortest paths using
Dijkstra’s algorithm.

Features
•Fast convergence
•Supports large networks
•Uses areas (hierarchical design)
•No hop count limitation

Advantages
•Efficient and scalable
•Supports load balancing
•Better fault tolerance

Disadvantages
•More complex configuration
•Higher resource usage

Use Case
•Large enterprise networks
3. BGP (Border Gateway Protocol)
BGP is a path vector routing protocol used to exchange routing information between autonomous
systems (AS) on the Internet.

Features
•Uses policies instead of metrics
•Highly scalable
•Runs over TCP (Port 179)

Advantages
•Internet-scale routing
•High reliability
•Policy-based routing

Disadvantages
•Complex configuration
•Slow convergence

Use Case
•Internet Service Providers (ISPs)
Unicast Routing
Unicast routing is the process of sending data from one source to one destination.

Characteristics
•One-to-one communication
•Most common form of routing
•Uses standard routing protocols

Examples
•Web browsing
•Email
•File transfer

Protocols Used
•RIP
•OSPF
•BGP
Multicast Routing
Multicast routing sends data from one source to multiple selected receivers simultaneously.

Characteristics
•One-to-many communication
•Efficient bandwidth usage
•Uses multicast groups

Advantages
•Reduces network traffic
•Efficient for streaming and conferencing

Examples
•Live video streaming
•Online classes
•Video conferencing

Multicast Routing Protocols


•IGMP (Internet Group Management Protocol)
•PIM (Protocol Independent Multicast)
•DVMRP
Routing Algorithms
A routing algorithm determines the best path for forwarding packets from a source to a destination in a
network.
The main routing algorithms are:
[Link] Path Routing
[Link] Vector Routing
[Link]-State Routing
1. Shortest Path Routing Algorithm
Shortest Path Routing selects the path between source and destination that has the minimum cost, where cost may
represent distance, delay, bandwidth, or hop count.
Working Principle
•The network is represented as a graph
•Each link has a weight (cost)
•The algorithm finds the least-cost path
Common Algorithm Used
•Dijkstra’s Algorithm
Example
If Path A has cost = 10 and Path B has cost = 6, the algorithm selects Path B.
Advantages Disadvantages
•Efficient path selection Requires complete network information
•Works well for stable networks Higher computation cost
2. Distance Vector Routing Algorithm
Distance Vector Routing is a routing algorithm where each router maintains a vector (table) containing the
distance (cost) to every destination and the next hop.

Working Principle
•Routers exchange routing tables with neighbor routers
•Uses Bellman-Ford algorithm
•Updates occur periodically

Key Features
•Metric: hop count or cost
•Routing decisions are based on neighbor information

Example Protocol
•RIP (Routing Information Protocol)

Advantages Disadvantages
•Simple implementation •Slow convergence
•Low overhead •Not suitable for large networks
3. Link-State Routing Algorithm
Link-State Routing is a routing algorithm where each router has a complete map of the network topology.

Working Principle
[Link] router discovers its neighbors
[Link] cost to neighbors
[Link] link-state information
[Link] a topology database
[Link] Dijkstra’s algorithm

Key Features
•Fast convergence
•Accurate routing decisions

Example Protocol
•OSPF (Open Shortest Path First)

Advantages Disadvantages
•Scalable •Complex implementation
•Less prone to routing loops •Requires more memory and CPU
Protocols Operating at the Network Layer
The Network Layer (Layer 3) of the OSI model is responsible for logical addressing, routing, and error handling.
Several supporting protocols operate at or closely with the Network Layer, including ARP, RARP, and ICMP.

1. ARP (Address Resolution Protocol)


ARP is used to map an IP address to a physical (MAC) address in a local network.
Why ARP is Needed
Communication in a LAN uses MAC addresses, while applications use IP addresses. ARP bridges this gap.
Working of ARP
[Link] broadcasts an ARP Request:
“Who has IP address X?”
[Link] target host replies with an ARP Reply containing its MAC address
[Link] sender stores this information in the ARP cache
Features
•Uses broadcast and unicast messages
•Works only within the same network
Advantages
•Automatic address resolution
•Fast communication
Example
Finding the MAC address for IP [Link]
2. RARP (Reverse Address Resolution Protocol)
RARP is used to find an IP address when the MAC address is known.

Purpose
Used by diskless systems to obtain an IP address during booting.

Working of RARP
[Link] sends a RARP request with its MAC address
[Link] server replies with the corresponding IP address

Limitations
•Requires a RARP server
•Works only in local networks
•Largely replaced by BOOTP and DHCP

Example
Diskless workstation requesting its IP address
3. ICMP (Internet Control Message Protocol)
ICMP is used for error reporting and network diagnostics.

Functions
•Reports unreachable destination
•Detects routing errors
•Supports network troubleshooting

Common ICMP Messages


•Echo Request / Echo Reply (used by ping)
•Destination Unreachable
•Time Exceeded (used by traceroute)

Features
•Encapsulated inside IP packets
•Does not carry application data

Advantages
•Helps diagnose network problems
•Improves network reliability
IPv6
IPv6 (Internet Protocol version 6) is the successor of IPv4, developed to solve problems such as limited
address space, complex header processing, and lack of built-in security in IPv4.
Advantages of IPv6

•Huge Address Space


IPv6 uses 128-bit addresses, eliminating the shortage of IP addresses.

•Simpler Packet Processing


Fixed-length header reduces router processing time.

•End-to-End Connectivity
No need for NAT, allowing direct device-to-device communication.

•Built-in Security
IPsec support improves data authentication and encryption.

•Better Performance for Multimedia


Flow Label and Traffic Class help manage real-time traffic.

•Auto Configuration
Devices can configure addresses automatically without a DHCP server.
IPv6 Packet Format

IPv6 has a simpler and fixed-length header compared to IPv4.


IPv6 Header Format (40 bytes)

Field Size Description


Version 4 bits IP version (6)
Traffic Class 8 bits Priority and QoS
Flow Label 20 bits Identifies packet flow
Payload Length 16 bits Size of payload
Next Header 8 bits Type of next header
Hop Limit 8 bits Prevents looping
Source Address 128 bits Sender’s address
Destination Address 128 bits Receiver’s address

IPv6 does not include checksum and fragmentation fields in the base header.
Dual Stack
Dual Stack is a technique where IPv4 and IPv6 run simultaneously on the same device.

Working
•Devices have both IPv4 and IPv6 addresses
•Communication uses IPv6 if available, otherwise IPv4

Advantages
•Smooth migration from IPv4 to IPv6
•No need to change existing infrastructure

Disadvantages
•Increased configuration complexity
•Requires more memory and processing
Tunneling
Tunneling allows IPv6 packets to be transmitted over an IPv4 network.

Working
•IPv6 packet is encapsulated inside an IPv4 packet
•IPv4 network carries the packet
•IPv6 packet is decapsulated at destination

Types of Tunneling
•Manual tunneling
•Automatic tunneling
•6to4 tunneling

Advantages
•Enables IPv6 communication without full IPv6 infrastructure
•Cost-effective transition method

Disadvantages
•Extra overhead due to encapsulation
•Slower performance

You might also like