CN WK 11 Lec 21 22
CN WK 11 Lec 21 22
CN WK 11 Lec 21 22
Recommended Reading:
We are studying topic of routing in the computer networks. In last lecture, we have
learned distance vector routing algorithm. In this lecture, we will study link state routing
algorithm, which is yet another famous routing algorithm but with a completely different
approach than distance vector. The outline for this lecture is as follows:
CN-WK-11-Lec-21-22 Page 1 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
In a decentralized routing algorithm, the calculation of the least-cost path is carried out
in an iterative, distributed manner. No node has complete information about the costs
of all network links. Instead, each node begins with only the knowledge of the costs of
its own directly attached links. Then, through an iterative process of calculation and
exchange of information with its neighboring nodes (that is, nodes that are at the other
end of links to which it itself is attached), a node gradually calculates the least-cost
path to a destination or set of destinations. The decentralized routing algorithm we’ll
study is called a distance-vector (DV) algorithm, because each node maintains a
vector of estimates of the costs (distances) to all other nodes in the network.
Bellman-Ford Equation
Let us say we want to compute least cost path from a source x to a destination y, then
CN-WK-11-Lec-21-22 Page 2 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
• The second part is dv(y) which means that least cost path from neighbor v to
destination y.
• By adding first and second part (cost of reaching neighbor and then cost of
reaching destination from neighbor), we get total cost from source x to
destination y via neighbor v.
• Since there could be more than one neighbor of a source, this computation is
performed for all neighbors.
• We will get total cost via each neighbor and finally a minimum cost neighbor will
be selected as a next hop in order to reach destination y.
Example
Let us take u as source and z as destination from figure 4.27. There are three
neighbors of u (v, w and x).
c(u,x) + dx(z),
c(u,w) + dw(z)
1 +3,
5 +3
CN-WK-11-Lec-21-22 Page 3 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
du(z) = 4
If node x’s distance vector has changed as a result of this update step, node x will then
send its updated distance vector to each of its neighbors, which can in turn update
their own distance vectors. It is important to remember that distance vector information
is shared only with neighbors (directly connected nodes) in this algorithm.
Furthermore, a node x updates its distance-vector estimate when it either sees a cost
CN-WK-11-Lec-21-22 Page 4 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
change in one of its directly attached links or receives a distance vector update from
some neighbor.
Example Scenario
Cost is 1 for each edge i.e., least cost path = shortest path (with fewest hops)
Distance vector routing algorithm is running on each node in this network.
The routing information is used to add forwarding table entries at each node.
Distance vector routing algorithm at node A:
CN-WK-11-Lec-21-22 Page 5 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Similarly, forwarding table can be shown for other nodes (B, C, D, E, F and G) in this
network.
Let us take another example by considering forwarding table at node G
CN-WK-11-Lec-21-22 Page 6 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
A 2 F
B ∞ -
C 2 D
D 1 D
E ∞ -
F 1 F
As you can notice that the process of receiving updated distance vectors from
neighbors, recomputing routing table entries, and informing neighbors of changed
costs of the least-cost path to a destination continues until no update messages are
sent. At this point, since no update messages are sent, no further routing table
calculations will occur and the algorithm will enter into a rest state and wait until a link
cost changes.
CN-WK-11-Lec-21-22 Page 7 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
But how long node G will take to detect this failure and update its forwarding table
accordingly. This process will take some time and steps are explained below
• First of all, node A will detect (A-B) link failure and set cost ∞ for destination
B (before link failure cost from A to B was 1)
• A will send this DV update to its neighbors, so F will receive this update and
also set cost ∞ for destination B
• Similarly in next iteration, G will get this DV update from F and set cost ∞ for
destination B
• Later G will get a DV update from D that B is reachable at cost of 2
• Using Bellman-Ford G will recompute its cost towards B which is (1+2) = 3
• G will update its forwarding table entry for destination B (i.e., cost 3, next hop
D)
As we notice that distance vector algorithm relies on the neighbor’s information in order to
reach a destination. First, a neighbor learns how to reach a destination and then it is shared
with others. This step by step (Iterative) learning takes a lot of time and results in slow route
CN-WK-11-Lec-21-22 Page 8 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
propagation which causes problems such as count to infinity. In next lecture, we will see
another routing algorithm (i.e., link state routing) where routing messages are propagated
quickly.
Recall from previous lecture that link-state algorithm is an example of global routing
algorithm. It means that network topology and all link/edge costs are known, that is,
available as input to the LS algorithm. The link state algorithm executes on each node
and every node knows the cost of all edges in that network. On a node, these link
costs are provided as an input to the route calculation algorithm. Then job of the
algorithm is to compute least cost path from that source node to all available
destinations in that network. In this regard, the algorithm which is used for route
calculation is known as Dijkstra’s algorithm, named after its inventor, but indeed it is a
link-state routing algorithm.
Example
CN-WK-11-Lec-21-22 Page 9 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Dijkstra’s algorithm
Dijkstra’s algorithm computes the least-cost path from one node (the source, which
we will refer to as u) to all other nodes in the network (destinations, which we will refer
to as v). Dijkstra’s algorithm is iterative and has the property that after the kth iteration
CN-WK-11-Lec-21-22 Page 10 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
of the algorithm, the least-cost paths are known to k destination nodes. Let us explain
how the Dijkstra’s algorithm works in order to compute least cost path:
1 From a source node u, algorithm starts computing costs of neighbor nodes as
a first step.
2 Cost is set to infinity for those destinations which are not neighbors.
3 As a next step, a least cost neighbor is selected and costs are recomputed via
that neighbor.
4 If a newly computed cost is smaller than earlier computed cost, then new cost
will replace earlier cost.
5 If earlier computed cost is smaller than the new cost, it will not be changed.
6 The algorithm will continue iteratively in the same fashion (step 3-5), until least
cost paths are computed for all destinations.
Let us define the following notation and explain the algorithm with the help of an
example:
• D(v): Cost of the least-cost path from the source node to destination v as of this
iteration of the algorithm.
• p(v): Previous node (neighbor of destination v) along the current least-cost path
from the source to v. As an example, let’s consider the network in Figure 4.27
and compute the least-cost paths from u to all possible destinations. A tabular
summary of the algorithm’s computation is shown in Table below.
• In the initialization step, the currently known least-cost paths from u to its
directly attached neighbors, v, x, and w, are initialized to 2, 1, and 5,
respectively. Note in particular that the cost to w is set to 5 (even though we will
soon see that a lesser-cost path does indeed exist) since this is the cost of the
direct (one hop) link from u to w. The costs to y and z are set to infinity because
they are not directly connected to u.
• In the first iteration, we look among those nodes and find that node with the
least cost as of the end of the previous iteration. That node is x, with a cost of
1, and thus paths are recomputed via x. The results are shown in the second
line (Step 1) in Table. The cost of the path to v is unchanged, since earlier
computed cost to reach v is 2 whereas it is 3 via x. The cost of the path to w
(which was 5 at the end of the initialization) through node x is found to have a
cost of 4. Hence this lower-cost path is selected and w’s predecessor along the
CN-WK-11-Lec-21-22 Page 11 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
• In the second iteration, nodes v and y are found to have the least-cost paths
(2), and we break the tie arbitrarily and select y for this iteration. The cost to the
nodes w and z, are updated, yielding the results shown in the third row in the
Table.
• And so on. . ..
When the LS algorithm terminates, we have, for each node, its predecessor along the
least-cost path from the source node. For each predecessor, we also have its
CN-WK-11-Lec-21-22 Page 12 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
predecessor, and so in this manner we can construct the entire path from the source
to all destinations. The forwarding table in a node, say node u, can then be constructed
from this information. Figure 4.28 shows the resulting least-cost paths and forwarding
table in u for the example network
CN-WK-11-Lec-21-22 Page 13 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Recommended Reading:
Transport Layer
In this lecture we are going to start a new chapter on transport layer. We will cover
following topics in this lecture:
CN-WK-11-Lec-21-22 Page 14 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
CN-WK-11-Lec-21-22 Page 15 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
CN-WK-11-Lec-21-22 Page 16 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Congestion Control
TCP also provides congestion control. Congestion means dropping packets on routers
due to excessive amount of traffic. Congestion control is not so much a service
provided to the application as it is a service for the Internet as a whole. TCP congestion
control prevents any one TCP connection from overloading the links and routers
between communicating hosts with an excessive amount of traffic. TCP tries to give
each connection traversing a link with an equal share of the link bandwidth. This is
done by regulating the rate at which the sending sides of TCP connections can send
traffic into the network. UDP traffic, on the other hand, is unregulated. An application
using UDP transport can send traffic at any rate.
In this chapter, we will explain how these aforementioned services are provided by
transport layer protocols. We will start our discussion with the most basic service of
Multiplexing and Demultiplexing.
CN-WK-11-Lec-21-22 Page 17 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Demultiplexing
Now let’s consider how a receiving host directs an incoming transport-layer segment
to the appropriate socket. Each transport-layer segment has a set of header fields in
for this purpose. At the receiving end, the transport layer examines these fields to
identify the receiving socket and then directs the segment to that socket. This job of
delivering the data in a transport-layer segment to the correct socket is called
demultiplexing.
Multiplexing
The job of gathering data chunks at the source host from different sockets,
encapsulating each data chunk with header information (that will later be used
in demultiplexing) to create segments, and passing the segments to the network
layer is called multiplexing.
CN-WK-11-Lec-21-22 Page 18 of 19
Computer Networks (CS-577)
Mr. Ali bin Tahir Email: ali@biit.edu.pk
Note that the transport layer in the middle host in Figure 3.2 must demultiplex
segments arriving from the network layer below to either process P1 or P2 above; this
is done by directing the arriving segment’s data to the corresponding process’s socket.
The transport layer in the middle host must also gather outgoing data from these
sockets, form transport-layer segments, and pass these segments down to the
network layer.
Source and Destination port number
Now that we understand the roles of transport-layer multiplexing and demultiplexing,
let us examine how it is actually done in a host. From the discussion above, we know
that transport-layer multiplexing requires (1) that sockets have unique identifiers, and
(2) that each segment have special header fields that indicate the socket to which the
segment is to be delivered. These special fields, illustrated in Figure 3.3, are the
source port number field and the destination port number field. (The UDP and TCP
headers have other fields as well, as discussed in the subsequent sections of this
chapter.) Each port number is a 16-bit number, ranging from 0 to 65535
.
Well-known port numbers
The port numbers ranging from 0 to 1023 are called well-known port numbers and are
restricted, which means that they are reserved for use by well-known application
protocols such as HTTP (which uses port number 80) and FTP (which uses port
number 21). The list of well-known port numbers is given in RFC 1700 and is updated
at http://www.iana.org [RFC 3232].
When we develop a new network application, we must assign the application a port
number. It should now be clear how the transport layer could implement the
demultiplexing service: Each socket in the host could be assigned a port number, and
when a segment arrives at the host, the transport layer examines the destination port
number in the segment and directs the segment to the corresponding socket. The
segment’s data then passes through the socket into the attached process.
CN-WK-11-Lec-21-22 Page 19 of 19