0% found this document useful (0 votes)
17 views

3_networking

Computer Networks Notes

Uploaded by

Sameer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

3_networking

Computer Networks Notes

Uploaded by

Sameer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 101

Unit-III

The Network Layer


Design Issues & Routing Algorithms
Unit-III
• Network Layer
• Design issues
• Routing algorithms
• Shortest path routing
• Flooding
• Hierarchical routing
• Broadcast
• Multicast
• Distance vector routing
Unit-III
• Congestion Control Algorithms
• Quality of Service
• Internetworking
• The Network layer in the internet
Network Layer Design Issues

• Store-and-Forward Packet Switching


• Services Provided to the Transport Layer
• Implementation of Connectionless Service
• Implementation of Connection-Oriented Service
• Comparison of Virtual-Circuit and Datagram Subnets
The Network Layer
• The network layer is concerned with
getting packets from the source to the
destination.
• It must also take care to select routes to
avoid overloading some of the
communication lines and routers while
leaving others idle.
Network layer duties
• Internetworking.
• Addressing.
• Routing.
• Packetizing.
• Fragmenting.
Network Layer Design Issues
➢ Store-and-Forward Packet Switching
• A host with a packet to send, transmits it to the
nearest router, either on its own LAN or over a
point-to-point link to the carrier.
• The packet is stored there until it has fully arrived
so the checksum can be verified.
• Then it is forwarded to the next router along the
path until it reaches the destination host, where it
is delivered.
Store-and-Forward Packet Switching

fig 5-1

The environment of the network layer protocols.


Network Layer Design Issues
➢ Services Provided to the Transport Layer
The network layer services have been designed with the
following goals in mind.

• The services should be independent of the router


technology.
• The transport layer should be shielded from the
number, type, and topology of the routers present.
• The network addresses made available to the
transport layer should use a uniform numbering
plan, even across LANs and WANs.
Network Layer Design Issues

➢ Services offered
▪ Connectionless service
• Packets are injected into the subnet individually
and routed independently of each other.
• No advance setup is needed.
• In this context, the packets are frequently called
datagrams.
Implementation of Connectionless Service

Routing within a datagram subnet.


Network Layer Design Issues

➢ Connection-oriented service
• A path from the source router to the destination
router must be established before any data
packets can be sent.
• This connection is called a VC (virtual circuit).
• This service is analogy with the physical
circuits set up by the telephone system .
Implementation of Connection-Oriented
Service

Routing within a virtual-circuit subnet.


Virtual-Circuit and Datagram
➢ Virtual-Circuit
• In this approach the relationship between all
packets belonging to a message or session is
preserved.
• A single route is selected between sender and
receiver at the beginning of the session.
• When the data are sent, all packets of the
transmission travel one after another along
that route.
Features of virtual circuits

• In VC every router has to maintain a


table.
• Each packet must have a virtual
circuit number field in its header in
addition to sequence number,
checksum etc.
• Circuit setup is required.
Datagram
• In this approach each packet is treated
independently.
• The routes from source to destination are not
worked out in advance.
• The datagram subnets have to do more work
but they are more robust and deal with failures
and congestion more easily as compared to
virtual circuits subnets.
Features of Datagrams
• The router do not have to maintain any table.
• Each datagrams must contain full destination
address. These address can be very long.
• When a packet comes in, the router finds an
available outgoing line and sends the packet
out on that line
Comparison of Virtual-Circuit and
Datagram Subnets

5-4
Routing Algorithm
• The routing algorithm is that part of the
network layer software responsible for
deciding which output line an incoming packet
should be transmitted on.

• If the subnet uses datagrams internally, this


decision must be made a new for every
arriving data packet since the best route may
have changed since last time.
Routing Algorithm

• If the subnet uses virtual circuits internally,


routing decisions are made only when a new
virtual circuit is being set up.
• Thereafter, data packets just follow the
previously-established route.
• This is sometimes also called session routing
because a route remains in force for an entire
user session (e.g., a login session at a terminal
or a file transfer).
Types of routing algorithms
➢ Routing algorithms can be grouped into two
major classes.

1. Non-adaptive Routing algorithms.


