0% found this document useful (0 votes)
4 views

Module-3 Network Layer

The document provides an overview of Module 3 of the Computer Networks course, focusing on the Network Layer, including design issues, routing algorithms, and congestion control. It discusses the responsibilities of the network layer in packet transmission, the differences between connection-oriented and connectionless services, and the implementation of routing algorithms. Key concepts such as store-and-forward packet switching, virtual-circuit networks, and the optimality principle in routing are also covered.

Uploaded by

Bishal King
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Module-3 Network Layer

The document provides an overview of Module 3 of the Computer Networks course, focusing on the Network Layer, including design issues, routing algorithms, and congestion control. It discusses the responsibilities of the network layer in packet transmission, the differences between connection-oriented and connectionless services, and the implementation of routing algorithms. Key concepts such as store-and-forward packet switching, virtual-circuit networks, and the optimality principle in routing are also covered.

Uploaded by

Bishal King
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Dayananda Sagar Academy of Technology & Management

(Affiliated to Visvesvaraya Technological University,Belagavi & Approved by AICTE,New


Delhi)
Opp. Art of Living, Udayapura, Kanakapura Road,Bangalore – 560082
Department of Information Science & Engineering
Accredited by NAAC A+ and Accredited by NBA, New Delhi
2023-2024

Computer Networks -21CS52


Module-3 Notes
Dr. Rajesh L,
Associate Professor
ISE, DSATM

Module 3: The Networks Layer


Syllabus:
The Network Layer:
Network Layer Design Issues, Routing Algorithms, Congestion Control
Algorithms, QoS.
Computer Networks

MODULE 3
THE NETWORK LAYER
Introductions
The network layer is responsible for ensuring packets travel from the source to the destination.
This often involves multiple hops through intermediate routers. Therefore, the network layer
handles end-to-end transmission.
To accomplish its tasks, the network layer must understand the network's topology, select
appropriate paths, and manage traffic to prevent congestion. It also addresses challenges when the
source and destination are in different networks. In this chapter, with a primary focus on the
Internet and its network layer protocol, IP.

I. NETWORK LAYER DESIGN ISSUES


1. Store-and-Forward Packet Switching
In the context of network layer protocols, it's essential to understand the components of the
network. In Figure 5-1, we see two key elements: ISP equipment (routers connected by
transmission lines) within the shaded oval and customers' equipment outside the oval. Host H1 is
directly connected to an ISP router, while H2 is on a LAN, connected to a customer-owned router.
Although routers like F are outside the ISP's ownership, they are considered part of the ISP network
for the purpose of this chapter, as they run similar algorithms. This distinction is relevant because
our focus here is on these algorithms.

When a host has a packet to send, it sends it to the nearest router, either on its own LAN or via a
point-to-point link to the ISP. The router stores the packet until it's fully received and processed
(including checksum verification), after which it forwards the packet to the next router along the
path. This process continues until the packet reaches its destination host, where it is delivered. This
mechanism is known as store-and-forward packet switching.

1
Computer Networks

2. Services Provided to the Transport Layer


The network layer provides services to the transport layer, which must be carefully designed with
specific goals in mind:
1. Services should be router technology independent.
2. The transport layer should remain unaware of the number, type, and topology of routers.
3. Network addresses available to the transport layer should follow a uniform numbering plan,
even across LANs and WANs.
The primary debate in network layer design centers on whether it should offer a connection-
oriented or connectionless service. One perspective, advocated by the Internet community,
suggests that the network's inherent unreliability necessitates hosts handling error control and flow
control independently. Thus, a connectionless service with minimal primitives like SEND
PACKET and RECEIVE PACKET is preferable.
In contrast, another camp, represented by telephone companies, argues for a reliable, connection-
oriented service. They draw from a century of experience with the telephone system, emphasizing
quality of service, especially for real-time traffic like voice and video.
This ongoing controversy has persisted for decades. While early networks were often connection-
oriented, connectionless network layers, like IP, have gained popularity, guided by the end-to-end
argument. Still, even within the Internet, connection-oriented features are evolving as quality-of-
service gains importance, as seen in technologies like MPLS and VLANs.
3. Implementation of Connectionless Service
In implementing a connectionless service at the network layer, two distinct approaches are
employed, depending on the type of service being offered.
a. Connectionless Service (Datagram Networks):
• In a connectionless service, packets, often referred to as datagrams, are injected into the
network independently and are routed without any prior setup.
• Each packet is treated as a standalone unit and is forwarded based on its own routing
information.
• No advance path establishment is required for transmitting individual packets.

