0% found this document useful (0 votes)
4 views69 pages

Module 5 Z0EUGu9

The document discusses routing algorithms within the network layer, focusing on their role in directing packets from source to destination. It categorizes routing algorithms into nonadaptive and adaptive types, explains the optimality principle, and describes various routing techniques including flooding, shortest-path routing, and distance-vector and link-state routing. Key concepts such as Dijkstra's algorithm and the distance vector algorithm are also covered, highlighting their processes and applications in routing decisions.

Uploaded by

aswathi
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)
4 views69 pages

Module 5 Z0EUGu9

The document discusses routing algorithms within the network layer, focusing on their role in directing packets from source to destination. It categorizes routing algorithms into nonadaptive and adaptive types, explains the optimality principle, and describes various routing techniques including flooding, shortest-path routing, and distance-vector and link-state routing. Key concepts such as Dijkstra's algorithm and the distance vector algorithm are also covered, highlighting their processes and applications in routing decisions.

Uploaded by

aswathi
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/ 69

text

Your paragraph text yt fb in ln wp


MODULE - 5
NETWORK LAYER
sYLLABUS
ROUTING ALGORITHMS
ROUTING ALGORITHMS
• main function of the network layer is routing packets from the source machine to the
destination machine
• routing algorithm is that part of the network layer software responsible for deciding which
output line an incoming packet should be transmitted on.
• Responsible for deciding which output line an incoming packet should be transmitted on.
• If the network uses datagrams internally, this decision must be made anew for every
arriving data packet since the best route may have changed since last time.
• If the network uses virtual circuits internally, routing decisions are made only when a new
virtual circuit is being set up. Thereafter, data packets just follow the already established
route.
• The latter case is sometimes called session routing because a route remains in force for an
entire session
• A router have two processes inside it.

• One of them handles each packet as it arrives, looking up the outgoing line to use for it in the routing tables.
This process is forwarding.

• The other process is responsible for filling in and updating the routing tables. That is where the routing
algorithm comes into play.

• properties desirable in a routing algorithm: correctness, simplicity, robustness, stability, fairness, and
efficiency.
• Routing algorithms can be grouped into two major classes: nonadaptive and adaptive.

• Nonadaptive algorithms do not base their routing decisions on any measurements or estimates of the current
topology and traffic.

• Instead, the choice of the route to use to get from I to J (for all I and J) is computed in advance, offline, and
downloaded to the routers when the network is booted.

• This procedure is sometimes called static routing.

• Because it does not respond to failures, static routing is mostly useful for situations in which the routing
choice is clear
• Adaptive algorithms change their routing decisions to reflect changes in the topology, and sometimes
changes in the traffic as well.

• These dynamic routing algorithms differ in where they get their information, when they change the routes ,
and what metric is used for optimization
THE OPTIMALITY PRINCIPLE

• optimal routes without regard to network topology or traffic. - optimality principle

• 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 part of the route from I to J as r1 and the rest of the route as r 2.
• If a route better than r 2 existed from J to K, it could be concatenated with r 1 to improve
the route from I to K, contradicting our statement that r 1r 2 is optimal.
• As a direct consequence of 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 where the distance metric is the number of hops.
• The goal of all routing algorithms is to discover and use the sink trees for all routers.
(a) A network. (b) A sink tree for router B.
• If all of the possible paths are to be chosen, the tree becomes a more general structure called a DAG
(Directed Acyclic Graph).

• DAGs have no loops.

• it does not contain any loops, so each packet will be delivered within a finite and bounded number of hops.
FLOODING
• every incoming packet is sent out on every outgoing line except the one it arrived on.
• have a hop counter contained in the header of each packet that is decremented at each hop,
with the packet being discarded when the counter reaches zero.
• 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 network.
• Flooding with a hop count can produce an exponential number of duplicate packets as the
hop count grows and routers duplicate packets they have seen before.
• have routers keep track of which packets have been flooded, to avoid sending them out a
second time.
• have the source router put a sequence number in each packet it receives from its hosts
• each list should be augmented by a counter, k, meaning that all sequence numbers through k have
been seen.

