0% found this document useful (0 votes)
157 views12 pages

CN CS-602 Unit-IV 1707930228

The document provides an overview of the network layer in computer networks, detailing its need, services, design issues, and routing algorithms such as Dijkstra's and Bellman-Ford. It discusses various routing techniques, including hierarchical, broadcast, and multicast routing, as well as congestion control algorithms like the leaky bucket and token bucket. The content is structured to support the curriculum of a Computer Science and Engineering course, specifically focusing on the principles and functionalities of the network layer.

Uploaded by

rihupofemob
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)
157 views12 pages

CN CS-602 Unit-IV 1707930228

The document provides an overview of the network layer in computer networks, detailing its need, services, design issues, and routing algorithms such as Dijkstra's and Bellman-Ford. It discusses various routing techniques, including hierarchical, broadcast, and multicast routing, as well as congestion control algorithms like the leaky bucket and token bucket. The content is structured to support the curriculum of a Computer Science and Engineering course, specifically focusing on the principles and functionalities of the network layer.

Uploaded by

rihupofemob
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/ 12

Chameli Devi Group of Institutions

Department of Computer Science and Engineering


CS602 Computer Networks
Subject Notes: UNIT-IV

Syllabus: Network Layer: Need, Services Provide, Design Issues, Routing Algorithms: Least Cost Routing
Algorithm, Dijkstra's Algorithm, Bellman-ford Algorithm, Hierarchical Routing, Broadcast Routing,
Multicast Routing. IP Addresses, Header Format, Packet Forwarding, Fragmentation and Reassembly,
ICMP, Comparative Study of IPv4 & IPv6.

Network Layer: Need


The network layer is considered the backbone of the OSI Model. It selects and manages the best logical
path for data transfer between nodes. This layer contains hardware devices such as routers, bridges,
firewalls and switches, but it actually creates a logical image of the most efficient communication route
and implements it with a physical medium.
Network layer protocols exist in every host or router. The router examines the header fields of all the IP
packets that pass through it. Internet Protocol and Netware IPX/SPX are the most common protocols
associated with the network layer.
In the OSI model, the network layer responds to requests from the layer above it (transport layer) and
issues requests to the layer below it (data link layer).

Network Layer: Services


 Routers and gateways operate in the network layer. Mechanism is provided by Network Layer for routing
the packets to final destination.
 Connection services are provided including flow control, error control and packet sequence control.
 Breaks larger packets into small packets.

Fig 4.1 Network Layer

There are two types of service that can be provided by the network layer:
 An unreliable connectionless service.
 A connection-oriented, reliable or unreliable, service.
Network Layer: Design Issues:
a) Store-and-Forward Packet Switching
b) Services Provided to the Transport Layer
c) Implementation of Connectionless Service
d) Implementation of Connection-Oriented Service
a) Store-and-Forward Packet Switching:
A host with a packet to send transmits it to the nearest router, either on its own LAN or over a point-to-
point link to the carrier. The packet is stored there until it has fully arrived so the checksum can be verified.
Then it is forwarded to the next router along the path until it reaches the destination host, where it is
delivered. This mechanism is store-and-forward packet switching.
Fig. 4.2 Store and Forward Packet Switching
b) Services Provided to the Transport Layer:
The network layer services have been designed with the following goals:
 The services should be independent of the router technology.
 The transport layer should be shielded from the number, type, and topology of the routers present.
 The network addresses should be made available to the transport with a uniform numbering plan, even
across LANs and WANs.

c) Implementation of Connectionless Service:


If connectionless service is offered, packets are injected into the subnet individually and routed
independently of each other. No advance setup is needed. In this context, the packets are frequently called
datagram’s and the subnet is called a datagram subnet.

Fig. 4.3 Connectionless Service