In contrast, if a connection-oriented service is employed:


b. Connection-Oriented Service (Virtual-Circuit Networks):
• Before transmitting data packets, a path from the source router to the destination router,
known as a Virtual Circuit (VC), must be established.
• This setup process involves configuring a specific path that the data packets will follow.
• The network is referred to as a virtual-circuit network, drawing an analogy to the physical
circuits established in the traditional telephone system.

In a datagram network, let's consider the process of transmitting a long message from process P1
on host H1 to process P2 on host H2. Here's how it works:

1. Process P1 hands the message to the transport layer, which adds a transport header to the
message. This transport layer code runs on H1.

2
Computer Networks

2. The resulting data is then passed to the network layer, typically another procedure within
the operating system.
3. Since the message is longer than the maximum packet size, it's divided into four packets:
1, 2, 3, and 4. Each packet is sent one after the other to router A using a point-to-point
protocol like PPP.
4. Within the ISP's network, each router has a routing table indicating where to send packets
for each possible destination. These tables contain pairs of destinations and the outgoing
lines to use.

5. Router A initially has a routing table as shown in the figure. Packets 1, 2, and 3 are briefly
stored and checked for checksum on arrival. Then they are forwarded according to A's
table, reaching H2 via routers E and F.
6. However, something different happens to packet 4. Router A sends it to router B instead of
following the same route as the first three packets. This change in routing might occur if A
learns of a traffic jam along the initial route and updates its routing table.
7. The algorithm responsible for managing routing tables and making routing decisions is
called the routing algorithm, a central topic in this chapter. Different types of routing
algorithms exist.
8. IP (Internet Protocol), the foundation of the Internet, is a prime example of a connectionless
network service. Each packet carries a destination IP address, allowing routers to forward
packets individually. IPv4 packets have 32-bit addresses, while IPv6 packets have 128-bit
addresses.

3
Computer Networks

4. Implementation of Connection-Oriented Service

In a connection-oriented service, a virtual-circuit network is employed to streamline packet


routing. Here's how it works:

1. Instead of choosing a new route for every packet as in connectionless service, a route from
the source to the destination is selected and stored in tables within the routers when a
connection is established. This chosen route is then used for all data traffic over that
connection, similar to how the telephone system operates.
2. When the connection is terminated, the virtual circuit is also released. Each packet in a
connection-oriented service carries an identifier indicating which virtual circuit it belongs
to.

3. For example, if host H1 establishes connection 1 with host H2, this connection is recorded
as the first entry in the routing tables of each router along the route. Packets from H1 to H2
are then directed through this established route.
4. If another host, say H3, wants to establish a connection to H2, it chooses connection
identifier 1 and requests the network to establish a new virtual circuit. This leads to the
creation of a second entry in the routing tables.
5. To avoid conflicts, routers need the ability to replace connection identifiers in outgoing
packets. This process is sometimes called label switching. An example of a connection-
oriented network service is MPLS (Multi-Protocol Label Switching), used within ISP
networks. MPLS uses a 20-bit connection identifier or label to route traffic efficiently.
6. MPLS is often employed within ISP networks to establish long-term connections for large
traffic volumes. It helps ensure quality of service and assists with various traffic
management tasks, even though it's often transparent to customers.

4
Computer Networks

5. Comparison of Virtual-Circuit and Datagram Networks

Inside a network, there are trade-offs between virtual circuits and datagrams:

1. Setup Time vs. Address Parsing Time:


