SlideShare a Scribd company logo
Unit IV - The Network Layer
Dr. S.Murugan
Associate Professor, Department of Computer Science.
Alagappa Government Arts College,
(Affiliated by Alagappa University)
Karaikudi.
Email: muruganjit@gmail.com
This slides compiled from
Computer Network by
Andrew S. Tenenbaum 4th Ed.
The Network Layer
➢ The network layer is concerned with getting packets
from the source all the way to the destination.
➢ To achieve its goals, the network layer must know
about the topology of the communication subnet (i.e.,
the set of all routers) and choose appropriate paths
through it.
5.1 Network Layer Design Issues
5.1.1 Store-and-Forward Packet Switching
➢ The environment of the network layer protocol is
represented in the figure 5.1.
5.1.1 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.
5.1.2 Services Provided to the Transport Layer
➢ The network layer provides services to the transport
layer at the network layer/transport layer interface.
The network layer services have been designed with
the following goals in mind.
1. The services should be independent of the router
technology.
2. The transport layer should be shielded from the
number, type, and topology of the routers present.
3. The network addresses made available to the
transport layer should use a uniform numbering
plan, even across LANs and WANs.
5.1.3 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
datagrams (in analogy with telegrams) and the subnet
is called a datagram subnet.
➢ 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.
5.1.3 Implementation of Connectionless Service
➢ This connection is called a VC (virtual circuit), in
analogy with the physical circuits set up by the
telephone system, and the subnet is called a virtual-
circuit subnet.
➢ Figure 5.2 shows the routing with the datagram
subnet. The message M is transfer from Host1 to
Host2.
➢ The network layer has to break the messages into four
packets, 1, 2, 3, and 4 and sends each of them in turn
to router A using some point-to-point protocol, for
example, PPP.
5.1.3 Implementation of Connectionless Service
➢ At this point the carrier takes over. Every router has an
internal table telling it where to send packets for each
possible destination.
➢ Each table entry is a pair consisting of a destination
and the outgoing line to use for that destination.
➢ Only directly-connected lines can be used.
5.1.3 Implementation of Connectionless Service
5.1.3 Implementation of Connectionless Service
➢ For example, in Fig. 5-2, A has only two outgoing
lines to B and C. so every incoming packet must be
sent to one of these routers, even if the ultimate
destination is some other router. A's initial routing
table is shown in the figure under the label ''initially.''
➢
➢ As they arrived at A, packets 1, 2, and 3 were stored.
Then each was forwarded to C according to A's table.
➢ Packet 1 was then forwarded to E and then to F.
When it got to F, it was encapsulated in a data link
layer frame and sent to H2 over the LAN. Packets 2
and 3 follow the same route.
5.1.3 Implementation of Connectionless Service
➢ However, something different happened to packet 4.
When it got to A it was sent to router B, even though it
is also destined for F.
➢ For some reason, A decided to send packet 4 via a
different route than that of the first three.
➢ Perhaps it learned of a traffic jam somewhere along
the ACE path and updated its routing table, as shown
under the label ''later.''
➢ The algorithm that manages the tables and makes the
routing decisions is called the routing algorithm.
5.1.4 Implementation of Connection-Oriented
Service
➢ For connection-oriented service, we need a virtual-
circuit subnet. virtual circuits is to avoid having to
choose a new route for every packet sent, as in Fig. 5-2.
➢ With connection-oriented service, each packet carries
an identifier telling which virtual circuit it belongs to.
➢ As an example, consider the situation of Fig. 5-3.
5.1.4 Implementation of Connection-Oriented
Service
5.1.4 Implementation of Connection-Oriented
Service
➢ Here, host H1 has established connection 1 with host
H2. It is remembered as the first entry in each of the
routing tables. The first line of A's table says that if a
packet bearing connection identifier 1 comes in from
H1, it is to be sent to router C and given connection
identifier 1. Similarly, the first entry at C routes the
packet to E, also with connection identifier 1.
➢ Now let us consider what happens if H3 also wants to
establish a connection to H2.
5.1.4 Implementation of Connection-Oriented
Service
➢ It chooses connection identifier 1 (because it is initiating
the connection and this is its only connection) and tells
the subnet to establish the virtual circuit. This leads to the
second row in the tables. Note that we have a conflict
here because although A can easily distinguish
connection 1 packets from H1 from connection 1 packets
from H3, C cannot do this.
➢ For this reason, A assigns a different connection
identifier to the outgoing traffic for the second
connection. Avoiding conflicts of this kind is why routers
need the ability to replace connection identifiers in
outgoing packets. In some contexts, this is called label
switching.
5.1.5 Comparison of Virtual-Circuit and Datagram
Subnets
5.2 Routing Algorithms
➢ The main function of the network layer is routing packets
from the source machine to the destination machine. In
most subnets, packets will require multiple hops to make
the journey.
➢ The routing algorithm is that part of the network layer
software responsible for deciding which output line an
incoming packet should be transmitted on.
➢ If the subnet uses datagrams internally, For every
arriving packet is routed independently. When virtual
circuit is established all packets are follows the same
route. The data packets just follow the previously-
established route is called session routing.
5.2 Routing Algorithms
➢ The desirable properties of a routing algorithm:
correctness, simplicity, robustness, stability, fairness, and
optimality.
➢ The robustness may be expected to run continuously for
years without system wide failures. During that period
there will be hardware and software failures of all kinds.
➢
➢ Routing algorithms can be grouped into two major
classes: nonadaptive and adaptive.
➢ In non-adaptive routing, the choice of the route is
calculated in advance. This type of routing procedure is
called static routing.
5.2 Routing Algorithms
➢ In adaptive routing the choice of the route is not
calculated in advance. This type of routing procedure is
called dynamic routing.
➢
➢ The set of optimal routes from all sources to a given
destination form a tree rooted at the destination. Such a
tree is called a sink tree and is illustrated in Fig. 5-6,
where the distance metric is the number of hops.
➢ The goal of all routing algorithms is to discover and use
the sink trees for all routers.
➢ A sink tree is indeed a tree, it does not contain any loops,
so each packet will be delivered within a finite and
bounded number of hops.
5.2 Routing Algorithms
Figure 5-6. (a) A subnet. (b) A sink tree for router B.
5.2.2 Shortest Path Routing
➢ The idea is to build a graph of the subnet, with each node
of the graph representing a router and each arc of the
graph representing a communication line (often called a
link).
➢ To choose a route between a given pair of routers, the
algorithm just finds the shortest path between them on
the graph.
➢ One way of measuring path length is the number of hops.
Using this metric, the paths ABC and ABE in Fig. 5-7 are
equally long. Another metric is the geographic distance
in kilometers, in which case ABC is clearly much longer
than ABE (assuming the figure is drawn to scale).
5.2.2 Shortest Path Routing
Figure 5-7. The first five steps used in computing the shortest path from A to D.
The arrows indicate the working node.
5.2.2 Shortest Path Routing
Possible Path 1 : ABCD : 2+7+3=12
Possible path 2 : ABEFCD: 2+2+2+3+3=12
Possible path3 : ABEFHD : 2+2+2+2+2=10 -→
Shortest Path
Shortest Path : ABEGHD: 2+2+1+4+2=11
5.2.2 Shortest Path Routing
➢ Several algorithms for computing the shortest path
between two nodes of a graph are known. This one is
due to Dijkstra (1959). Each node is labeled (in
parentheses) with its distance from the source node
along the best known path.
➢ Initially, no paths are known, so all nodes are labeled
with infinity. As the algorithm proceeds and paths are
found, the labels may change, reflecting better paths.
A label may be either tentative or permanent. Initially,
all labels are tentative. When it is discovered that a
label represents the shortest possible path from the
source to that node, it is made permanent and never
changed thereafter.
5.2.2 Shortest Path Routing
➢ To illustrate how the labeling algorithm works, look at
the weighted, undirected graph of Fig. 5-7(a), where
the weights represent, for example, distance. We want
to find the shortest path from A to D.
➢ We start out by marking node A as permanent,
indicated by a filled-in circle. Then we examine, in
turn, each of the nodes adjacent to A (the working
node), relabeling each one with the distance to A.
➢ Whenever a node is relabeled, we also label it with
the node from which the probe was made so that we
can reconstruct the final path later.
5.2.2 Shortest Path Routing
➢ Having examined each of the nodes adjacent to A, we
examine all the tentatively labeled nodes in the whole
graph and make the one with the smallest label
permanent, as shown in Fig. 5-7(b).
➢ This one becomes the new working node. We now
start at B and examine all nodes adjacent to it.
➢ If the sum of the label on B and the distance from B to
the node being considered is less than the label on that
node, we have a shorter path, so the node is relabeled.
5.2.3 Flooding
1. Identify the number of hop (Jump) from source to
destination.
2. Initialise the counter value
3. Decrease the counter value at each hop reaches
4. Stop the process when counter reaches to zero.
5.2.4 Distance Vector Routing
➢ Modern computer networks generally use dynamic
routing algorithms. Two dynamic algorithms, in
particular, distance vector routing and link state
routing, are the most popular.
➢ In distance vector routing, each router maintains a
routing table indexed by, and containing one entry for,
each router in the subnet.
➢ This entry contains two parts: the preferred outgoing
line to use for that destination and an estimate of the
time or distance to that destination. The metric used
might be number of hops, the time delay in
milliseconds, total number of packets queued along
the path, or something similar.
5.2.4 Distance Vector Routing
➢ The router is assumed to know the ''distance'' to each
of its neighbors. If the metric is hops, the distance is
just one hop. If the metric is queue length, the router
simply examines each queue. If the metric is delay, the
router can measure it by time delay.
➢ By using the bellman ford calculation for each
neighbor, a router can find out which estimate seems
the best and use that estimate and the corresponding
line in its new routing table.
➢ The updating process is illustrated in Fig. 5-9. Part (a)
shows a subnet. The Fig 5-9 determines the next
estimated delay from J. The first four columns of part
(b) show the delay vectors received from the
neighbors of router J.
5.2.4 Distance Vector Routing
5.2.4 Distance Vector Routing
5.2.4 Distance Vector Routing
Consider how J computes its new route to router G.
Step 1: Distance vector from A to remaining router B.C,D,…L via J
(i.e, router A to router B via J=12msec, router A to router C via J=25,
etc. represented as Black bold)
Step 2: For example, J has measured or estimated its delay to its
neighbors, A, I, H, and K as 8, 10, 12, and 6 msec, respectively.
Step 3: Determine the shortest path from G to A, I, H and K via
router J.
Delay for G to A = JA Delay time + GA Delay time ➔ 8 + 18 =26;
Delay for G to A = JI Delay time + GI Delay time ➔ 31+10 =41;
Delay for G to A = JH Delay time + GH Delay time ➔ 6 + 12 =18;
Delay for G to A = JK Delay time + GK Delay time ➔ 31 + 6 =37;
Step 4: The best of these values is 18, so it makes an entry in its
routing table that the delay to G is 18 msec and that the route to use
is via H.
The same calculation is performed for all the other destinations, with
the new routing table shown in the last column of the figure.
5.2.5 Link State Routing
➢ The idea behind link state routing is simple and can be
stated as five parts. Each router must do the following:
1. Discover its neighbors and learn their network addresses.
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.
5.2.5 Link State Routing
Learning about the Neighbors
➢ When a router is booted, its first task is to learn who its
neighbors are. It accomplishes this goal by sending a
special HELLO packet on each point-to-point line. The
router on the other end is expected to send back a reply
telling who it is.
➢ When two or more routers are connected by a LAN, the
situation is slightly more complicated. Fig. 5-11(a)
illustrates a LAN to which three routers, A, C, and F,
are directly connected. Each of these routers is
connected to one or more additional routers, as shown.
5.2.5 Link State Routing
➢ One way to model the LAN is to consider it as a node
itself, as shown in Fig. 5-11(b).
➢ Here introduced a new, artificial node, N, to which A,
C, and F are connected. The fact that it is possible to
go from A to C on the LAN is represented by the path
ANC here.
5.2.5 Link State Routing
Measuring Line Cost
➢ The link state routing algorithm requires each router to
know, or at least have a reasonable estimate of, the
delay to each of its neighbors.
➢ The most direct way to determine this delay is to send
over the line a special ECHO packet that the other side
is required to send back immediately.
➢ Unfortunately, there is an argument against including
the load in the delay calculation. Consider the subnet of
Fig. 5-12, which is divided into two parts, East and
West, connected by two lines, CF and EI.
5.2.5 Link State Routing
➢ Suppose that most of the traffic between East and West
is using line CF, and as a result, this line is heavily
loaded with long delays. Including queueing delay in
the shortest path calculation will make EI more
attractive.
➢ After the new routing tables have been installed, most
of the East-West traffic will now go over EI,
overloading this line. Consequently, in the next update,
CF will appear to be the shortest path. As a result, the
routing tables may oscillate wildly, leading to erratic
routing and many potential problems.
5.2.5 Link State Routing
5.2.5 Link State Routing
Building Link State Packets
➢ Once the information needed for the exchange has been
collected, the next step is for each router to build a
packet containing all the data. The packet starts with the
identity of the sender, followed by a sequence number
and age (to be described later), and a list of neighbors.
➢ For each neighbor, the delay to that neighbor is given.
An example subnet is given in Fig. 5-13(a) with delays
shown as labels on the lines. The corresponding link
state packets for all six routers are shown in Fig. 5-
13(b).
5.2.5 Link State Routing
Building Link State Packets
➢ Once the information needed for the exchange has been
collected, the next step is for each router to build a
packet containing all the data. The packet starts with the
identity of the sender, followed by a sequence number
and age (to be described later), and a list of neighbors.
➢ For each neighbor, the delay to that neighbor is given.
An example subnet is given in Fig. 5-13(a) with delays
shown as labels on the lines. The corresponding link
state packets for all six routers are shown in Fig. 5-
13(b).
5.2.5 Link State Routing
5.2.5 Link State Routing
➢ The fundamental idea is to use flooding to distribute the
link state packets. To keep the flood in check, each
packet contains a sequence number that is incremented
for each new packet sent. When a new link state packet
comes in, it is checked against the list of packets already
seen. If it is new, it is forwarded on all lines except the
one it arrived on. If it is a duplicate, it is discarded.
➢ The solution to router crash or sequence number loss is
to include the age of each packet after the sequence
number and decrement it once per second. When the age
hits zero, the information from that router is discarded.
5.2.5 Link State Routing
➢ The data structure used by router B for the subnet
shown in Fig. 5-13(a) is depicted in Fig. 5-14. Each row
here corresponds to a recently-arrived, but as yet not
fully-processed, link state packet.
➢ The table records where the packet originated, its
sequence number and age, and the data. In addition,
there are send and acknowledgement flags for each of
B's three lines (to A, C, and F, respectively).
➢ The send flags mean that the packet must be sent on the
indicated line. The acknowledgement flags mean that it
must be acknowledged there.
5.2.5 Link State Routing
5.2.5 Link State Routing
Computing the New Routes
Once a router has accumulated a full set of link state
packets, it can construct the entire subnet graph because
every link is represented. Every link is, in fact, represented
twice, once for each direction. The two values can be
averaged or used separately.
5.2.6 Hierarchical Routing
➢ When hierarchical routing is used, the routers are
divided into what we will call regions, with each router
knowing all the details about how to route packets to
destinations within its own region.
➢ Figure 5-15 gives a quantitative example of routing in a
two-level hierarchy with five regions.
➢ The full routing table for router 1A has 17 entries, as
shown in Fig. 5-15(b).
5.2.6 Hierarchical Routing
➢ When routing is done hierarchically, as in Fig. 5-15(c),
there are entries for all the local routers as before, but
all other regions have been condensed into a single
router, so all traffic for region 2 goes via the 1B -2A
line, but the rest of the remote traffic goes via the 1C -
3B line.
➢ Hierarchical routing has reduced the table from 17 to 7
entries. As the ratio of the number of regions to the
number of routers per region grows, the savings in table
space increase.
5.2.6 Hierarchical Routing
➢ Full table for 1A is derived from Fig. 5.15 a. In Fig 5.15 a,
Region 1 has 2 lines 1B and 1C. By using these two lines,
the packet can tranvel from one region to another region.
5.2.7 Broadcast Routing
➢ In some applications, hosts need to send messages
to many or all other hosts.
➢ Sending a packet to all destinations simultaneously
is called broadcasting.
➢ For example, a service distributing weather
reports, stock market updates, or live radio
programs might work best by broadcasting to all
machines.
5.2.8 Multicast Routing
➢ Some applications require that widely-separated
processes work together in groups, for example, a
group of processes implementing a distributed
database system.
➢ Sending a message to such a group is called
multicasting, and its routing algorithm is called
multicast routing.

