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

Unit-4: Network Layer

This document summarizes key aspects of the network layer: 1. The network layer is responsible for delivering data segments from sending to receiving hosts/routers by encapsulating segments into datagrams. 2. Its key functions are forwarding, where routers move packets to the appropriate output link, and routing, where the best path through the network is determined. 3. It provides services for both individual datagrams like guaranteed delivery and for flows of datagrams like in-order delivery and minimum bandwidth. Virtual circuit switching uses connection state in routers to forward packets.

Uploaded by

Nilesh Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
224 views

Unit-4: Network Layer

This document summarizes key aspects of the network layer: 1. The network layer is responsible for delivering data segments from sending to receiving hosts/routers by encapsulating segments into datagrams. 2. Its key functions are forwarding, where routers move packets to the appropriate output link, and routing, where the best path through the network is determined. 3. It provides services for both individual datagrams like guaranteed delivery and for flows of datagrams like in-order delivery and minimum bandwidth. Virtual circuit switching uses connection state in routers to forward packets.

Uploaded by

Nilesh Patil
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 73

2140709

Computer Networks

Unit-4
Network Layer

Prof. Maulik D. Trivedi


9998265805
[email protected]
Introduction: Network Layer
application  To deliver segment from
transport
network
data link
sending to receiving host/
physical
network network router.
data link data link
network
data link
physical physical
 On sending side, it
physical network network
data link
physical
data link
physical
encapsulates segments into
datagrams.
network network
data link
physical
data link
physical
 On receiving side, it delivers
network
data link
physical
segments to transport layer.
network
application
transport  Network layer protocols in
data link network network
network
data link
physical data link
physical
data link
physical
every host and router.
physical
 Router examines header fields
in all IP datagrams passing
through it.
Unit: 4 – Network Layer 2 Darshan Institute of Engineering & Technology
Key Function of Network Layer
 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.

Unit: 4 – Network Layer 3 Darshan Institute of Engineering & Technology


Routing and Forwarding
routing algorithm routing algorithm determines
end-end-path through network

local forwarding table forwarding table determines


header value output link local forwarding at this router
0100 3
0101 2
0111 2
1001 1

value in arriving
packet’s header
0111 1

3 2

Unit: 4 – Network Layer 4 Darshan Institute of Engineering & Technology


Network Service Model
 Services provided by network layer for individual datagrams.
 Guaranteed delivery
✔ This service guarantees that the packet will eventually arrive at its
destination.
 Guaranteed delivery with bounded delay
✔ This service not only guarantees delivery of the packet, but delivery within
a specified host-to-host delay bound.

Unit: 4 – Network Layer 5 Darshan Institute of Engineering & Technology


Network Service Model – Cont…
 Services provided by network layer for a flow of datagrams.
 In-order packet delivery
✔ This service guarantees that packets arrive at the destination in the order
that they were sent.
 Guaranteed minimal bandwidth
✔ This network-layer service emulates the behaviour of a transmission link of
a specified bit rate (for example, 1 Mbps) between sending and receiving
hosts.
✔ As long as the sending host transmits bits at a rate below the specified bit
rate, then no packet is lost.

Unit: 4 – Network Layer 6 Darshan Institute of Engineering & Technology


Network Service Model – Cont…
 Guaranteed maximum jitter
✔ This service guarantees that the amount of time between the transmission
of two successive packets at the sender is equal to the amount of time
between their receipt at the receiver.
 Security services
✔ Using a secret session key known only by a source and destination host, the
network layer in the source host could encrypt the payloads of all
datagrams being sent to the destination host.
✔ The network layer in the destination host would then be responsible for
decrypting the payloads.

Unit: 4 – Network Layer 7 Darshan Institute of Engineering & Technology


Virtual Circuit Switching
 A VC consists of
1. A path between the source and destination hosts
2. VC numbers, one number for each link along the path
3. Entries in the forwarding table in each router along the path
 A packet belonging to a virtual circuit will carry a VC number in its
header.
 VC number can be changed on each link
✔ New VC number comes from forwarding table

Unit: 4 – Network Layer 8 Darshan Institute of Engineering & Technology


VC Forwarding Table
12 22 32
1 3
2
VC number
interface
forwarding table in number
router:
Incoming interface Incoming VC # Outgoing interface Outgoing VC #