d) Implementation of Connection-Oriented Service:
If connection-oriented service is used, a path from the source router to the destination router must be
established before any data packets can be sent. This connection is called a VC (virtual circuit) and the
subnet is called a virtual-circuit subnet.
The process is completed in three phases:
 Establishment Phase.
 Data Transfer Phase.
 Connection Release Phase.

Fig. 4.4 Connection-Oriented Service


Routing Algorithms:
A routing algorithm is a set of step-by-step operations used to direct Internet traffic efficiently. When a
packet of data leaves its source, there are many different paths it can take to its destination. The routing
algorithm is used to determine mathematically the best path to take.

Properties of Routing Algorithm:


Correctness: The routing should be done properly and correctly so that the packets may reach their proper
destination.
Simplicity: The routing should be done in a simple manner so that the overhead is as low as possible. With
increasing complexity of the routing algorithms the overhead also increases.
Robustness: The algorithms designed for routing should be robust enough to handle hardware and
software failures and should be able to cope with changes in the topology and traffic without requiring all
jobs in all hosts to be aborted and the network rebooted every time some router goes down.
Stability: The routing algorithms should be stable under all possible circumstances.
Fairness: Every node connected to the network should get a fair chance of transmitting their packets. This
is generally done on a first come first serve basis.
Optimality: The routing algorithms should be optimal in terms of throughput and minimizing mean packet
delays. Here there is a trade-off and one has to choose depending on his suitability.

Routing can be grouped into two categories:


1. Adaptive Routing Algorithm: These algorithms change their routing decisions to reflect changes in the
topology and in traffic as well. These get their routing information from adjacent routers or from all
routers. The optimization parameters are the distance, number of hops and estimated transit time. This
can be further classified as follows:
 Centralized: In this type some central node in the network gets entire information about the network
topology, about the traffic and about other nodes. This then transmits this information to the respective
routers. The advantage of this is that only one node is required to keep the information.
The disadvantage is that if the central node goes down the entire network is down, i.e. single point of
failure.
 Isolated: In this method the node decides the routing without seeking information from other nodes. The
sending node does not know about the status of a particular link. The disadvantage is that the packet may
be send through a congested route resulting in a delay.

2.Non-Adaptive Routing Algorithm: These algorithms do not base their routing decisions on
measurements and estimates of the current traffic and topology. Instead the route to be taken in going
from one node to the other is computed in advance, off-line, and downloaded to the routers when the
network is booted. This is also known as static routing. This can be further classified as follows:
1. Flooding: Flooding adapts the technique in which every incoming packet is sent on every outgoing line
except the one on which it arrived. One problem with this method is that packets may go in a loop. As a
result of this a node may receive several copies of a particular packet which is undesirable. Some
techniques adapted to overcome these problems are as follows:
 Sequence Numbers: Every packet is given a sequence number. When a node receives the packet it sees
its source address and sequence number. If the node finds that it has sent the same packet earlier then it
will not transmit the packet and will just discard it.
 Hop Count: Every packet has a hop count associated with it. This is decremented (or incremented) by
one by each node which sees it. When the hop count becomes zero (or a maximum possible value) the
packet is dropped.
 Spanning Tree: The packet is sent only on those links that lead to the destination by constructing a
spanning tree routed at the source. This avoids loops in transmission but is possible only when all the
intermediate nodes have knowledge of the network topology.
2. Random Walk: In this method a packet is sent by the node to one of its neighbours randomly. This
algorithm is highly robust. When the network is highly interconnected, this algorithm has the property of
making excellent use of alternative routes. It is usually implemented by sending the packet onto the least
queued link.

The Optimality Principle:


The optimality principle states that if router J is on the optimal path from router I to router K, then the
optimal path from J to K also falls along the same route. As a consequence of that principle, we can see
that the set of optimal routes from all sources to a given destination form a tree rooted at the destination.
Such tree is called a sink tree.

Fig. 4.5 (a) Subnet (b) Sink Tree for Router (b)
Shortest Path Algorithm (Least Cost Routing Algorithm):
 In the path length between each node is measured as a function of distance, Bandwidth, average traffic,
