Unit-4: Network Layer
Unit-4: Network Layer
Computer Networks
Unit-4
Network Layer
value in arriving
packet’s header
0111 1
3 2
1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …
application application
5. data flow begins 6. receive data
transport transport
network 4. call connected 3. accept call
1. initiate call network
data link 2. incoming call
data link
physical physical
application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical
State Information None other than router table Route established at setup, all
containing destination network packets follow same route.
Effect of Router Only on packets lost during All virtual circuits passing through
Failure crash failed router terminated.
Congestion Control Difficult since all packets routed Simple by pre-allocating enough
independently router resource buffers to each virtual circuit at
requirements can vary. setup, since maximum number of
circuits fixed.
memory
system bus
link layer
physical layer
172 16 254 1
16,777,216 2,147,483,648
Class A 0 8 24 128 (27) 0.0.0.0 127.255.255.255 255.0.0.0 /8
(224) (231)
2,097,152 536,870,912
Class C 110 24 8 256 (28) 192.0.0.0 223.255.255.255 255.255.255.0 /24
(221) (229)
223 1 1 1
Unit: 4 – Network Layer 33 Darshan Institute of Engineering & Technology
Subnet
223.1.1.0/24
Subnet: high order bits defines 223.1.2.0/24
subnet 223.1.1.1
✔ E.g.: 10.0.0.255
223.1.2.0/24
223.1.3.1 223.1.3.2
223.1.3.0/24
Unit: 4 – Network Layer 44 Darshan Institute of Engineering & Technology
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 change while it
is still connected.
It allows reuse of addresses (only hold address while connected
“on”).
It also support mobile users who want to join network.
DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP
dest: 255.255.255.255, 68
server!
yiaddrr:Here’s an IP
223.1.2.4
transaction
address youID:can
654use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. 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
Broadcast:
dest: OK. You’ve
255.255.255.255, 68
yiaddrr: 223.1.2.4
got that IPID:
transaction address!
655
lifetime: 3600 secs
10.0.0.4
10.0.0.2
138.76.29.7
10.0.0.3
5
3
v w 5
2
u 2 1 z
3
1 2
x 1
y
v w
u z
x y
recompute estimates
from
from
y ∞∞ ∞ y 2 0 1
z ∞∞ ∞ z 7 1 0
Dx(z) = min{c(x,y) +
node y cost to
table x y z Dy(z), c(x,z) + Dz(z)}
x ∞ ∞ ∞ = min{2+1 , 7+0} = 3
y 2 0 1
from
z ∞∞ ∞
y
2 1
node z cost to
table x y z x z
7
x ∞∞ ∞
from
y ∞∞ ∞
z 7 1 0
time
Unit: 4 – Network Layer 62 Darshan Institute of Engineering & Technology
Distance Vector Algorithm - Example
node x cost to cost to cost to
table x y z x y z x y z
x 0 2 7 x 0 2 3 x 0 2 3
from
from
y ∞∞ ∞ y 2 0 1 y 2 0 1
from
y
z ∞∞ ∞ z 7 1 0 z 3 1 0 2 1
node y cost to
x z
cost to cost to 7
table x y z x y z x y z
x ∞ ∞ ∞ x 0 2 7 x 0 2 3
from
y 2 0 1 y 2 0 1
from
y 2 0 1
from
z ∞∞ ∞ z 7 1 0 z 3 1 0
from
y 2 0 1 y 2 0 1
from
y ∞∞ ∞
z 7 1 0 z 3 1 0 z 3 1 0
time
Unit: 4 – Network Layer 63 Darshan Institute of Engineering & Technology
Difference: LS and DV Routing Algorithm
Distance Vector Protocol Link State Protocol
Entire routing table is sent as an update Updates are incremental & entire routing table is
not sent as update
Distance vector protocol send periodic Updates are triggered not periodic
update at every 30 or 90 second
Update are broadcasted Updates are multicasted
Updates are sent to directly connected Update are sent to entire network & to just
neighbour only directly connected neighbour
Routers don't have end to end visibility Routers have visibility of entire network of that
of entire network. area only.
It is prone to routing loops No routing loops