1 12 3 22
2 63 1 18
3 7 2 17
1 97 3 87
… … … …

VC routers maintain connection state information


Unit: 4 – Network Layer 9 Darshan Institute of Engineering & Technology
Virtual Circuit Setup
There are three identifiable phases in a virtual circuit:
1. VC setup
2. Data transfer
3. VC teardown

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

Unit: 4 – Network Layer 10 Darshan Institute of Engineering & Technology


Datagram Network
 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.

application application
transport transport
network 1. send datagrams 2. receive datagrams network
data link data link
physical physical

Unit: 4 – Network Layer 11 Darshan Institute of Engineering & Technology


Datagram Network vs. Virtual Circuit Network

Datagram Virtual Circuit


Connection Setup None Required
Addressing Packet contains full source and Each virtual circuit number entered
destination address to table on setup, used for routing.

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.

Unit: 4 – Network Layer 12 Darshan Institute of Engineering & Technology


Router Architecture
 Routers have four components:
1. Input ports
2. Switching fabric
3. Output ports
4. Routing processor

Unit: 4 – Network Layer 13 Darshan Institute of Engineering & Technology


Input Port Functions
lookup,
link forwarding
line layer switch
termination protocol fabric
(receive)
queueing

 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.
Unit: 4 – Network Layer 14 Darshan Institute of Engineering & Technology
Input Port Functions – Cont…
 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 routing protocol
information) are forwarded from an input port to the routing
processor.

Unit: 4 – Network Layer 15 Darshan Institute of Engineering & Technology


Switching Fabrics
 It connects the router’s input ports to its output ports.
 It is completely contained within the router - a network inside of a
network router.
 Switching rate: A rate at which packets can be transfer from inputs
to outputs.
 Also measured as multiple of input/output line rate.
 Three types of switching fabrics:

memory

memory bus crossbar

Unit: 4 – Network Layer 16 Darshan Institute of Engineering & Technology


Switching via Memory
input output
port memory port
(e.g., (e.g.,
Ethernet) Ethernet)

system bus

 Like traditional computers, with switching between input and


output ports being done under direct control of the CPU (routing
processor).
 Packet signalled a routing processor via an interrupt then copied
from the input port into processor memory.

Unit: 4 – Network Layer 17 Darshan Institute of Engineering & Technology


Switching via Memory – Cont…
 Routing processor extracted the destination address from the
header, from forwarding table, and copied the packet to the
output port’s buffers.
 If the memory bandwidth is such that B packets per second can be
written into, or read from, then the overall forwarding throughput
must be less than B/2.
 Two packets cannot be forwarded at the same time, even if they
have different destination ports.
 Only one memory read/write over the shared system bus can be
done at a time.

Unit: 4 – Network Layer 18 Darshan Institute of Engineering & Technology


Switching via bus
 An input port transfers a packet to the output
port over a shared bus, without intervention
by the routing processor.
 The packet is received by all output ports, but
only the port that matches the label will keep
the packet.
 The label is then removed at the output port,
and only used within the switch to cross the bus
bus.
 Switching speed of the router is limited to the
bus speed.

Unit: 4 – Network Layer 19 Darshan Institute of Engineering & Technology


Switching via an interconnection network
 Crossbar switch consists 2N buses.
 N input ports to N output ports.
 Its overcome the bandwidth limitation of
shared bus; used to interconnect processors in
a multiprocessor computer architecture.
 Cross-point connection can be opened or
closed at any time by the switch fabric
controller.
 Crossbar networks are capable of forwarding
multiple packets in parallel.

Unit: 4 – Network Layer 20 Darshan Institute of Engineering & Technology


Output Port
datagram
switch buffer link
fabric layer line
protocol termination
queueing (send)

 It buffers packets received from the switching fabric and transmits


these packets on the outgoing link.
 Packets can be lost due to congestions lacks of buffers.
 When a link is bidirectional, an output port will typically be paired
with the input port for that link on the same line card.

Unit: 4 – Network Layer 21 Darshan Institute of Engineering & Technology


Routing Processor
 The routing processor executes the routing protocols, maintains
routing tables and attached link state information and computes
the forwarding table for the router.
 It also performs the network management functions.