More Related Content

PDF
Lecture Notes - Introduction to Computer Network
PDF
Lecture Notes Unit III PArt 2 - The DataLink Layer Medium Access Control Subl...
PDF
Lecture Notes - Unit II - The Physical Layer
PPT
UNIT I.ppt
PDF
Lecture Notes Unit III The DataLink Layer
PPTX
Overlay network
PPTX
MODULE-4_CCN.pptx
PDF
TCP over wireless slides
Lecture Notes - Introduction to Computer Network
Lecture Notes Unit III PArt 2 - The DataLink Layer Medium Access Control Subl...
Lecture Notes - Unit II - The Physical Layer
UNIT I.ppt
Lecture Notes Unit III The DataLink Layer
Overlay network
MODULE-4_CCN.pptx
TCP over wireless slides

What's hot (20)

PPTX
Unit 1 introduction to computer networks
PPT
Tcp Udp Icmp And The Transport Layer
PPTX
Physical organization of parallel platforms
PDF
Location Aided Routing (LAR)
PPTX
Replication in Distributed Systems
PDF
Introduction to TCP/IP
PPTX
Transport layer services (cn)
PDF
Slide05 Message Passing Architecture
PPT
Osi , tcp/ip protocol and Addressing
PPT
Mac layer
PPTX
Ch 19 Network-layer protocols Section 1
PPTX
Data Dissemination and Synchronization
PPTX
Internet Protocols
PPTX
Computer Networks - Unit 1 PPT
PPTX
Security aspect in GSM
PPT
Mobile Computing UNIT-7
PDF
Cs8591 Computer Networks - UNIT V
PPTX
Data link layer
PPT
ATM Networking Concept
PPTX
Classification of routing protocols
Unit 1 introduction to computer networks
Tcp Udp Icmp And The Transport Layer
Physical organization of parallel platforms
Location Aided Routing (LAR)
Replication in Distributed Systems
Introduction to TCP/IP
Transport layer services (cn)
Slide05 Message Passing Architecture
Osi , tcp/ip protocol and Addressing
Mac layer
Ch 19 Network-layer protocols Section 1
Data Dissemination and Synchronization
Internet Protocols
Computer Networks - Unit 1 PPT
Security aspect in GSM
Mobile Computing UNIT-7
Cs8591 Computer Networks - UNIT V
Data link layer
ATM Networking Concept
Classification of routing protocols
Ad