communication cost, mean queue length, measured delay.
 By changing the weighing function, the algorithm then computes the shortest path measured according
to any one of a number of criteria or a combination of criteria.
 Each node of graph representing a router and each arc of the graph representing a communication link.
Each link has a cost associated with it.
A graph G is:
 G= (N, E), Where N: nodes that represent routers, Where E: edges that represent physical links.
 Each edge has a value representing its cost.
 Find a path between the source and destination that has least cost.
Two algorithms for computing the shortest path between two nodes of a graph are:-
1. Dijkstra’s Algorithm 2. Bellman-Ford Algorithm

Dijkstra's Algorithm:
 Compute the least cost path from one node to all other nodes in the network.
 Iterative algorithm - After the kth iteration, the least cost paths for k destination nodes are found.
 D(v): cost of the least cost path from source node to destination v
 p(v): previous node of v along the least-cost path from source.
 N’: set of nodes to which the least-cost path is found.

Fig 4.6 Dijkstra's Algorithm


Fig 4.7 Shortest-Path Tree
Bellman-ford Algorithm:
Following are the detailed steps.
Input: Graph and a source vertex src.
Output: Shortest distance to all vertices from src. If there is a negative weight cycle, then shortest
distances are not calculated, negative weight cycle is reported.
 This step initializes distances from source to all vertices as infinite and distance to source itself as 0.
Create an array dist[] of size |V| with all values as infinite except dist[src] where src is source vertex.
 This step calculates shortest distances. Do following |V|-1 times where |V| is the number of vertices in
given graph.
 Following for each edge u-v:
If dist[v] >dist[u] + weight of edge uv, then update dist[v]
dist[v] = dist[u] + weight of edge uv
 This step reports if there is a negative weight cycle in graph. Do following for each edge u-v
If dist[v] >dist[u] + weight of edge uv, then “Graph contains negative weight cycle.
The idea of step 3 is, step 2 guarantees shortest distances if graph doesn’t contain negative weight cycle. If
we iterate through all edges one more time and get a shorter path for any vertex, then there is a negative
weight cycle.
Example:
The given source vertex be 0. Initialize all distances as infinite, except the distance to source itself. Total
number of vertices in the graph is 5, so all edges must be processed 4 times.

Fig 4.8 Bellman-ford Algorithm


All edges are processed in following order: (B, E), (D, B), (B, D), (A, B), (A, C), (D, C), (B, C), (E, D). We get
following distances when all edges are processed first time. The first row in shows initial distances. The
second row shows distances when edges (B, E), (D, B), (B, D) and (A, B) are processed. The third row shows
distances when (A, C) is processed. The fourth row shows when (D, C), (B, C) and (E, D) are processed.

Fig 4.9 Bellman-ford Algorithm (Example Step-1)


The first iteration guarantees to give all shortest paths which are at most 1 edge long. We get following
distances when all edges are processed second time (The last row shows final values).
Fig 4.10 Bellman-ford Algorithm (Example Step-2)
The second iteration guarantees to give all shortest paths which are at most 2 edges long. The algorithm
processes all edges 2 more times. The distances are minimized after the second iteration, so third and
fourth iterations don’t update the distances.

Hierarchical Routing:
 As the number of routers becomes large, the overhead involved in maintaining routing information
becomes prohibitive.
 Internet providers want to manage their network as they wish, while still being able to connect to other
networks.
 Routing within the same AS (Autonomous System) is called “Intra-domain” routing.
 One or more routers in an AS (Autonomous System) are responsible to forward packets to destinations
outside AS.
 Inter-AS routing protocol: – Obtain reachability information from neighbouring ASs, and Propagate the
reachability information to all routers in AS.
 Routing between two different AS (Autonomous System) is called, “Inter-domain” routing.

Fig 4.11 Hierarchical Routing


