0% found this document useful (0 votes)
54 views76 pages

Unit - 3

This document provides an overview of the network layer. It discusses key functions of the network layer including forwarding and routing. It describes routing and forwarding tables and how they are used. The document also covers different network service models and virtual circuit switching including virtual circuit setup, data transfer, and teardown. It provides examples of forwarding tables used in virtual circuit routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views76 pages

Unit - 3

This document provides an overview of the network layer. It discusses key functions of the network layer including forwarding and routing. It describes routing and forwarding tables and how they are used. The document also covers different network service models and virtual circuit switching including virtual circuit setup, data transfer, and teardown. It provides examples of forwarding tables used in virtual circuit routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 76

Computer Networks (CN)

GTU #3150710

Unit-4:
Network Layer

Prof. Maulik D Trivedi


Computer Engineering Department
Darshan Institute of Engineering & Technology, Rajkot
[email protected]
+91-9998265805
 Outline
Looping
• Introduction
• Virtual and Datagram networks
• Study of Router
• IP protocol and addressing in the Internet
• Routing algorithms
• Broadcast and Multicast Routing
Introduction of Network Layer
Introduction: Network Layer
 To deliver segment from sending to receiving
host/ router. application
transport

 On sending side, it encapsulates segments into network


data link
physical
datagrams. network
data link
network
data link
network
 On receiving side, it delivers segments to data link
physical
physical physical

network network
transport layer. data link
physical
data link
physical

 Network layer protocols in every host and network network


router. data link
physical
network
data link
physical

 Router examines header fields in all IP data link


physical

datagrams passing through it. network


data link
application
transport
network network
network physical data link data link
data link physical physical
physical

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 4


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 5


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 6


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 7


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 8


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 9


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 10


VC Forwarding Table

12 22 32
1 3
2
VC number
interface
number
Forwarding table in
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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 11


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 12


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 13


Datagram Network vs. Virtual Circuit Network

Datagram Virtual Circuit


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

State Information None other than router table containing Route established at setup, all packets follow
destination network same route.
Effect of Router Failure Only on packets lost during crash All virtual circuits passing through failed router
terminated.
Congestion Control Difficult since all packets routed Simple by pre-allocating enough buffers to each
independently router resource requirements virtual circuit at setup, since maximum number of
can vary. circuits fixed.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 14


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 16


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 17


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 18


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 19


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 20


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 21


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.
 Switching speed of the router is limited to the bus speed.

bus

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 22


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 23


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 24


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 25


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 26


IPv4 Datagram format
IP protocol version 32 bits
number total datagram
header length head. type of length (bytes)
ver length
(bytes) len service for
“type” of data fragment fragmentation/
16-bit identifier flags
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
Total IP Datagram Size data taken, specify
?? (variable length, list of routers
Minimum IP Header Size typically a TCP to visit.
?? or UDP segment)
Maximum IP Header Size ??

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 27


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 28


Classification of IP Addresses (Classful Addressing)
Class: A
0
7 Bit Network
Fix ID 24 Bit Host
ID
Class: B
1 0
Fix 14 Bit Network 16 Bit Host
ID ID
Class: C
1 1 0
Fix 21 Bit Network 8 Bit Host
ID ID
Class: D
1 1 1 0
Fix
Class: E Multicast address
1 1 1 1
Fix Reserved address
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 29
Class A: (0.0.0.0 to 127.255.255.255)
0
7 Bit Network 24 Bit Host
ID 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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 30


Class B: (128.0.0.0 to 191.255.255.255)
1 0
Fix 14 Bit Network 16 Bit Host
ID 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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 31


Class C: (192.0.0.0 to 223.255.255.255)

1 1 0
Fix 21 Bit Network 8 Bit Host
ID 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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 32


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:

11100000 – 11101111
224 - 239
 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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 33


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 34


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

Class A 0 8 24 128 (27) 16,777,216 (224) 2,147,483,648 (231) 0.0.0.0 127.255.255.255 255.0.0.0 /8

Class B 10 16 16 16,384 (214) 65,536 (216) 1,073,741,824 (230) 128.0.0.0 191.255.255.255 255.255.0.0 /16

2,097,152
Class C 110 24 8 256 (28) 536,870,912 (229) 192.0.0.0 223.255.255.255 255.255.255.0 /24
(221)

Class D not not


1110 not defined not defined not defined 268,435,456 (228) 224.0.0.0 239.255.255.255 not defined
(multicast) defined defined

Class E not not


1111 not defined not defined not defined 268,435,456 (228) 240.0.0.0 255.255.255.255 not defined
(reserved) defined defined

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 35


IP Addressing - Example
 IP address: It is 32-bit identifier for host,
