M3-Cs306-Computer Networking-Ktustudents - in PDF
M3-Cs306-Computer Networking-Ktustudents - in PDF
CS 306-COMPUTER NETWORKS
Module-III
Network layer – Routing – Shortest path routing, Flooding, Distance Vector Routing, Link
State Routing, RIP, OSPF, Routing for mobile hosts.
• The network layer must know the topology of the subnet and choose appropriate paths
through it.
• When source and destination are in different networks, the network layer (IP) must
deal with these differences.
Design Goals:
• The services provided by the network layer should be independent of the subnet
topology.
• The Transport Layer should be shielded from the number, type and topology of the
KTU •
subnets present.
STUDENTS
The network addresses available to the Transport Layer should use a uniform
numbering plan (even across LANs and WANs).
Hosts send packets into the network; packets are forwarded by routers
1
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
3. Network addresses available to transport layer use uniform numbering plan even
across LANs and WANs
KTU STUDENTS
Implementation of Connectionless Service:
● Datagram
● Virtual Circuit
2
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
Comparison of Virtual-Circuit and Datagram Networks:
3
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU
Routing Algorithms:
STUDENTS
The routing algorithm is that part of the network layer software responsible for deciding
which output line an incoming packet should be transmitted on.
➢ Static Routing
➢ Dynamic Routing
• Optimality principle
• Flooding
• Hierarchical Routing
• Broadcast Routing
• Multicast Routing
4
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
Optimality Principle:
Before we get into specific algorithms, it may be helpful to note that one can make a general
statement about optimal routes without regard to network topology or traffic. This statement
is known as the optimality principle.
As a direct consequence of the optimality principle, we can see that the set of optimal routes
from all sources to a given destination form a tree rooted at the destination. Such a tree is
called a sink tree and is illustrated in Fig. , where the distance metric is the number of hops.
Note that a sink tree is not necessarily unique; other trees with the same path lengths may
exist. The goal of all routing algorithms is to discover and use the sink trees for all routers.
KTU STUDENTS
Figure: (a) A subnet. (b) A sink tree for router
Since a sink tree is indeed a tree, it does not contain any loops, so each packet will be
delivered within a finite and bounded number of hops. In practice, life is not quite this easy.
Links and routers can go down and come back up during operation, so different routers may
have different ideas about the current topology. Also, we have quietly finessed the issue of
whether each router has to individually acquire the information on which to base its sink tree
computation or whether this information is collected by some other means. We will come
back to these issues shortly. Nevertheless, the optimality principle and the sink tree provide a
benchmark against which other routing algorithms can be measured.
5
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
The idea is to build a graph of the subnet, with each node of the graph representing a router
and each arc of the graph representing a communication line (often called a 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(assuming the figure is drawn to scale).
KTU STUDENTS
Figure: The first five steps used in computing the shortest pathfromAtoD. The arrows
indicate the working node.
6
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
Several algorithms for computing the shortest path between two nodes of a graph are known.
This one is due to Dijkstra (1959). Each node is labeled (in parentheses) with its distance
from the source node along the best known path. Initially, no paths are known, so all nodes a
relabeled with infinity. As the algorithm proceeds and paths are found, the labels may change
,reflecting better paths. A label may be either tentative or permanent. Initially, all labels are
tentative. When it is discovered that a label represents the shortest possible path from the
source to that node, it is made permanent and never changed thereafter. To illustrate how the
labeling algorithm works, look at the weighted, undirected graph of Fig.(a), where the
weights represent, for example, distance. We want to find the shortest path from A to D. We
start out by marking node A as permanent, indicated by a filled-in circle. Then we examine,
in turn, each of the nodes adjacent to A(the working node), relabeling each one with the
distance to A. Whenever a node is relabeled, we also label it with the node from which the
probe was made so that we can reconstruct the final path later. Having examined each of the
nodes adjacent to A, we examine all the tentatively labeled nodes in the whole graph and
make the one with the smallest label permanent, as shown in Fig. (b). This one becomes the
new working node. We now start at B and examine all nodes adjacent to it. If the sum of the
KTU STUDENTS
label on Band the distance from B to the node being considered is less than the label on that
node, we have a shorter path, so the node is relabeled.
After all the nodes adjacent to the working node have been inspected and the tentative label s
changed if possible, the entire graph is searched for the tentatively-labeled node with the
smallest value. This node is made permanent and becomes the working node for the next
round. Figure shows the first five steps of the algorithm. To see why the algorithm works,
look at Fig.(c). At that point we have just made E permanent. Suppose that there were a
shorter path than ABE, say AXYZE. There are two possibilities: either node Z has already
been made permanent, or it has not been. If it has, then E has already been probed (on the
round following the one when Z was made permanent), so the AXYZE path has not escaped
our attention and thus cannot be a shorter path. Now consider the case where Z is still
tentatively labeled. Either the label at Z is greater than or equal to that at E, in which case
AXYZE cannot be a shorter path than ABE, or it is less than that of E, in which case Z and not
E will become permanent first, allowing E to be probed from Z
7
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
Flooding:
Flooding, in which every incoming packet is sent out on every outgoing line except the one it
arrived on. Flooding obviously generates vast numbers of duplicate packets, in fact, an
infinite number unless some measures are taken to damp the process. One such measure is to
have a hop counter contained in the header of each packet, which is decremented at each hop,
with the packet being discarded when the counter reaches zero. Ideally, the hop counter
should be initialized to the length of the path from source to destination. If the sender does
not know how long the path is, it can initialize the counter to the worst case, namely, the full
diameter of the subnet
Distance vector routing algorithms operate by having each router maintain a table (i.e, a
vector) giving the best known distance to each destination and which line to use to get there.
8
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
These tables are updated by exchanging information with the neighbors. The distance vector
routing algorithm is sometimes called by other names, most commonly the distributed
Bellman-Ford routing algorithm and the Ford-Fulkerson algorithm, after the researchers
who developed it (Bellman, 1957; and Ford and Fulkerson, 1962). It was the original
ARPANET routing algorithm and was also used in the Internet under the name RIP.
KTU STUDENTS
In distance vector routing, each router maintains a routing table indexed by, and containing
one entry for, each router in the subnet. This entry contains two parts: the preferred outgoing
line to use for that destination and an estimate of the time or distance to that destination. The
metric used might be number of hops, time delay in milliseconds, total number of packets
Part (a) shows a subnet. The first four columnsof part (b) show the delay vectors received
from the neighbors of routerJ .Aclaims to have a12-msec delay toB, a 25-msec delay toC, a
40-msec delay toD, etc. Suppose thatJhasmeasured or estimated its delay to its neighbors,A,I,
H, andKas 8, 10, 12, and 6 msec,respectively.
9
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
Figure:
(a) A subnet. (b) Input from
A
,
I
,
KTU
H
,
K
, and the ne w routing
table for
J
STUDENTS
Consider howJcomputes its new route to routerG. It knows that it can get toAin 8
msec,andAclaims to be able to get toGin 18 msec, soJknows it can count on a delay of 26
msectoGif it forwards packets bound forGtoA. Similarly, it computes the delay toGviaI,H,
andKas 41 (31 + 10), 18 (6 + 12), and 37 (31 + 6) msec, respectively. The best of these
valuesis 18, so it makes an entry in its routing table that the delay toGis 18 msec and that
theroute to use is viaH. The same calculation is performed for all the other destinations, with
thenew routing table shown in the last column of the figure
10
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
Routing table Distribution:
11
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
Final Routing Table:
12
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU
Count-to-InfinityProblem:
STUDENTS
From this figure, it should be clear why bad news travels slowly: no router ever has a value
more than one higher than the minimum of all its neighbors. Gradually, all routers work their
way up to infinity, but the number of exchanges required depends on the numerical value
used for infinity. For this reason, it is wise to set infinity to the longest path plus 1. If the
metric is time delay, there is no well-defined upper bound, so a high value is needed to
prevent a path with a long delay from being treated as down. Not entirely surprisingly, this
problem is known as the count-to-infinity problem.
Variants of link state routing are now widely used.The idea behind link state routing is simple
and can be stated as five parts. Each router must do the following:
13
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
In effect, the complete topology and all delays are experimentally measured and distributed
toevery router. Then Dijkstra's algorithm can be run to find the shortest path to every
otherrouter.
When a router is booted, its first task is to learn who its neighbors are. It accomplishes this
goal by sending a special HELLO packet on each point-to-point line. The router on the other
end is expected to send back a reply telling who it is. These names must be globally unique
because when a distant router later hears that three routers are all connected toF, it is essential
that it can determine whether all three mean the same
KTU STUDENTS
Figure . (a) Nine routers and a LAN. (b) A graph model of (a).
14
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
15
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
Figure (a) A subnet. (b) The link state packets for this subnet
KTU STUDENTS
16
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
The trickiest part of the algorithm is distributing the link state packets reliably. As the packets
are distributed and installed, the routers getting the first ones will change their routes.
Consequently, the different routers may be using different versions of the topology, which
can lead to inconsistencies, loops, unreachable machines, and other problems.
RIP:
● Each router advertises its distance vector every 30 seconds (or whenever its routing
table changes) to all of its neighbors
● Routes are timeout (set to 16) after 3 minutes if they are not updated
KTU
RIP Message format:
STUDENTS
RIP Messages:
17
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
● Request messages
● Response messages
• contains an update
RIP Problems:
● Even for a small network, it takes several minutes until the routing tables have
settled after a change
• RIP has all the problems of distance vector algorithms, e.g., count-to-Infinity
An Example of RIP:
KTU •
STUDENTS
In this example, C’s update to A would indicate that C can reach Networks 2 and 3
with cost 0, Networks 5 and 6 with cost 1 and Network 4 with cost 2.
OSPF:
• OSPF will form neighbor relationships with adjacent routers in the same Area.
18
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
• Instead of advertising the distance to connected networks, OSPF advertises the status of
directly connected links using Link-State Advertisements (LSAs).
• OSPF sends updates (LSAs) when there is a change to one of its links, and will only send
the change in the update. LSAs are additionally refreshed every 30 minutes.
• OSPF traffic is multicast either to address 224.0.0.5 (all OSPF routers) or 224.0.0.6 (all
Designated Routers).
• OSPF uses the Dijkstra Shortest Path First algorithm to determine the shortest path.
• OSPF uses cost as its metric, which is computed based on the bandwidth of the link.
KTU STUDENTS
• A topology table – contains a list of all possible routes to all known networks within an
area.
• A routing table – contains the best route for each known network.
OSPF Neighbors OSPF forms neighbor relationships, called adjacencies, with other routers in
the same Area by exchanging Hello packets to multicast address 224.0.0.5. Only after an
adjacency is formed can routers share routing information. Each OSPF router is identified by
a unique Router ID. The Router ID can be determined in one of three ways:
• If not manually specified, the highest IP address configured on any Loopback interface on
the router will become the Router ID.
• If no loopback interface exists, the highest IP address configured on any Physical interface
will become the Router ID.
Multicast Routing:
Some applications require that widely-separated processes work together in groups, for
example, a group of processes implementing a distributed database system. In these
situations, it is frequently necessary for one process to send a message to all the other
19
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
rmembers of the group. If the group is small, it can just send each other member a
point-to-point message. If the group is large, this strategy is expensive. Sometimes
broadcasting can be used, but using broadcasting to inform 1000 machines on a million-node
network isinefficient because most receivers are not interested in the message (or worse yet,
they aredefinitely interested but are not supposed to see it). Thus, we need a way to send
messages towell-defined groups that are numerically large in size but small compared to the
network as awhole.Sending a message to such a group is calledmulticasting, and its routing
algorithm is calledmulticast routing.
KTU STUDENTS
Figure: (a) A network. (b) A spanning tree for the leftmost router. (c) Amulticast tree for
group 1. (d) A multicast tree for group 2.
20
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU
Routing for Mobile Hosts:
STUDENTS
Hosts that never move are said to be stationary. They are connected to the network by copper
wires or fiber optics. In contrast, we can distinguish two other kinds of hosts. Migratory hosts
are basically stationary hosts who move from one fixed site to another from time to time but
use the network only when they are physically connected to it. Roaming hosts actually
compute on the run and want to maintain their connections as they move around. We will use
the term mobile hoststo mean either of the latter two categories, that is, all hosts that areaway
from home and still want to be connected. All hosts are assumed to have a permanent home
locationthat never changes. Hosts also have a permanent home address that can be used to
determine their home locations, analogous to the way the telephone number 1-212-5551212
indicates the United States(country code 1) and Manhattan (212). The routing goal in systems
with mobile hosts is to make it possible to send packets to mobile hosts using their home
addresses and have the packets efficiently reach them wherever they may be. The trick, of
course, is to find them.
21
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
KTU STUDENTS
Registration Procedure:
3. The foreign agent contacts the mobile host's home agent and says: One of your hosts
isover here. The message from the foreign agent to the home agent contains the
foreignagent's network address. It also includes the security information to convince
the homeagent that the mobile host is really there.
22
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
Module-3
4. The home agent examines the security information, which contains a timestamp,
toprove that it was generated within the past few seconds. If it is happy, it tells
theforeign agent to proceed.
5. When the foreign agent gets the acknowledgement from the home agent, it makes
anentry in its tables and informs the mobile host that it is now registered.
-------------------------------------------------------------------------------------------------------
KTU STUDENTS
23
Dept. of Computer Science and Engineering
For more study materials>www.ktustudents.in
IP Addressing & Subnetting
▪IP Addressing
▪Subnetting
▪VLSM
KTU
CIDR
▪ STUDENTS
KTU STUDENTS
KTU STUDENTS
KTU STUDENTS
KTU STUDENTS
KTU STUDENTS
KTU
Broadcast 15.255 STUDENTS 31.255 255.255
KTU STUDENTS
KTU STUDENTS
KTU
●
◦
STUDENTS
netE: must support 28 host
Determine what mask allows the required number of hosts.
◦ netA: requires a /28 (255.255.255.240) mask to support 14 hosts
◦ netB: requires a /27 (255.255.255.224) mask to support 28 hosts
◦ netC: requires a /30 (255.255.255.252) mask to support 2 hosts
◦ netD: requires a /28 (255.255.255.240) mask to support 7 hosts
◦ netE: requires a /27 (255.255.255.224) mask to support 28 hosts
KTU STUDENTS