0% found this document useful (0 votes)
36 views126 pages

CN - Unit 5

Computer network

Uploaded by

6353si2456
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)
36 views126 pages

CN - Unit 5

Computer network

Uploaded by

6353si2456
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/ 126

Unit - 5

Network Layer

Karan Padhiyar
IT Dept.
BVM
 What is Network Layer?
Contents
1. Network Layer Design Issues [From Attached PDF]

Routing Algorithms:
Shortest Path Routing,
Flooding,
[From Attached PDF as
2. Distance Vector Routing,
well as Forouzan Ch-22]
Link State Routing,
Broadcast,
Multicast routing
[From Attached PDF as
3. Congestion Control Algorithms
well as Forouzan Ch-24]
4. Quality of Service [Forouzan Ch-24]

5. Example protocols: OSPF, BGP [Forouzan Ch-22]

6. Internet multicasting IPv4 and IPv6 [Forouzan Ch-20]

7. IPv4 Addresses [Forouzan Ch-19]


Working
 To deliver segment from sending to receiving host/
router.
 On sending side, it encapsulates segments into
datagrams.
 On receiving side, it delivers segments to transport
layer.
 Network layer protocols in every host and router.
 Router examines header fields in all IP datagrams
passing through it.
Key Function of Network Layer
 Two important network layer functions can be
identified:
1. Forwarding
◦ When a packet arrives at a router’s input link, the router
must move the packet to the appropriate output link.
2. Routing
◦ It’s a process of selecting best paths in a network.
◦ The network layer must determine the route or path taken
by packets as they flow from a sender to a receiver.
◦ The algorithms that calculate these paths are referred to
as routing algorithms.
IP Address
Network Layer Design Issues

• Store-and-Forward Packet Switching


• Services Provided to the Transport Layer
• Implementation of Connectionless Service
• Implementation of Connection-Oriented Service
• Comparison of Virtual-Circuit and Datagram Subnets
Store-and-Forward Packet Switching
The environment of the network layer protocols.

fig 5-1
Services Provided to the Transport Layer
• S er v i c es s h o u l d be i n d e p e n d e n t o f ro u t e r
technology

• The transpor t layer should be shielded from


(covered with) number, type and topology of
routers present

• Th e n etw o r k a ddr es s es ma de a va i l a bl e to
transport layer should use a uniform numbering
plan, even across LANs and WANs
Implementation of Connectionless Service
Routing within a diagram subnet.
Implementation of Connection-Oriented Service
Routing within a virtual-circuit subnet.
Comparison of Virtual-Circuit and Datagram Subnets

5-4
Routing Algorithms
• The Optimality Principle
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State Routing
• Broadcast Routing
• Multicast Routing
The Optimality Principle

(a) A subnet. (b) A sink tree for


router B.
Shortest Path Routing

 Also known as Dijkstra


algorithm
 Path length is measured
using:
◦ Number of hops
◦ Geographic distance
◦ Other metrics like mean
queueing and transmission
delay
Shortest Path Routing
Shortest Path Routing - Example
Flooding
 Every incoming packet is forwarded on every outgoing link
except the one it arrived on
 Problem: duplicates
 Constraining the flood:
◦ Sequencing – Each packet is uniquely numbered at the source.
◦ Hop count – Each time a node passes on a packet, it decrements
the value by one. When its value becomes ‘0’, the packet is
discarded.
◦ Selective flooding – Exclude unreasonable links
An incoming packet to A, will be sent to B, C and D.

B will send the packet to C and E.

C will send the packet to B, D and F.

D will send the packet to C and F.

E will send the packet to F.

F will send the packet to C and E.


Advantages of Flooding

 It is
very simple to setup and implement, since a router
may know only its neighbours.

 It is
extremely robust. Even in case of malfunctioning of a
large number routers, the packets find a way to reach the
destination.

 All nodes which are directly or indirectly connected are


visited. So, there are no chances for any node to be left
out. This is a main criteria in case of broadcast messages.

 The shortest path is always chosen by flooding.


Limitations of Flooding

 Flooding tends to create an infinite number of


duplicate data packets, unless some measures are
adopted to damp packet generation.

 It iswasteful if a single destination needs the


packet, since it delivers the data packet to all nodes
irrespective of the destination.
Flooding Example
 Static Algorithms (Non-Adaptive)
1.Shortest-path routing.
2.Flooding.

 Dynamic Routing (Adaptive Routing)


1. Distance vector routing.
2. Link state routing.
Distance Vector Routing

In distance vector routing, each node