Similar to Computer Network Unit IV - Lecture Notes - Network Layer (20)

PPTX
CN-UNIT-3 __Network Layer (2).pptx
PPTX
Computer networks for cse Unit-3 (1).pptx
PPTX
Final several design issues at network layer
PPTX
Network layer u3
PDF
Network layer (Unit 3) part1.pdf
PPTX
Network Layer
PDF
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
PPT
Network Layer
PPTX
routing in computer networks for btech.pptx
PDF
Answer sheet of switching & routing
PPTX
Computer networks network layer,routing
PPTX
Comparative Analysis of Distance Vector Routing & Link State Protocols
PPTX
chapter 5.1.pptx
PPT
NETWORK LAYER.ppt
PPTX
Network layer new
PDF
Routing Protocols notes document .pptx.pdf
PDF
CCN Unit-4 Network Layer by Dr. K. Adisesha
PDF
Lecture 9 10 .mobile ad-hoc routing protocols
PPTX
Network Layer
CN-UNIT-3 __Network Layer (2).pptx
Computer networks for cse Unit-3 (1).pptx
Final several design issues at network layer
Network layer u3
Network layer (Unit 3) part1.pdf
Network Layer
4af46e43-4dc7-4b54-ba8b-3a2594bb5269 j.pdf
Network Layer
routing in computer networks for btech.pptx
Answer sheet of switching & routing
Computer networks network layer,routing
Comparative Analysis of Distance Vector Routing & Link State Protocols
chapter 5.1.pptx
NETWORK LAYER.ppt
Network layer new
Routing Protocols notes document .pptx.pdf
CCN Unit-4 Network Layer by Dr. K. Adisesha
Lecture 9 10 .mobile ad-hoc routing protocols
Network Layer
Ad

