159.334 Computer Networks159.334 Computer Networks
Network Layer – Routing Devices andShortest Path Algorithms for Routing
Professor Richard Harris
School of Engineering and AdvancedTechnology (SEAT)
Computer NetworksComputer Networks -- 1/1/22
159.334 Computer Networks159.334 Computer Networks
Presentation Outline
Networking Devices
Dijkstra’s AlgorithmBackground
Summary of the method
Example
Bellman – Ford AlgorithmExample
Floyd’s AlgorithmExample
Dantzig’s AlgorithmExample
Computer NetworksComputer Networks -- 1/1/33
159.334 Computer Networks159.334 Computer Networks
Objectives
You will be able to describe the various network devices including:
Hubs and repeaters
Bridges
Routers
Gateways
For the various shortest route algorithms, you will be able to:
Perform the Dijkstra algorithm for a sample communication network.
Perform a trace-back of the shortest path after applying the algorithm.
Determine the shortest route tree structure.
Develop an appreciation of the requirements for a shortest pathalgorithm.
Be able to apply the Bellman-Ford algorithm to a simple network.
Digital Networks 216.381 Computer NetworksComputer Networks -- 1/1/44
159.334 Computer Networks159.334 Computer Networks
Objectives
From this lecture you will be able to:Perform the Dijkstra algorithm for a sample communicationnetwork.
Perform a trace-back of the shortest path after applying thealgorithm.
Determine the shortest route tree structure.
Develop an appreciation of the requirements for a shortest pathalgorithm.
Be able to apply the Bellman-Ford algorithm to a simple network.
Computer NetworksComputer Networks -- 1/1/55
159.334 Computer Networks159.334 Computer Networks
Routing Devices
In a network, various network devices are used to routedata to various points in a network.
These network devices follow a hierarchical approach insupporting the network as shown below:
Computer NetworksComputer Networks -- 1/1/66
159.334 Computer Networks159.334 Computer Networks
Repeaters
Repeaters regenerate signals in a network. They are designed for use inlocal area networks (LANs). Repeaters are Layer 1 devices; they do notinterpret any part of the data and are not capable of examining any of theaddresses in a protocol header.
Repeaters receive the signal either in electrical or optical form andregenerate the entire signal based on the results of an algorithm.
An example of a repeater is a network hub.
Computer NetworksComputer Networks -- 1/1/77
159.334 Computer Networks159.334 Computer Networks
Function of a Repeater
Computer NetworksComputer Networks -- 1/1/88
159.334 Computer Networks159.334 Computer Networks
Bridges - 1
A bridge is designed for use between LANs to join two different networksegments. It does NOT join two different networks (e.g., Token Ring andEthernet) together.
Large networks with many nodes should be divided into smaller networksegments with fewer nodes to prevent traffic congestion. Then, a bridge isused to interconnect these smaller network segments together.
Computer NetworksComputer Networks -- 1/1/99
159.334 Computer Networks159.334 Computer Networks
Bridges - 2
The functions of the bridge are:Read all frames transmitted on LAN1 and accept thoseaddressed to any station on LAN2.
Using the medium access control protocol (MAC) for LAN2,retransmit each frame on LAN2.
Do the same for LAN2-to-LAN1 traffic.
The bridge makes no modification to the content or format of theframes it receives, nor does it encapsulate them with anadditional header.
The bridge should contain enough buffer space to meet peakdemands because frames may arrive faster than they can beretransmitted.
The bridge must contain addressing and routing intelligence.
A bridge may connect more than two LANs.
Computer NetworksComputer Networks -- 1/1/1010
159.334 Computer Networks159.334 Computer Networks
Learning Bridge
Computer NetworksComputer Networks -- 1/1/1111
159.334 Computer Networks159.334 Computer Networks
Bridges - BRouters
In today’s complex communication industry, bridgesoften provide additional functionality, making it difficultto draw the line between routers, bridges, repeaters.
A BRouter is one such device. It is a bridge and routerall in one.
Computer NetworksComputer Networks -- 1/1/1212
159.334 Computer Networks159.334 Computer Networks
Routers - 1
Routing is the process of choosing a path over which tosend packets. For TCP/IP, routing occurs when a hostsends IP packets, and occurs again at an IP router.
A router is a device (or software in a computer) thatdetermines the next network point to which a packetshould be forwarded to its destination.
A routing decision has to be made by consulting arouting table.
Computer NetworksComputer Networks -- 1/1/1313
159.334 Computer Networks159.334 Computer Networks
Routers - 2
131.170.16.0 131.170.16.3Default 131.170.16.1
Routing Table
131.170.8.0 131.170.8.1131.170.16.0 131.170.16.1131.170.24.0 131.170.24.1
Routing Table
131.170.16.3 131.170.16.1
131.170.16.0
131.170.24.1
131.170.24.0
131.170.8.1
131.170.8.0
Router
Computer NetworksComputer Networks -- 1/1/1414
159.334 Computer Networks159.334 Computer Networks
Routers - 3
A routing table contains entries with the IP addresses ofrouter interfaces to other networks that it cancommunicate with.
Example of a routing decision:When a host attempts communication with another host, IP firstdetermines whether the destination host is local or on a remotenetwork.
If the destination host is remote, IP then checks the routing tablefor a route to the remote host or remote network.
If no explicit route is found, IP uses its default gateway addressto deliver the packet to a router.
Computer NetworksComputer Networks -- 1/1/1515
159.334 Computer Networks159.334 Computer Networks
Routers - 4
At the router, the routing table is again consulted for a path tothe remote host or network. If a path is not found, the packet issent to the router’s default gateway address.
As each route is found, the packet is sent to the next router,called a “hop”, and finally delivered to the destination host. If aroute is not found, an error message is sent to the source host.
Computer NetworksComputer Networks -- 1/1/1616
159.334 Computer Networks159.334 Computer Networks
A Routing Example
Computer NetworksComputer Networks -- 1/1/1717
159.334 Computer Networks159.334 Computer Networks
Static Routing & Dynamic Routing - 1
Routing information is obtained in the two followingways:
Static routing
Dynamic routing
Static routing: This is a function of IP and it requiresrouting tables to be manually built and manuallyupdated. Because the routing tables are static; staticrouters do not inform each other in the event of a routechange, nor do they exchange routing information withdynamic routers.
Computer NetworksComputer Networks -- 1/1/1818
159.334 Computer Networks159.334 Computer Networks
Static Routing & Dynamic Routing - 2
Dynamic Routing: This is a function of routing protocolssuch as Routing Information Protocol (RIP), OpenShortest Path First (OSPF), Border Gateway Protocol(BGP4), Exterior Gateway Protocol (EGP) or InteriorGateway Protocol (IGP).
Dynamic routing protocols exchange routing informationperiodically or when a route change occurs.
Computer NetworksComputer Networks -- 1/1/1919
159.334 Computer Networks159.334 Computer Networks
Gateways - 1
A gateway is the network point to the entrance ofanother network.
Typically a gateway is used for protocol conversion.Examples include:
Protocol conversion between Token Ring and Ethernet.
Enabling a personal computer (PC) to communicate with amainframe computer.
Enabling different e-mail systems to communicate with eachother.
Gateways operate at many different layers depending onthe functionality required.
Computer NetworksComputer Networks -- 1/1/2020
159.334 Computer Networks159.334 Computer Networks
Gateways - 2
Today, it is rather confusing because routers can alsoprovide gateway functionality.
GATEWAY
Ethernet Network Token Ring Network
Computer NetworksComputer Networks -- 1/1/2121
159.334 Computer Networks159.334 Computer Networks
Network Interface Cards (NIC)
Also known as a network adapter or network card, it isthe device that is installed into a computer, which in turnallows the computer to be connected to a network.
The NIC is protocol-specific and has a unique machineaddress ‘burned’ into it. Theoretically, computers indifferent networks can have identical machineaddresses because there is also a network address toseparate the two nodes.
Computer NetworksComputer Networks -- 1/1/2222
159.334 Computer Networks159.334 Computer Networks
Other Network Routing Devices
These include:Modems
Cable modems
xDSL modems
ISDN routers
ATM switches
159.334 Computer Networks159.334 Computer Networks
Routing Algorithms
Dijkstra and Bellman-Ford
Computer NetworksComputer Networks -- 1/1/2424
159.334 Computer Networks159.334 Computer Networks
Dijkstra's Algorithm Background
The algorithm proceeds by assigning to all nodes a label whichis either temporary or permanent. A temporary label representsan upper bound on the shortest distance from the home node tothat node; while a permanent label is the actual shortest distancefrom the home node to that node.
We also record information about predecessor nodes so that wemay find our way along the path from the home node to the finalnode of the network.
The paths traced out by the shortest route algorithm forms whatis known as a tree structure and this is a very important conceptin communications and transportation theory.
Computer NetworksComputer Networks -- 1/1/2525
159.334 Computer Networks159.334 Computer Networks
Dijkstra's Algorithm Summary
Initial step:Initialise by assigning a permanent label of zero to the home node (source). Allother node labels are declared to be temporary and are equal to the directdistance from the source node to that node. Select the minimum of thesetemporary labels and declare it permanent. In the event of a tie, choose themarbitrarily.
Step 1:Suppose that node K has been assigned a permanent label most recently. Nowconsider the remaining nodes with temporary labels. Compare, one at a time,the temporary label of each node to the sum of the permanent label of node Kand the direct distance from node K to the node under consideration. Assign theminimum of these distances as the new temporary label for that node. (If the oldtemporary label is still minimal, then it will remain unchanged during this step.)
Step 2:Select the minimum of all of the temporary labels and declare it permanent. Inthe case of ties, select just one of them and declare it permanent. If this happensto the destination node, then terminate. Otherwise go to step 1.
Computer NetworksComputer Networks -- 1/1/2626
159.334 Computer Networks159.334 Computer Networks
Shortest Path: Example - 1
1
43
4
3
3
2
Problem: Find the shortest route from node 1to each of the other nodes.
Problem: Find the shortest route from node 1to each of the other nodes.
1
3
2 4
5
Computer NetworksComputer Networks -- 1/1/2727
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 2
Step 1:Label node 1 with (0*,-) and declare it to be permanently labelled - Iuse a (*). Label the other nodes with upper bounds of ( ,-) anddeclare them to be temporary labels.
1
43
4
3
3
2
1
3
2 4
5
( , ) ( , )
( , )
( , )
( , )*0
Computer NetworksComputer Networks -- 1/1/2828
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 3
Step 2:Since i=1 was the most recent node to have been permanentlylabelled, we now consider the nodes which can be reachedfrom it, namely, nodes 2 and 3. We consider
Node 2: min( , 0+1) = 1
Node 3: min( , 0+4) = 4
1
43
4
3
3
2
1
3
2 4
5
( , ) ( , )
( , )
( , )
( , )*0
Computer NetworksComputer Networks -- 1/1/2929
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 4
The smallest temporary label is on node 2, so we nowlabel it permanently (1*, 1).
What is the meaning of the second field?
It means the node which determined the minimum value- or predecessor node.
1
43
4
3
3
2
1
3
2 4
5
( ,-)
(4,1)
( ,-)
(0,-)
(1,1)
Computer NetworksComputer Networks -- 1/1/3030
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 5
Step 4:
Now, there are still nodes left in the network with temporary labels, so we continuethe process. The most recently assigned permanent label is node 2, so we examinelinks leaving this node as before:
Node 3: Min(4, 1+3) = 4 (tie)
Node 4: Min( ,1+2) = 3
Node 5: Min(, 1+4) = 5
In each case, the predecessor node is node 2 – but we shall leave node 3 alone in thiscase.
1
43
4
3
3
2
1
3
2 4
5
( ,-)
(4,1)
( ,-)
(0,-)
(1,1)
Computer NetworksComputer Networks -- 1/1/3131
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 6
Step 5:
Now the smallest temporary label is on node 4, so this becomespermanently labelled (3*, 2).
Since nodes 3 and 5 are still temporarily labelled we must continue theprocedure.
Consider node 4, only node 5 can be reached so we check:
min(5, 3+3) = 5 so the distance remains unchanged.
The minimum temporarily labelled node is node 3 so this now becomespermanently labelled.
1
43
4
3
3
2
1
3
2 4
5
(3 ,2)
(4,1)
(0,-)
(1,1)
(5 ,2)
Computer NetworksComputer Networks -- 1/1/3232
159.334 Computer Networks159.334 Computer Networks
Shortest Path Example - 7
From node 3, only node 5 can be reached so wecheck this: min(5, 4+3) = 5 (no change to the label)
The only temporary label remaining is that for node 5so we label it permanently, and now the algorithm iscomplete.
1
43
4
3
3
2
1
3
2 4
5
(3 ,2)
(4,1)
(0,-)
(1,1)
(5 ,2)
Computer NetworksComputer Networks -- 1/1/3333
159.334 Computer Networks159.334 Computer Networks
The Shortest Route Tree"
We now have the shortest route between the given home node(node 1) and the destination node (node 5). We can determine theroute to be used by making use of the predecessor nodeinformation stored with the labels. The route is identified usingthe red arrows.
1
43
4
3
3
2
1
3
2 4
5
(3 ,2)
(4,1)
(0,-)
(1,1)
(5 ,2)
Computer NetworksComputer Networks -- 1/1/3434
159.334 Computer Networks159.334 Computer Networks
Application of Dijkstra's Algorithm -Another Example
Consider the following directed network:
2
10 3
2
3
2
44
3
3
2
1
You give it a try now!
3
2
1
4
5
6
8
7
9
Computer NetworksComputer Networks -- 1/1/3535
159.334 Computer Networks159.334 Computer Networks
Application of Dijkstra's Algorithm -Solution
2
10 3
2
3
2
44
3
32
1
1
3
2
6
4
5
8
7
9
The tree is, once again, given in red arrows.
Computer NetworksComputer Networks -- 1/1/3636
159.334 Computer Networks159.334 Computer Networks
Comments
You have seen how to apply the method when you haveall the information at your finger tips.
You will be shown how to develop this method and othershortest path methods for determining the shortest pathusing a distributed approach - ie you need to discoverthe information required for the computation of theshortest route tree.
Computer NetworksComputer Networks -- 1/1/3737
159.334 Computer Networks159.334 Computer Networks
Bellman-Ford Algorithm
Initialise d and p:For each node j
dj =
pj = 0
Set source distance ds = 0
Repeat the following process |N|-1 times:For each link (i,j) in G, perform relax process, where
Relax:
– If( dj > di +wij) then
• dj = di + wij
• pj = i
(Where wij is the distance between i and j)
These are initial estimates of the distance
These are initial predecessor nodes - null
Computer NetworksComputer Networks -- 1/1/3838
159.334 Computer Networks159.334 Computer Networks
Shortest Path: Example – 1 (Again!)
1
43
4
3
3
2
Problem: Find the shortest route from node 1to each of the other nodes.
Problem: Find the shortest route from node 1to each of the other nodes.
1
3
2 4
5
d1 =
d2 =
d3 =
d4 =
d5 =
Computer NetworksComputer Networks -- 1/1/3939
159.334 Computer Networks159.334 Computer Networks
First Pass
Link 1 – 2: d2 > d1 + 1 d2 = 0 + 1 = 1 ; p2 = 1
Link 1 – 3: d3 > d1 + 4 d3 = 0 + 4 = 4 ; p3 = 1
Link 2 – 3: d3 > d2 + 3 X d3 = unchanged ; p2 = 1
Link 2 – 4: d4 > d2 + 2 d4 = 1 + 2 = 3 ; p4 = 2
Link 2 – 5: d5 > d2 + 4 d5 = 1 + 4 = 5 ; p5 = 2
Link 3 – 5: d5 > d3 + 3 X d5 = unchanged ; p5 = 2
Link 4 – 5: d5 > d4 + 3 X d5 = unchanged ; p5 = 2
SummarySummary:d1 = 0; p1 = 0
d2 = 1; p2 = 1
d3 = 4; p3 = 1
d4 = 3; p4 = 1
d5 = 5; p5 = 2
Computer NetworksComputer Networks -- 1/1/4040
159.334 Computer Networks159.334 Computer Networks
Output from 1st and 2nd passes
Computer NetworksComputer Networks -- 1/1/4141
159.334 Computer Networks159.334 Computer Networks
Output from final passes and solution
Computer NetworksComputer Networks -- 1/1/4242
159.334 Computer Networks159.334 Computer Networks
Labelling after Pass #1
1
43
4
3
3
2
1
3
2 4
5
d1 = 0; p1 = 0
d2 = 1; p2 = 1 d4 = 3; p4 = 2
d3 = 4; p3 = 1 d5 = 5; p5 = 2