shares its routing table with its immediate
neighbors periodically and when there is a
change.
Figure 22.14 Distance vector routing tables
Figure 22.15 Initialization of tables in distance vector routing
Figure 22.16 Updating in distance vector routing
Link State Routing
Each router must do the following:
1. Discover its neighbors, learn their network address.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router.
Link State Routing Protocol
 Link State protocols rely on each router having a
complete view of the network topology.
 Instead of sharing their entire routing tables with
neighbors, routers distribute information about their
directly connected links (link state) throughout the
network.
 Each router uses this information to build a
complete map of the network and independently
calculates the best path to each destination.
Building Link State Packets

(a) A subnet. (b) The link state packets for this subnet.

Example Protocol: OSPF (Open Shortest Path First) and


IS-IS (Intermediate System to Intermediate System).
Feature Shortest Path Link State
A type of routing protocol that
An algorithmic concept to find the
Concept uses link state information to
optimal route
determine the best path

Often refers to Dijkstra’s algorithm Uses Dijkstra’s algorithm to


Algorithm
for finding the shortest path calculate routes

General concept used in various A specific class of routing


Usage
routing protocols protocols (e.g., OSPF, IS-IS)
Requires each router to have a
Can be applied to any network
Topology Knowledge complete view of the network
view, partial or full
topology
Uses Link State Advertisements
Update Mechanism N/A (just an algorithm) (LSAs) to share network status
across routers
Used by various protocols for OSPF, IS-IS, and other link-state
Protocols That Use It
route calculation (e.g., OSPF, RIP) protocols
Fast convergence after network
Convergence N/A
changes
Highly scalable, suitable for large
Scalability Depends on implementation
networks
Broadcast Routing
It is the process of “Sending a packet to all destinations simultaneously
”. Various methods are:
 Send packet to each destination
 Flooding – point-to-point routing algorithm
 Multidestination routing – new packet for each output line to be used.
(Each output line will contain the destination address that are to use
that line)
 Spanning tree
 Reverse path forwarding

Broadcast Routing is a routing technique used in computer networks


where data packets are sent from one node to all nodes in the network.
In other words, the message is transmitted to every device on the
network, not just a specif ic destination. This is commonly used when a
source node wants to share information with all other nodes on a
network simultaneously.
Broadcast Routing
Reverse path forwarding
(a) A subnet. (b) a Sink tree. (c) The tree built by reverse path
forwarding.
Protocols Using Broadcast
 ARP
 RIP
 DHCP
Multicast Routing
 process of transmitting data from one sender to a
specific group of receivers in a network.
 rather than broadcasting it to all devices (as in
broadcast routing) or sending it to a single
destination (as in unicast routing). Multicast
enables more efficient use of bandwidth when
delivering data to multiple destinations.
Used
 Video conferencing.
 Live video streaming (like IPTV or webinars).
 Real-time financial data distribution.
 Online gaming.
Multicast Routing

(a) A network. (b) A spanning tree for the leftmost router.


(c) A multicast tree for group 1. (d) A multicast tree for group
Congestion Control

 Cong e sti on c ontrol re fe rs to te c hni que s and


mechanisms that can either prevent congestion, before it
happens, or remove congestion, after it has happened.

 I n g e n e ra l , w e c a n d i v i d e c o n g e s t i o n c o n t r o l
mechanisms into two broad categories:
1. open-loop congestion control (prevention) and
2. closed-loop congestion control (removal).
Congestion
 Congestion occurs when too many packets are
present in the network, causing network devices
such as routers and switches to become overloaded.
This can lead to packet loss, high latency, and
reduced network performance.
 Congestion in a network typically happens when the
demand for network resources (like bandwidth)
exceeds the available capacity, causing excessive
packet queuing and potential packet drops.
Congestion Control vs Flow Control
 Congestion Control: Focuses on preventing or
managing overload within the network (i.e., between
routers, switches, and other intermediary devices).

 FlowControl: Manages data flow between sender


and receiver to ensure that the sender doesn't
overwhelm the receiver.
Figure 24.5 Congestion control categories
Figure 24.6 Backpressure method for alleviating congestion

Figure 24.7 Choke packet


Hop-by-Hop
Choke Packets
(a) A choke packet
that affects only
the source.

(b) A choke packet


that affects each
hop it passes
through.
24-5 QUALITY OF SERVICE

Quality of service (QoS) is the use of mechanisms


or technologies that work on a network to control
traf fic and ensure the performance of critical
applications with limited network capacity. It
enables organizations to adjust their overall
network traf fic by prioritizing specif ic high-
performance applications.
Figure 24.15 Flow characteristics
Reliability
 It is
