Routing
Routing
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 I want to
are go to
This block
R2 school
R4 Go this
way
Where
I don’t know
is my any one
school other than
Geeeeee…! R4 I will
send him via
!!! R4
I am here!!!
R6
R2 = 2 stops
R3 = 3 stops
so I will This I want to
send him via way go to
R2
R3 school
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
V1
E2, 5
V3 V = {V1, V2, V3, V4}
E = { (v1,v2, 2), (v3, v1, 5),
E3, 1
V4 E5, 2
(v1,v4, 1), (v2,v3, 4),
(v4, v3, 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.
V2 E4 The highlighted part is a path from
E1
V2 to V4
E2
V1 V3
E3 V4 E5
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.
E2, 5
V1 V3
E3, 1
V4 E5, 2
Spanning Tree – A tree that covers all the vertices of the graph or network is
called a spanning tree.
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:
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.
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).