More from Murugan146644 (17)

PDF
Assembly Language Program for 16_bit_Addition
PDF
Lecture Notes Microprocessor and Controller Unit2
PDF
Lecture Notes - Microprocessor - Unit 1 - Microprocessor Architecture and its...
PDF
Lecture Notes Unit3 chapter22 - distributed databases
PDF
Lecture Notes Unit3 chapter21 - parallel databases
PDF
Lecture Notes Unit3 chapter20 - Database System Architectures
PDF
Relational Database Management System (RDBMS) LAB - GROUP B
PDF
Relational Database Managment System Lab - Group A
PDF
Lecture Notes Unit2 chapter7 RelationalDatabaseDesign
PDF
Lecture Notes Unit 1 chapter 6 E-R MODEL
PDF
Lecture Notes Unit1 chapter1 Introduction
PDF
Lecture Notes Unit5 chapter19 Cursor in Pl/SQL
PDF
Lecture Notes Unit5 chapter18 Packages.pdf
PDF
Lecture Notes Unit5 chapter17 Stored procedures and functions
PDF
Lecture Notes Unit5 chapter16 Trigger Creation
PDF
Lecture Notes Unit5 chapter 15 PL/SQL Programming
PDF
Lecture Notes Unit4 Chapter13 users , roles and privileges
Assembly Language Program for 16_bit_Addition
Lecture Notes Microprocessor and Controller Unit2
Lecture Notes - Microprocessor - Unit 1 - Microprocessor Architecture and its...
Lecture Notes Unit3 chapter22 - distributed databases
Lecture Notes Unit3 chapter21 - parallel databases
Lecture Notes Unit3 chapter20 - Database System Architectures
Relational Database Management System (RDBMS) LAB - GROUP B
Relational Database Managment System Lab - Group A
Lecture Notes Unit2 chapter7 RelationalDatabaseDesign
Lecture Notes Unit 1 chapter 6 E-R MODEL
Lecture Notes Unit1 chapter1 Introduction
Lecture Notes Unit5 chapter19 Cursor in Pl/SQL
Lecture Notes Unit5 chapter18 Packages.pdf
Lecture Notes Unit5 chapter17 Stored procedures and functions
Lecture Notes Unit5 chapter16 Trigger Creation
Lecture Notes Unit5 chapter 15 PL/SQL Programming
Lecture Notes Unit4 Chapter13 users , roles and privileges