router interface 223.1.1.1

 Interface: It is a connection between 223.1.2.1


223.1.1.2
host/router and physical link.
 A router’s typically have multiple interfaces 223.1.1.4 223.1.2.9

 A host typically has one or two interfaces


 IP addresses associated with each 223.1.1.3
223.1.3.27
223.1.2.2
interface.

223.1.3.1 223.1.3.2

223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 1
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 36
Subnet
 Subnet: high order bits defines subnet 223.1.1.0/24
223.1.2.0/24
 Host: low order bits defines host 223.1.1.1

 To determine the subnets, detach each interface from


223.1.1.2 223.1.2.1
its host or router. 223.1.1.4 223.1.2.9

 Creating islands of isolated networks, with interfaces 223.1.2.2


terminating the end points of the isolated networks. 223.1.1.3 223.1.3.27

 Each of these isolated networks is called a subnet. subnet

223.1.3.1 223.1.3.2

223.1.3.0/24
Network consisting of 3 subnets

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 37


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 38


Type of addresses – Cont…

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 39


Classless Inter-Domain Routing(CIDR)
 CIDR is a slash notation of subnet mask. CIDR tells us number of on bits in a network
address.
host
subnet 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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 40


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 41


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, 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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 42


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 43


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 44


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 45


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 46


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.2.2 network
223.1.1.3 223.1.3.27

223.1.2.0/24

223.1.3.1 223.1.3.2

223.1.3.0/24
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 47
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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 48


DHCP Client Server Interaction

DHCP server: 223.1.2.5 DHCP discover arriving


client
src : 0.0.0.0, 68
Broadcast:
dest.: is there a DHCP server
255.255.255.255,67
out there?
yiaddr: 0.0.0.0
transaction ID: 654

DHCP offer
src: 223.1.2.5, 67
Broadcast: I’m a DHCP68server!
dest: 255.255.255.255,
Here’s an yiaddrr:
IP address you can use
223.1.2.4
transaction ID: 654
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255, 67
Broadcast: OK. I’ll take that
yiaddrr: 223.1.2.4
IP
address!
transaction ID: 655
lifetime: 3600 secs

DHCP ACK
src: 223.1.2.5, 67
Broadcast:255.255.255.255,
dest: OK. You’ve got 68 that IP
yiaddrr: 223.1.2.4
address!
transaction ID: 655
lifetime: 3600 secs

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 49


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 source NAT datagrams with source or
IP address: 138.76.29.7,different destination in this network
source port numbers have 10.0.0/24 address for
source, destination (as usual)

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 50


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 51


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 52


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 53


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 54


IPv6 Datagram Format

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 55


Difference between IPv4 & IPv6

IPv4 IPv6
 32 bit length  128 bit length
 Fragmentation is done by sender and  Fragmentation is done only by sender
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 header  No option fields, but Extension headers are available

 Address Resolution Protocol (ARP)is available to  Address Resolution Protocol (ARP) is replaced with
map IPv4 addresses to MAC addresses Neighbor Discovery Protocol

 Broadcast messages are available  Broadcast messages are not available


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 56


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 57


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'

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 58


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 59


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 60


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)
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 61
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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 62


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)


v
+ d v(y) }

cost from neighbor v to destination y


cost to neighbor v

min taken over all neighbors v of x

4-63
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 63
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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 64


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
2 0 1
from

y
z ∞ ∞ ∞ y
2 1
node z cost to
table x y z x z
7
x ∞∞ ∞
from

y ∞ ∞ ∞
z 7 1 0
time
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 65
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

from
2 0 1 y
z ∞ ∞ ∞ z 7 1 0 z 2 1
3 1 0
node y
x z
cost to 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 from y 2 0 1 y

from
2 0 1
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 y 2 0 1
from

y ∞ ∞ ∞ 2 0 1
z z 3 1 0 z 3 1 0
7 1 0
time
Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 66
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 update at every Updates are triggered not periodic
30 or 90 second
Update are broadcasted Updates are multicasted

Updates are sent to directly connected neighbour only Update are sent to entire network & to just directly connected
neighbour
Routers don't have end to end visibility of entire Routers have visibility of entire network of that area only.
network.
It is prone to routing loops No routing loops

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 67


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 68


Hierarchical Routing - Example

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 69


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 70


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 71


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 72


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 73


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.

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 74


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

Prof. Maulik D. Trivedi #3150710(CN)  Unit 4 – Network Layer 75


Computer Networks (CN)
GTU #3150710

Thank
You

Prof. Maulik Trivedi


Computer Engineering Department
Darshan Institute of Engineering & Technology, Rajkot
[email protected]
9998265805

You might also like