Broadcast Routing:
Delivering a packet sent from a source node to all other nodes in the network. By default, the broadcast
packets are not routed and forwarded by the routers on any network. Routers create broadcast domains.
But it can be configured to forward broadcasts in some special cases. A broadcast message is destined to
all network devices.
 A router creates a data packet and then sends it to each host one by one. In this case, the router creates
multiple copies of single data packet with different destination addresses. All packets are sent as unicast
but because they are sent to all, it simulates as if router is broadcasting.
 This method consumes lots of bandwidth and router must destination address of each node.
 When router receives a packet that is to be broadcasted, it simply floods those packets out of all
interfaces. All routers are configured in the same way.
Fig 4.12 Broadcast Routing
This method is easy on router's CPU but may cause the problem of duplicate packets received from peer
routers. Reverse path forwarding is a technique, in which router knows in advance about its predecessor
from where it should receive broadcast. This technique is used to detect and discard duplicates.

Multicast Routing:
Multicast routing is special case of broadcast routing with significance difference and challenges. In
broadcast routing, packets are sent to all nodes even if they do not want it. But in Multicast routing, the
data is sent to only nodes which wants to receive the packets.

Fig 4.13 Multicast Routing


The router must know that there are nodes, which wish to receive multicast packets (or stream) then only
it should forward. Multicast routing works spanning tree protocol to avoid looping. Multicast routing also
uses reverse path Forwarding technique, to detect and discard duplicates and loops.
 DVMRP- Distance Vector Multicast Routing Protocol
 MOSPF- Multicast Open Shortest Path First
 CBT- Core Based Tree
 PIM- Protocol independent Multicast

Congestion Control Algorithms:


Congestion
A state occurring in network layer when the message traffic is so heavy that it slows down network
response time.
Effects of Congestion
 As delay increases, performance decreases.
 If delay increases, retransmission occurs, making situation worse.
General Principles of Congestion Control Principles:
 Many problems in complex systems, such as computer networks, can be viewed from a control theory
point of view. This approach leads to dividing all solutions into two groups: open loop and closed loop.
 Open loop solutions attempt to solve the problem by good design, in essence, to make sure it does not
occur in the first place. Once the system is up and running, midcourse corrections are not made.
 Tools for doing open-loop control include deciding when to accept new traffic, deciding when to discard
packets and which ones, and making scheduling decisions at various points in the network. All of these
have in common the fact that they make decisions without regard to the current state of the network.
 In contrast, closed loop solutions are based on the concept of a feedback loop. This approach has three
parts when applied to congestion control:
1. Monitor the system to detect when and where congestion occurs.
2. Pass this information to places where action can be taken.
3. Adjust system operation to correct the problem.

Congestion Control Algorithms:


Leaky Bucket Algorithm
Imagine a bucket with a small hole in the bottom. No matter at what rate water enters the bucket, the
outflow is at constant rate. When the bucket is full with water additional water entering spills over the
sides and is lost.

Fig 4.14 Leaky Bucket Algorithm


Similarly, each network interface contains a leaky bucket and the following steps are involved in leaky
bucket algorithm:
 When host wants to send packet, packet is thrown into the bucket.
 The bucket leaks at a constant rate, meaning the network interface transmits packets at a constant rate.
 Burst traffic is converted to a uniform traffic by the leaky bucket.
 In practice the bucket is a finite queue that outputs at a finite rate.

Token Bucket Algorithm


Need of token bucket Algorithm:-
The leaky bucket algorithm enforces output pattern at the average rate, no matter how burst the traffic is.
So in order to deal with the burst traffic we need a flexible algorithm so that the data is not lost. One such
algorithm is token bucket algorithm.
Steps of this algorithm can be described as follows:
 In regular intervals tokens are thrown into the bucket.
 The bucket has a maximum capacity.
 If there is a ready packet, a token is removed from the bucket, and the packet is send.
 If there is no token in the bucket, the packet cannot be send.