Recently uploaded (20)

PPTX
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
PPTX
master seminar digital applications in india
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Business Ethics Teaching Materials for college
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharma ospi slides which help in ospi learning
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
PDF
Insiders guide to clinical Medicine.pdf
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Renaissance Architecture: A Journey from Faith to Humanism
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
Introduction to Child Health Nursing – Unit I | Child Health Nursing I | B.Sc...
master seminar digital applications in india
GDM (1) (1).pptx small presentation for students
Business Ethics Teaching Materials for college
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Anesthesia in Laparoscopic Surgery in India
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharma ospi slides which help in ospi learning
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Insiders guide to clinical Medicine.pdf
2.FourierTransform-ShortQuestionswithAnswers.pdf
Mark Klimek Lecture Notes_240423 revision books _173037.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
O7-L3 Supply Chain Operations - ICLT Program
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Renaissance Architecture: A Journey from Faith to Humanism
Microbial disease of the cardiovascular and lymphatic systems
BOWEL ELIMINATION FACTORS AFFECTING AND TYPES
human mycosis Human fungal infections are called human mycosis..pptx

Computer Network Unit IV - Lecture Notes - Network Layer

  • 1. Unit IV - The Network Layer Dr. S.Murugan Associate Professor, Department of Computer Science. Alagappa Government Arts College, (Affiliated by Alagappa University) Karaikudi. Email: [email protected]
  • 2. This slides compiled from Computer Network by Andrew S. Tenenbaum 4th Ed.
  • 3. The Network Layer ➢ The network layer is concerned with getting packets from the source all the way to the destination. ➢ To achieve its goals, the network layer must know about the topology of the communication subnet (i.e., the set of all routers) and choose appropriate paths through it.
  • 4. 5.1 Network Layer Design Issues 5.1.1 Store-and-Forward Packet Switching ➢ The environment of the network layer protocol is represented in the figure 5.1.
  • 5. 5.1.1 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.
  • 6. 5.1.2 Services Provided to the Transport Layer ➢ The network layer provides services to the transport layer at the network layer/transport layer interface. The network layer services have been designed with the following goals in mind. 1. The services should be independent of the router technology. 2. The transport layer should be shielded from the number, type, and topology of the routers present. 3. The network addresses made available to the transport layer should use a uniform numbering plan, even across LANs and WANs.
  • 7. 5.1.3 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 datagrams (in analogy with telegrams) and the subnet is called a datagram subnet. ➢ 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.
  • 8. 5.1.3 Implementation of Connectionless Service ➢ This connection is called a VC (virtual circuit), in analogy with the physical circuits set up by the telephone system, and the subnet is called a virtual- circuit subnet. ➢ Figure 5.2 shows the routing with the datagram subnet. The message M is transfer from Host1 to Host2. ➢ The network layer has to break the messages into four packets, 1, 2, 3, and 4 and sends each of them in turn to router A using some point-to-point protocol, for example, PPP.
  • 9. 5.1.3 Implementation of Connectionless Service ➢ At this point the carrier takes over. Every router has an internal table telling it where to send packets for each possible destination. ➢ Each table entry is a pair consisting of a destination and the outgoing line to use for that destination. ➢ Only directly-connected lines can be used.
  • 10. 5.1.3 Implementation of Connectionless Service
  • 11. 5.1.3 Implementation of Connectionless Service ➢ For example, in Fig. 5-2, A has only two outgoing lines to B and C. so every incoming packet must be sent to one of these routers, even if the ultimate destination is some other router. A's initial routing table is shown in the figure under the label ''initially.'' ➢ ➢ As they arrived at A, packets 1, 2, and 3 were stored. Then each was forwarded to C according to A's table. ➢ Packet 1 was then forwarded to E and then to F. When it got to F, it was encapsulated in a data link layer frame and sent to H2 over the LAN. Packets 2 and 3 follow the same route.
  • 12. 5.1.3 Implementation of Connectionless Service ➢ However, something different happened to packet 4. When it got to A it was sent to router B, even though it is also destined for F. ➢ For some reason, A decided to send packet 4 via a different route than that of the first three. ➢ Perhaps it learned of a traffic jam somewhere along the ACE path and updated its routing table, as shown under the label ''later.'' ➢ The algorithm that manages the tables and makes the routing decisions is called the routing algorithm.
  • 13. 5.1.4 Implementation of Connection-Oriented Service ➢ For connection-oriented service, we need a virtual- circuit subnet. virtual circuits is to avoid having to choose a new route for every packet sent, as in Fig. 5-2. ➢ With connection-oriented service, each packet carries an identifier telling which virtual circuit it belongs to. ➢ As an example, consider the situation of Fig. 5-3.
  • 14. 5.1.4 Implementation of Connection-Oriented Service
  • 15. 5.1.4 Implementation of Connection-Oriented Service ➢ Here, host H1 has established connection 1 with host H2. It is remembered as the first entry in each of the routing tables. The first line of A's table says that if a packet bearing connection identifier 1 comes in from H1, it is to be sent to router C and given connection identifier 1. Similarly, the first entry at C routes the packet to E, also with connection identifier 1. ➢ Now let us consider what happens if H3 also wants to establish a connection to H2.
  • 16. 5.1.4 Implementation of Connection-Oriented Service ➢ It chooses connection identifier 1 (because it is initiating the connection and this is its only connection) and tells the subnet to establish the virtual circuit. This leads to the second row in the tables. Note that we have a conflict here because although A can easily distinguish connection 1 packets from H1 from connection 1 packets from H3, C cannot do this. ➢ For this reason, A assigns a different connection identifier to the outgoing traffic for the second connection. Avoiding conflicts of this kind is why routers need the ability to replace connection identifiers in outgoing packets. In some contexts, this is called label switching.
  • 17. 5.1.5 Comparison of Virtual-Circuit and Datagram Subnets
  • 18. 5.2 Routing Algorithms ➢ The main function of the network layer is routing packets from the source machine to the destination machine. In most subnets, packets will require multiple hops to make the journey. ➢ The routing algorithm is that part of the network layer software responsible for deciding which output line an incoming packet should be transmitted on. ➢ If the subnet uses datagrams internally, For every arriving packet is routed independently. When virtual circuit is established all packets are follows the same route. The data packets just follow the previously- established route is called session routing.
  • 19. 5.2 Routing Algorithms ➢ The desirable properties of a routing algorithm: correctness, simplicity, robustness, stability, fairness, and optimality. ➢ The robustness may be expected to run continuously for years without system wide failures. During that period there will be hardware and software failures of all kinds. ➢ ➢ Routing algorithms can be grouped into two major classes: nonadaptive and adaptive. ➢ In non-adaptive routing, the choice of the route is calculated in advance. This type of routing procedure is called static routing.
  • 20. 5.2 Routing Algorithms ➢ In adaptive routing the choice of the route is not calculated in advance. This type of routing procedure is called dynamic routing. ➢ ➢ The set of optimal routes from all sources to a given destination form a tree rooted at the destination. Such a tree is called a sink tree and is illustrated in Fig. 5-6, where the distance metric is the number of hops. ➢ The goal of all routing algorithms is to discover and use the sink trees for all routers. ➢ A sink tree is indeed a tree, it does not contain any loops, so each packet will be delivered within a finite and bounded number of hops.
  • 21. 5.2 Routing Algorithms Figure 5-6. (a) A subnet. (b) A sink tree for router B.
  • 22. 5.2.2 Shortest Path Routing ➢ The idea is to build a graph of the subnet, with each node of the graph representing a router and each arc of the graph representing a communication line (often called a link). ➢ To choose a route between a given pair of routers, the algorithm just finds the shortest path between them on the graph. ➢ One way of measuring path length is the number of hops. Using this metric, the paths ABC and ABE in Fig. 5-7 are equally long. Another metric is the geographic distance in kilometers, in which case ABC is clearly much longer than ABE (assuming the figure is drawn to scale).
  • 23. 5.2.2 Shortest Path Routing Figure 5-7. The first five steps used in computing the shortest path from A to D. The arrows indicate the working node.
  • 24. 5.2.2 Shortest Path Routing Possible Path 1 : ABCD : 2+7+3=12 Possible path 2 : ABEFCD: 2+2+2+3+3=12 Possible path3 : ABEFHD : 2+2+2+2+2=10 -→ Shortest Path Shortest Path : ABEGHD: 2+2+1+4+2=11
  • 25. 5.2.2 Shortest Path Routing ➢ Several algorithms for computing the shortest path between two nodes of a graph are known. This one is due to Dijkstra (1959). Each node is labeled (in parentheses) with its distance from the source node along the best known path. ➢ Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm proceeds and paths are found, the labels may change, reflecting better paths. A label may be either tentative or permanent. Initially, all labels are tentative. When it is discovered that a label represents the shortest possible path from the source to that node, it is made permanent and never changed thereafter.
  • 26. 5.2.2 Shortest Path Routing ➢ To illustrate how the labeling algorithm works, look at the weighted, undirected graph of Fig. 5-7(a), where the weights represent, for example, distance. We want to find the shortest path from A to D. ➢ We start out by marking node A as permanent, indicated by a filled-in circle. Then we examine, in turn, each of the nodes adjacent to A (the working node), relabeling each one with the distance to A. ➢ Whenever a node is relabeled, we also label it with the node from which the probe was made so that we can reconstruct the final path later.
  • 27. 5.2.2 Shortest Path Routing ➢ Having examined each of the nodes adjacent to A, we examine all the tentatively labeled nodes in the whole graph and make the one with the smallest label permanent, as shown in Fig. 5-7(b). ➢ This one becomes the new working node. We now start at B and examine all nodes adjacent to it. ➢ If the sum of the label on B and the distance from B to the node being considered is less than the label on that node, we have a shorter path, so the node is relabeled.
  • 28. 5.2.3 Flooding 1. Identify the number of hop (Jump) from source to destination. 2. Initialise the counter value 3. Decrease the counter value at each hop reaches 4. Stop the process when counter reaches to zero.
  • 29. 5.2.4 Distance Vector Routing ➢ Modern computer networks generally use dynamic routing algorithms. Two dynamic algorithms, in particular, distance vector routing and link state routing, are the most popular. ➢ In distance vector routing, each router maintains a routing table indexed by, and containing one entry for, each router in the subnet. ➢ This entry contains two parts: the preferred outgoing line to use for that destination and an estimate of the time or distance to that destination. The metric used might be number of hops, the time delay in milliseconds, total number of packets queued along the path, or something similar.
  • 30. 5.2.4 Distance Vector Routing ➢ The router is assumed to know the ''distance'' to each of its neighbors. If the metric is hops, the distance is just one hop. If the metric is queue length, the router simply examines each queue. If the metric is delay, the router can measure it by time delay. ➢ By using the bellman ford calculation for each neighbor, a router can find out which estimate seems the best and use that estimate and the corresponding line in its new routing table. ➢ The updating process is illustrated in Fig. 5-9. Part (a) shows a subnet. The Fig 5-9 determines the next estimated delay from J. The first four columns of part (b) show the delay vectors received from the neighbors of router J.
  • 33. 5.2.4 Distance Vector Routing Consider how J computes its new route to router G. Step 1: Distance vector from A to remaining router B.C,D,…L via J (i.e, router A to router B via J=12msec, router A to router C via J=25, etc. represented as Black bold) Step 2: For example, J has measured or estimated its delay to its neighbors, A, I, H, and K as 8, 10, 12, and 6 msec, respectively. Step 3: Determine the shortest path from G to A, I, H and K via router J. Delay for G to A = JA Delay time + GA Delay time ➔ 8 + 18 =26; Delay for G to A = JI Delay time + GI Delay time ➔ 31+10 =41; Delay for G to A = JH Delay time + GH Delay time ➔ 6 + 12 =18; Delay for G to A = JK Delay time + GK Delay time ➔ 31 + 6 =37; Step 4: The best of these values is 18, so it makes an entry in its routing table that the delay to G is 18 msec and that the route to use is via H. The same calculation is performed for all the other destinations, with the new routing table shown in the last column of the figure.
  • 34. 5.2.5 Link State Routing ➢ The idea behind link state routing is simple and can be stated as five parts. Each router must do the following: 1. Discover its neighbors and learn their network addresses. 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.
  • 35. 5.2.5 Link State Routing Learning about the Neighbors ➢ When a router is booted, its first task is to learn who its neighbors are. It accomplishes this goal by sending a special HELLO packet on each point-to-point line. The router on the other end is expected to send back a reply telling who it is. ➢ When two or more routers are connected by a LAN, the situation is slightly more complicated. Fig. 5-11(a) illustrates a LAN to which three routers, A, C, and F, are directly connected. Each of these routers is connected to one or more additional routers, as shown.
  • 36. 5.2.5 Link State Routing ➢ One way to model the LAN is to consider it as a node itself, as shown in Fig. 5-11(b). ➢ Here introduced a new, artificial node, N, to which A, C, and F are connected. The fact that it is possible to go from A to C on the LAN is represented by the path ANC here.
  • 37. 5.2.5 Link State Routing Measuring Line Cost ➢ The link state routing algorithm requires each router to know, or at least have a reasonable estimate of, the delay to each of its neighbors. ➢ The most direct way to determine this delay is to send over the line a special ECHO packet that the other side is required to send back immediately. ➢ Unfortunately, there is an argument against including the load in the delay calculation. Consider the subnet of Fig. 5-12, which is divided into two parts, East and West, connected by two lines, CF and EI.
  • 38. 5.2.5 Link State Routing ➢ Suppose that most of the traffic between East and West is using line CF, and as a result, this line is heavily loaded with long delays. Including queueing delay in the shortest path calculation will make EI more attractive. ➢ After the new routing tables have been installed, most of the East-West traffic will now go over EI, overloading this line. Consequently, in the next update, CF will appear to be the shortest path. As a result, the routing tables may oscillate wildly, leading to erratic routing and many potential problems.
  • 39. 5.2.5 Link State Routing
  • 40. 5.2.5 Link State Routing Building Link State Packets ➢ Once the information needed for the exchange has been collected, the next step is for each router to build a packet containing all the data. The packet starts with the identity of the sender, followed by a sequence number and age (to be described later), and a list of neighbors. ➢ For each neighbor, the delay to that neighbor is given. An example subnet is given in Fig. 5-13(a) with delays shown as labels on the lines. The corresponding link state packets for all six routers are shown in Fig. 5- 13(b).
  • 41. 5.2.5 Link State Routing Building Link State Packets ➢ Once the information needed for the exchange has been collected, the next step is for each router to build a packet containing all the data. The packet starts with the identity of the sender, followed by a sequence number and age (to be described later), and a list of neighbors. ➢ For each neighbor, the delay to that neighbor is given. An example subnet is given in Fig. 5-13(a) with delays shown as labels on the lines. The corresponding link state packets for all six routers are shown in Fig. 5- 13(b).
  • 42. 5.2.5 Link State Routing
  • 43. 5.2.5 Link State Routing ➢ The fundamental idea is to use flooding to distribute the link state packets. To keep the flood in check, each packet contains a sequence number that is incremented for each new packet sent. When a new link state packet comes in, it is checked against the list of packets already seen. If it is new, it is forwarded on all lines except the one it arrived on. If it is a duplicate, it is discarded. ➢ The solution to router crash or sequence number loss is to include the age of each packet after the sequence number and decrement it once per second. When the age hits zero, the information from that router is discarded.
  • 44. 5.2.5 Link State Routing ➢ The data structure used by router B for the subnet shown in Fig. 5-13(a) is depicted in Fig. 5-14. Each row here corresponds to a recently-arrived, but as yet not fully-processed, link state packet. ➢ The table records where the packet originated, its sequence number and age, and the data. In addition, there are send and acknowledgement flags for each of B's three lines (to A, C, and F, respectively). ➢ The send flags mean that the packet must be sent on the indicated line. The acknowledgement flags mean that it must be acknowledged there.
  • 45. 5.2.5 Link State Routing
  • 46. 5.2.5 Link State Routing Computing the New Routes Once a router has accumulated a full set of link state packets, it can construct the entire subnet graph because every link is represented. Every link is, in fact, represented twice, once for each direction. The two values can be averaged or used separately.
  • 47. 5.2.6 Hierarchical Routing ➢ When hierarchical routing is used, the routers are divided into what we will call regions, with each router knowing all the details about how to route packets to destinations within its own region. ➢ Figure 5-15 gives a quantitative example of routing in a two-level hierarchy with five regions. ➢ The full routing table for router 1A has 17 entries, as shown in Fig. 5-15(b).
  • 48. 5.2.6 Hierarchical Routing ➢ When routing is done hierarchically, as in Fig. 5-15(c), there are entries for all the local routers as before, but all other regions have been condensed into a single router, so all traffic for region 2 goes via the 1B -2A line, but the rest of the remote traffic goes via the 1C - 3B line. ➢ Hierarchical routing has reduced the table from 17 to 7 entries. As the ratio of the number of regions to the number of routers per region grows, the savings in table space increase.
  • 49. 5.2.6 Hierarchical Routing ➢ Full table for 1A is derived from Fig. 5.15 a. In Fig 5.15 a, Region 1 has 2 lines 1B and 1C. By using these two lines, the packet can tranvel from one region to another region.
  • 50. 5.2.7 Broadcast Routing ➢ In some applications, hosts need to send messages to many or all other hosts. ➢ Sending a packet to all destinations simultaneously is called broadcasting. ➢ For example, a service distributing weather reports, stock market updates, or live radio programs might work best by broadcasting to all machines.
  • 51. 5.2.8 Multicast Routing ➢ Some applications require that widely-separated processes work together in groups, for example, a group of processes implementing a distributed database system. ➢ Sending a message to such a group is called multicasting, and its routing algorithm is called multicast routing.