• When a packet comes in, it is easy to check if the packet has already been flooded by comparing its
sequence number to k; if so, it is discarded.

• ensures that a packet is delivered to every node in the network.

• flooding is tremendously robust

• can be used as a building block for other routing algorithms that are more efficient but need more
in the way of setup.

• Flooding can also be used as a metric against which other routing algorithms can be compared.

• Flooding always chooses the shortest path because it chooses every possible path in parallel.
• Selective flooding
Shortest-Path Routing
• Path-selection model
•Destination-based
•Load-insensitive (e.g., static link weights)
•Minimum hop count or sum of link weights

2
3 1
1
4
2 1
5
4 3
11
Shortest-Path Problem
• Given: network topology with link costs
• c(x,y): link cost from node x to node y
• Infinity if x and y are not direct neighbors
• Compute: least-cost paths to all nodes
• From a given source u to all other nodes
• p(v): predecessor node along path2 from source to v
3 1
1
u 4
2 1
5
p(v)
4 3
w
12 v
Routing
• A routing protocol sets up a routing table in routers

• A node makes a local choice depending on global


topology
□ Forwarding
◆ Move packet from input link to the appropriate output link
◆ Purely local computation
◆ Must go be very fast (executed for every packet)

□ Routing
◆ Make sure that the next hop actually leads to the destination
◆ Global decisions; distributed computation and communication
◆ Can go slower (only important when topology changes)
Forwarding Options
□ Source routing
◆ Complete path listed in packet

□ Virtual circuits
◆ Set up path out-of-band and store path identifier in routers
◆ Local path identifier in packet

□ Destination-based forwarding
◆ Router looks up address in forwarding table
◆ Forwarding table contains (address, next-hop) tuples
Distance-vector & Link-state Routing
• Both assume router knows
• address of each neighbor
• cost of reaching each neighbor
• Both allow a router to determine global routing information by
talking to its neighbors

• Distance vector - router knows cost to each destination

• Link state - router knows entire network topology and computes


shortest path
Link-State Routing
• Each router keeps track of its incident links
• Whether the link is up or down
• The cost on the link
• Each router broadcasts the link state
• To give every router a complete view of the graph
• Each router runs Dijkstra’s algorithm
• To compute the shortest paths
• … and construct the forwarding table
• Example protocols
• Open Shortest Path First (OSPF)
• Intermediate System – Intermediate System (IS-IS)
17
□ Two phases
◆ Reliable flooding
• » Tell all routers what you know about your local topology
◆ Path calculation (Dijkstraʼs algorithm)
• » Each router computes best path over complete network

□ Motivation
◆ Global information allows optimal route computation
◆ Straightforward to implement and verify
A Link State Routing Algorithm
Dijkstra’s algorithm Notation:
■ net topology, link costs ■ c(i,j): link cost from node i
known to all nodes to j. cost infinite if not direct
– accomplished via “link neighbors
state broadcast”
■ D(v): current value of cost
– all nodes have same info of path from source to dest.
■ computes least cost paths V
from one node (‘source”) to
■ p(v): predecessor node
all other nodes
along path from source to v,
– gives routing table for that is next v
that node
■ N: set of nodes whose least
■ iterative: after k iterations,
cost path definitively known
know least cost path to k
dest.’s
Dijsktra’s Algorithm
1 Initialization:
2 N' = {u}
3 for all nodes v
4 if v adjacent to u
5 then D(v) = c(u,v)
6 else D(v) = ∞
7
8 Loop
9 find w not in N' such that D(w) is a minimum
10 add w to N'
11 update D(v) for all v adjacent to w and not in N' :
12 D(v) = min( D(v), D(w) + c(w,v) )
13 /* new cost to v is either old cost to v or known
14 shortest path cost to w plus cost from w to v */
15 until all nodes in N'

Network Layer 4-20