• Virtual circuits require a setup phase, which consumes time and resources but
simplifies packet routing. Datagram networks don't need setup but require more
complex address lookup.
2. Address Length:
• Datagram networks use longer destination addresses with global meaning, which
can result in significant overhead for short packets, wasting bandwidth.
3. Table Space in Router Memory:
• Datagram networks need entries for every possible destination, whereas virtual-
circuit networks only need entries for each virtual circuit. However, connection
setup packets in virtual-circuit networks also use destination addresses.
4. Quality of Service and Congestion Management:
• Virtual circuits offer advantages in guaranteeing quality of service and managing
congestion by reserving resources in advance during connection setup. Datagram
networks face more challenges in congestion avoidance.
5. Use Case Dependence:

5
Computer Networks

• For transaction processing systems, setting up and clearing virtual circuits may be
too costly compared to their use. However, for long-running applications like
VPNs, permanent virtual circuits can be valuable.
6. Vulnerability:
• Virtual circuits are vulnerable to disruptions if a router crashes and loses memory,
requiring all circuits to be aborted. Datagram networks are more resilient in this
regard.
7. Network Load Balancing:
• Datagram networks allow routers to balance traffic by changing routes during a
sequence of packet transmissions, providing flexibility compared to fixed virtual
circuits.

II. ROUTING ALGORITHMS


The network layer's primary function is routing packets from the source machine to the destination
machine, often requiring multiple hops in most networks. Routing algorithms and data structures
are central to network layer design.

• Routing Algorithm: It decides which output line an incoming packet should be sent on. For
datagram networks, this decision is made for every data packet, while virtual-circuit networks
determine routes during setup and reuse them. This process can be divided into routing (route
selection) and forwarding (packet arrival handling).
• Desirable Properties: Routing algorithms should be correct, simple, robust (able to handle
failures and topology changes), stable (converging to fixed paths), fair, and efficient.
• Trade-offs: Efficiency and fairness can sometimes conflict in routing decisions, requiring a
balance. Networks often optimize goals like minimizing packet delay, maximizing total
throughput, or reducing the number of hops a packet travels.
• Routing Algorithm Classes: Routing algorithms are categorized as nonadaptive (pre-
computed routes) and adaptive (responding to changes in topology and traffic). Adaptive
algorithms can differ in information sources, frequency of route changes, and optimization
metrics.

1. The Optimality Principle


Before diving into specific routing algorithms, it's important to understand the optimality principle,
which holds true regardless of network topology or traffic patterns. This principle, introduced by
Bellman in 1957, states that if router J lies on the optimal path from router I to router K, then the
optimal path from J to K also follows the same route. This can be explained by considering routes
from I to J (r1) and from J to K (r2). If a better route than r2 existed from J to K, it could be
combined with r1 to create a superior route from I to K, contradicting the optimality of r1r2.

6
Computer Networks

• Sink Tree: The sink tree is a tree-like structure formed by optimal routes from all sources
to a specific destination, adhering to the optimality principle. Sink trees play a central role
in routing algorithms, helping efficiently route packets in networks fig(b).
• Directed Acyclic Graphs (DAGs): Sink trees can extend to become DAGs if all possible
paths are considered, allowing for more flexibility in route selection. However, the
fundamental structure of a sink tree is retained in DAGs.
• Network Dynamics: In practice, network dynamics, such as link and router failures, can
affect the stability and accuracy of sink trees. Routers may have varying views of the
current topology, leading to dynamic adjustments in the sink tree.

2. Shortest Path Algorithm


The Shortest Path Algorithm is a fundamental routing technique that computes the optimal paths
within a network when provided with a complete network overview. These are the paths we aim
for a distributed routing algorithm to discover, even if not all routers possess comprehensive
network details.
Here's how it works: We construct a network graph, where each node represents a router, and each
edge signifies a communication link. When determining the route between a specific pair of
routers, the algorithm simply seeks the shortest path within this graph.
The concept of a "shortest path" may be interpreted in various ways. One approach measures path
length in terms of hops, making paths ABC and ABE in Fig. 5-7 equal in length. Another metric
could be geographical distance in kilometers, where ABC would be considerably longer than ABE
if the figure is drawn to scale. Beyond hops and physical distance, numerous other metrics are
feasible. For instance, edges could be labeled with the mean delay of a standard test packet, making
the shortest path the fastest path, regardless of the number of edges or kilometers.
In the broader context, edge labels could be computed based on various factors such as distance,
bandwidth, average traffic, communication cost, measured delay, and more. By adjusting the
weighting function, the algorithm can compute the "shortest" path according to different criteria
or a combination thereof.
7
Computer Networks