2. Adaptive Routing algorithms.
Nonadaptive algorithms
• Nonadaptive algorithms do not base their
routing decisions on measurements or
estimates of the current traffic and topology.
• Instead, the choice of the route to use to get
from I to J (for all I and J) is computed in
advance, off-line, and downloaded to the
routers when the network is booted.
• This procedure is sometimes called static
routing.
Adaptive algorithms
• Adaptive algorithms, change their routing decisions
to reflect changes in the topology, and usually the
traffic as well.

• Adaptive algorithms differ in where they get their


information such as when they can change the routes,
and what metric is used for optimization.
Routing Algorithms
• The Optimality Principle
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State Routing
• Hierarchical Routing
• Broadcast Routing
• Multicast Routing
• Routing for Mobile Hosts
• Routing in Ad Hoc Networks
The Optimality Principle
• 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. It states that if router J is on the
optimal path from router I to router K, then
the optimal path from J to K also falls along
the same route.
The Optimality Principle

• To see this, call the part of the route from I to


J, r1 and the rest of the route r2.
• If a route better than r2 exist from J to K, it
could be concatenated with r1 to improve the
route from I to K, contradicting our statement
that r1r2 is optimal.
The Optimality Principle
• According to the optimality principle 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 has been shown
in below figure 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.
The Optimality Principle

(a) A subnet. (b) A sink tree for router B.


The Optimality Principle

• 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.
Shortest Path Routing
• 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 select a route between a given pair of routers,
the algorithm just finds the shortest path between
them on the graph.

30
• One way of measuring path length is the number of
hops. Using this metric, the paths ABC and ABE in
the above figure are equally long.
• Another metric is the geographic distance in
kilometers, in which case ABC is clearly much
longer than ABE
Shortest Path Routing
• However, many other metrics besides hops and
physical distance are also possible.
• In the general case, the labels on the arcs could
be computed as a function of the distance,
bandwidth, average traffic, communication
cost, mean queue length, measured delay, and
other factors.
• By changing the weighting function, the
algorithm would then compute the ''shortest''
path measured according to any one of a
number of criteria or to a combination of
criteria.
Shortest Path Routing
➢ Dijkstra's algorithm
• 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 are
labeled with infinity.
• As the algorithm proceeds and paths are found,
the labels may change, reflecting better paths.
Shortest Path Routing
• 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.
• Permanent node is indicated by a filled-in
circle.
Shortest Path Routing

The first 5 steps used in computing the shortest path from A to D.


The arrows indicate the working node.
Dijkstra’s algorithm
Flooding
• Another static algorithm is 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 control the process.
Flooding
Flooding
Flooding
Flooding
• 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.
Flooding
• An alternative technique for damming the flood is
to keep track of which packets have been flooded.
• To avoid sending them out a second time achieve
this goal is to have the source router put a
sequence number in each packet it receives from
its hosts.
• Each router then needs a list per source router
telling which sequence numbers originating at
that source have already been seen.
• If an incoming packet is on the list, it is not
flooded.
Flooding
• A variation of flooding that is slightly
more practical is selective flooding.
• In this algorithm the routers do not send
every incoming packet out on every line,
only on those lines that are going
approximately in the right direction.
Flooding
• Flooding is not practical in most applications, but it does
have some uses.
• In military applications, where large numbers of routers
may be blown to bits at any instant, the tremendous
robustness of flooding is highly desirable.
• In distributed database applications, it is sometimes
necessary to update all the databases concurrently, in
which case flooding can be useful.
• In wireless networks, all messages transmitted by a
station can be received by all other stations within its
radio range, which is, in fact, flooding, and some
algorithms utilize this property.
Dynamic routing algorithms
• Modern computer networks generally use
dynamic routing algorithms rather than the
static ones, because static algorithms do not
take the current network load into account.

• Two dynamic algorithms in particular,


distance vector routing and link state routing
are the most popular.
Distance Vector Routing
• 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.

• These tables are updated periodically by