Dijkstra’s algorithm: example
Step N' D(v),p(v) D(w),p(w) D(x),p(x) D(y),p(y) D(z),p(z)
0 u 2,u 5,u 1,u ∞ ∞
1 ux 2,u 4,x 2,x ∞
2 uxy 2,u 3,y 4,y
3 uxyv 3,y 4,y
4 uxyvw 4,y
5 uxyvwz

v 3 w
2 5
u 2 1 z
3
1 2
x 1
y

Network Layer 4-21


Dijkstra’s algorithm, discussion
Algorithm complexity: n nodes
• each iteration: need to check all nodes, w, not in N
• n(n+1)/2 comparisons: O(n2)
• more efficient implementations possible: O(nlogn)
Oscillations possible:
• e.g., link cost = amount of carried traffic

1 A A A A
1+e 2+e 0 0 2+e 2+e 0
D 0 0 B D B D B D B
1+e 1 0 0 1+e 1
0 e 0 0 1 1+e 0 e
1
C C C C
1
e
… recompute … recompute … recompute
initially
routing
Network Layer 4-22
Step 1 Step 2
Step 4
Step 3
Step 5
Final
Distance Vector Algorithm Overview
• Each router starts with a distance table consisting of the value “0” for itself and
the value “infinity” for every other destination
• Each router will transmit its distance vector to each of its neighbors whenever
the information changes (as well as when a link to a neighbor first comes up)
• Each router saves the most recently received distance vector from each of its
neighbors, and calculate its own distance vector, based on minimizing the cost to
each destination
Distance Vector Algorithm
iterative:
Distance Table data structure
■ continues until no nodes
exchange info. ■ each node has its own
■ self-terminating: no ■ row for each possible destination
“signal” to stop ■ column for each directly-attached
neighbor to node
asynchronous:
■ example: in node X, for dest. Y via
■ nodes need not
neighbor Z:
exchange info/iterate in
lock step!
distributed: distance from X to
■ each node X = Y, via Z as next hop
D
communicates only with (Y,Z) Z
= c(X,Z) + min {D (Y,w)}
directly-attached w
neighbors
Distance Table: An Example
B 1 C E
cost to destination via
7 D () A B D
A 8 2
A 1 14 5
1
E D
2 B 7 8 5

destination
E D C 6 9 4
D (C,D) = c(E,D) + min {D (C,w)}
w
= 2+2 = 4 D 4 11 2
E D
D (A,D) = c(E,D) + minw{D (A,w)}
= 2+3 = 5 loop!
E B
D (A,B) = c(E,B) + minw{D (A,w)}
= 8+6 = 14
loop!
Distance Table Gives Routing Table
cost to destination via
E Outgoing link
D () A B D
to use, cost
A 1 14 5 A A,1
B 7 8 5 B D,5
destination

desti natio
C 6 9 4 C D,4

n
D 4 11 2 D D,4

Distance table Routing table


Distance Routing: Overview
Iterative, asynchronous: Each node:
each local iteration caused
by:
■ local link cost change wait for (change in local link
■ message from neighbor: its cost of msg from neighbor)
least cost path change from
neighbor
recompute distance table
Distributed:
■ each node notifies neighbors
only when its least cost path if least cost path to any dest
to any destination changes has changed, notify neighbors
– neighbors then notify their
neighbors if necessary
Distance Vector Algorithm
At all nodes, X:

1 Initialization:
2 for all adjacent nodes v:
3 DX(*,v) = infty /* the * operator means "for all rows" */
4 DX(v,v) = c(X,v)
5 for all destinations, y
6 send min DX(y,w) to each neighbor /* w over all X's neighbors */
w
Distance Vector Algorithm: Cont’d
8 loop
9 wait (until I see a link cost change to neighbor V
10 or until I receive update from neighbor V)
11
12 if (c(X,V) changes by d)
13 /* change cost to all dest's via neighbor v by d */
14 /* note: d could be positive or negative */
15 for all destinations y: DX(y,V) = DX(y,V) + d
16
17 else if (update received from V wrt destination Y)
18 /* shortest path from V to some Y has changed */
19 /* V has sent a new value for its minw DV(Y,w) */
20 /* call this received new value is "newval" */
21 for the single destination y: DX(Y,V) = c(X,V) + newval
22
23 if we have a new minw DX(Y,w)for any destination Y
24 send new value of minw DX(Y,w) to all neighbors
25
26 forever
Distance Vector Algorithm: Example