Several algorithms are available for calculating the shortest path between two nodes in a graph.
The one we'll discuss is attributed to Dijkstra (1959) and is utilized to find the shortest paths from
a source to all destinations within the network. Each node is assigned a label (in parentheses)
indicating its distance from the source node along the best-known path. Distances must always be
non-negative, particularly when they are based on real factors like bandwidth and delay.
Initially, no paths are known, so all nodes are labeled with infinity. As the algorithm progresses
and identifies paths, labels may change to reflect better routes. Labels can be either tentative or
permanent, with all labels beginning as tentative. Once it's determined that a label represents the
shortest possible path from the source to a particular node, it becomes permanent and remains
unchanged thereafter.

In this algorithm illustration, we'll demonstrate the process using a weighted, undirected graph
(Fig. 5-7a), where the weights represent parameters like distance. Our objective is to discover the
shortest path from A to D. Here's how it works:
1. We begin by marking node A as permanent (indicated by a filled-in circle).
2. Next, we examine each node adjacent to A, one by one (the working node). We relabel each
of these nodes with the distance to A. Additionally, we record the node from which the
probe was made to reconstruct the final path later. If multiple shortest paths exist from A
to D, we must remember all the probe nodes that could reach a node with the same distance.

8
Computer Networks

3. Having examined all nodes adjacent to A, we then inspect all tentatively labeled nodes
across the entire graph. We make the one with the smallest label permanent (as shown in
Fig. 5-7b), and this node becomes the new working node.
4. We repeat the process, starting from node B and examining all nodes adjacent to it. If the
sum of the label on B and the distance from B to the considered node is less than the label
on that node, we have a shorter path, so the node is relabeled.
5. After inspecting all nodes adjacent to the working node and updating tentative labels if
necessary, we search the entire graph for the tentatively labeled node with the smallest
value. This node becomes permanent and serves as the working node for the next round.
Fig. 5-7 illustrates the first six steps of the algorithm.
To understand why this algorithm works, consider Fig. 5-7c. At this point, we've made E
permanent. Now, suppose there were a shorter path than ABE, let's say AXYZE (with X and Y as
intermediate nodes). There are two possibilities: Either node Z has already been made permanent,
or it hasn't. If it has, then E has already been probed in a previous round when Z became permanent,
so the AXYZE path has been considered, and it cannot be shorter.
Now, let's look at the case where Z is still tentatively labeled. If the label at Z is greater than or
equal to that at E, then the AXYZE path cannot be shorter than ABE. If the label is less than that
of E, then Z will become permanent before E, allowing E to be probed from Z.
3. Flooding
Routing algorithms often rely on local knowledge rather than a complete network view. One basic
local technique is "flooding," where every incoming packet is sent out on all outgoing lines except
the one it arrived on.
To control the potential chaos of flooding, a hop counter is added to each packet's header,
decrementing with each hop until the packet is discarded when the counter hits zero. Ideally, the
hop counter should be initialized to the estimated path length from source to destination.
To further manage flooding, routers keep track of flooded packets to avoid duplication. This can
be achieved by having source routers include sequence numbers in their packets and maintaining
lists of seen sequence numbers for each source.
While not practical for most packets, flooding has its uses. It ensures delivery to every node in the
network, making it useful for broadcasting information and maintaining robustness, even in
challenging conditions. Flooding's minimal setup requirements also make it a foundational element
for more efficient routing algorithms and a valuable metric for performance comparisons. Flooding
inherently chooses the shortest path, as it explores all possible paths simultaneously.
4. Distance Vector Routing