Fig 4.15 Token Bucket Algorithm


IP Address:
An Internet Protocol address (IP address) is a logical numeric address that is assigned to every single
computer, printer, switch, router or any other device that is part of a TCP/IP-based network.
The IP address is the core component on which the networking architecture is built; no network exists
without it. An IP address is a logical address that is used to uniquely identify every node in the network.
The numerals in an IP address are divided into 2 parts:
 The network part specifies which networks this address belongs to and
 The host part further pinpoints the exact location.
Network nodes are assigned IP addresses by the Dynamic Host Configuration Protocol server as soon as the
nodes connect to a network. DHCP assigns IP addresses using a pool of available addresses which are part
of the whole addressing scheme. Though DHCP only provides addresses that are not static, many machines
reserve static IP addresses that are assigned to that entity forever and cannot be used again.
IP addresses falls into two types:
 Classfull IP addressing is a legacy scheme which divides the whole IP address pools into 5 distinct
classes—A, B, C, D and E.
 Classless IP addressing has an arbitrary length of the prefixes.

Fig 4.16 IP Address Class

IPV4 Header:

Fig 4.17 IPV4 Header Format


 Version −Version no. of Internet Protocol used (e.g. IPv4).
 IHL − Internet Header Length; Length of entire IP header.
 DSCP −Differentiated Services Code Point; this is Type of Service.
 ECN − Explicit Congestion Notification; It carries information about the congestion seen in the route.
 Total Length −Length of entire IP Packet (including IP header and IP Payload).
 Identification −Unique Packet Id for identifying the group of fragments of a single IP datagram (16 bits).
 Flags −As required by the network resources, if IP Packet is too large to handle, these ‘flags’ tells if they
can be fragmented or not. In this 3-bit flag, the MSB is always set to ‘0’.
 Fragment Offset -This offset tells the exact position of the fragment in the original IP Packet.
 Time to Live −To avoid looping in the network, every packet is sent with some TTL value set, which tells
the network how many routers (hops) this packet can cross. At each hop, its value is decremented by one
and when the value reaches zero, the packet is discarded.
 Protocol −Tells the Network layer at the destination host, to which Protocol this packet belongs to, i.e.
the next level Protocol. For example protocol number of ICMP is 1, TCP is 6 and UDP is 17.
 Header Checksum −This field is used to keep checksum value of entire header which is then used to
check if the packet is received error-free.
 Source Address −32-bit address of the Sender (or source) of the packet.
 Destination Address −32-bit address of the Receiver (or destination) of the packet.
 Options −This is optional field, which is used if the value of IHL is greater than 5. These options may
contain values for options such as Security, Record Route, Time Stamp, etc.

IPV6 Header:

Fig 4.18 IPV6 Header Format


 Version (4-bits): It represents the version of Internet Protocol, i.e. 0110.
 Traffic Class (8-bits): These 8 bits are divided into two parts. The most significant 6 bits are used for Type
of Service to let the Router Known what services should be provided to this packet. The least significant 2
bits are used for Explicit Congestion Notification (ECN).
 Flow Label (20-bits): This label is used to maintain the sequential flow of the packets belonging to a
communication. The source labels the sequence to help the router identify that a particular packet belongs
to a specific flow of information. This field helps avoid re-ordering of data packets. It is designed for
streaming/real-time media.
 Payload Length (16-bits): This field is used to tell the routers how much information a particular packet
contains in its payload. Payload is composed of Extension Headers and Upper Layer data. With 16 bits, up
to 65535 bytes can be indicated; but if the Extension Headers contain Hop-by-Hop Extension Header, then
the payload may exceed 65535 bytes and this field is set to 0.
 Next Header (8-bits): This field is used to indicate either the type of Extension Header, or if the Extension
