190 likes | 404 Views
Routing. We first need to know what is a route… Come on we all know what is a route!!! A path that leads us to our destination is known as a route. Just think Mac needs to go to his school. If does not know how will he find out the route? He will ask somebody isn't it?
E N D
Routing We first need to know what is a route… Come on we all know what is a route!!! A path that leads us to our destination is known as a route. Just think Mac needs to go to his school. If does not know how will he find out the route? He will ask somebody isn't it? Lets say he has police men to ask at some crossings who know about some of the places near them and other policemen standing at other crossings. The next slide displays such a situation. The arrows indicate the places and policemen, a policeman knows. Lets see how Mac finds out the route to his school!!!
There you are This block I want to go to school R2 Go this way R4 Where is my school I don’t know any one other thanR4 I will send him via R4 Geeeeee…!!!! I am here!!! R6 R2 = 2 stops R3 = 3 stops so I will send him via R2 This way I want to go to school R3 R5 R1
So, we can see that Mac has ultimately found out the route!!! We can also see that a path has been established from Mac’s starting place to his school. Now let us figure out the various components involved in this model. Mac – Analogous to Data Packet Blocks – Analogous to Distinct Networks Police Men – Analogous to routers.
Now we can explain Router – Router is a device that connects different networks and also finds the minimum cost path between them. The fact is that a router never finds out the full path. Doing this is practically not possible. It just redirects the data packet to the next router (also referred to as ‘next hop’) on the shortest path. We will now try to learn how.
What is meant by “shortest path” ? Well, the path from one point to another is logically weighted according to the distance. The weight is called “metric”. Metric is calculated on the basis of a number of factors. For instance – • Number of “Hops” – Number of routers the data will have to pass through. • Time required – The total time delay of the path. • Cost – The path taken may cost some units at every router.
So how do we estimate the metric? To estimate the metric and find out the shortest path on that basis, some standardized algorithms may be used. Before this we must understand a mathematical model representing a network.
V2 E4 E1 E2 V1 V3 E3 V4 E5 Let’s first define a network A network (also called a graph) can be defined by two sets – • A set of nodes (or vertices – machines) V. • A set of connections (Edges or links) E. An edge may be defined by a pair of vertices. Thus for an edge to exist at least two vertices must exist in V. If number of vertices is n then the maximum no. of edges is nC2. Thus the sets E and V may be defined as – V = {V1, V2, V3, V4} E = { (v1,v2), (v1,v3), (v1,v4), (v2,v3), (v3,v4) }
V2 E4 E1 E2 V1 V3 E3 V4 E5 Other definitions Directed Graph (or Digraph) – When the elements of E are ordered pairs then we call the graph a directed graph. This means, that while traversing through the edge, we can take only a fixed direction, as implied by arrows. Thus the sets E and V may be defined as – V = {V1, V2, V3, V4} E = { (v1,v2), (v3, v1), (v1,v4), (v2,v3), (v4, v3) }
V2 E4 E1 E2 V1 V3 E3 V4 E5 Weighted Graph – This is a kind of graph where the element of E are triples with two vertices and a number representing the weight (cost) of the edge. Thus the sets E and V may be defined as – V = {V1, V2, V3, V4} E = { (v1,v2, 2), (v3, v1, 5), (v1,v4, 1), (v2,v3, 4), (v4, v3, 2) } V2 E4, 4 E1, 2 E2, 5 V1 V3 V4 E3, 1 E5, 2 Path – This is a part of the graph connecting two distinct vertices and has no loops. More fundoo – It consists of subsets of V and E where each element of V is associated with some E. The highlighted part is a path from V2 to V4
The highlighted portion is a tree Tree – This is a graph or sub-graph where there exists maximum one path between two nodes. This simply means that there is no loop in the graph. V2 E4, 4 E1, 2 E2, 5 V1 V3 V4 E3, 1 E5, 2 Spanning Tree – A tree that covers all the vertices of the graph or network is called a spanning tree. V2 E4 The highlighted part is a spanning tree E1 E2 V1 V3 E3 V4 E5
Algorithms to find the shortest path between two nodes.Dijkstra’s Algorithm The algorithm works as follows: 1. Label the start vertex's final value as 0 (as it is the origin), and label it 1. 2. Update the working values (if they have no working value yet, or if the new working value is lower) of all the vertices that can be reached directly from the last vertex labelled. 3. Choose the unlabelled vertex with the smallest working value, and record its working value as its final value and record its order of labellling. 4. Repeat steps 2 and 3 until the destination vertex is labelled. The working value for the destination vertex is its best working value. The shortest route can now be found by tracking back: If vertex a lies on the route, then vertex b is the previous vertex if the label at a - label at b =weight of edge ab
Example of using Dijkstra's algorithm to get from A to C: This is the graph given Step 1 – Label the start vertex's final value as 0 (as it is the origin), and label it 1.
Step 2 – Update the working values of B,E and D. Step 3 – Choose the vertex with the lowest working value (B), and record its working value as its final value and the order in which it was labelled
Step 4 Update all working values 5 Label the smallest working value vertex with no label (E),final value=working value.
Step 6 – Update working values (no change) Step 7 – Choose smallest working value (D), label. Step 8 – Update working values (No change) Step 9 – Choose and label smallest working value, unlabelled, vertex. It is C, so C's final working value is To find the path: 7-5=2 and 7-1=6 so the path can either be ADC or ABC (it doesn't matter which we choose).
There are a number of similar algorithms for finding the shortest path. There is another called Floyd’s Algorithm in which we use a matrix formation to find out the shortest paths, but right now let us concentrate on basics. So how does the router take advantage of these algorithms? The routers actually communicate with their neighbours to create a table called routing table This is how a routing table looks like. Destination Gateway Flags Ref Use Interface 127.0.0.1 127.0.0.1 UH 1 298 lo0 default 172.16.12.1 UG 2 50360 172.16.12.0 172.16.12.2 U 40 111379 le0 172.16.2.0 172.16.12.3 UG 4 1179 172.16.1.0 172.16.12.3 UG 10 1113 172.16.3.0 172.16.12.3 UG 2 1379 172.16.4.0 172.16.12.3 UG 4 1119
If we look at the above table closely, we will find that it has the next hop information. For instance if some packet is destined for the network 172.16.12.0 then it will be sent to the gateway 172.16.12.2 . The rest of the headache is to be taken by the later. A question may be asked over here that “how was this routing table generated?”. The routers have communicated the costs of connecting to their neighbours to all the other routers. Then the routers have used some or other “shortest path algorithms” to determine the routing table for itself. This communication may be done only once (The first time they are connected – Static Routing), Periodically (At fixed time intervals - Dynamic) or in Triggered manner (Whenever there is some change in the network – new router is added or an existing one is removed etc. - Triggered). Table updating can also be done manually in some routers. However in a vast network like the internet, we would like automatic configurations.
Are there any standard methods for communication between routers? Yes, of course there are!!! The simplest method is Flooding – A router sends a copy of it’s table to its neighbours. These neighbours update the table accordingly and send it to their neighbours and this way, all the routers in the network share their data. However this leads in congestion in the network and leads to multiple copies of the same data reaching on place. To avoid this problem, occurring on a periodic basis, triggered updating schemes are used. Moreover time stamps are attached with these packets so that old or already received packets can be rejected.
There are many protocols that define rules for the communication between routers. E.g. RIP, BGP etc. Two important definitions - • Routing Protocols – The protocols that govern how the routing should be managed • Routed Protocols – The protocols that govern the data flow.