Distance Vector Routing is a common dynamic routing algorithm used in computer networks. It
operates by having each router maintain a table, known as a vector, which contains information
about the best-known distance to each destination and the appropriate link to reach it. These tables

9
Computer Networks

are continually updated through communication with neighboring routers, allowing each router to
determine the optimal path to every destination.
In distance vector routing, each router's routing table includes entries for every router in the
network. Each entry consists of the preferred outgoing line for that destination and an estimate of
the distance to reach it. The distance can be measured in various ways, such as the number of hops
or other metrics like propagation delay, which can be determined using specialized ECHO packets.
For instance, let's consider using delay as a metric, and assume that each router knows the delay
to its neighboring routers. Periodically, let's say every T milliseconds, each router shares a list of
its estimated delays to reach various destinations with its neighbors. In return, it receives similar
lists from its neighbors.

For instance, if a router receives a table from neighbor X with Xi representing X's delay estimates
to different routers, and it already knows the delay to X is m milliseconds, it can calculate that it
can reach router i via X in Xi + m milliseconds. By performing this calculation for each neighbor's
estimates, the router can determine the best estimate and corresponding link to update its routing
table. Notably, the old routing table is not used in this calculation.
This updating process is demonstrated in Figure 5-9. Part (a) depicts a network, and part (b)
illustrates delay vectors received from router J's neighbors. Each neighbor claims different delay
values to various destinations. Assuming J has its own delay estimates to its neighbors A, I, H, and
K as 8, 10, 12, and 6 milliseconds, respectively, it calculates its new route to router G. For example,
J knows it can reach A in 8 milliseconds, and A claims a 18-millisecond delay to G. Thus, J can
10
Computer Networks

expect a 26-millisecond delay to G if it forwards packets through A. It performs similar


calculations for other neighbors and destinations, updating its routing table accordingly.
The Count-to-Infinity Problem
Convergence refers to the process of routers settling on the best paths within a network. Distance
vector routing, while a straightforward method for routers to collectively calculate shortest paths,
suffers from a significant drawback: it can be slow to converge. It quickly responds to positive
changes but sluggishly adapts to negative ones.
To illustrate the speed at which good news spreads, let's examine a simple five-node network (Fig.
5-10) with hop count as the metric. Initially, router A is down, and all other routers register A's
delay as infinity. When A comes back up, the routers learn about it through vector exchanges.
Imagine there's a signal (like a gong) that triggers simultaneous vector exchanges across all routers.
During the first exchange, B learns that its left neighbor has zero delay to A and updates its routing
table accordingly. The others still think A is down. The good news about A's revival propagates at
one hop per exchange. In a network with the longest path of N hops, it takes N exchanges for
everyone to know about revived links or routers.