Y
2 1
X Z
7
Distance Vector Algorithm: Example

Y
2 1
X Z X Z
7 D (Y,Z) = c(X,Z) + minw{D (Y,w)}
= 7+1 = 8

X Y
D (Z,Y) = c(X,Y) + minw{D (Z,w)}
= 2+1 = 3
Distance Vector Algorithm: Link Cost Changes
Link cost changes:
1
■ node detects local link cost change Y
■ updates distance table (line 15) 4 1
if cost change in least cost path, notify X Z
■ 50
neighbors (lines 23,24)

algorithm
“good terminates
news
travels
fast”
Count to infinity: Another Example

A B C
1 1
Distance Vector: Link Cost Changes
Link cost changes: 60
■ good news travels fast Y
4 1
■ bad news travels slow - X Z
“count to infinity” problem! 50

algorithm
continues
on!
Distance Vector: Position Reverse
If Z routes through Y to get to X : 60
■ Z tells Y its (Z’s) distance to X is infinite Y
4 1
(so Y won’t route to X via Z)
X Z
■ will this completely solve count to infinity 50
problem?
algorithm
terminates
Distance Vector Example: Step 1
Optimum 1-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A
1
2 F
B 4 B B 0 B
6
C ∞ – C ∞ –
1
D ∞ – D 3 D 3 D
E 2 E E ∞ – A 4

F 6 F F 1 F B
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A ∞ – A ∞ – A 2 A A 6 A
B ∞ – B 3 B B ∞ – B 1 B
C 0 C C 1 C C ∞ – C 1 C
D 1 D D 0 D D ∞ – D ∞ –
E ∞ – E ∞ – E 0 E E 3 E
F 1 F F ∞ – F 3 F F 0 F
39
Distance Vector Example: Step 2
Optimum 2-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A 1
2 F
B 4 B B 0 B
6
C 7 F C 2 F
1
D 7 B D 3 D 3 D
E 2 E E 4 F
A 4

F 5 E F 1 F
B
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 7 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D ∞ – D 2 C
E 4 F E ∞ – E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F
40
Distance Vector Example: Step 3
Optimum 3-hop paths
Table for A Table for B
E 3 C
Dst Cst Hop Dst Cst Hop 1
A 0 A A 4 A 1
2 F
B 4 B B 0 B
6
C 6 E C 2 F
1
D 7 B D 3 D 3 D
E 2 E E 4 F
A 4

F 5 E F 1 F
B
Table for C Table for D Table for E Table for F
Dst Cst Hop Dst Cst Hop Dst Cst Hop Dst Cst Hop
A 6 F A 7 B A 2 A A 5 B
B 2 F B 3 B B 4 F B 1 B
C 0 C C 1 C C 4 F C 1 C
D 1 D D 0 D D 5 F D 2 C
E 4 F E 5 C E 0 E E 3 E
F 1 F F 2 C F 3 F F 0 F
41
Comparison of LS and DV Algorithm
Message complexity Robustness: what happens
■ LS: with n nodes, E links, if router malfunctions?
O(nE) msgs sent each LS:
■ DV: exchange between
– node can advertise
neighbors only
incorrect link cost
– convergence time varies
– each node computes only
Speed of Convergence its own table
■ LS: O(n**2) algorithm requires DV:
O(nE) msgs – DV node can advertise
– may have oscillations incorrect path cost
■ DV: convergence time varies – each node’s table used by
– may be routing loops others
– count-to-infinity problem o error propagate thru
network
CONGESTION CONTROL
CONGESTION CONTROL ALGORITHMS
• When too many packets are present in (a part of) the subnet, performance degrades.
This situation is called congestion.
• the number of packets <carrying capacity of subnet, the number delivered is
proportional to the number sent
• At very high traffic, performance collapses completely and almost no packets are
delivered
Congestion can be brought on by
• If all of a sudden, streams of packets begin arriving on three or four input lines and all
need the same output line, a queue will build up.

• If there is insufficient memory to hold all of them, packets will be lost.

• if routers have an infinite amount of memory, congestion gets worse, not better,
because by the time packets get to the front of the queue, they have already timed out
(repeatedly) and duplicates have been sent

• Slow processors can also cause congestion


Congestion Control vs Flow Control
• Congestion control has to do with • Flow control relates to the point-to-point
making sure the subnet is able to carry traffic between a given sender and a
the offered traffic. given receiver.

• make sure that a fast sender cannot


continually transmit data faster than the
• involves the behavior of all the hosts, all receiver is able to absorb it.
the routers, the store-and-forwarding
processing within the routers, and all the
other factors that tend to diminish the • frequently involves some direct feedback
carrying capacity of the subnet. from the receiver to the sender to tell
the sender how things are doing at the
other end.
GENERAL PRINCIPLES OF CONGESTION CONTROL

• solutions into two groups: open loop and closed loop

• Open Loop- solve the problem by good design to make sure it does not occur in the
first place.
• Tools for doing open-loop control include
1. deciding when to accept new traffic,
2. deciding when to discard packets and which ones,
3. making scheduling decisions at various points in the network.

• Closed Loop- based on the concept of a feedback loop. This approach has three parts
when applied to congestion control:
1. Monitor the system to detect when and where congestion occurs.
2. Pass this information to places where action can be taken.
3. Adjust system operation to correct the problem.
Monitor the system to detect when and where congestion occurs.

• metrics to monitor the subnet for congestion.


1. percentage of all packets discarded for lack of buffer space,
2. the average queue lengths,
3. the number of packets that time out and are retransmitted,
4. the average packet delay,
5. standard deviation of packet delay.

In all cases, rising numbers indicate growing congestion


Pass this information to places where action can be taken.

transfer the information about the congestion from the point where it is detected to the
point where something can be done about it.

1. router detecting the congestion will send a packet to the traffic source or sources,
announcing the problem.
2. a bit or field can be reserved in every packet for routers to fill in whenever congestion
gets above some threshold level.
3. have hosts or routers periodically send probe packets out to explicitly ask about
congestion
4. knowledge of congestion will cause the hosts to take appropriate action to reduce the
congestion.
Adjust system operation to correct the problem
• The presence of congestion means that the load is (temporarily) greater than the
resources (in part of the system) can handle.

• Two solutions : increase the resources or decrease the load.


• increasing transmission power, Splitting traffic over multiple , spare routers that are
normally used only as backups (to make the system fault tolerant) can be put on-line
to give more capacity
• reduce the load includes denying service to some users, degrading service to some or
all users, and having users schedule their demands in a more predictable way.
CONGESTION PREVENTION POLICIES
CONGESTION CONTROL IN DATAGRAM SUBNETS
• Each router can easily monitor the utilization of its output lines and other resources.
• For example, it can associate with each line a real variable, u, whose value, between
0.0 and 1.0, reflects the recent utilization of that line.
• to maintain a good estimate of u, a sample of the instantaneous line utilization, f
(either 0 or 1), can be made periodically and u updated according to

• where the constant a determines how fast the router forgets recent history.
• Whenever u moves above the threshold, the output line enters a ''warning'' state.
• Each newly-arriving packet is checked to see if its output line is in warning state. If it
is, some action is taken.
Choke Packets
• To tell the source to slow down, the router sends a choke packet back to the source
host, giving it the destination found in the packet
• original packet is tagged (a header bit is turned on) so that it will not generate any
more choke packets farther along the path and is then forwarded in the usual way .
• When the source host gets the choke packet, reduce the traffic sent to the specified
destination by X percent
• the host should ignore choke packets referring to that destination for a fixed time
interval.
• After that period has expired, the host listens for more choke packets for another
interval.
• If one arrives, the line is still congested, so the host reduces the flow still more and
begins ignoring choke packets again.
• If no choke packets arrive during the listening period, the host may increase the flow
again.
• Hosts can reduce traffic by adjusting their policy parameters, for example, their
window size.
• Variation -routers can maintain several thresholds. Depending on which threshold has
been crossed, the choke packet can contain a mild warning, a stern warning, or an
ultimatum.
• Another variation -use queue lengths or buffer utilization instead of line utilization as
the trigger signal. The same exponential weighting can be used with this metric as with
u
LOAD SHEDDING
• when routers are being inundated by packets that they cannot handle, they just throw
them away