one of the main characteristics that the flow
needs. If there is a lack of reliability then it simply
means losing any packet or losing an
acknowledgement due to which retransmission is
needed.

 Reliability becomes more important for electronic


mail, file transfer, and for internet access.
Delay
 Anothercharacteristic of the flow is the delay in
transmission between the source and destination.
During audio conferencing, telephony, video
conferencing, and remote conferencing there should
be a minimum delay.
Jitter
 It isbasically the variation in the delay for packets
that belongs to the same flow. Thus Jitter is
basically the variation in the packet delay. Higher the
value of jitter means there is a large delay and the
low jitter means the variation is small.
Bandwidth
 The different applications need different bandwidth.
24-6 TECHNIQUES TO IMPROVE QoS

In Section 24.5 we tried to def ine QoS in terms of


its characteristics. In this section, we discuss
some techniques that can be used to improve the
quality of service. We brief ly discuss four common
methods: scheduling, traf fic shaping, admission
control, and resource reservation.
Topics discussed in this section:
Scheduling
Traffic Shaping
Resource Reservation
Admission Control
Scheduling
 Scheduling is the process of determining the order
in which packets are sent. This is crucial for
managing network congestion and prioritizing
certain types of traffic.
 FIFO (First In, First Out) Queuing:
 Priority Queuing:
 Weighted Fair Queuing (WFQ):
1.1 Scheduling - FIFO

Figure 24.16 FIFO queue

FIFO is the simplest type of scheduling where packets are processed in the
order they arrive. It does not prioritize any packet over another, so it may lead
to delays for time-sensitive packets if the queue is large.
1. 2 Scheduling – Priority queuing

This approach assigns a priority level to packets. Higher priority packets are sent first, while
lower priority packets may have to wait. This method ensures that critical packets, such as
voice or video data, are sent quickly, reducing latency for important applications.

Figure 24.17 Priority queuing


1. 3 Scheduling – Weighted Fair queuing

In WFQ, different types of traffic are assigned different weights based on their importance or
bandwidth requirements. Packets are then sent in proportion to their assigned weights,
ensuring that more critical or bandwidth-intensive traffic receives more resources, while still
serving other types of traffic.

Figure 24.18 Weighted fair queuing


Traffic shaping controls the flow of data into the network to avoid overwhelming network
resources.

2.1 Traffic Shaping – Leaky bucket

Figure 24.19 Leaky bucket


Leaky Bucket:
 This algorithm regulates data transmission by
making it flow at a steady rate.
 It can smooth bursty traffic (sudden spikes of data),
ensuring that packets are sent at a consistent pace.
If the data rate exceeds the bucket's capacity,
packets may be dropped.
Figure 24.20 Leaky bucket implementation
2.2 Traffic Shaping – Token bucket

Figure 24.21 Token bucket


Token Bucket:
 The Token Bucket allows for bursty traffic but sets a
limit on the amount of data that can be transmitted
within a certain time frame.
 Unlike the leaky bucket, the token bucket lets bursts
of data be sent if there are enough tokens (which
represent permission to send data) available,
providing more flexibility while still controlling
overall traffic rates.
Note

• A leaky bucket algorithm shapes bursty


traf fic into f ixed-rate traf fic by averaging
the data rate. It may drop the packets if
the bucket is full.
• The token bucket allows bursty traf fic at
a regulated maximum rate.
3. Resource Reservation – RSVP Protocol
Resource reservation ensures that specific resources (such as bandwidth) are
reserved for particular traffic flows, guaranteeing that these flows receive the
necessary resources to maintain their performance.

• RSVP Messages
 Path messages
 Resv messages
• Reservation merging
Figure 24.22 Path messages

Path Message: The sender sends a Path message downstream to establish a path
for the data packets. This message carries information about the sender and the
characteristics of the data flow.
Figure 24.23 Resv messages

Resv Message: The receivers respond with a Resv (reservation) message, which
travels upstream. This message specifies the resources that the receiver requires
(e.g., bandwidth).
Figure 24.24 Reservation merging

Resource Allocation: Routers along the path process these messages and allocate the
necessary resources. They maintain reservation states that dictate how much
bandwidth has been reserved for each flow.
Figure 24.25 Reservation styles

•Fixed Reservation: A fixed amount of resources is reserved for


a traffic flow for a predetermined duration. This is simple but
can lead to inefficient resource usage if the traffic is variable.
•Dynamic Reservation: Resources are allocated dynamically
based on the current load and traffic conditions. This approach
can be more efficient but also more complex to manage.
•Partial Reservation: Only a portion of the required resources is
reserved initially, allowing for more flexibility in managing traffic
flows.
4. Admission Control
• Admission control involves deciding whether to
accept or reject a new flow of traffic based on the
current network capacity.
• Before allowing a new flow, the system checks
predefined parameters (e.g., available bandwidth,
CPU capacity, buffer size) to ensure the network can
handle the additional traffic without compromising
QoS for existing flows.
• Capacity means in terms of bandwidth, buffer size, CPU
speed etc.
Example protocols – OSPF & BGP