Now consider the scenario in Fig. 5-10(b), where all links and routers are initially operational.
Routers B, C, D, and E have distances to A of 1, 2, 3, and 4 hops, respectively. Suddenly, either A
goes down or the A-B link is severed (effectively the same from B's perspective).
In the first exchange, B doesn't receive any news from A. Fortunately, C reports having a 2-hop
path to A. However, B doesn't know that C's path includes itself, so it believes the path to A via C
is 3 hops long. D and E don't update their entries for A in the first exchange.
In the second exchange, C realizes that its neighbors all claim to have 3-hop paths to A, so it
randomly picks one and updates its distance to A as 4 hops. Subsequent exchanges follow the
history shown in the figure.
This scenario illustrates why bad news travels slowly: no router's value exceeds the minimum of
its neighbors' values by more than one. Gradually, all routers increase their distance to infinity, but
the number of exchanges required depends on the value set for infinity. Therefore, setting infinity
to the longest path plus 1 is a prudent choice.
11
Computer Networks

This problem is known as the count-to-infinity problem, and various attempts have been made to
solve it, like using heuristics such as the split horizon with poisoned reverse rule discussed in RFC
1058. However, none of these heuristics work well in practice due to the fundamental challenge:
routers can't determine if they are on a path when another router advertises it.
5. Link State Routing
Link State Routing replaced Distance Vector Routing in the ARPANET in 1979 due to the count-
to-infinity problem, which caused slow convergence after network topology changes. This
innovative algorithm, now known as Link State Routing, forms the basis for widely used routing
protocols like IS-IS and OSPF. The Link State Routing concept comprises five key steps for routers
to function effectively:

1. Neighbor Discovery: Routers identify their neighboring devices and learn their network
addresses.
2. Distance Metric Assignment: Each router assigns distance or cost metrics to its
neighboring routers.
3. Packet Construction: Routers construct packets containing the information they've
gathered.
4. Packet Exchange: These packets are sent to and received from all other routers in the
network.
5. Shortest Path Computation: Routers calculate the shortest path to reach every other
router in the network.

Learning about the Neighbors: When a router boots up, it identifies its neighbors by sending
HELLO packets over point-to-point connections, receiving replies with unique neighbor names.
For broadcast links (e.g., Ethernet), the setup is more complex. Instead of modeling each link
separately, a LAN is treated as a single node. This node, with a designated router, connects routers
like A, C, and F. This simplifies the topology and reduces message overhead. Connectivity between
routers, like A and C, is represented as paths within this LAN node, such as ANC.

Setting Link Costs: In the link state routing algorithm, each link must have a distance or cost
metric for calculating the shortest paths. These metrics can be automatically determined or
configured by the network operator. Typically, cost is inversely proportional to link bandwidth,
making higher-capacity links preferable. For geographically dispersed networks, link delay can be

12
Computer Networks

factored into the cost, measured using Round-Trip Time with special ECHO packets, ensuring
shorter links are favored in path selection.

Building Link State Packets: In the link state routing algorithm, each router creates a packet
containing sender identity, sequence number, age, and neighbor list with associated costs. Packet
creation is straightforward. The challenge lies in determining when to build these packets. They
can be generated periodically or triggered by significant events like a line or neighbor status change
in fig 5.11.

Distributing the Link State Packets: Distributing link state packets is a crucial aspect of the
algorithm. To ensure all routers quickly and reliably receive these packets, a flooding approach is
used. Each packet contains a sequence number that is incremented with each new transmission,
preventing duplicates. However, to address potential issues, packet age is also included and
decremented periodically. Once the age reaches zero, the information is discarded. This technique
ensures timely updates and prevents obsolete data. Additionally, some refinements include a
holding area for incoming packets and the comparison of sequence numbers to handle duplicates
and errors, with all link state packets acknowledged to enhance robustness.

• Router B uses a data structure, as shown in Fig. 5-13, to manage link state packets. Each
row in this structure represents an incoming packet with information about its origin,
sequence number, age, and data. It also includes flags for sending and acknowledging
packets on B's three links (to A, C, and F).
• For example, when a packet arrives directly from A, it's sent to C and F and acknowledged
to A as indicated by the flag bits. Similarly, a packet from F is forwarded to A and C and
acknowledged to F.
• However, if a packet, like the one from E, arrives through multiple paths (EAB and EFB),
it's sent only to C but acknowledged to both A and F, reflecting the bit settings.

• In cases of duplicate packets arriving while the original is still in the buffer, the flag bits
are adjusted. For instance, if a copy of C's state arrives from F before the original is
forwarded, the bits are changed to indicate acknowledgment to F but no sending.

13
Computer Networks

Computing the New Routes: In link state routing, once a router has collected all link state packets
representing the entire network graph, it can construct a comprehensive view of the network,
considering links in both directions with potential different costs. Dijkstra's algorithm is then
employed locally to compute the shortest paths to all destinations, informing the router of the
preferred link for each destination, which is added to the routing tables.

Compared to distance vector routing, link state routing demands more memory and computation,
with memory needs proportional to k*n (n = number of routers, k = average neighbors), potentially
exceeding the size of a routing table. However, link state routing offers faster convergence, making
it practical for many scenarios. Actual networks often use link state routing protocols like IS-IS
(Intermediate System-Intermediate System) and OSPF (Open Shortest Path First).

14

You might also like