Unit: 4 – Network Layer 22 Darshan Institute of Engineering & Technology


Internet Network Layer

transport layer: TCP, UDP

routing protocols IP protocol


 path selection  addressing conventions
 RIP, OSPF, BGP  datagram format
network  packet handling conventions
layer forwarding
table
ICMP protocol
 error reporting
 router “signaling”

link layer

physical layer

Unit: 4 – Network Layer 23 Darshan Institute of Engineering & Technology


IPv4 Datagram format
IP protocol version 32 bits
number total datagram
header length length (bytes)
ver head. type of length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flgs
offset reassembly
max number time to upper header
remaining hops live layer checksum
(decremented at
32 bit source IP address
each router)
32 bit destination IP address
upper layer protocol
to deliver payload to options (if any) e.g. timestamp,
record route
how much overhead? data taken, specify
 20 bytes of TCP (variable length, list of routers
 20 bytes of IP
typically a TCP to visit.
 = 40 bytes +
or UDP segment)
application layer
overhead
Unit: 4 – Network Layer 24 Darshan Institute of Engineering & Technology
IP Address
 IP addresses are useful in identifying a specific host in a network.
 IP addresses are 32 bit numbers which are divided into 4 octets.
Each octet represents 8 bit binary number.
 Below is an example of an IP address:

10101100 00010000 11111110 00000001

172 16 254 1

IP addresses are divided into 2 parts:


Network ID & Host ID
<NID> <HID> = IP Address

Unit: 4 – Network Layer 25 Darshan Institute of Engineering & Technology


Classification of IP Addresses (Classful Addressing)
Class: A
0
7 Bit 24 Bit
Fix Network ID Host ID
Class: B
1 0
Fix 14 Bit 16 Bit
Network ID Host ID
Class: C
1 1 0
Fix 21 Bit 8 Bit
Network ID Host ID
Class: D
1 1 1 0
Fix
Class: E Multicast address
1 1 1 1
Fix Reserved address
Unit: 4 – Network Layer 26 Darshan Institute of Engineering & Technology
Class A: (0.0.0.0 to 127.255.255.255)
0
7 Bit 24 Bit
Network ID Host ID
 Only 126 addresses are used for network address.
 All 0’s and 1’s in Network-ID are dedicated for special IP address.
So, total number of IP address in class A can be represented:
0.0.0.0 Special IP Address
00000001.0.0.1
1.0.0.2
1.0.0.3
.
. 224 – 2 are Host IP
.
126.255.255.254

127.255.255.255 Special IP Address – Loopback

Unit: 4 – Network Layer 27 Darshan Institute of Engineering & Technology


Class B: (128.0.0.0 to 191.255.255.255)
1 0
Fix 14 Bit 16 Bit
Network ID Host ID
 No special network address here. All are usable.

128.0.0.0 Special IP Address


10000001.0.0.1
130.0.0.2
130.0.0.3
.
. 216 – 2 are Host IP
.
190.255.255.254

10111111.255.255.255 Special IP Address – Loopback

Unit: 4 – Network Layer 28 Darshan Institute of Engineering & Technology


Class C: (192.0.0.0 to 223.255.255.255)
1 1 0
Fix 21 Bit 8 Bit
Network ID Host ID

192.0.0.0 Special IP Address


11000001.0.0.1
194.0.0.2
194.0.0.3
.
. 28 – 2 are Host IP
.
222.255.255.254

11011111.255.255.255 Special IP Address – Loopback

Unit: 4 – Network Layer 29 Darshan Institute of Engineering & Technology


Class D: (224.0.0.0 to 239.255.255.255)
 Very first four bits of the first octet in Class D IP addresses are set
to 1110, giving a range of:

 Class D has IP address rage from 224.0.0.0 to 239.255.255.255.


 Class D is reserved for Multicasting.
 In multicasting data is not destined for a particular host, that is
why there is no need to extract host address from the IP address,
and Class D does not have any subnet mask.

Unit: 4 – Network Layer 30 Darshan Institute of Engineering & Technology


Class E: (240.0.0.0 to 255.255.255.255)
 This IP Class is reserved for experimental purposes only for R&D or
Study.
 IP addresses in this class ranges from 240.0.0.0 to
