Unit 4 (3150710 - Computer Networks)
Unit 4 (3150710 - Computer Networks)
Unit - 4
Network Layer
I N T RO D U C T I O N : N E T WO R K L AY E R
applicatio
ntransport
d
networ
kata link
To deliver segment from
physical
networ
sending to receiving
host/ router.
networ
d
kata d
kata
networ link
link
physic
d
kata
al physic On sending side,
link
physic networ alnetwor
al dkata kata
d encapsulates
it segments
link
physic
al
link
physic into datagrams.
networ
al
networ
On receiving side,
d
kata
dkata
link
physic
n twor
link delivers segments it
al e k
data
link
physic
physic
al transport layer. to
al applicatio Network layer
networ
d
kata networ
ntranspo
rt in every host and router.
protocols
link
physic networ
data Router examines header
networ kata
d
kata
d al link
physic k
physical
link
physic
al
al link
fields in all IP
datagrams passing
through it.
K E Y F U N C T I O N O F N E T WO R K L AY E R
Role of the network layer is simple - to move packets
from a sending host to a receiving host.
Two important network layer functions can
be identified:
1. Forwarding
⚫ When a packet arrives at a router’s input link, the router
must move the packet to the appropriate output link.
2. Routing
⚫ It’s a process of selecting best paths in a network.
⚫ The network layer must determine the route or path taken
by packets as they flow from a sender to a receiver.
⚫ The algorithms that calculate these paths are referred to
as routing algorithms.
R O U T I N G A N D F O RWA R D I N G
value in
arriving
packet’s 1
011
header 1
3 2
N E T WO R K S E RV I C E M O D E L
Services provided by network layer for individual
datagrams.
Guaranteed delivery
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
2. Data transfer
3. V C teardown
applicatio applicatio
6. receive
ntranspor 5. data flow ntranspor
data
tnetwork begins tnetwork
data link 4. call 3. accept
data link
connected call
physical physical
1. initiate call 2. incoming
call
D ATAG R A M N E T WO R K
In connectionless service, packets are injected
into the subnet individually and routed
independently of each other.
No advance setup is needed. The packets are
frequently called datagrams and the subnet is
called a datagram subnet.
Only directly-connected lines can be used.
applicatio applicatio
ntranspor ntranspor
tnetwork 1. send tnetwork
2. receive
data link datagrams datagrams data link
physical physical
D ATAG R A M N E T WO R K VS. V I RT UA L C I R C U I T N E T WO R K
lookup,
link forwardi
line layer ng switc
terminati protoco h
on l fabri
(receiv queuein
c
e) g
It performs the physical layer function of terminating an incoming
physical link at a router.
It performs link-layer functions needed to interoperate with the
link layer at the other side of the incoming link; this is represented
by the middle boxes in the input and output ports.
A lookup function is performed at the input port;
⚫ this will occur in the rightmost box of the input port.
Goal: Complete input port processing at line speed
Queuing: If datagrams arrive faster than forwarding rate into
switch fabric
I N P U T P O RT F U N C T I O N S – C O N T …
The forwarding table is consulted to determine
the router output port to which an arriving
packet will be forwarded via the switching fabric.
Control packets (for example, packets carrying
memor
y
memor bu crossba
y s r
S W I T C H I N G VIA M E M O RY
input output
port port
memory
(e.g., (e.g.,
Etherne Etherne
t) t)
system bus
datagra
switc m link
h buffer layer line
fabri protoc terminati
c queuein ol on
g (send)
functions.
I N T E R N E T N E T WO R K L AY E R
ICMP protocol
• error reporting
• router
“signaling”
link layer
physical layer
IP V 4 D ATAG R A M F O R M AT
IP protocol 32
version numb total
bits datagram
er header
length ver head. type lengt length
( h fragme (bytes)
of flg
bytes len nt for
time uppe s heade
) offset fragmentati
“type” r
to service checksu
r
live laye on/
of data 16-bit32 bit source IP m reassembly
r
address
identifier
max 32 bit destination IP
number address
remaining options (if e.g.
hops any) timestamp,
how much overhead? data record route
(decremented
20 bytes of
at TCP
each (variable taken,
20 bytes ofrouter)
length, specify list
IP
typically a TCP of routers to
= 40 bytes
upper+layer visit.
application or UDP
protocol to segment)
layer
deliver payload
overhead to
F R AG M E N TAT I O N
E X A M P LE
An IP datagram of size 1000 bytes arrives at a router. The router has to
forward this packet on a link whose M T U (maximum transmission unit) is 100
bytes. Assume that the size of the IP header is 20 bytes. The number of
fragments that the IP datagram will be divided into for transmission is :
Note : This question was asked as Numerical Answer Type.
(A) 10
(B) 50
(C) 12
(D) 13
172 16 254
14.23.120.8 Class A
252.5.15.111
33
C L A S S I F I C AT I O N O F IP A D D R E S S E S
Class: A
(C L A S S F U L A D D R E S S I N G )
0
7 Bit 24 Bit
Fix Network ID Host ID
Class: B
10
Fix 14 Bit 16 Bit
Network ID Host ID
Class: C
11 0
Fix 21 Bit 8 Bit
Network ID Host ID
Class: D
11 10
F ix
Class: E Multicast address
11 11
F ix Reserved address
Example
11 0
Fix
19.49
IP A D D R E S S I N G S U M M ARY
Leadi
Size
of netwo
Size
Number Addresses
Default sub
net CIDR
of rest Total Start
Class ng rk of per addresses E n d address mask in dot notati
bit address
bits number networks network in class -decimal on
field
bit field notation
Exam
Curricular Academic
Placement
SUBNETTING 2^n=2^2=4
n=2
200.10.20. _ _ _ _ _ _ _ _ s1 s2
200.10.20.00
s4 s3
200.10.20.01000000(64)
200.10.20.01111111(127)
200.10.20.10
200.10.20.11
255.255.255.11000000(192) WWW
200.10.20.0
TYPE OF ADDRESSES – C O N T …
C L A S S L E S S I N T E R -D O M A I N R O U T I N G (CIDR)
C I D R is a slash notation of subnet mask. C I D R tells
us number of on bits in a network address.
subn hos
et t
11001000 00010111
part par
00010000
t
00000000
200.23.16.0/23
A single IP address can be used to designate many
unique IP addresses with C IDR .
A C I D R IP address looks like a normal IP address
except that it ends with a slash followed by a number,
called the IP network prefix.
C I D R addresses reduce the size of routing tables and
make more IP addresses available within
organizations.
SUBNETTING
Subnetting places when we extend the
default subnet mask.
take
We cannot perform subnetting with default
subnet mask and every classes
subnet mask. have default
Now find the host bits borrowed to create subnets
and convert them in decimal.
For example find the subnet mask of
address 188.25.45.48/20 ?
1. Class B, Default Subnet mask: 255.255.0.0
2. Borrowed 4 bit from host part so mask is now:
11111111 11111111 11110000 00000000
255 255 240
0
H OW MANY S UBNETS FROM GIVEN
S U B N E T M AS K ?
To calculate the number of subnets provided by
given subnet mask we use 2 N , where N = number
of bits borrowed from host bits to create subnets.
For example in 192.168.1.0/27, N is 3.
hosts
H is the number of host bits
We have 32 - 26
Total subnets ( 2 N ) : 21 = 2
= 126
D Y NA M I C H O S T C O N F I G U R AT I O N P RO T O C O L - D H C P
Dynamic Host Configuration Protocol is
protocol
a for assigning dynamic IP addresses to
devices on a network.
DHCP
223.1.1.0/24
server
223.1.1. 223.1.2.
1 1
223.1.3. 223.1.3.
1 2
223.1.3.0/24
DHCP – CONT…
With dynamic addressing, a device can have a
different IP address every time it connects to the
network.
In some systems, the device's IP address can even
network.
D H C P C L I E N T S E RV E R I N T E R AC T I O N
DHCP server: DHCP discover arrivin
223.1.2.5 g
src : 0.0.0.0, 68
Broadcast:
dest.:is there
clien
a DHCP server out
255.255.255.255,67 t
yiaddr:
there? 0.0.0.0
transaction ID: 654
DHCP offer
src: 223.1.2.5, 67
Broadcast:
dest: I’m a
DHCP server!
255.255.255.255, 68
yiaddrr: 223.1.2.4
Here’s an IP
transaction ID: 654
DHCP request address yousecs
lifetime: 3600 can
src: 0.0.0.0, 68
use
dest::
Broadcast: OK.
255.255.255.255, 67
I’ll take
yiaddrr: 223.1.2.4
that IP address!
transaction ID: 655
lifetime: 3600 secs
DHCP ACK
src: 223.1.2.5, 67
dest:
Broadcast: OK.
255.255.255.255, 68
You’ve got that
yiaddrr: 223.1.2.4 IP
address!
transaction ID: 655
lifetime: 3600 secs
N E T WO R K A D D R E S S T R A N S L AT I O N
NAT is a method that is used to translate
Private IP addresses to Public IP addresses.
rest local network
of (e.g., home
Intern network) 10.0.0.
et 1
10.0.0/24
10.0.0.4 10.0.0.
2
138.76.29
.7
10.0.0.
3
problems:
⚫ Solve shortage of IPv4 IP addresses
⚫ To Hide the Network Address
NAT T E R M I N O L O GY
Inside Local Address: The name of the inside
source address before translation. This would be a
Private IP.
Inside Global Address: The name of the inside host
after translation. This would be the Public IP.
Outside Local Address: The name of the
destination host before translation.
Outside Global Address: The name of the
destination host after translation.
Where:
⚫ Global Addresses → Public
⚫ Local Addresses → Private
⚫ Inside Hosts → Within Local Network
⚫ Outside Hosts → Outside Local Network
NAT – C O N T …
IPv4 IPv6
32 bit length 128 bit length
Fragmentation is by Fragmentation is done only by sender
done sender
and
fNoorwparcdkientgflroowutiedresntificati
Packet flow identification is available
on
within the IPv6 header using the Flow
Checksum field in header LNaobcehlefcei klsdum field in header
v 3 w
2 5
u 2 1 z
3
1 2
x 1
y
D I J KS T R A ’ S A L G O R I T H M – E XA M P LE :2
v
u z
w
x y
8
4
R4 R5
R2
7
3 R3 4
Visited R1 R2 R3 R4 R5
R1 0 4 🙙 8 🙙
R1,R2 7 8 🙙
R1,R2,R3 Min(11,8)= 🙙
8
R1,R2,R3, Min(18,15)
R4 =15
D I S TA N C E V E C T O R A L G O R I T H M
Distance-vector (DV) algorithm is iterative,
asynchronous, and distributed.
It is distributed in that each node receives some
information from one or more of its directly
attached neighbours, performs a calculation, and
then distributes the results of its calculation back
to its neighbours.
It is iterative. so, process continues on until no
more information is exchanged between
neighbours.
The algorithm is asynchronous. It does not
require all of the nodes to operate with each
other.
D I S TA N C E V E C T O R A L G O R I T H M – C O N T …
Let dx(y) be the cost of the least-cost path
from node x to node y.
Then least costs are related by the
celebrated Bellman-Ford equation:
dx(y) = cost of least-cost path from x to y then
dx(y) = min {c(x,v) + dv(y) }
v
4-
81
D I S TA N C E V E C T O R A L G O R I T H M – C O N T …
each node:
recompute estimates
from
from
y ∞∞ = min{2+0 , 7+1} = 2
y 3
∞ 2 0 1 Dx(z) = min{c(x,y) +
node y
z ∞ ∞ to
cost z 7 1 0
table x y Dy(z), c(x,z) +
∞
z Dz(z)}
x
∞ ∞
2 0 = min{2+1 , 7+0} =
fro
m
1
y ∞ 3
y
∞∞ 2 1
Table for Router X
node z ∞cost to
x y D est. D ist. N ext
x z
table z 7
x ∞∞ X. 0 X
∞
from
y ∞∞
Y. 2 Y
∞ Z. 7 Z tim
z 7 1 0 e
D I S TA N C E V E C T O R A L G O R I T H M -
noEdeXxAMcoP cost to cost to
x y
stLtoE
table x y z x y
z z
x 0 2 7 x x 0 2 3
0 2
from
from
from
y ∞∞ y 2 0 y
y 3 2 1
∞ 2 0 1 1
node y
x z
z ∞ ∞ to
cost z 7 cost
1 to0 z 7
table x y x y 3cost
1 to0
∞ x y
z z z
x 0 2 7 x 0 2
x ∞ ∞
from
∞ 2 0 3
from
fro
y 2 0 1
m
1
y y 2 0
∞∞ z 7 1
1 cost to
node zz ∞cost to 0 cost to
x y x y z x3 y1
table z
x ∞∞ x z0 2 x0 z0 2 3
from
7
from
∞ y 2 0 1
from
y ∞∞ y 2 0 z 3 1 0
∞ 1 time
z 7 1 0
Table for R5
1) Only neighbor
Dest. Dist. Next R1
2) Only Distance Vector
Table for R1
R1 🙘 -
Dest. Dist. Next
R2 3 R2
R1 0 R1
R3 🙘 - 1
3 R2 1 R2
R4 4 R4 R5 R2 R3 🙘 -
R5 0 R5
R4 🙘 -
R5 🙘 -
Dist Dist
1 At R1 R1 New RT
1 4 6 R2 Dist.
0
Dest. Dist. Next
0 6 Dist
🙘 R1 0 R1
1
6
3 R2 1 R2
0
🙘 R4 2 6 R3 7 R2
R3 🙘 R4 🙘 -
3
3
R5 4 R2
DIFFERENCE: L S AND DV ROUTING ALGORITHM
Updates are sent to directly Update are sent to entire network & to
connected neighbour only just directly connected neighbour
Routers don't have end to end Routers have visibility of entire network of
visibility of entire network. that area only.
It is prone to routing loops No routing loops
H I E R A RC H I C A L R O U T I N G
As networks grow in size, the router routing
tables grow proportionally.
Router memory, C P U time and more bandwidth