Topics discussed in this section:


OSPF Protocol
BGP Protocol
it is an intradomain protocol

The Example Protocol – OSPF


• Open Shortest Path First
• Areas – Collection of networks, host and
routers all contained within an autonomous
system
• Area Border routers
• Backbone & Backbone routers
• Virtual link
• Area identification
• Metric
• Types of links
Figure 22.24 Areas in an autonomous system
Figure 22.25 Types of links
Figure 22.26 Point-to-point link

Point-to-point link: The point-to-point link directly connects


the two routers without any host or router in between.
Figure 22.27 Transient link

When several routers are attached in a network, they are known as a transient link.

Unrealistic topology: When all the routers are connected to each other, it is known as an
unrealistic topology.

Realistic topology: When some designated router exists in a network then it is known as a
realistic topology. Here designated router is a router to which all the routers are connected.
All the packets sent by the routers will be passed through the designated router.
Figure 22.28 Stub link

Stub link: It is a network that is connected to the single router. Data enters to the network
through the single router and leaves the network through the same router.
Figure 22.29 Example of an AS and its graphical representation in OSPF

Virtual link: If the link between the two routers is broken, the administration creates the
virtual path between the routers, and that path could be a long one also.
The Example Protocol – BGP
• Border Gateway Protocol
It is an interdomain routing protocol, and it uses the path-
vector routing. It is a gateway protocol that is used to
exchange routing information among the autonomous
system on the internet.
Figure 22.32 Internal and external BGP sessions
20-2 IPv4

The Internet Protocol version 4 (IPv4) is the


delivery mechanism used by the TCP/IP protocols.

Topics discussed in this section:


Datagram
Fragmentation
Checksum
Options
Figure 20.4 Position of IPv4 in TCP/IP protocol suite
Figure 20.5 IPv4 datagram format
1.Version (4 bits): This f ie ld specif ie s the version of the IP protocol being used, which is IPv4 in this
case.
2.Header Length (4 bits): The header length f ie ld indicates the length of the IPv4 header in 32-bit
words. Since the header is a fixed size of 20 bytes, the value of this field is typically 5.
3.Type of Service (8 bits): This f ie ld is used to def in e the quality of service (QoS) for the packet,
including priorities and other parameters for routing and processing.
4.Total Length (16 bits): The total length f ield specif ies the length of the entire IPv4 packet, including
both the header and the data, in bytes.
5.Identif ication (16 bits): The identif ication f ie ld is used for packet fragmentation and reassembly. It
helps in grouping fragments of a larger packet together.
6.Flags (3 bits): These bits are used for controlling and identifying packet fragmentation. The f lags
include the "Don't Fragment" (DF) and "More Fragments" (MF) flags.

Various Control Flags.


Bit 0: Reserved. Must be 0.
Bit 1: (DF) 0 = May Fragment, 1 = Don’t Fragment
Bit 2: (MF) 0 = Last Fragment, 1 = More Fragments
7. Fragment Offset (13 bits): The fragment offset f ield specif ies the position of the fragment within
the original packet. It is used to reassemble fragmented packets correctly.

8.Time to Live (TTL) (8 bits): The TTL f ie ld represents the maximum number of hops (routers or
network segments) that the packet can traverse before it is discarded. Each router decrements
this value by one.

9.Protocol (8 bits): This f ie ld indicates the type of protocol used in the data portion of the packet,
such as TCP, UDP, ICMP, or others.

10.Header Checksum (16 bits): The header checksum field is used to verify the integrity of the IPv4
header during transmission. Routers and devices recalculate this checksum to check for errors.

11.Source IP Address (32 bits): This f ie ld contains the IP address of the sender or source of the
packet.

12.Destination IP Address (32 bits): This f ield holds the IP address of the recipient or destination of
the packet.
Figure 20.6 Service type or differentiated services
Table 20.1 Types of service
Table 20.2 Default types of service
Table 20.3 Values for codepoints
Note

The total length field defines the total length of


the datagram including the header.
Figure 20.8 Protocol field and encapsulated data
Table 20.4 Protocol values
Example 20.1

An IPv4 packet has arrived with the first 8 bits as