255.255.255.254.
 Like Class D, this class too is not equipped with any subnet mask.

Unit: 4 – Network Layer 31 Darshan Institute of Engineering & Technology


IP Addressing Summary
Size Default subnet
Size
Class Leading of network of rest Number Addresses Total addresses Start End address mask in dot- CIDR
bits number bit of networks per network in class address decimal notation
bit field
field notation

    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)

    16,384     65,536     1,073,741,824


Class B     10     16     16 128.0.0.0 191.255.255.255 255.255.0.0 /16
(214) (216) (230)

    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)

Class D     not     not     not     not     268,435,456 not


(multicast)     1110
224.0.0.0 239.255.255.255 not defined
defined defined defined defined (228) defined

Class E     not     not     not     not     268,435,456 not


    1111 240.0.0.0 255.255.255.255 not defined
(reserved) defined defined defined defined (228) defined

Unit: 4 – Network Layer 32 Darshan Institute of Engineering & Technology


IP Addressing - Example
 IP address: It is 32-bit 223.1.1.1

identifier for host, router 223.1.2.1


223.1.1.2
interface
 Interface: It is a connection 223.1.1.4 223.1.2.9

between host/router and


physical link. 223.1.1.3
223.1.3.27
223.1.2.2
✔ A router’s typically have
multiple interfaces
✔ A host typically has one or two
223.1.3.1 223.1.3.2
interfaces
 IP addresses associated with
each interface.
223.1.1.1 = 11011111 00000001 00000001 00000001

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

 Host: low order bits defines host


223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
 To determine the subnets, detach
each interface from its host or 223.1.2.2
router. 223.1.1.3 223.1.3.27

 Creating islands of isolated subnet


networks, with interfaces
terminating the end points of the 223.1.3.1 223.1.3.2
isolated networks.
 Each of these isolated networks is
223.1.3.0/24
called a subnet.
Network consisting of 3 subnets

Unit: 4 – Network Layer 34 Darshan Institute of Engineering & Technology


Type of addresses in IPv4 Network
 Network address - The address by which we refer to the network.
✔ E.g.: 10.0.0.0

 Broadcast address - A special address used to send data to all


hosts in the network.
✔ The broadcast address uses the highest address in the network range.

✔ E.g.: 10.0.0.255

 Host addresses - The addresses assigned to the end devices in the


network.
✔ E.g.: 10.0.0.1

Unit: 4 – Network Layer 35 Darshan Institute of Engineering & Technology


Type of addresses – Cont…

Unit: 4 – Network Layer 36 Darshan Institute of Engineering & Technology


Classless Inter-Domain Routing(CIDR)
 CIDR is a slash notation of subnet mask. CIDR tells us number of on
bits in a network address.
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23

 A single IP address can be used to designate many unique IP


addresses with CIDR.
 A CIDR IP address looks like a normal IP address except that it ends
with a slash followed by a number, called the IP network prefix.
 CIDR addresses reduce the size of routing tables and make more IP
addresses available within organizations.
Unit: 4 – Network Layer 37 Darshan Institute of Engineering & Technology
Subnetting
 Subnetting take places when we extend the default subnet mask.
 We cannot perform subnetting with default subnet mask and
every classes have default subnet mask.
 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

Unit: 4 – Network Layer 38 Darshan Institute of Engineering & Technology


How many subnets from given subnet mask?
 To calculate the number of subnets provided by given subnet
mask we use 2N , where N = number of bits borrowed from host
bits to create subnets.
 For example in 192.168.1.0/27, N is 3.
 By looking at address we can determined that this address is
belong to class C and default subnet mask 255.255.255.0 [/24 in
CIDR].
 In given address we borrowed 27 - 24 = 3 host bits to create
subnets.
 Now 23 = 8, so our answer is 8.

Unit: 4 – Network Layer 39 Darshan Institute of Engineering & Technology


What are the valid subnets?
 Calculating valid subnet is two steps process.
 First calculate total subnet by using formula 2N.
 In second step find the block size and count from zero in block
until subnet mask value.
 For example calculate the valid subnets for 192.168.1.0/26