exchanging information with the neighbors.
Distance Vector Routing
• 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.
Distance Vector Routing
• 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 queued along the path, or something
similar.
Distance Vector Routing
• The router is assumed to know the ''distance''
to each of its neighbors.
• If the metric is hops, the distance is just one
hop.
• If the metric is queue length, the router simply
examines each queue.
• If the metric is delay, the router can measure it
directly with special ECHO packets that the
receiver just timestamps and sends back as fast
as it can.
Distance Vector Routing
• For example consider that delay is used as a
metric.
• Each router knows the delay to each of its
neighbors.
• Once every T msec each router sends to each
neighbor a list of its estimated delays to each
destination.
• It also receives a similar list from each of its
neighbors.
Distance Vector Routing
• Consider the subnet shown in below figure (a).
• The first four columns in below figure (b)
show the delay vectors received from the
neighbors of router J.
• A claims to have a 12-msec delay to B, a 25-
msec delay to C, a 40-msec delay to D, etc.
• Suppose that J has measured or estimated its
delay to its neighbors, A, I, H, and K as 8, 10,
12, and 6 msec respectively.
Distance Vector Routing

(a) A subnet. (b) Input from A, I, H, K, and the new routing


table for J.
Distance Vector Routing
• Now consider how J computes its new route to
router G.
• It knows that it can get to A in 8 msec, and A
claims to be able to get to G in 18 msec, so J
knows it can count on a delay of 26 msec to G
if it forwards packets bound for G to A.
• Similarly, it computes the delay to G via I, H,
and K as 41 (31 + 10), 18 (6 + 12), and 37 (31
+ 6) msec, respectively.
Distance Vector Routing
• The best of these values is 18, so it makes an
entry in its routing table that the delay to G is
18 msec and that the route to use is via H.
• The same calculation is performed for all the
other destinations, with the new routing table
shown in the last column of the figure (b).
Distance Vector Routing
➢Count-to-infinity Problem
• Consider the five-node linear subnet as shown
in below figure.
• The delay metric is the number of hops.
• Suppose A is down initially and all the other
routers know this.
• In other words, they have all recorded the
delay to A as infinity.
Distance Vector Routing

The count-to-infinity problem.


Distance Vector Routing
• When A comes up, the other routers learn
about it via the vector exchanges.
• At the time of the first exchange, B learns that
its left neighbor has zero delay to A.
• B now makes an entry in its routing table that
A is one hop away to the left.
• All the other routers still think that A is down.
• At this point, the routing table entries for A are
as shown in the second row of figure (a).
Distance Vector Routing
• On the next exchange, C learns that B has a
path of length 1 to A, so it updates its routing
table to indicate a path of length 2.
• But D and E do not hear the good news until
later.
• Clearly, the good news is spreading at the rate
of one hop per exchange.
• In a subnet whose longest path is of length N
hops, within N exchanges everyone will know
about newly-revived lines and routers.
Distance Vector Routing
• Now let us consider the situation of figure (b)
in which all the lines and routers are initially
up.
• Routers B, C, D, and E have distances to A of
1, 2, 3, and 4 respectively.
• Suddenly A goes down, or the line between A
and B is broken which is effectively the same
thing from B's point of view.
Distance Vector Routing

The count-to-infinity problem.


Distance Vector Routing
• At the first packet exchange B does not hear
anything from A.
• Fortunately C says that do not worry i have a
path to A of length 2.
• For all B knows, C might have ten lines all
with separate paths to A of length 2.
• As a result, B thinks it can reach A via C with a
path length of 3.
• D and E do not update their entries for A on the
first exchange.
Distance Vector Routing
• On the second exchange, C notices that each of
its neighbors claims to have a path to A of
length 3.
• It picks one of the them at random and makes
its new distance to A 4, as shown in the third
row of figure(b).
Link State Routing
• Distance vector routing was used in the
ARPANET until 1979.
• Two primary problems caused its demise.
• First, since the delay metric was queue length,
it did not take line bandwidth into account
when choosing routes.
Link State Routing
• The second problem is that the algorithm often
took too long to converge (the count-to-infinity
problem).
• For these reasons, it was replaced by an
entirely new algorithm, now called link state
routing.
• Variants of link state routing are now widely
used.
Link State Routing
• The idea behind link state routing is simple and
can be stated as five parts. Each router must do the
following:
1. Discover its neighbors and learn their network
addresses.
2. Measure the delay or cost to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to all other routers.
5. Compute the shortest path to every other router.
Link State Routing
➢ Learning about the Neighbors
• When a router is booted, its first task is to learn
who are its neighbors.
• 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.
Link State Routing
➢ Measuring Line Cost
• The link state routing algorithm requires each
router to know the reasonable estimate of the
delay to each of its neighbors.
• The most direct way to determine this delay is to
send over the line a special ECHO packet that
the other side is required to send back
immediately.
• By measuring the round-trip time and dividing it
by two, the sending router can get a reasonable
estimate of the delay.
Link State Routing
➢ Building Link State Packets
• Once the information needed for the exchange
has been collected, the next step is for each
router to build a packet containing all the data.
• The packet starts with the identity of the
sender, followed by a sequence number and
age, and a list of neighbors.
• For each neighbor, the delay to that neighbor
is given.
Link State Routing

