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

CN Unit 4

The document provides an overview of the Network Layer in computer networking, detailing its responsibilities including routing, logical addressing, and packet management. It discusses various routing algorithms, including adaptive and non-adaptive types, as well as specific algorithms like Dijkstra and Bellman-Ford. Additionally, it contrasts IPv4 and IPv6, explains ICMP's role in diagnostics, and outlines concepts like least cost routing and IP address classes.

Uploaded by

Coder R1ck
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 views21 pages

CN Unit 4

The document provides an overview of the Network Layer in computer networking, detailing its responsibilities including routing, logical addressing, and packet management. It discusses various routing algorithms, including adaptive and non-adaptive types, as well as specific algorithms like Dijkstra and Bellman-Ford. Additionally, it contrasts IPv4 and IPv6, explains ICMP's role in diagnostics, and outlines concepts like least cost routing and IP address classes.

Uploaded by

Coder R1ck
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/ 21

CN UNIT 4

NETWORK LAYER :

1. This layer is responsible for routing data packets between


different networks or sub-networks. It determines the best
path for data to travel from source node to destination
node.
2. It deals with logical addressing (IP) of data packets , path
selection via routing protocols, and handles packet
fragmentation/reassembly.
3. It performs various functions like Routing , Logical
addressing and packet fragmentation and reassembly.
4. It uses protocols like IPV4 , IPV6 , ICMP ,ARP etc.

SERVICES PROVIDED BY NETWORK LAYER :

1) Logical Addressing
2) Routing
3) Packetizing
4) Packet Forwarding
5) Packet Fragmentation & Reassembly
6) Error Handling & Diagnostics

 Logical Addressing : Logical addressing is the process of


assigning unique IP addresses (IPv4 or IPv6) to identify
devices within a network. Helps in identifying the source and
destination of each packet across different networks.

 Routing :
1. Routing is the process of determining the optimal path
for data packets to travel from source to destination node.

2.The Network Layer uses routing protocols (e.g., RIP,


OSPF, BGP) to exchange routing information and
maintain routing tables, enabling dynamic path selection
based on network conditions.
 Packetizing

Packetizing is the process of encapsulating data from the


Transport Layer into Network Layer Protocol Data Units (PDUs),
known as packets .
This process involves adding necessary headers to packets for
routing and delivery of packets.

 Packet Forwarding -

Forwarding is the actual process of moving a packet from an


incoming interface of a router to the appropriate outgoing interface,
based on the router's routing table.

When a packet arrives, the router quickly consults its forwarding


(or routing) table to make a hop-by-hop decision, directing the
packet closer to its final destination effectively.

 Packet Fragmentation & Reassambly -


If a packet is too large for the underlying network , the Network
Layer breaks it into smaller pieces (fragments).

These fragments are reassembled at the destination to reconstruct


the original packet.

 Error Handling & Diagnostics -

The Network Layer includes mechanisms for error detection and


diagnostics. Protocols like ICMP (Internet Control Message
Protocol) are used to report errors, provide feedback on network
conditions, and facilitate troubleshooting.

ROUTING :
Routing is the process of determining the optimal path for
data packets to travel from source to destination node.

ROUTING ALGORITHMS :
A routing algorithm refers to set of rules used by routers
to determine the best path for forwarding packets from
source to destination across a network.

Properties :
1) Correctness
2) Robustness
3) Stability
4) Optimality
5) Simplicity
Types of Routing Algorithms :

6) Adaptive (Dynamic) Routing Algorithm :

These are the algorithms that change their routing decisions


whenever network topology or traffic load changes. Routers
exchange routing information, and routing tables are
updated continuously in response to changes in network
topology, traffic, or link costs.

Types :

Isolated : In this method each, node makes its routing


decisions using the information it has without seeking
information from other nodes.

Centralized : In this method, a centralized node has entire


information about the network and makes all the routing
decisions.

Distrubuted : In this method, the node receives information


from its neighbors and then takes the decision about routing
the packets.

7) Non-Adaptive (Static) Routing Algoritm :

These are the algorithms that do not change their routing


decisions once they have been selected. This is also known
as static routing as a route to be taken is computed in
advance and downloaded to routers when a router is booted
Types :

Flodding : In this method, every incoming packet is sent on


every outgoing line except from which it arrived. One
problem with this is that packets may go in a loop and as a
result of which a node may receive duplicate packets.

Random Walk : In this method, packets are sent node by


node to one of its neighbors randomly. This is a highly robust
method that is usually implemented by sending packets onto
the link which is least queued.
DIJKSTRA ALGORITHM :

DJKSTRA is a graph search algorithm & is used for


computing the shortest path from a single source node to
every other node in a weighted graph (network) where the
weights represent the cost (like distance, time, or bandwidth
usage) between nodes.
It is widely used in Link-State Routing protocols like OSPF
(Open Shortest Path First).
The idea is to build a graph of the subnet, where:
Nodes : each node of the graph representing a router
Edges : each edge of the graph representing a
communication line (often called a link) b/w routers.
Edge Weights (Costs) : represent cost of traversing a link.
To choose a route between a given pair of routers, the
algorithm just finds the shortest path between them on the
graph.
ALGORITHM :