1. Borrowed host bits are 2 [26-24]
2. Total subnets are 22 = 4
3. Subnet mask would be 255.255.255.192
4. Block size would be 256-192 = 64
5. Start counting from zero at blocks of 64, so our valid subnets would be
0,64,128,192

Unit: 4 – Network Layer 40 Darshan Institute of Engineering & Technology


What are the total hosts?
 Total hosts are the hosts available per subnet
 To calculate total hosts use formula 2H = Total hosts
 H is the number of host bits
 For example in address 192.168.1.0/26
 We have 32 - 26
1. [Total bits in IP address - Bits consumed by network address] = 6
2. Total hosts per subnet would be 26 = 64

Unit: 4 – Network Layer 41 Darshan Institute of Engineering & Technology


Network Prefixes
 For Class C, Default subnet mask of class C is 255.255.255.0
 CIDR notation of class C is /24, which means 24 bits from IP
address are already consumed by network portion.
 We have 8 host bits remain.
 Subnetting moves from left to right. So Class C subnet masks can
only be the following:
CIDR Decimal Binary
/25 128 10000000
/26 192 11000000
/27 224 11100000
/28 240 11110000
/29 248 11111000
/30 252 11111100

Unit: 4 – Network Layer 42 Darshan Institute of Engineering & Technology


Network Prefixes- Example
 /25
✔ CIDR /25 has subnet mask 255.255.255.128 and 128 is 10000000 in binary.
✔ We used one host bit in network address.
 N = 1 [Number of host bit]
 H = 7 [Remaining host bits]
 Total subnets ( 2N ) : 21 = 2
 Block size (256 - subnet mask) :- 256 - 128 = 128
 Valid subnets ( Count blocks from 0) :- 0, 128
 Total hosts (2H) :- 27 = 128
 Valid hosts per subnet ( Total host - 2 ) :- 128 - 2 = 126

Unit: 4 – Network Layer 43 Darshan Institute of Engineering & Technology


Dynamic Host Configuration Protocol - DHCP
 Dynamic Host Configuration Protocol is a protocol for assigning
dynamic IP addresses to devices on a network.
DHCP
223.1.1.0/24
server
223.1.1.1 223.1.2.1

223.1.1.2 arriving DHCP


223.1.1.4 223.1.2.9
client needs
address in this
223.1.3.27
223.1.2.2 network
223.1.1.3

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.

Unit: 4 – Network Layer 45 Darshan Institute of Engineering & Technology


DHCP Client Server Interaction
DHCP server: 223.1.2.5 DHCP discover arriving
client
src : 0.0.0.0, 68
Broadcast: is there a
dest.: 255.255.255.255,67
DHCPyiaddr:
server 0.0.0.0
out there?
transaction ID: 654

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

Unit: 4 – Network Layer 46 Darshan Institute of Engineering & Technology


Network Address Translation
 NAT is a method that is used to translate Private IP addresses to
Public IP addresses.
rest of local network
Internet (e.g., home network)
10.0.0/24 10.0.0.1

10.0.0.4
10.0.0.2
138.76.29.7

10.0.0.3

all datagrams leaving local


network have same single datagrams with source or
source NAT IP address: destination in this network
138.76.29.7,different source have 10.0.0/24 address for
port numbers source, destination (as usual)
Unit: 4 – Network Layer 47 Darshan Institute of Engineering & Technology
NAT – Cont…
 Local network uses just one IP address as far as outside world is
concerned.
 This means that only a single, unique IP address is required to
represent an entire group of computers.
 The technique was originally used for ease of rerouting traffic in IP
networks without readdressing every host.
 The concept of NAT as developed to solve two problems:
✔ Solve shortage of IPv4 IP addresses
✔ To Hide the Network Address

Unit: 4 – Network Layer 48 Darshan Institute of Engineering & Technology


NAT Terminology
 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

Unit: 4 – Network Layer 49 Darshan Institute of Engineering & Technology


NAT – Cont…
NAT translation table 1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
changes datagram sends datagram to
source addr from 138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
10.0.0.1, 3345 to …… ……
138.76.29.7, 5001,
updates table S: 10.0.0.1, 3345
D: 128.119.40.186, 80
10.0.0.1
1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 10.0.0.4
10.0.0.2
138.76.29.7 S: 128.119.40.186, 80
D: 10.0.0.1, 3345
4
S: 128.119.40.186, 80
D: 138.76.29.7, 5001 3 10.0.0.3
4: NAT router
3: reply arrives changes datagram
dest. address: dest addr from
138.76.29.7, 5001 138.76.29.7, 5001 to 10.0.0.1, 3345