shown:
01000010
The receiver discards the packet. Why?
Solution
There is an error in this packet. The 4 leftmost bits
(0100) show the version, which is correct. The next 4
bits (0010) show an invalid header length (2 × 4 = 8).
The minimum number of bytes in the header must be
20. The packet has been corrupted in transmission.
Example 20.2

In an IPv4 packet, the value of HLEN is 1000 in binary.


How many bytes of options are being carried by this
packet?

Solution
The HLEN value is 8, which means the total number
of bytes in the header is 8 × 4, or 32 bytes. The first 20
bytes are the base header, the next 12 bytes are the
options.
Example 20.3

In an IPv4 packet, the value of HLEN is 5, and the


value of the total length f ield is 0x0028. How many
bytes of data are being carried by this packet?

Solution
The HLEN value is 5, which means the total number
of bytes in the header is 5 × 4, or 20 bytes (no
options). The total length is 40 bytes, which means
the packet is carrying 20 bytes of data (40 − 20).
Example 20.4

An IPv4 packet has arrived with the first few


hexadecimal digits as shown.
0x45000028000100000102 . . .
How many hops can this packet travel before being
dropped? The data belong to what upper-layer
protocol?
Solution
To f ind the time-to-live f ield, we skip 8 bytes. The time
-to-live f ield is the ninth byte, which is 01. This means
the packet can travel only one hop. The protocol f ield
is the next byte (02), which means that the upper-
layer protocol is IGMP.
Fragmentation

Figure 20.9 Maximum transfer unit (MTU)


Table 20.5 MTUs for some networks
Figure 20.10 Flags used in fragmentation
Figure 20.11 Fragmentation example
Figure 20.12 Detailed fragmentation example
Figure 20.13 Example of checksum calculation in IPv4
Figure 20.14 Taxonomy of options in IPv4
20-3 IPv6

The network layer protocol in the TCP/IP protocol


suite is currently IPv4. Although IPv4 is well
designed, data communication has evolved since
the inception of IPv4 in the 1970s. IPv4 has some
def ic iencies that make it unsuitable for the fast-
growing Internet.

Topics discussed in this section:


Advantages
Packet Format
Extension Headers
Figure 20.15 IPv6 datagram header and payload
Figure 20.16 Format of an IPv6 datagram
Version: IP version number

Traffic class: used to give priority to certain datagram

Flow label: used to identify a flow of datagrams

Payload length: number of bytes in the IPv6 datagram following the


fixed-length 40 byte header

Next header: indicates Transport layer protocol (similar to as the


protocol field in the IPv4 header)

Hop limit: max. number of router a datagram can travel before


reaching to destination

Source and destination addresses: IPv6 128-bit address of source


and des

Data: payload portion of the IPv6 datagram


Table 20.6 Next header codes for IPv6
Table 20.9 Comparison between IPv4 and IPv6 packet headers
19-1 IPv4 ADDRESSES

An IPv4 address is a 32-bit address that uniquely


and universally def ines the connection of a device
(for example, a computer or a router) to the
Internet.

19.11
0
Figure 19.1 Dotted-decimal notation and binary notation for an IPv4 address

19.11
1
Example 19.1

Change the following IPv4 addresses from binary


notation to dotted-decimal notation.

Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation.

19.11
2
Example 19.2

Change the following IPv4 addresses from dotted-


decimal notation to binary notation.

Solution
We replace each decimal number with its binary
equivalent (see Appendix B).

19.11
3
Example 19.3

Find the error, if any, in the following IPv4 addresses.

Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
19.11
4
Figure 19.2 Finding the classes in binary and dotted-decimal notation

19.11
5
Example 19.4

Find the class of each address.


a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111

Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a
class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E. 19.11
6
Table 19.1 Number of blocks and block size in classful IPv4 addressing

19.11
7
Table 19.2 Default masks for classful addressing

19.11
8
Figure 19.3 A block of 16 addresses granted to a small organization

19.11
9
Note

In IPv4 addressing, a block of addresses


can be defined as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.

19.12
0
Note

The first address in the block can be found


by setting the rightmost
32 − n bits to 0s.

19.12
1
Example 19.6

A block of addresses is granted to a small


organization. We know that one of the addresses is
205.16.37.39/28. What is the f ir st address in the
block?

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
This is actually the block shown in Figure 19.3. 19.12
2
Note

The last address in the block can be found


by setting the rightmost
32 − n bits to 1s.

19.12
3
Example 19.7

Find the last address for the block in Example 19.6.

Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.16.37.47
This is actually the block shown in Figure 19.3.

19.12
4
Note

The number of addresses in the block can


be found by using the formula
232−n.

19.12
5
Example 19.8

Find the number of addresses in Example 19.6.

Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.

19.12
6

You might also like