cn unit 3 notes
cn unit 3 notes
LECTURENOTES
COMPUTER NETWORKS
SUBJECTCODE: 22PC0CS14
AY: 2024-2025
YEAR III
SEMESTER I
STREAM :CSE
Network Layer
UNIT–III Notes
SYLLABUS: Network Layer: Design issues, Routing algorithms: the optimality principle, shortest path
algorithm, Flooding, distance vector routing, Hierarchical routing, Broadcast Routing, Multicast
Routing. Congestion Control Algorithms, Quality of Service, Internetworking, the Network layer in
the internet: IPv4 Protocol, IP Address, IPv6.
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 ISP. The packet is stored there until it has fully arrived and the link has finished its
processing by verifying the checksum. 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.
The network layer provides services to the transport layer at the network.
If connectionless service is offered, packets are injected into the network individually and routed
independently of each other. No advance setup is needed. In this context, the packets are frequently
called datagrams.
A’s Table (Initially) | A’s Table (Later) | C’s Table | E’s Table
Let us assume for this example that the message is four times longer than the maximum packet size, so
the network layer has to break it into four packets, 1, 2, 3, and 4, and send each of them in turn to
router A. Every router has an internal table telling it where to send packets for each of the possible
destinations. Each table entry is a pair (destination and the outgoing line). Only directly connected
lines can be used.
A’s initial routing table is shown in the figure under the label "initially." At A, packets 1, 2, and 3 are
stored briefly, having arrived on the incoming link. Then each packet is forwarded according to A’s
table, onto the outgoing link to C within a new frame. Packet 1 is then forwarded to E and then to F.
However, something different happens to packet 4. When it gets to A, it is sent to router B, even though
it is also destined for F. For some reason (traffic jam along ACE path), A decided to send packet 4
via a different route than that of the first three packets. Router A 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.
If connection-oriented service is used, a path from the source router all the way to the destination router
must be established before any data packets can be sent. This connection is called a VC (virtual
circuit), and the network is called a virtual-circuit network.
When a connection is established, a route from the source machine to the destination machine is chosen
as part of the connection setup and stored in tables inside the routers. That route is used for all traffic
flowing over the connection, exactly the same way that the telephone system works. When the
connection is released, the virtual circuit is also terminated.
Routing Algorithms
The main function of NL (Network Layer) is routing packets from the source machine to the
destination machine. There are two processes inside a router:
a) One of them handles each packet as it arrives, looking up the outgoing line to use for it in the routing
table. This process is forwarding.
b) The other process is responsible for filling in and updating the routing tables. That is where the
routing algorithm comes into play. This process is routing.
Regardless of whether routes are chosen independently for each packet or only when new connections
are established, certain properties are desirable in a routing algorithm:
Correctness, Simplicity, Robustness, Stability, Fairness, Optimality.
Non-Adaptive Algorithm
Non-adaptive algorithms do not base their routing decisions on measurements or estimates of the current
traffic and topology. Instead, the choice of the route to use to get from I to J is computed in advance,
offline, and downloaded to the routers when the network is booted. This procedure is sometimes
called static routing.
Adaptive Algorithm
Dept. of CSE Page3
Adaptive algorithms, in contrast, change their routing decisions to reflect changes in the topology and
usually the traffic as well. Adaptive algorithms differ in:
1. Where they get their information (e.g., locally, from adjacent routers, or from all routers).
2. When they change the routes (e.g., every ΔT sec, when the load changes, or when the topology
changes).
3. What metric is used for optimization (e.g., distance, number of hops, or estimated transit time). This
procedure is called dynamic routing.
Optimality Principle
Shortest Path Algorithm
Flooding
Distance Vector Routing
Link State Routing
Hierarchical Routing
One can make a general statement about optimal routes without regard to network topology or traffic.
This statement is known as the optimality principle.
It states that if router J is on the optimal path from router I to router K, then the optimal path from J to
K also falls along the same path.
As a direct consequence of the optimality principle, we can see that the set of optimal routes from all
sources to a given destination form a tree rooted at the destination. Such a tree is called a sink
tree.
The goal of all routing algorithms is to discover and use the sink trees for all routers.
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 or link.
To choose a route between a given pair of routers, the algorithm just finds the shortest path between
them on the graph.
1. Start with the local node (router) as the root of the tree.
2. Assign a cost of 0 to this node and make it the first permanent node.
3. Examine each neighbor of the node that was the last permanent node.
4. Assign a cumulative cost to each node and make it tentative.
5. Among the list of tentative nodes, find the node with the smallest cost and make it permanent.
6. If a node can be reached from more than one route, then select the route with the shortest
cumulative cost.
7. Repeat steps 3 to 6 until every node becomes permanent.
When a data packet arrives at a router, it is sent to all the outgoing links except the one it has arrived
on.
For example, let us consider the network in the figure, having six routers that are connected through
transmission lines.
Advantages of Flooding
It is very simple to set up and implement, since a router may know only its neighbors.
It is extremely robust. Even in case of malfunctioning of a large number of 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 criterion in case of broadcast messages.
The shortest path is always chosen by flooding.
Dijkstra’s algorithm can find the shortest path from the source to the destination. In a real
network, how the topology is obtained.
Distance Vector Routing algorithm – Dynamic routing
o Each router maintains a table (vector), giving the best known distance to each destination and the
outgoing line to get there.
o These tables are updated by exchanging information with the neighbors.
o The metric used might be the number of hops, time delay, or the number of queued packets.
o The router is assumed to know the “distance” to each of its neighbors.
Hierarchical Routing
With the increase of network/routers, it is infeasible to have an entry for each router. The hierarchical
routing is required.
Sending a packet to a group of nodes (a subset of the nodes in the network) is called multicasting.
(a) A network.
(b) A spanning tree for the leftmost router.
(c) A multicast tree for group 1.
(d) A multicast tree for group 2.
(c) Congestion is a problem when too many packets are present in the subnet, causing performance
degradation.
(d) Congestion can be brought on by several factors:
When too much traffic is offered, congestion sets in, and performance degrades sharply. The figure
below depicts the onset of congestion.
When the number of packets hosts send into the network is well within its carrying capacity, the
number delivered is proportional to the number sent. If twice as many are sent, twice as many are
delivered.
However, as the offered load approaches the carrying capacity, bursts of traffic occasionally fill up
the buffers inside routers, and some packets are lost. These lost packets consume some of the
capacity, so the number of delivered packets falls below the ideal curve. The network is now
congested.
Congestion control has to do with making sure the network is able to carry the offered traffic. It
is a global issue, involving the behavior of all the hosts and routers.
Flow control, in contrast, relates to the traffic between a particular sender and a particular
receiver. Its job is to make sure that a fast sender cannot continually transmit data faster than
the receiver is able to absorb it.
To see the difference between these two concepts, consider a network made up of 100 Gbps fiber
optic links on which a supercomputer is trying to force-feed a large file to a personal computer
that is capable of handling only 1 Gbps.
Although there is no congestion (the network itself is not in trouble), flow control is needed to force
the supercomputer to stop frequently to give the personal computer a chance to breathe.
At the other extreme, consider a network with 1-Mbps lines and 1000 large computers, half of which
are trying to transfer files at 100 kbps to the other half.
Here, the problem is not that of fast senders overpowering slow receivers, but that the total offered
traffic exceeds what the network can handle.
The reason congestion control and flow control are often confused is that the best way to handle both
problems is to get the host to slow down.
Thus, a host can get a "slow down" message either because the receiver cannot handle the load or
because the network cannot handle it.
Requirements
Techniques for Achieving Good Quality of Service
Integrated Services
Differentiated Services
Label Switching and MPLS
Reliability
Delay
Jitter
Bandwidth
To achieve high reliability, the checksum is used to verify the packet at the destination. If a packet is
damaged in transit, it is not acknowledged and will be retransmitted eventually.
Requirements:
A connection to a remote host is set up by concatenating virtual circuits in all networks it passes by.
Gateways are responsible for converting packet format and maintaining the virtual circuit (VC).
Works best when all networks have the same properties:
o Either all reliable or all unreliable.
Can also be done on the transport layer.
2. Connectionless Internetworking:
Advantages:
Disadvantages:
Connectionless Internetworking:
Advantages:
Disadvantages:
Tunneling
Tunneling is the transmission of data in such a way that the routing nodes in the network are unaware
that the transmission is from a different network.
How It Works?
New in IPv6
Auto-configuration
This replaces the TTL field in the IPv4 header that was originally intended to be used as a time-based
hop limit.
Source Address (16 bytes) – The IPv6 address of the sending node.
Destination Address (16 bytes) – The IPv6 address of the destination node.
The advantage of implementing security at the IP level is that it can be applied without the need for
security-aware implementations of application programs.
Security in IPv6 is implemented through the authentication and encrypted security payload extension
header types, ensuring data integrity and privacy.
Instead of an immediate switch, isolated “islands” of IPv6 will be converted initially, communicating via
tunnels. As the IPv6 islands grow, they will merge into bigger islands. Eventually, all the islands will
merge, and the Internet will be fully converted.