Header is not present then it indicates the Upper Layer PDU. The values for the type of Upper Layer PDU
are same as IPv4’s.
 Hop Limit (8-bits): This field is used to stop packet to loop in the network infinitely. This is same as TTL in
IPv4. The value of Hop Limit field is decremented by 1 as it passes a link (router/hop). When the field
reaches 0 the packet is discarded.
 Source Address (128-bits): This field indicates the address of originator of the packet.
 Destination Address (128-bits): This field provides the address of intended recipient of the packet.

Packet forwarding:
Packet forwarding is the basic method for sharing information across systems on a network. Packets are
transferred between a source interface and a destination interface, usually on two different systems.
When you issue a command or send a message to a nonlocal interface, your system forwards those
packets onto the local network.
The interface with the destination IP address that is specified in the packet headers then retrieves the
packets from the local network. If the destination address is not on the local network, the packets are then
forwarded to the next adjacent network, or hop.

Fig 4.19 Packet Forwarding


Fragmentation and Reassembly:
Fragmentation is the process of breaking a packet into smaller pieces so that they will fit into the frames of
the underlying network. The receiving system reassembles the pieces into the original packets. The term
MTU (maximum transmission unit) refers to the maximum amount of data that can travel in a frame.
Different networks have different MTU sizes, so packets may need to be fragmented in order to fit within
the frames of the network that they transit.
If we are already reassembling a packet with this source address and ID number. If not, allocate a
reassembly context.
 Start or re-start a timer for this packet.
 Add the fragment to the packet as indicated by the offset field.
 If the packet is now complete, deliver it as indicated by the protocol field.

Fig 4.20 Fragmentation and Reassembly


ICMP:
The ICMP stands for Internet Control Message Protocol. It is a network layer protocol. It is used for error
handling in the network layer, and it is primarily used on network devices such as routers. As different
types of errors can exist in the network layer, so ICMP can be used to report these errors and to debug
those errors.
The primary purpose of ICMP is for error reporting. When two devices connect over the Internet, the ICMP
generates errors to share with the sending device in the event that any of the data did not get to its
intended destination.
Secondary use of ICMP protocol is to perform network diagnostics; the commonly used terminals utilities
trace route and ping both operate using ICMP. The trace route utility is used to display the routing path
between two Internet devices.

Fig 4.21 ICMP


Comparative Study of IPv4 & IPv6:
S.No. IPv4 IPv6
1 Addresses are 32 bits (4 bytes) in length. Addresses are 128 bits (16 bytes) in length.
2 Address (A) resource records in DNS to map Address (AAAA) resource records in DNS to
host names to IPv4 addresses. map host names to IPv6 addresses.
3 Pointer (PTR) resource records in the IN- Pointer (PTR) resource records in the
ADDR.ARPA DNS domain to map IPv4 IP6.ARPA DNS domain to map IPv6 addresses
addresses to host names. to host names.
4 IPSec is optional and should be supported IPSec support is not optional
externally
5 Header does not identify packet flow for QoS Header contains Flow Label field, which
handling by routers Identifies packet flow for QoS handling by
router.
6 Both routers and the sending host fragment Routers do not support packet
packets. fragmentation. Sending host fragments
packets
7 Header includes a checksum. Header does not include a checksum.
8 ARP uses broadcast ARP request to resolve IP Multicast Neighbour Solicitation messages
to MAC/Hardware address. resolve IP addresses to MAC addresses.
9 Internet Group Management Protocol (IGMP) Multicast Listener Discovery (MLD) messages
manages membership in local subnet groups manage membership in local subnet groups.
10 Broadcast addresses are used to send traffic to IPv6 uses a link-local scope all-nodes
all nodes on a subnet. multicast address.
11 Configured either manually or through DHCP. Does not require manual configuration or
DHCP.
12 Must support a 576-byte packet size (possibly Must support a 1280-byte packet size
fragmented). (without fragmentation).
Table 4.1 Comparison (IPv4 and IPv6)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy