CN2-01-Network Layer - 1
CN2-01-Network Layer - 1
( 12CS63 )
19.01.2016 12:04 1
You never really learn much
from hearing yourself talk
George Clooney
19.01.2016 12:04 2
Real listening is
a willingness to
let the other person
change you
Alan Alda
19.01.2016 12:04 3
I hear and I forget
I do and I understand
Confucius
19.01.2016 12:04 Confucius 4
Let us
together
layers 1, 2, 3 :
deal with moving data from one device to
another ….
electrical specs, physical connections,
physical
19.01.2016 12:04
addressing, timing, reliability 6
Computer Networks
Organization of the Network layers
layer 4 :
links the two subgroups viz. network
support and user support layers
ensures that lower layers transmit
entities in a form that the upper layers
can make use of
layers 5, 6, 7 :
allow interoperability among unrelated
software systems
19.01.2016 12:04 7
Computer Networks
Network layer
responsible for delivery from source host
to destination host
handles delivery of packet from its point-
of-origin to its final destination possibly
across multiple networks
19.01.2016 12:04 8
Computer Networks
Network layer
source to destination delivery
19.01.2016 12:04 9
Computer Networks
Network layer
Tasks of network layer
• logical addressing :
including logical addresses of the
sender and receiver
• routing :
sending packets to their final destination
through intermediate networks
19.01.2016 12:04 10
Computer Networks
Network Layer
Topics to be discussed:
• network layer design issues
• routing algorithms
• quality of service
19.01.2016 12:04 11
Computer Networks
Network Layer
Goal
end-to-end transport of packets from source
node all the way to destination node
(compare with data link layer)
19.01.2016 12:04 13
Computer Networks
Network Layer
Design issues :
services provided to the transport layer
internal design of the subnet
2 transmit 2
Customers’ Link
Customers’
equipment equipment
leased service leased
line provider line
__
19.01.2016 12:04 18
Computer Networks
Network Layer
19.01.2016 12:04 19
Computer Networks
Network Layer
Connection - oriented Service
A virtual circuit :
• is a circuit or path between points in a
network
• appears to be a discrete, physical path,
but …..
• is actually a managed pool of circuit
resources from which …..
• specific circuits are allocated, as
needed,
19.01.2016 12:04
to meet traffic requirements 20
Computer Networks
Network Layer
Connectionless Service
Datagram subnet
Router tables
• source /
destination
• connection ID
Router tables
19.01.2016 12:04 26
Computer Networks
Network Layer
Connection - oriented Service
19.01.2016 12:04 31
Computer Networks
Network Layer
VC :
choose route from source to destination
set up connection
add identifier (VC number) to each packet
(router replaces connection ids in
outgoing packets - called label switching)
store details in router tables
use the route for transporting all packets
release connection, terminate VC
19.01.2016 12:04 32
Computer Networks
Network Layer
Comparison of Datagram and VC subnets
complicated lookup setup time
bandwidth
router memory
dynamic allotment
of CPU cycles,
buffers, bandwidth
19.01.2016 12:04 33
Computer Networks
Network Layer
Routing algorithms
• Shortest Path Routing
• Flooding
• Distance Vector Routing
• Link State Routing
• Hierarchical Routing
• Broadcast Routing
• Multicast Routing
19.01.2016 12:04 34
Computer Networks
Network Layer
Routing algorithms
routing algorithm is a part of the Network
Layer software that is responsible for
deciding ……….
Routing Forwarding
filling in and handling packet as
updating .......... it arrives, i.e.
routing tables looking up routing
use of table to ascertain
routing algorithm out - going line and
send packet
19.01.2016 12:04 37
Computer Networks
Network Layer
Desirable features in routing algorithm
• correctness
• simplicity
(#)
• robustness (tolerance to faults, topology
& traffic changes, router
crashes)
• stability (quick convergence to equilibrium)
• fairness
• optimality
(#) : without requiring all jobs in all hosts to be aborted and the network to be
rebooted every time some router crashes
19.01.2016 12:04 38
Computer Networks
Network Layer
classes of routing algorithm :
• non-adaptive or static
• adaptive or dynamic
19.01.2016 12:04 39
Computer Networks
Network Layer
Assume :
(i) cost of transmission capacity is 0.5
paisa per 106 bytes per hop
(ii) cost of router memory is 0.5 paisa per
byte and depreciates in 2 years @ 40
hours per week
Compute and compare the cost of overheads in
the above two implementations (VC and
datagram) for the given set of parameters
19.01.2016 12:04 43
Computer Networks
Network Layer
Example AT 5.5
19.01.2016 12:04 44
Computer Networks
Network Layer
Example AT 5.5
filled in circle :
permanent
19.01.2016 12:04
finding shortest path from A to D 50
Computer Networks
Network Layer
Shortest Path Routing
2. Examine, in turn, each of the nodes
adjacent to A
working
node 7
2 2 3 3
2
6 1 2 2
4
19.01.2016 12:04
finding shortest path from A to D 51
Computer Networks
Network Layer
Shortest Path Routing
3. Continue
7
2 3 3
2
2
1 2 2
6
4
19.01.2016 12:04
finding shortest path from A to D 52
Computer Networks
Network Layer
Shortest Path Routing
4. Continue
7
2 3
2 3
2
6 1 2 2
4
19.01.2016 12:04
finding shortest path from A to D 53
Computer Networks
Network Layer
Shortest Path Routing
5. Continue
7
2 3
2 3
2
1 2
6 2
4
19.01.2016 12:04
finding shortest path from A to D 54
Computer Networks
Network Layer
Shortest Path Routing
6. Continue
7
2 3
3
2
2
1
6 2 2
4
19.01.2016 12:04
finding shortest path from A to D 55
Computer Networks
Network Layer
Shortest Path Routing
Source Dest
filled in circle :
permanent
demo of an example
graph available at :
19.01.2016 12:04 http://optlab-server.sce.carleton.ca/POAnimations2007/DijkstrasAlgo.html 57
Computer Networks
Network Layer
Dijkstra’s algorithm
1. Router builds graph of
network and identifies
source and destination
nodes, say V1 and V2
2. It builds a matrix, called
the adjacency matrix
3. Each entry of matrix
indicates weight
4. [ i, j ] is the weight of a
link between nodes Vi and Vj
19.01.2016 12:04 58
Computer Networks
Network Layer
5. If there is no direct link between Vi and
Vj, this weight is identified as infinity
6. Builds a status record set for every
node on the network. The record
contains three fields:
Predecessor field - the first field shows the
previous node
Length field - the second field shows the sum of
the weights from the source to that node
Label field - the last field shows the status of
node -- each node can have one status mode:
permanent or tentative
19.01.2016 12:04 59
Computer Networks
Network Layer
6. Initializes the parameters of the status
record set (for all nodes) and sets their
length to infinity and their label to tentative
7. Sets a T-node. For example, if V1 is to be the
source T-node, the router changes V1's label
to permanent - when a label changes to
permanent, it never changes again
8. Updates the status record set for all tentative
nodes that are directly linked to the source T-
node
19.01.2016 12:04 60
Computer Networks
Network Layer
9. Looks at all of the tentative nodes and
chooses the one whose weight to V1 is
lowest. That node is then the destination T-
node
10. If this node is not V2 (the intended
destination), the router goes back to step 9
11. If this node is V2, the router extracts its
previous node from the status record set
and does this until it arrives at V1. This list
of nodes shows the best route from V1 to V2
19.01.2016 12:04 61
Computer Networks
Network Layer
Flooding ( static method )
every incoming packet is sent on every
outgoing line, except the one it arrived on
19.01.2016 12:04 65
Computer Networks
Network Layer
Flooding ( static method ) : Uses
Flooding is not practical in most applications,
but is highly robust and so, is desirable in :
19.01.2016 12:04 66
Computer Networks
Network Layer
Distance Vector Routing (dynamic method)
Bellman - Ford / Ford - Fulkerson Algorithm
each router maintains a table (i.e. vector),
indexed by, and containing one entry for, each
router in the subnet; each entry has two parts :
18,H
30,I
Forwarding Tables
19.01.2016 12:04 73
Computer Networks
Example : Network Layer PD 3.3
19.01.2016 12:04 74
Computer Networks
Distance Vector Routing :
Example (distance) PD 4.15
19.01.2016 12:04 77
Computer Networks
Distance Vector Routing :
Example PD 4.15
19.01.2016 12:04 78
Computer Networks
Distance Vector Routing :
Example PD 4.15
19.01.2016 12:04 79
Computer Networks
Network Layer
Distance Vector Routing Example AT 5.9
Consider the subnet shown in the figure
(next slide).
Distance vector routing is used, and the
following vectors have come in to router C :
from B : (5, 0, 8, 12, 6, 2)
from D : (16, 12, 6, 0, 9, 10)
from E : (7, 6, 3, 9, 0, 4)
The measured delays to B, D and E are 6, 3 and
5 respectively.
Give C’s new routing table indicating outgoing
line to use and the expected delay.
19.01.2016 12:04 80
Computer Networks
Network Layer
Distance Vector Routing Example AT 5.9
19.01.2016 12:04 81
Computer Networks
Network Layer
Distance Vector Routing : Example AT 5.9
Vectors coming
into C from → B D E
A 5 16 7
B 0 12 6
C 8 6 3
D 12 0 9
E 6 9 0
F 2 10 4
Measured
Delay
C to B/D/E 6 3 5
19.01.2016 12:04 82
Computer Networks
Network Layer Example AT 5.9
19.01.2016 12:04 83
Computer Networks
Network Layer Example AT 5.9
B 0 12 6 6 3+12=15 5+6=11 B
D 12 0 9 6 +12=18 3 5+9=14 D
E 6 9 0 6+6=12 3+9=12 5 E
19.01.2016 12:04 84
Computer Networks
Network Layer
Distance Vector Routing : converges, but slowly
The count-to-infinity problem
metric used : number of hops
five node linear subnet example
X
∞
B ←
C →
D →
E →
Line 1
Line 2
at regular intervals
event-driven
(ex. neighbour / link going down /
coming up / change of properties)
19.01.2016 12:04 93
Computer Networks
Network Layer
Link State Routing : (d) Distributing Link State Packets
Need : reliable distribution ---- issue
as the packets are distributed and
installed, routers getting the first LS
packets will change their routes →
over a period of time, different routers
may use different versions of topology →
inconsistencies, loops, unreachable
machines, ……
19.01.2016 12:04 94
Computer Networks
Network Layer
Link State Routing : (d) Distributing Link State Packets
Basic distribution algorithm : flooding
LSP
from Y X A X A X sends a copy of new LSP
(received with highest
sequence number) to A and C
C B D C B D
(a) (b)
X A X A
C B D C B D
B accepts the copy of
(c) LSP which arrived first (d)
19.01.2016 12:04 95
Computer Networks
Network Layer
Link State Routing : (d) Distributing Link State Packets
Basic distribution algorithm : flooding
Why Seq. no. ? → to keep control of the flood :
each packet contains a sequence no.
sequence no. is incremented for each new
packet sent
other routers keep track of the following
information pair they ‘ see ’ :
{source
19.01.2016 12:04
router & sequence no.} → 96
Computer Networks
Network Layer
Link State Routing : (d) Distributing Link State Packets
Solution :
include age of packet after the sequence no.
decrement it once per second
when age becomes zero, discard the link
state packet from that router
19.01.2016 12:04 100
Computer Networks
Network Layer
Link State Routing : (e) Computation of new route
(i) once a router has accumulated a full
set of LSPs …..
it constructs the entire subnet graph,
because every link is represented
Packet buffer
for Router B
1A Region
Region
Region
Region
7 entries
One combination :
15 clusters, with each cluster having …….
16 regions , with each region having …….
20 routers
Total = 51 entries
Hops
↓
1
3
4
5
Subnet A sink tree for router I
19.01.2016 12:04
Tree built by reverse 119
path forwarding
Computer Networks
Network Layer
Broadcast Routing :
5. Reverse path forwarding
hop - 1 : I sends packets to F, H, J, N (four)
hop - 2 : eight packets are generated - five
arrive on preferred lines (A, D, G, O, M)
hop - 3 : six packets are generated - three
arrive on preferred lines (E, C, K)
hop - 4 : four packets are generated - two
arrive on preferred lines (B, L)
pruned pruned
ST for ∙ ∙ ST for
group 1 group 2
..
..
..
..
..
..
..
..
.
19.01.2016 12:04 134
Computer Networks
Network Layer
Network Congestion
Factors causing congestion
(a) streams of packets arriving on many
input lines, contending for the same
output line → building up of queue →
memory crunch → loss of packets
(b) slow CPUs on router → queue build
up due to bookkeeping tasks (updating
tables, queuing buffers,…) taking long
time
(c) low
19.01.2016 12:04
bandwidth lines 135
Computer Networks
Network Layer
Network Congestion
Flow control vs. Congestion control
Flow control :
• relates to point-to-point traffic between a
given sender - receiver pair
• is more a local issue
• involves some direct feedback from the
receiver to the sender to inform the
sender to slow down transmission to
facilitate
19.01.2016 12:04
the receiver to handle it 136
Computer Networks
Network Layer
Network Congestion
Flow control vs. Congestion control
Congestion control
• is a global issue
• involves the behaviour of all hosts, all
routers, store-and forward processing
within routers, other factors
Congestion control requirements :
to ensure that subnet is able to carry traffic
19.01.2016 12:04 137
Computer Networks
Network Layer
Network Congestion
Flow Control :
OFC network 1000 Gbps
Supercomputer trying FTP to PC at 1 Gbps
Congestion Control :
Store-and forward network with 1 Mbps lines
1000 large computers
500 computers are trying FTP at 100 Kbps
each to the other 500 computers
19.01.2016 12:04 total offered traffic >> what the network can handle 138
Computer Networks
Network Layer
Congestion Control Algorithms
General principles of Congestion Control
(a) open-loop :
good design : prevention of congestion
no state-related / mid-course corrections
taking prior scheduling decisions at
various points on network regarding …..
when to accept traffic, which packet to
discard & when
two solutions :
(i) increase resources
(c)
(long →response time suffers,
small → more retransmissions)
(no. of queues,
(b) round robin /
priority)
(long →clogging,
small →timeouts)
(GBN vs SR)
(a) (piggyback)
(small window)
19.01.2016 12:04 (#) designed to minimize congestion proactively 148
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion prevention policies (open-loop)
Datalink layer:
(a) re-transmission policy
a sender with a small time out retransmits all
outstanding packets ; using ‘Go-back n’ will
put a heavier load on the system than ….
a sender that uses ‘Selective repeat’
at the receiver, if receiver discards all out-of-
order packets → retransmission → extra load
Selective repeat is better than Go-back n
19.01.2016 12:04 149
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion prevention policies (open-loop)
Datalink layer:
(b) acknowledgement policy :
piggybacking reduces extra traffic…
but if acknowledgements are saved and
wait till piggybacked ….
extra timeouts and retransmissions may result
(c) flow control : tight control with small
window reduces data rate →
better congestion
19.01.2016 12:04
control 150
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion prevention policies (open-loop)
Network layer:
(a) VC vs. datagram inside the subnets -
some algorithms work for one, some
others for other : choice to be clear
(b) packet queuing and service policy -
routers have one queue for input line, one
queue for output line, or both
(c) order of packet processing policy :
round robin or priority - based
19.01.2016 12:04 151
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion prevention policies (open-loop)
Network layer:
(d) packet discard policy :
which to drop when there is no buffer
(e) routing algorithm :
should be able to spread traffic over all lines
(f) packet lifetime management :
long → lost packets may cause clogging,
short → packets timeout → retransmissions
19.01.2016 12:04 152
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion prevention policies (open-loop)
Transport layer:
issues are similar to datalink layer
determining timeout interval across
network is more difficult
too short → extra packets sent unnecessarily
too long → congestion will be reduced,
but response time will suffer whenever
packet is
19.01.2016 12:04
lost 153
Computer Networks
Network Layer
Congestion Control Algorithms
Congestion control in VC subnets (dynamic)
A to B
(one possible route)
(router-2)
2
6
4 to D only here
19.01.2016 12:04 (a) a choke packet that affects only the source 164
Computer Networks
Network Layer
Congestion control in datagram subnets
(c) Hop-by-Hop Choke packets
Consider two hosts A and D (Bangalore to
New Delhi) separated by 2000 Km
i.e. RTT = 20 msec
1 4 impact:
greater demand
F
E reduced flow on the buffers of E
A
5
2 reduced
flow
E
multimedia applications →
desirable to retain newer packets
(new is better than old)
19.01.2016 12:04 169
Computer Networks
Network Layer
(e) Random Early Detection algorithm (RED)
Routers drop packets before (“early”)
situation gets out of control. When ?
Router maintains a running average of its
queue length ; if > threshold →
congestion impending → take action
since router cannot ascertain which
source is causing congestion →
randomly picks packets for discarding
19.01.2016 12:04 170
Computer Networks
Network Layer
(e) Random Early Detection algorithm (RED)
how does the router provide feedback to
the source ? →
(i) by choke packet
(ii) do not send any feedback
source will, anyway, detect missing ACK,
(#)
concludes that the lost packets are generally
due to congestion (i.e. discards), slows
down transmission
19.01.2016 12:04 (#) OK for wired networks; not for wireless networks 171
Computer Networks
Network Layer
(f) RED and Explicit Congestion Notification (ECN)
dropping packets implicitly signals
congestion, but can hurt applications
sensitive to delay / packet loss
in ECN, bits 6 and 7 of IP TOS field are used
one bit is set by source to indicate that it is
ECN-capable and can react to a congestion
notification
the other bit is set by routers when congestion
is encountered and source responds if bit is set
19.01.2016 12:04 172
Computer Networks
Network Layer
Jitter Control
Jitter : variation in packet arrival times
packet no. 8 has been delayed and is not available when its play
slot comes up;
play back must stop until its arrival; creates an annoying gap in
the audio or video
can be improved by delaying the starting time → requires more buffer
19.01.2016 12:04 189
Computer Networks
Network Layer
Quality of Service (QoS)
Buffering (at the receiving side)
as the packets arrive, they are buffered at
the receiver / client system
when to start playing back needs to be
decided : most sites start at 10 seconds
problem of packet no. 8 can be overcome
by delaying the start of replay; but ……
more delay in playing back requires more
buffer space
19.01.2016 12:04 190
Computer Networks
Network Layer
Quality of Service (QoS)
Traffic shaping
non-uniform / irregular transmission of
outputs from source → congestion
Example : server handling many streams
concurrently, allowing fast forward/rewind,
user authentication, …
QoS would be better if servers / hosts can
transmit at uniform rate
traffic shaping smoothes out traffic at
source
19.01.2016 12:04
(server) end 191
Computer Networks
Network Layer
Quality of Service (QoS)
Traffic shaping
regulation of average rate / burstiness of
data transmission
when a connection is set up, customer
and carrier agree upon certain traffic
pattern (SLA)
customer sends as per SLA → carrier
delivers as per SLA ;
carrier monitors traffic flow (traffic policing)
19.01.2016 12:04 192
Computer Networks
Network Layer
Quality of Service (QoS)
Leaky bucket Algorithm each host is connected
to the network by an
interface containing a
leaky bucket i.e. a finite
internal queue
3 packets
Before After leave
1 token = 5 µsecs
in one second, no. of tokens = 2 x 105
No. of bytes per token = 48
= 384 bits
Data rate = 2 x 105 x 384 bps
= 76.8 Mbps
19.01.2016 12:04 212
Computer Networks
Network Layer
Quality of Service (QoS)
Token Bucket Algorithm
burst length = S seconds
token bucket capacity = C bytes
token arrival rate = ρ bytes per second
maximum output rate = M bytes per second
(C + ρS) = MS
S = C ÷ (M - ρ)
19.01.2016 12:04 213
Computer Networks
Network Layer
Quality of Service (QoS)
Token Bucket Algorithm
Example - 2 AT 5.27
C = 8 Mb
M = 6 Mbps
ρ = 1 Mb / sec
S = C ÷ (M - ρ)
S = 1.6 seconds
Given :
Max. packet size = 1000 bytes
Token bucket rate = 10 million bytes / sec
Token bucket size = 1 million bytes
Max. transmission rate = 50 million bytes/sec
Compute :
how long can a burst at maximum speed last
19.01.2016 12:04 216
Computer Networks
Network Layer
Quality of Service (QoS)
Token Bucket Algorithm
Example - 3 AT 5.28
ρ = 10 MB / sec
C = 1 MB
M = 50 MB / sec
S = length of burst = C ÷ (M - ρ)
= (1 MB) ÷ (50 - 10 MB / sec) = 25 msec
Source
3
Example : AT 5.30
multicast receivers
Reservations :
R3 : 2 Mbps
R2 : 3 Mbps
R1 : 3 Mbps
reservation of bandwidth in a router
should meet the requirement of the
highest flow through it
19.01.2016 12:04 256
Computer Networks
Network Layer
Quality of Service (QoS)
Integrated Services
S1 S2 S1 S2 S1 S2
RSVP :
R3 R4 R5 R3 R4 R5 R3 R4 R5
R3 to S1 R3 to S1 R3 to S1
R3 to S2 R3 to S2
19.01.2016 12:04 R5 to S1 257
Computer Networks
Network Layer
Quality of Service (QoS)
Integrated Services
RSVP :
(a) R3 requests a channel to S1 →
reservation is done
(b) R3 requests another channel, this time
to S2, for receiving a separate
stream → reservation is done
(c) two separate channels are required
from R3 to E, since two streams are
different
19.01.2016 12:04 258
Computer Networks
Network Layer
Quality of Service (QoS)
Integrated Services
RSVP :
(d) R5 also decides to receive stream
being transmitted from S1
(e) dedicated bandwidth is reserved upto
router H
(f) router H sees that due to its already
having a feed from S1, bandwidth is
already reserved…no more reservation
19.01.2016 12:04 259
Computer Networks
Network Layer
Quality of Service (QoS)
Integrated Services
RSVP :
(g) if R3 {see (a)} and R5 {see (d)} have
sought different bandwidths, higher of
these to bandwidths is to be allotted
Example : → →
multicast senders
multicast receivers
S1 S2
multicast senders
1 A 2
2
C 1
E 3
3
H 3
3 J 3
K 2
3 2 1 L 1
multicast receivers
R3 R4 R3 R5
Network
19.01.2016 12:04 2-S1 2-S1 1-S2 1-S2 263
Computer Networks
Network Layer
Quality of Service (QoS)
Issues with Integrated Services
flow-based algorithms : demerits
• require advance set up to establish each flow
so, scalability to large no. of flows is a problem
• maintain internal per-flow states in
routers, vulnerable to router crashes
• changes required to router code are
high, involves complex router-to-router
exchanges for setting up flows
19.01.2016 12:04 class-based → → → 264
Computer Networks
Network Layer
Quality of Service (QoS)
Differentiated Services (DS)
class-based methods RFC 2474, 2475, …
simpler approach to easy QoS
implementation - locally in each router
without any of the following issues :
(a) advance setup easy to
(b) involving the whole path implement
(c) reservation
(d) time consuming end-to-end negotiation
with each flow
19.01.2016 12:04 265
Computer Networks
Network Layer
Quality of Service (QoS)
Differentiated Services (DS)
DS can be offered by a set of routers
forming an administrative domain (eg. ISP)
a set of service classes with corresponding
forwarding rules is defined by administration
customer packets entering a domain carries
a Type of Service field { e.g. premium (better),
ordinary, .. }
classes may differ in terms of delay, jitter,
discarding
19.01.2016 12:04
in the event of congestion 266
Computer Networks
Network Layer
Quality of Service (QoS)
Differentiated Services (DS)
(a) Expedited forwarding : RFC 3246