CN-UNIT-3 - Network Layer
CN-UNIT-3 - Network Layer
CN-UNIT-3 - Network Layer
Network Layer
B SAI BABA,M.Tech(Ph.D),VIT,Bhimavaram
B. SAI BABA,VIT,BVRM
Syllabus
★ Network Layer:
○ Network layer design issues
★ Routing Algorithms:
○ Optimality Principle
○ Shortest Path Algorithm
○ Flooding
○ Distance Vector
○ Link State Routing
○ Hierarchical Routing
○ Broadcast Routing
○ Multicast Routing
★ Congestion Control Algorithms
B. SAI BABA,VIT,BVRM
★ The Network Layer or Layer 3 of the OSI (Open Systems Interconnection) model is
concerned delivery of data packets from the source to the destination across multiple hops or
links.
5. Routing
6. Congestion Control
B. SAI BABA,VIT,BVRM
switching.
★ The node which has a packet to send, delivers it to the nearest router.
★ The packet is stored in the router until it has fully arrived and its checksum is verified for
error detection.
★ Since, each router needs to store the entire packet before it can forward it to the next hop,
In this service, a path is setup between the source and the destination, and all the
data packets belonging to a message are routed along this path.
2. Connectionless Service :
★ In this context, the packets are frequently called datagrams and the network is
★ 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 using some point-to-point protocol.
★ At this point the ISP takes over. Every router has an internal table telling it where to send
packets for each of the possible destinations.
★ 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.
★ For example, in Fig. 5-2, A has only two outgoing lines—to B and to C—so every incoming
packet must be sent to one of these routers, even if the ultimate destination is to some other
router.
★ A’s initial routing table is shown in the figure under the label ‘‘initially.’’
B. SAI BABA,VIT,BVRM
★ At A, packets 1, 2, and 3 are stored briefly, having arrived on the incoming link and had their
checksums verified. 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. When it gets to F, it is sent within a frame
over the LAN to H2. Packets 2 and 3 follow the same route.
★ 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, A decided to send packet 4 via a different route than that of the first three
packets. Perhaps it has 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.
B. SAI BABA,VIT,BVRM
★ 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.
★ The idea behind virtual circuits is to avoid having to choose a new route for every packet
sent, as in Fig. 5-2.
★ Instead, 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.
★ With connection-oriented service, each packet carries an identifier telling which virtual
circuit it belongs to.
★ As an example, consider the situation shown in Fig. 5-3. Here, host H1 has established
connection 1 with host H2. This connection is remembered as the first entry in each of the
routing tables.
B. SAI BABA,VIT,BVRM
★ 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.
★ It chooses connection identifier 1 (because it is initiating the connection and this is it's only
connection) and tells the network 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 process is called label switching.
B. SAI BABA,VIT,BVRM
Routing Algorithms
B. SAI BABA,VIT,BVRM
Routing Algorithm
★ In order to transfer the packets from source to the destination, the network layer must
determine the best route through which packets can be transmitted.
★ Whether the network layer provides datagram service or virtual circuit service, the main
job of the network layer is to provide the best route. The routing protocol provides this job.
★ The routing protocol is a routing algorithm that provides the best path from the source to the
destination. The best path is the path that has the "least-cost path" from source to the
destination.
★ Routing is the process of forwarding the packets from source to the destination but the best
route to send the packets is determined by the routing algorithm.
B. SAI BABA,VIT,BVRM
Optimality Principle
B. SAI BABA,VIT,BVRM
Introduction :
★ A general statement is made about optimal routes without regard to network topology or
traffic. This statement is known as the optimality principle( Bellman,1975).
Statement of the optimality principle :
★ It states that if the router J is on the optimal path from router I to router K, then the optimal
path from J to K also falls along the same route. Call the route from I to J, r1 and the rest of
the route r2. it could be concatenated with r1 to improve the route from I to K, contradicting
our statement that r1r2 is optimal only if a route better than r2 existed from J to K.
B. SAI BABA,VIT,BVRM
Introduction :
★ A general statement is made about optimal routes without regard to network topology or
traffic. This statement is known as the optimality principle( Bellman,1975).
Explanation:
★ The purpose of a routing algorithm at a router is to decide which output line an incoming
packet should go.
★ The optimal path from a particular router to another may be the least cost path, the least
distance path, the least time path, the least hops path or a combination of any of the above.
Example
Consider a network of routers, {G, H, I, J, K, L, M, N} as shown in the figure. Let the
optimal route from I to K be as shown via the green path, i.e. via the route I-G-J-L-K.
According to the optimality principle, the optimal path from J to K with be along the
same route, i.e. J-L-K.
B. SAI BABA,VIT,BVRM
Now, suppose we find a better route from J to K is found, say along J-M-N-K.
Consequently, we will also need to update the optimal route from I to K as I-GJ- M-N-K,
since the previous route ceases to be optimal in this situation. This new optimal path is
shown line orange lines in the following figure −
B. SAI BABA,VIT,BVRM
★ In this algorithm, the routing decisions are made based on network traffic and topology.
★ The parameters which are used in adaptive routing algorithms are distance, hop,
○ Centralized algorithm
○ Isolation algorithm
○ Distributed algorithm
B. SAI BABA,VIT,BVRM
Centralized algorithm:
★ In centralized routing, one centralized node has the total network information and takes
the routing decisions.
★ It finds the least-cost path between source and destination nodes by using global
knowledge about the network. So, it is also known as global routing algorithm.
★ The advantage of this routing is that only the central node is required to store network
information and so the resource requirement of the other nodes may be less.
★ Eg: Link state routing algorithm
Isolated algorithm:
★ This algorithm procures the routing information by using local information instead of
gathering information from other nodes.
B. SAI BABA,VIT,BVRM
Distributed algorithm:
★ This is a decentralized algorithm where each node receives information from its
neighbouring nodes and takes the decision based upon the received information.
★ The least-cost path between source and destination is computed iteratively in a
distributed manner.
★ An advantage is that each node can dynamically change routing decisions based upon the
changes in the network.
★ Example : distance vector routing algorithm.
B. SAI BABA,VIT,BVRM
★ In a non-adaptive routing algorithm, the routing decisions are not made based on
terms of complexity.
○ Flooding
○ Random walks
B. SAI BABA,VIT,BVRM
Introduction:
★ Dijkstra's algorithm and the Bellman-Ford algorithm are two different algorithms used
It works only for graphs with It works for graphs with both
non-negative edge weights. non-negative and negative edge
weights.
B. SAI BABA,VIT,BVRM
Dijkstra's algorithm:
★ The shortest path algorithm was first introduced by Edsger W. Dijkstra in 1956.
★ This algorithm, commonly known as Dijkstra's algorithm, is used to find the shortest path
between nodes in a graph, particularly in weighted graphs where each edge has a
non-negative weight.
networking, transportation systems, and more, to find the shortest path from a source
● The idea is to build a graph of the network, with each node of the graph representing a
router and each edge 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.
● The concept of a shortest path deserves some explanation.
○ One way of measuring path length is the number of hops. Using this metric, the paths
ABC and ABE in Fig. are equally long.
○ Another metric is the geographic distance in kilometers, in which case ABC is
clearly much longer than ABE
B. SAI BABA,VIT,BVRM
B. SAI BABA,VIT,BVRM
● The first six steps used in computing the shortest path from A to D.
Bellman-Ford algorithm:
The Distance Vector calculation is based on minimizing the cost to each
destination
Dx(y) = Estimate of least cost from x to y
C(x,v) = Node x knows cost to each neighbor v
At Router A :
B. SAI BABA,VIT,BVRM
At Router B:
B. SAI BABA,VIT,BVRM
At Router C:
B. SAI BABA,VIT,BVRM
At Router D:
B. SAI BABA,VIT,BVRM
Router A Router B
Router C Router D
B. SAI BABA,VIT,BVRM
● Cost of reaching destination A from router B = min { 2+0 , 3+5 , 3+1 } = 2 via A.
● Cost of reaching destination C from router B = min { 2+5 , 3+0 , 3+10 } = 3 via C.
● Cost of reaching destination D from router B = min { 2+1 , 3+10 , 3+0 } = 3 via A.
B. SAI BABA,VIT,BVRM
● Cost of reaching destination A from router D = min { 1+0 , 3+2 , 10+5 } = 1 via A.
● Cost of reaching destination B from router D = min { 1+2 , 3+0 , 10+3 } = 3 via A.
● Cost of reaching destination C from router D = min { 1+5 , 3+3 , 10+0 } = 6 via A.
B. SAI BABA,VIT,BVRM
Router A Router B
Router C Router D