Example : write your


you own
BELLMAN FORD ALGORITHM :

Bellman–Ford is a distance–vector routing algorithm that


computes the shortest paths from a single source node to all
other nodes in a weighted graph. It can correctly compute
shortest paths even in graphs containing negative edge
weights.
Distance vector routing algorithms work by having each
node(router) maintain a routing table (i.e. a vector) giving the
best known distance to each destination and which line to
use to get there. These tables are updated by exchanging
information with the neighbors.
In computer networks, it is the foundational algorithm for
Distance Vector routing protocols (e.g., RIP - Routing
Information Protocol), which are used for intra-domain
routing.

Steps of Bellman-Ford Algorithm :


Initialization:
Set the source node’s distance to 0.
Assign infinity to all other nodes.
Edge Relaxation (V-1 iterations):
For each node V-1 times (where V = number of nodes):
Update distances for every edge (u, v) using:
distance[v]=min(distance[v],distance[u]+weight(u,v))
Negative Cycle Check:
Check
After V-1 iterations, if any edge can still be relaxed, the
graph contains a negative cycle

Example : watch a yt video for example.

BROADCAST ROUTING :

1. Delivers packets from a source to all nodes in the


network, regar dless of whether they need the
regardless
information.
2. All nodes in the network receive the packet, regardless
of need
3. Commonly used in LAN’S for tasks like ARP requests,
or network-wide alerts.
Methods Used :
1. Flooding :
Every router receiving a broadcast packet forwards it on all
outgoing links except the one it arrived on. This continues until
all nodes receive the packet. While simple, flooding can cause
excessive duplicate packets and network congestion
2. Spanning Tree Protocol (STP):
Routers use a spanning tree structure (a loop-free subset of the
network) to ensure each link is used only once, minimizing
duplicate packets Each router forwards the broadcast packet only
along spanning tree links.
3. Sending Individual Packet :
The source sends a separate packet to each destination. This
method is bandwidth-inefficient and requires the sender to know
all destinations

Adv : Simple , Efficient Delivery

DisAdv : Bandwidth Inefficient, Network Congestion


MULTICAST ROUTING :

1. Delivers packets from a source to only a sel


selected group
of interested nodes (multicast group).
2. Only nodes that are part of the multicast group receive
the packet
3. Widely used in applications like video streaming, where
only subscribers need the stream.
Multicast Routing Protocols :
Multicast routing uses spanning trees ,toto avoid loops. The
optimal trees are called ( shortest path spanning trees).
trees)
Commonly used routing protocols are :
1. Protocol Independent Multicast (PIM),
2. Distance Vector Multicast Routing Protocol (DVMRP),
3. and Multicast OSPF (MOSPF)
4. IGMP (Internet Group Management Protocol)
Adv : Bandwidth efficient, Reduced Network Congestion

DisAdv : Complexity , Group Management Overhead

HIERARCHIAL ROUTING :

1. It is a routing technique where a large network is


divided into smaller, manageable regions or layers
(hierarchies) to simplify routing.
2. Each router maintains complete information about how
to reach destinations within its own region, but only
summary or aggregated information about other regions
3. At the highest level the network is partitioned into
Autonomous Systems which are then further divided
into regions or areas.
4. Area Border Routers (ABRs) : Routers that connect
two or more areas.
Working :
Routing in a hierarchical structure operates at two distinct
levels:

Within an Area: Routers exchange link-state or distance-


vector updates; each computes shortest paths using
Dijkstra or Bellman-Ford.
Between Areas: ABRs collect routes, summarize them
and advertise the summary to other ABRs.
Adv :

 Reduced Routing Table Size:


 Scalability
 Improved Performance
 Simplified Management:

DisAdv : Complexity , Potential for Sub optimal paths.

Example :
Internet Routing
The Internet itself is a prime example of hierarchical routing, where
different autonomous systems (AS) manage their internal routing while
exchanging summarized routes with other ASes using BGP.
IPv4 vs IPv6

Feature IPv4 IPv6


Address 32-bit address 128-bit address
Length
Address It can generate It can generate
Space 4.29x10^9 addres 3.4x10^38 address
s space space
Fields IPv4 consists of 4 IPv6 consists of 8 fields,
fields which are which are separated by
separated by a colon (:)
addresses dot (.)
Address Dotted-decimal Hexadecimal notation,
Format notation separated by colons
Message Broadcast Multicast & anycast
Transmission message transmission
Scheme scheme.
Header Size Variable header Fixed header size (40
size (20 to 60 bytes)
bytes)
Checksum Includes a header No header checksum.
checksum field Error handled by
for error TCP/UDP layers.
checking.
Fragmentation Routers can Only the sender
fragment packets performs fragmentation.
if they exceed the
MTU of a link.
Security IPsec (IP IPsec is built-in and
Security) is mandatory in the IPv6
optional and standard, providing
implemented as native end-to-end
an add-on. security.
Address It Supports It supports Auto and
Configuration Manual renumbering address
and DHCP addre configuration.
ss configuration
QoS Limited QoS Improved Qos
capabilities Capabilities
Packet flow Not Available Available & uses flow
identification label field in header
Example Example of IPv4: Example of IPv6:
66.94.29.13 2001:0000:3238:DFE1:0
063:0000:0000:FEFB