• Which packet to discard may depend on the applications running

• applications must mark their packets in priority classes to indicate how important they
are.

• Another option -allow hosts to exceed the limits specified in the agreement negotiated
when the virtual circuit was set up, but subject to the condition that all excess traffic
be marked as low priority.
Random Early Detection(RED)
• idea of discarding packets before all the buffer space is really exhausted
• popular algorithm for doing this is called RED (Random Early Detection)
• idea is that there is time for action to be taken before it is too late.
• To determine when to start discarding, routers maintain a running average of their
queue lengths.
• When the average queue length on some line exceeds a threshold, the line is said to be
congested and action is taken.
• Router to tell the source about the problem-
1. One way is to send it a choke packet
2. just discard the selected packet and not report it. The source will eventually notice the
lack of acknowledgement and take action.
QUALITY OF SERVICE
Quality of Service Requirements
• A stream of packets from a source to a destination is called a flow
• The needs of each flow can be characterized by four primary parameters: reliability,
delay, jitter, and bandwidth.
• Together these determine the QoS (Quality of Service) the flow requires
• Reliability- No bits may be delivered incorrectly. Achieved by checksumming each
packet and verifying the checksum at the destination

• If all packets are delayed uniformly by a few seconds, no harm is done.

• Jitter- sensitive to the packets arriving with irregular time intervals between them.

• Bandwidth- the applications differ in their bandwidth needs
Techniques for Achieving Good Quality of Service

• Overprovisioning
• Buffering
• Traffic Shaping
• The Leaky Bucket Algorithm
• The Token Bucket Algorithm
• Resource Reservation
• Admission Control
• Proportional Routing
• Packet Scheduling
Buffering
• Flows can be buffered on the receiving side before being delivered.
• does not affect the reliability or bandwidth, and increases the delay, but it smooths out
the jitter
Traffic Shaping
• smooths out the traffic on the server side, rather than on the client side.
• regulating the average rate (and burstiness) of data transmission

• service level agreement - When a connection is set up, the user and the subnet
agree on a certain traffic pattern for that circuit.

• Traffic shaping reduces congestion and thus helps the carrier live up to its promise.

• with traffic shaping the customer says to the carrier: My transmission pattern will look
like this; can you handle it?

• Monitoring a traffic flow is called traffic policing - if the customer is following the
agreement and what to do if the customer is not.
The Leaky Bucket Algorithm

• each host is connected to the network by an interface containing a leaky bucket, that
is, a finite internal queue.

• If a packet arrives at the queue when it is full, the packet is discarded.

• single-server queueing system with constant service time.

• host is allowed to put one packet per clock tick onto the network.

• turns an uneven flow of packets from the user processes inside the host into an even
flow of packets onto the network, smoothing out bursts and greatly reducing the
chances of congestion.
Implementation of Leaky Bucket
• The leaky bucket consists of a finite queue.
• When a packet arrives, if there is room on the queue it is appended to the queue;
otherwise, it is discarded.
• At every clock tick, one packet is transmitted (unless the queue is empty).

• The byte-counting leaky bucket


• At each tick, a counter is initialized to n.
• If the first packet on the queue has fewer bytes than the current value of the counter,
it is transmitted, and the counter is decremented by that number of bytes.
• Additional packets may also be sent, as long as the counter is high enough.
• When the counter drops below the length of the next packet on the queue,
transmission stops until the next tick, at which time the residual byte count is reset
and the flow can continue.
text

You might also like