Unit: 4 – Network Layer 50 Darshan Institute of Engineering & Technology


Internet Control Message Protocol - ICMP
 When something unexpected occurs, the event is reported by the
ICMP, which is also used to test the Internet.
 About a dozen types of ICMP messages are defined. The most
important are listed below. Each ICMP message type is
encapsulated in an IP packet.
Message Type Description
Destination unreachable Packet could not be delivered
Time exceeded Time to live field hit 0
Parameter problem Invalid header field
Source quench Choke packet
Redirect Teach a router about geography
Echo Ask a machine if it is alive
Echo reply Yes, I am alive
Timestamp request Same as Echo request, but with timestamp
Timestamp reply Same as Echo reply, but with timestamp

Unit: 4 – Network Layer 51 Darshan Institute of Engineering & Technology


IPv6 Datagram Format

Unit: 4 – Network Layer 52 Darshan Institute of Engineering & Technology


Difference between IPv4 & IPv6
IPv4 IPv6
 32 bit length  128 bit length
 Fragmentation is done by sender  Fragmentation is done only by sender
and forwarding routers
 No packet flow identification  Packet flow identification is available within
the IPv6 header using the Flow Label field
 Checksum field in header  No checksum field in header
 Options fields are available in  No option fields, but Extension headers are
header available
 Address Resolution Protocol (ARP)is  Address Resolution Protocol (ARP) is
available to map IPv4 addresses replaced with Neighbor Discovery Protocol
to MAC addresses

 Broadcast messages are available  Broadcast messages are not available


 Static IP addresses or DHCP is  Auto-configuration of addresses is available
required to configure IP addresses

Unit: 4 – Network Layer 53 Darshan Institute of Engineering & Technology


Link State Routing Algorithm
 Also known as Dijkstra’s Algorithm.
 It computes the least-cost path from one node (source node) to all
other nodes in the network.
 Its iterative and after the kth least-cost paths are known to k
destination nodes.
 Notation:
✔ c(x,y): link cost from node x to y; = ∞ if not direct neighbours
✔ D(v): current value of cost of path from source to destination v
✔ p(v): predecessor node along path from source to v
✔ N': set of nodes whose least cost path definitively known

Unit: 4 – Network Layer 54 Darshan Institute of Engineering & Technology


Dijkstra’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'

Unit: 4 – Network Layer 55 Darshan Institute of Engineering & Technology


Dijkstra’s Algorithm – Example:1
D(v) D(w) D(x) D(y) D(z)
Step N' p(v) p(w) p(x) p(y) p(z)
0 u 7,u 3,u 5,u ∞ ∞
1 uw 6,w 5,u 11,w ∞
2 uwx 6,w 11,w 14,x
3 uwxv 10,v 14,x
x
4 uwxvy 12,y 9
5 uwxvyz
5 7
4
8
3 w z
u y
2
3
7 4
v

Unit: 4 – Network Layer 56 Darshan Institute of Engineering & Technology


Dijkstra’s Algorithm – Example:2
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

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

Unit: 4 – Network Layer 57 Darshan Institute of Engineering & Technology


Dijkstra’s Algorithm – Example:2
resulting shortest-path tree from u:

v w
u z
x y

resulting forwarding table in u:


destination link
v (u,v)
x (u,x)
y (u,x)
w (u,x)
z (u,x)
Unit: 4 – Network Layer 58 Darshan Institute of Engineering & Technology
Distance Vector Algorithm
 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.

Unit: 4 – Network Layer 59 Darshan Institute of Engineering & Technology


Distance Vector Algorithm – Cont…
 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

cost from neighbor v to destination y


cost to neighbor v

min taken over all neighbors v of x

Unit: 4 – Network Layer 60 4-60


Darshan Institute of Engineering & Technology
Distance Vector Algorithm – Cont…
each node:

wait for (change in local link


cost or message from neighbor)

recompute estimates

if DV to any destination has


changed, notify neighbors