Figure (a) A subnet. (b) The link state packets


for this subnet.
Link State Routing
• Building the link state packets is easy. The
hard part is determining when to build them.
• One possibility is to build them periodically,
that is, at regular intervals.
• Another possibility is to build them when
some significant event occurs, such as a line
or neighbor going down or coming back up
again or changing its properties appreciably.
Link State Routing
➢ Distributing the Link State Packets
• The fundamental idea is to use flooding to
distribute the link state packets.

• To keep the flood in check, each packet contains a


sequence number that is incremented for each new
packet sent.

• When a new link state packet comes in, it is


checked against the list of packets already seen.
Link State Routing

• If it is new, it is forwarded on all lines except


the one it arrived on. If it is a duplicate, it is
discarded.

• If a packet with a sequence number lower than


the highest one seen so far ever arrives, it is
rejected as being obsolete since the router has
more recent data.
Link State Routing

• The packet buffer for router B


Link State Routing
➢ Computing the New Routes
• Now Dijkstra's algorithm can be run locally
to construct the shortest path to all possible
destinations.

• The results of this algorithm can be installed


in the routing tables, and normal operation
resumed.
Hierarchical Routing
• As networks grow in size, the router routing
tables grow proportionally.
• Not only is router memory consumed by ever-
increasing tables, but more CPU time is
needed to scan them and more bandwidth is
needed to send status reports about them.
• At a certain point the network may grow to the
point where it is no longer feasible for every
router to have an entry for every other router.
Hierarchical Routing
• When hierarchical routing is used, the routers
are divided into regions.
• Each router will know all the details about how
to route packets to destinations within its own
region.
• But they doesn’t know about the internal
structure of other regions.
Hierarchical Routing
• Below figure shows an example of routing in a
two-level hierarchy with five regions.
• The full routing table for router 1A has 17
entries, as shown in figure (b).
• When routing is done hierarchically, as shown
in figure (c), there are entries for all the local
routers as before.
• But all other regions have been condensed into
a single router.
Hierarchical Routing
• Therefore all traffic for region 2 goes via the
1B -2A line.
• But the rest of the remote traffic goes via the
1C -3B line.
• Hierarchical routing has reduced the table from
17 to 7 entries.
• As the ratio of the number of regions to the
number of routers per region grows, the
savings in table space increase.
Hierarchical Routing