ICMP :

1) The Internet Control Message Protocol (ICMP) is an


integral part of the Network Layer (Layer 3) in the
TCP/IP suite.
2) Unlike IP, which delivers user data, ICMP is used only
for network diagnostics and error reporting.
Key Functions of ICMP:
 Error Reporting: reports error message back to original
source IP in case of lost packet or problem processing a
packet .
 Network Diagnostics: ICMP is widely used by network
administrators and troubleshooting tools to assess
network connectivity, measure latency, and map
network paths.
 Informational Messages: Beyond errors, ICMP also
exchanges certain informational messages to help
devices understand network conditions or discover
network parameters.

ICMP messages can be broadly divided into two broad


categories:
error reporting messages and query messages as follows.
Error reporting Messages:
1) Destination unreachable,
2) Time exceeded,
3) Source quench,
4) Parameter problems,
5) Redirect
Query:
1) Echo request and reply,
2) Timestamp request and reply,
3) Address mask request and reply
Header Format :
0 8 16 31
Type Code ChekSum
Rest of Header
Original IP Header + 64 bits of Datagram

Error Reporting message headers use this format.

Type Code ChekSum


Identifier Sequence Number
Original IP Header + 64 bits of Datagram

Echo Request Headers , TimeStamp , etc. use this format.


Least Cost Routing :

Least Cost Routing (LCR) is a fundamental principle in


computer networking that explains how routers determine
the most efficient path for data packets to travel from a
source to a destination.
It's not a specific algorithm itself, but rather a guiding
objective for various dynamic routing algorithms.

Working Principle of Least Cost Routing

1. The Concept of "Cost":


In Least Cost Routing, every link (connection) between two
nodes (routers or network segments) in a network topology
is assigned a numerical "cost" or "weight."
This cost represents a metric that the network administrator
or routing protocol considers important for path selection.
Common metrics include:
 Hop Count: The simplest cost, where each link counts as 1.
(Used by RIP).
 Delay/Latency: The time taken for a packet to traverse the
link. Lower delay means lower cost.
 Bandwidth: The capacity of the link. Higher bandwidth links
typically have lower costs.
 Load: The current traffic volume on the link.
 Reliability: The stability or error rate of the link.
The goal is to find a path where the sum of the costs of all
links along that path is minimized.
2. Path Calculation:
Routing algorithms (like Dijkstra's or Bellman-Ford) that
implement LCR operate by calculating the total cost of all
possible paths from a source to every other destination in
the network.
For each destination, the algorithm identifies the path with
the smallest accumulated cost.
This identified path is then deemed the "least cost" or
"optimal" path.
3. Dynamic Adaptation:
In adaptive (dynamic) routing, these link costs can change in
real-time (e.g., if a link becomes congested, its cost might
increase).
Routing algorithms constantly monitor these costs and re-
calculate paths to ensure that the least-cost principle is
maintained, making the network responsive to changing
conditions.
Give Short Example of Dijkstra :
IP CLASSES :

In the context of IPv4, IP addresses were historically divided


into different "classes" to simplify network design and
allocation.

Class A
 Network-ID Bits: 8 (first bit always 0)
 Host-ID Bits: 24
 Number of Networks: 126 (2^7 - 2; 0 and 127 are reserved)
 Number of Hosts per Network: 16,777,214 (2^24 - 2)
 Range: 1.0.0.0 to 126.255.255.255 (127.x.x.x is reserved for
loopback)124
Class B
 Network-ID Bits: 16 (first two bits always 10)
 Host-ID Bits: 16
 Number of Networks: 16,384 (2^14)
 Number of Hosts per Network: 65,534 (2^16 - 2)
 Range: 128.0.0.0 to 191.255.255.2551245
Class C
 Network-ID Bits: 24 (first three bits always 110)
 Host-ID Bits: 8
 Number of Networks: 2,097,152 (2^21)
 Number of Hosts per Network: 254 (2^8 - 2)
 Range: 192.0.0.0 to 223.255.255.2551245
Class D
 Network-ID/Host-ID Bits: Not applicable (used for
multicasting)
 Range: 224.0.0.0 to 239.255.255.2551245
Class E
 Network-ID/Host-ID Bits: Not applicable (reserved for
experimental use)
 Range: 240.0.0.0 to 255.255.255.2551245

You might also like