Unit: 4 – Network Layer 61 Darshan Institute of Engineering & Technology


Distance Vector Algorithm - Example
node x cost to cost to
table x y z x y z
Dx(y) = min{c(x,y) + Dy(y), c(x,z) + Dz(y)}
x 0 2 7 x 0 2 3
= min{2+0 , 7+1} = 2

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

node z cost to cost to cost to


table x y z x y z x y z
x ∞∞ ∞ x 0 2 7 x 0 2 3
from

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

Unit: 4 – Network Layer 64 Darshan Institute of Engineering & Technology


Hierarchical Routing
 As networks grow in size, the router routing tables grow
proportionally.
 Router memory, CPU time and more bandwidth consumed to send
status reports about them.
 When hierarchical routing is used, the routers are divided into
what called regions.
 Each router knowing all the details about how to route packets to
destinations within its own region.
 But knowing nothing about the internal structure of other regions.

Unit: 4 – Network Layer 65 Darshan Institute of Engineering & Technology


Hierarchical Routing - Example

Unit: 4 – Network Layer 66 Darshan Institute of Engineering & Technology


Broadcast Routing
 Host need to send messages to many or all other hosts.
 For example
✔ A service distributing weather reports
✔ Stock market updates
✔ Live radio programs
 In Short, Sending a packet to all destinations simultaneously is called
broadcasting.
 First broadcasting method that simply send a distinct packet to each
destination.
 So, it waste of bandwidth, but it also requires the source to have a
complete list of all destinations.
 In practice this may be the only possibility, but it is the least desirable of
the methods.
Unit: 4 – Network Layer 67 Darshan Institute of Engineering & Technology
Broadcast Routing – Cont…
 Flooding is Second method. Although flooding is for ordinary
point-to-point communication, for broadcasting it might rate
serious consideration, especially if none of the methods are
applicable.
 The problem with flooding as a broadcast technique is the same
problem it has as a point-to-point routing algorithm.
 It generates too many packets and consumes too much
bandwidth.
 A third algorithm is Multi Destination Routing.
 If this method is used, each packet contains either a list of
destinations or a bit map indicating the desired destinations.

Unit: 4 – Network Layer 68 Darshan Institute of Engineering & Technology


Broadcast Routing – Cont…
 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.
 A fourth broadcast algorithm makes explicit use of the sink tree for the
router initiating the broadcast-or any other convenient spanning tree for
that matter.
 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.
Unit: 4 – Network Layer 69 Darshan Institute of Engineering & Technology
Multicast Routing
 Sending a message to a group is called multicasting, and its routing
algorithm is called multicast routing.
 Multicasting requires group management. Need to create and destroy
groups, and to allow processes to join and leave groups.
 To do multicast routing, each router computes a spanning tree covering
all other routers.
 For example, in Figure (a) we have two groups, 1 and 2.
 Some routers are attached to hosts that belong to one or both of these
groups, as indicated in the figure.

Unit: 4 – Network Layer 70 Darshan Institute of Engineering & Technology


Multicast Routing – Cont…
 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, removing all lines that do not
lead to hosts that are members of the group.
 In our example, Figure (c) shows the pruned spanning tree for group 1.
 Figure(d) shows the pruned spanning tree for group 2. Multicast packets
are forwarded only along the appropriate spanning tree.

Unit: 4 – Network Layer 71 Darshan Institute of Engineering & Technology


Comparison between RIP OSPF and BGP
RIP OSPF BGP
RIP is intra domain OSPF is also intra domain It is inter domain routing
routing protocol used routing protocol used protocol used between
with in the autonomous with in the autonomous the autonomous system
system system
RIP is used for Small OSPF is used in large The BGP protocol is used
networks with maximum autonomous system with for very large-scale
number of hops 16 no limitation networks
RIP uses Distance Vector OSPF uses Link State BGP uses Path Vector
RIP send entire routing OSPF send multicast Hello BGP send Open packet to
update to all directly packet to the neighbours, the neighbours to create
connected interface to create session session
RIP use Bellman ford OSPF use Dijikstra BGP use Path-Vector
Algorithm Algorithm Routing

Unit: 4 – Network Layer 72 Darshan Institute of Engineering & Technology


Thank You

You might also like