Hierarchical routing.
Problems – optimal paths are sacrificed
Hierarchical Routing
• When a single network becomes very large, an
interesting question is: How many levels should
the hierarchy have?
• For example, consider a subnet with 720 routers.
• If there is no hierarchy each router needs 720
routing table entries.
• If the subnet is partitioned into 24 regions of 30
routers each, each router needs 30 local entries
plus 23 remote entries for a total of 53 entries.
Hierarchical Routing
• If a three-level hierarchy is chosen, with eight
clusters, each containing 9 regions of 10
routers, each router needs 10 entries for local
routers, 8 entries for routing to other regions
within its own cluster, and 7 entries for distant
clusters, for a total of 25 entries.
• Kamoun and Kleinrock in 1979 have
discovered that the optimal number of levels
for an N router subnet is ln N.
• It requires a total of e ln N entries per router.
Broadcast Routing
• In some applications, hosts need to send messages
to many or all other hosts.
• Sending a packet to all destinations
simultaneously is called broadcasting.
• For example, a service distributing weather
reports, stock market updates, or live radio
programs might work best by broadcasting to all
machines and letting those that are interested read
the data.
Broadcast Routing
• Various methods are being used for broadcast
routing.
• One of broadcasting method where the source
will create multiple copies of a packet and
send a distinct packet to each destination.
• In this method the source requires to maintain
the complete list of all destinations.
• It is the least desirable of the methods because
the link bandwidth will be wasted.
Broadcast Routing
• Flooding is another method for broadcast
routing.
• Flooding is not suitable for ordinary point-to-
point communication.
• For broadcasting it might be a good
alternative.
• The problem with flooding as a broadcast
technique is it generates too many packets and
consumes too much bandwidth.
Broadcast Routing
• Multidestination routing is the third
algorithm for broadcast routing.
• In this method each packet contains the list of
destinations.
• When a packet arrives at a router, the router
checks all the destinations to determine the set
of output lines that will be needed.
• The router generates a new copy of the packet
for each output line to be used and includes in
each packet only those destinations that are to
use the line.
Broadcast Routing
• In effect, the destination set is partitioned
among the output lines.
• After a sufficient number of hops, each packet
will carry only one destination and can be
treated as a normal packet.
• Multidestination routing is like separately
addressed packets, except that when several
packets must follow the same route, one of
them pays full fare and the rest ride free.
Broadcast Routing
• A fourth broadcast algorithm that uses the sink
tree for the router initiating the broadcast.
• A spanning tree is a subset of the subnet that
includes all the routers but contains no loops.
• If each router knows which of its lines belong
to the spanning tree, it can copy an incoming
broadcast packet onto all the spanning tree
lines except the one it arrived on.
Broadcast Routing
• This method makes excellent use of
bandwidth, generating the absolute minimum
number of packets necessary to do the job.
• The only problem is that each router must have
knowledge of some spanning tree for the
method to be applicable. Sometimes this
information is available (e.g., with link state
routing) but sometimes it is not (e.g., with
distance vector routing).
Broadcast Routing
• The last broadcast algorithm is called as
reverse path forwarding.
• When a broadcast packet arrives at a router,
the router checks to see if the packet arrived on
the line that is normally used for sending
packets to the source of the broadcast.
• If so, then it is being considered that the
broadcast packet followed the best route from
the router.
Broadcast Routing
• Therefore the first copy has been arrived at the
router.
• Hence the router forwards copies of it onto all
lines except the one it arrived on.
• However the broadcast packet arrived on a line
other than the preferred one for reaching the
source the packet is discarded as it considered
as duplicate.
Broadcast

Reverse path forwarding.


(a) A subnet. (b) A Sink tree.
(c) The tree built by reverse path forwarding.
Broadcast Routing
• Consider an example of reverse path
forwarding as shown in above figure.
• Figure (a) shows a subnet, figure (b) shows a
sink tree for router I of that subnet.
• The figure (c) shows the working of reverse
path algorithm.
• On the first hop, I sends packets to F, H, J, and
N as indicated by the second row of the tree.
Broadcast Routing
• Each of these packets arrives on the preferred
path to I and indicated by a circle around the
letter.
• On the second hop eight packets are generated,
two by each of the routers that received a
packet on the first hop.
• As it turns out, all eight of these arrive at
previously unvisited routers, and five of these
arrive along the preferred line.
Broadcast Routing
• Of the six packets generated on the third hop
only three arrive on the preferred path (at C, E,
and K); the others are duplicates.
• After five hops and 24 packets, the
broadcasting terminates, compared with four
hops and 14 packets had the sink tree been
followed exactly.
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 such situations it is frequently necessary for
one process to send a message to all the other
members of the group.
• If the group is small, it can just send each other
member a point-to-point message.
Multicast Routing
• 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 is
inefficient because most receivers are not
interested in the message.
• Therefore we need a way to send messages to
well-defined groups that are numerically large
in size but small compared to the network as a
whole.
Multicast Routing
• Sending a message to such a group is called
multicasting.
• The routing algorithm is called multicast
routing.
• To perform multicast routing each router
computes a spanning tree covering all other
routers.
• For example consider the network shown in
below figure (a).
• We have two groups 1 and 2.
Multicast Routing

(a) A network. (b) A spanning tree for the leftmost router.


(c) A multicast tree for group 1. (d) A multicast tree for group 2.
Multicast Routing
• Some routers are attached to hosts that belong
to one or both of these groups shown in figure
(a).
• A spanning tree for the leftmost router is
shown in figure (b).
• When a process sends a multicast packet to a
group, the first router examines its spanning
tree and prunes it.
• Figure (c) shows the pruned spanning tree for
group 1.
Multicast Routing
• Similarly figure (d) shows the pruned spanning
tree for group 2.
• Multicast packets are forwarded only along the
appropriate spanning tree.

You might also like