0% found this document useful (0 votes)
0 views149 pages

Unit 4 - Network Layer

The document covers the Network Layer in computer networks, detailing its key functions such as forwarding and routing, as well as various network service models including connection-oriented and connectionless services. It explains the structure and operation of routers, including input/output port functions, switching fabrics, and the IPv4 datagram format. Additionally, it discusses fragmentation and IP addressing, emphasizing the importance of these concepts in ensuring effective data transmission across networks.

Uploaded by

jagtapdev55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views149 pages

Unit 4 - Network Layer

The document covers the Network Layer in computer networks, detailing its key functions such as forwarding and routing, as well as various network service models including connection-oriented and connectionless services. It explains the structure and operation of routers, including input/output port functions, switching fabrics, and the IPv4 datagram format. Additionally, it discusses fragmentation and IP addressing, emphasizing the importance of these concepts in ensuring effective data transmission across networks.

Uploaded by

jagtapdev55
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 149

3150710 – Computer Networks

UNIT-4
NETWORK LAYER
✓Syllabus
Loopi Network Layer: Introduction to forwarding
ng
and routing, Network Service models, Virtual
and Datagram networks, study of router, IP
protocol and addressing in the Internet, Routing
algorithms, Broadcast and Multicast routing

2
✓Outline
Loopin
g

• Introduction to Network Layer


• Forwarding and routing
• Network Service models
• Virtual and Datagram networks
• Study of router
• IP protocol and addressing in the Internet
• Routing algorithms
• Broadcast and Multicast routing
INTRODUCTION: NETWORK LAYER

application
transport
networ
dkata link
● To deliver segment from
physical
network network
sending to receiving
data link
network
data link
data link
physical physical host/router.
physical network
data link
network
data link
● On sending side, it
physical physical
encapsulated segments into
network
data link
network
data link
datagrams.
physical
n twork
data link
physical
● On receiving side, it delivers
e
physical
application
segments to transport layer.
network
data link network
transport
network
● Network layer protocols in
physical data link
network
data link
data link
physical physical every host and router.
physical
● Router examines header fields
in all IP datagrams passing
through it.
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.
ROUTING AND FORWARDING
NETWORK SERVICE MODEL
Services provided by network layer for individual
datagrams are:
1) Guaranteed delivery
This service guarantees that the packet will
eventually arrive at its destination.
2) Guaranteed delivery with bounded delay
This service not only guarantees delivery of the packet,
but delivery within a specified host-to-host delay
bound.
Services provided by network layer for a flow of
datagrams are:
1) In-order packet delivery
This service guarantees that packets arrive at the
destination in the order that they were sent.
2) Guaranteed minimum 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.
3) 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.
4) 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.
CONNECTION-ORIENTED VS. CONNECTION LESS

Transport Layer Network Layer


Process to- process services Host-to-host services
UDP, a connectionless service Connectionless service at the
network layer are called
datagram networks: does not
have any handshaking
preliminaries.
TCP, a connection-oriented Connection service at the
service. network layer are called
virtual-circuit(VC) networks;
handshaking between the source and
destination hosts.
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
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


VIRTUAL CIRCUIT SETUP
There are three identifiable phases in a virtual circuit:
1. VC setup
2. Data transfer
3. VC teardown

application application
transport 5. data flow
transport
network begins 6. receive data
4. call connected
network
data link 3. accept call data link
physical physical
1. initiate call 2. incoming
call
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
DATAGRAM NETWORK VS. VIRTUAL CIRCUIT NETWORK

Criteria Datagram Virtual Circuit

Connection Setup None Required


Addressing Packet contains full source Each virtual circuit
and destination address number entered to table on
for routing.
setup, used
State Information None other than Route established at setup, all
router
network table containing packets follow same route.
destination
Effect of Router Only on packets lost during All virtual circuits passing
terminated.
Failure crash through failed router
Congestion Difficult since all packets Simple by pre-allocating enough
Control routed independently router buffers to each virtual circuit at
resource requirements can setup, since maximum number
vary. of circuits fixed.
DATAGRAM SWITCHING VS. VIRTUAL CIRCUIT

Datagram Switching Virtual Circuit


Connectionless Connection Oriented
No Reservation Reservation
(Bandwidth, CPU Memory,
Buffer)
May or May Use different Path Same Path
Out of Order Same Order
High Overhead Less Overhead
Packet Lost High Packet Lost Less
Used in Internet Used in X.35, Frame, Relay, ATM
Less Costly Costly
Not Reliable Highly Reliable
ROUTER ARCHITECTURE
Routers have four components:
1. Input ports
2. Switching fabric
3. Output ports
4. Routing processor
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.
Goal: Complete input port processing at line speed
Queuing: If datagrams arrive faster than forwarding rate into switch fabric
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.
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


SWITCHING VIA MEMORY

input output
port (e.g., memory port (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.
Traditional computers with switching under direct control of CPU
Packet copied to system’s memory
Speed limited by memory bandwidth (2 bus crossings per datagram)
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.
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.
❖ datagram from input port memory
to output port memory via a shared bus
❖ bus contention: switching speed limited by bus
bandwidth
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.
OUTPUT PORT

datagram
switch buffer link
line
fabric layer
termination
protocol
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.
❖ buffering required when datagrams arrive from fabric faster than
the transmission rate
❖ scheduling discipline chooses among queued datagrams for
transmission
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.
IPv4 DATAGRAM FORMAT
IP stands for Internet Protocol and v4 stands for Version Four
(IPv4).
IPv4 was the primary version brought into action for
production within the ARPANET in 1983.
Internet Protocol Version 4 (IPv4) is the fourth revision of
the Internet Protocol and a widely used protocol in data
communication over different kinds of networks.
IPv4 is a connectionless protocol used in packet-switched
layer networks, such as Ethernet.
It provides a logical connection between network devices by
providing identification for each device.
IPv4 DATAGRAM FORMAT (Contd…)
VERSION: Version of the IP protocol (4 bits), which is 4 for IPv4
HLEN: IP header length (4 bits), which is the number of 32 bit
words in the header. The minimum value for this field is 5 and the
maximum is 15.
Type of service: Low Delay, High Throughput, Reliability (8 bits)
Total Length: Length of header + Data (16 bits), which has a
minimum value 20 bytes and the maximum is 65,535 bytes.
Identification: Unique Packet Id for identifying the group of
fragments of a single IP datagram (16 bits)
Flags: 3 flags of 1 bit each : reserved bit (must be zero), do not
fragment flag, more fragments flag (same order).
Fragment Offset: Represents the number of Data Bytes ahead of
the particular fragment in the particular Datagram. Specified in
terms of number of 8 bytes, which has the maximum value of
65,528 bytes.
IPv4 DATAGRAM FORMAT (Contd…)
Time to live: Datagram’s lifetime (8 bits), It prevents the
datagram to loop through the network by restricting the
number of Hops taken by a Packet before delivering to the
Destination.
Protocol: Name of the protocol to which the data is to be
passed (8 bits)
Header Checksum: 16 bits header checksum for checking
errors in the datagram header
Source IP address: 32 bits IP address of the sender
Destination IP address: 32 bits IP address of the receiver
Option: Optional information such as source route, record
route. Used by the Network administrator to check whether a
path is working or not.
Due to the presence of options, the size of the datagram
header can be of variable length (20 bytes to 60 bytes).
FRAGMENTATION

● The image shows a fragmentation process diagram, illustrating how a


router breaks down a large network layer datagram into smaller
fragments to meet the requirements of different Maximum Transmission
Units (MTUs) along the transmission path.
Key Concepts
● MTU (Maximum Transmission Unit): The largest size of a packet or
frame that can be transmitted in a network layer, depending on the link.
● The source has an MTU of 520 bytes, and the destination has an MTU of
200 bytes.
● Source: The source sends a network layer datagram with a header of 20
bytes and a data payload of 500 bytes, making the total size 520 bytes.
● This fits the MTU of the source's network but is too large for the
destination.
● Router: The router, positioned between the source and the destination,
performs fragmentation to break down the large datagram.
● Since the destination has an MTU of 200 bytes, the datagram is divided
into smaller fragments.
● Each fragment contains 20 bytes of header (H) and a payload, respecting
the MTU limit.
● The payloads of the fragments are 180 bytes and 140 bytes for the two
fragments.
● Destination: The destination receives the fragments, which fit within the
destination's MTU of 200 bytes.
● The fragments are eventually reassembled at the network layer to restore
the original data.
EXAMPLE
An IP datagram of size 1000 bytes arrives at a router. The
router has to forward this packet on a link whose MTU
(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?

Explanation: MTU = 100 bytes


Size of IP header = 20 bytes
So, size of data that can be transmitted in one fragment = 100
– 20 = 80 bytes
Size of data to be transmitted = Size of datagram – size of
header
= 1000 – 20 = 980 bytes
Now, we have a datagram of size 1000 bytes.
So, we need ceil(980/80) = 13 fragments.
Thus, there will be 13 fragments of the datagram.
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
Dotted-decimal notation and binary notation for an IPv4 address
CLASSIFICATION OF IP ADDRESSES
(CLASSFUL ADDRESSING)
Class: A
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
Fix
Class: E Multicast address
11 11
Fix Reserved address
Example

Find the error, if any, in the following IPv4


addresses.
Note
The address space of IPv4 is
32 or 4,294,967,296.
2
CLASS A: (0.0.0.0 TO 127.255.255.255)
0
7 Bit 24 Bit
Network 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


BLOCKS IN CLASS A
CLASS B: (128.0.0.0 TO 191.255.255.255)
1 0
Fix
14 Bit Network ID 16 Bit 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
BLOCKS IN CLASS B
CLASS C: (192.0.0.0 TO 223.255.255.255)

1 1 0
Fix

21 Bit Network ID 8 Bit 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
BLOCKS IN CLASS C
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 ranges 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.
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 thisclass ranges from 240.0.0.0 to
255.255.255.254.
Like Class D, this class too is not equipped with any subnet
mask.
Finding the classes in binary and dotted-decimal notation

19.49
IP ADDRESSING SUMMARY
Size Default sub
Size of Total
Leadi of netwo Number of Addresses net CIDR
rest bit addresses Start
Class ng rk networks per End address mask in dot notati
field address
bits number network in class -decimal on
bit field notation

16,777,2 2,147,483,6 127.255.255.2


Class A 0 8 24 128 (27) 0.0.0.0 255.0.0.0 /8
16 (224) 48 (231) 55

16,384 65,536 1,073,741,8 128.0.0. 191.255.255.2


Class B 10 16 16 255.255.0.0 /16
(214) (216) 24 (230) 0 55

2,097,15 536,870,91 192.0.0. 223.255.255.2 255.255.255.


Class C 110 24 8 256 (28) /24
2 (221) 2 (229) 0 55 0

Class D not not


not not not 268,435,45 224.0.0. 239.255.255.2
(multica 1110 define not defined define
defined defined defined 6 (228) 0 55
st) d d

Class E not not


not not not 268,435,45 240.0.0. 255.255.255.2
(reserve 1111 define not defined define
defined defined defined 6 (228) 0 55
d) d d
NETWORK ADDRESSES

The network address is the first address.


The network address defines the network to the rest of
the Internet.
Given the network address, we can find the class of
the address, the block, and the range of the addresses
in the block
The network address is the beginning address of each
block. It can be found by applying the default mask to
any of the addresses in the block(including itself). It
retains the netid of the block and sets the hostid to
zero.
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
MASK

• A mask is a 32-bit binary number.


• The mask is ANDeD with IP address to get
• The block address (Network address)
• Mask And IP address = Block Address
DEFAULT MASK

Class A default mask is 255.0.0.0


Class B default mask is 255.255.0.0
Class C Default mask 255.255.255.0
SUBNET 223.1.1.0/24
223.1.2.0/24
223.1.1.1
Subnet: high order bits defines
subnet
223.1.1.2 223.1.2.1
223.1.1.4 223.1.2.9
Host: low order bits defines
host 223.1.2.2
223.1.1.3 223.1.3.27
To determine the subnets,
detach each interface from its subnet
host or router.
223.1.3.1 223.1.3.2
Creating islands of isolated
networks, with interfaces
terminating the end points of
the isolated networks. 223.1.3.0/24

Each of these isolated networks Network consisting of 3 subnets


is called a subnet.
SUBNETTING
If an organization was granted a large block in class A or B,
it could divide the address into several contiguous groups
and assign each group to smaller network(called subnets).
Divide the big network into small networks.
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
1100100000010111 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.
To find the subnet mask of the address 188.25.45.48/20 and determine how
many host bits were borrowed for subnetting?
Step 1: Determine the Class and Default Subnet Mask
The IP address 188.25.45.48 belongs to Class B, which has a default subnet
mask of 255.255.0.0 or /16.
Step 2: Identify the Current Subnet Mask
In the given CIDR notation /20, this indicates that the first 20 bits are the
network portion of the address.
Step 3: Calculate the Subnet Mask
The subnet mask for /20 in binary is:
- The first 20 bits are ones:
11111111 11111111 11110000 00000000
- This translates to:
- First Octet: 11111111 = 255
- Second Octet: 11111111 = 255
- Third Octet: 11110000 = 240
-Fourth Octet: 00000000 = 0
Thus, the subnet mask in dotted-decimal notation is 255.255.240.0
Step 4: Determine Borrowed Bits
- The default subnet mask for Class B is /16 or
255.255.0.0.
- The new subnet mask is /20.
To find out how many bits were borrowed from the host
portion for subnetting:
- Original network bits (for Class B): 16 bits
- New network bits (for /20): 20 bits
So, the number of bits borrowed is:
Borrowed bits = 20 - 16 = 4 bits
Step 5: Convert Borrowed Bits to Decimal
When 4 bits are borrowed from the host part, it results in
the following calculation for the number of subnets and
hosts:
Number of Subnets=2borrowed bits = 24 = 16 subnets
Number of Hosts per Subnet:
The number of bits remaining for hosts is = 32 - 20 = 12
2remaining host bits - 2 = 212 - 2 = 4096 - 2 = 4094 hosts per
subnet
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.
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
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
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
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
DYNAMIC HOST CONFIGURATION PROTOCOL - DHCP
Dynamic Host Configuration Protocol is a protocol
for assigning dynamic IP addresses to devices on a
network.
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
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 CLIENT SERVER INTERACTION
DHCP server: 223.1.2.5 DHCP discover arriving
src : 0.0.0.0, 68 client
Broadcast: is there a
dest.:
DHCP server out there?
255.255.255.255,67
yiaddr: 0.0.0.0
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
address youID:can
transaction 654 use
lifetime: 3600 secs
DHCP request
src: 0.0.0.0, 68
dest:: 255.255.255.255,
Broadcast: 67
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: OK. 68
dest: 255.255.255.255,
yiaddrr: 223.1.2.4
You’ve got that IP
transaction ID: 655
address!
lifetime: 3600 secs
NETWORK ADDRESS TRANSLATION (NAT)
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 have
138.76.29.7,different source 10.0.0/24 address for source,
port numbers destination (as usual)
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


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


NAT translation table
1: host 10.0.0.1
2: NAT router WAN side addr LAN side addr
sends datagram to
changes datagram 138.76.29.7, 5001 10.0.0.1, 3345 128.119.40.186, 80
source addr from …… ……
10.0.0.1, 3345 to
138.76.29.7, 5001, S: 10.0.0.1, 3345
updates table 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
ADVANTAGES OF NAT
It hide the real IP address of your internal network from
public network and act as a firewall
It allow unlimited number of private addresses to
access the single internet connection.
Hence, it allows multiple devices to access single
internet connection.
It help to save moneyto buying multiple internet
connection for multiple devices.
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
IPv6 DATAGRAM FORMAT
DIFFERENCE BETWEEN IPv4 & IPv6
LINK STATE ROUTING ALGORITHM
Also known as Dijkstra’s Algorithm.
It is a unicast routing algorithm, a routing scheme in computer
networks where each packet is forwarded along a single path to
its destination node, resulting in minimal transmission overhead
and buffer space usage.
It computes the least-cost path from one node(source
node) to all other nodes in the network.
Link state routing is a technique in which each router shares
the knowledge of its neighborhood with every other router in
the internetwork.
The three keys to understand the Link State Routing algorithm
Knowledge about the neighborhood: Instead of sending its
routing table, a router sends the information about its
neighborhood only. A router broadcast its identities and cost of
the directly attached links to other routers.
Flooding: Each router sends the information to every other
router on the internetwork except its neighbors. This process
is known as Flooding. Every router that receives the packet
sends the copies to all its neighbors. Finally, each and every
router receives a copy of the same information.
Information sharing: A router sends the information to every
other router only when the change occurs in the information.
Link State Routing has two phases:
1) Reliable Flooding
Initial state: Each node knows the cost of its neighbors.
Final state: Each node knows the entire graph.

2) Route Calculation
Each node uses Dijkstra's algorithm on the graph to calculate
the optimal routes to all nodes.
The Link state routing algorithm is also known as Dijkstra's
algorithm which is used to find the shortest path from one
node to every other node in the network.
The Dijkstra's algorithm is an iterative, and it has the property
that after kth iteration of the algorithm, the least cost paths are
well known for k destination nodes.
Notations:
c( i , j): Link cost from node i to node j. If i and j nodes are not
directly linked, then c(i , j) = ∞.
D(v): It defines the cost of the path from source code to
destination v that has the least cost currently.
P(v): It defines the previous node (neighbor of v) along with
current least cost path from source to v.
N: It is the total number of nodes available in the network.
Algorithm

● In the above algorithm, an


initialization step is followed by
the loop.
● The number of times the loop is
executed is equal to the total
number of nodes available in
the network.
EXAMPLE

In this figure, source vertex is A.


Step 1:
● The first step is an initialization step.
● The currently known least cost path from A to its directly
attached neighbors, B, C, D are 2,5,1 respectively.
● The cost from A to B is set to 2, from A to D is set to 1 and
from A to C is set to 5.
● The cost from A to E and F are set to infinity as they are not
directly linked to A.
Step 2:
● In the above table, we observe that vertex D contains the
least cost path in Step 1.
● Therefore, it is added in N.
● Now, we need to determine a least-cost path through D
vertex.
a) Calculating shortest path from A to B
v = B, w = D
D(B) = min( D(B) , D(D) + c(D,B) )
= min( 2, 1+2)
= min( 2, 3)
The minimum value is 2. Therefore, the currently shortest path
from A to B is 2.
b) Calculating shortest path from A to C
v = C, w = D
D(C) = min( D(C) , D(D) + c(D,C) )
= min( 5, 1+3)
= min( 5, 4)
The minimum value is 4. Therefore, the currently shortest path
from A to C is 4.
c) Calculating shortest path from A to E
v = E, w = D
D(E) = min( D(E) , D(D) + c(D,E) )
= min( ∞, 1+1)
= min(∞, 2)
The minimum value is 2. Therefore, the currently shortest path
from A to E is 2.
The vertex D has no direct link to vertex E. Therefore, the value
of D(F) is infinity.
Step 3:
● In the above table, we observe that both E and B have the
least cost path in Step 2.
● Let's consider the E vertex.
● Now, we determine the least cost path of remaining vertices
through E.
● Therefore, it is added in N.
a) Calculating the shortest path from A to B.
v = B, w = E
D(B) = min( D(B) , D(E) + c(E,B) )
= min( 2 , 2+ ∞ )
= min( 2, ∞)
The minimum value is 2. Therefore, the currently shortest path
from A to B is 2.
b) Calculating the shortest path from A to C.
v = C, w = E
D(C) = min( D(C) , D(E) + c(E,C) )
= min( 4 , 2+1 )
= min( 4,3)
The minimum value is 3. Therefore, the currently shortest path
from A to C is 3.
c) Calculating the shortest path from A to F.
v = F, w = E
D(F) = min( D(F) , D(E) + c(E,F) )
= min( ∞ , 2+2 )
= min( ∞ , 4)
The minimum value is 4. Therefore, the currently shortest path
from A to F is 4.
Step 4:
● In the above table, we observe that B vertex has the least
cost path in Step 3.
● Therefore, it is added in N.
● Now, we determine the least cost path of remaining vertices
through B.
a) Calculating the shortest path from A to C.
v = C, w = B
D(B) = min( D(C) , D(B) + c(B,C) )
= min( 3 , 2+3 )
= min( 3,5)
The minimum value is 3. Therefore, the currently shortest path
from A to C is 3.
b) Calculating the shortest path from A to F.
v = F, w = B
D(F) = min( D(F) , D(B) + c(B,F) )
= min( 4, ∞)
= min(4, ∞)
The minimum value is 4. Therefore, the currently shortest path
from A to F is 4.
Step 5:
● In the above table, we observe that C vertex has the least
cost path in Step 4.
● Therefore, it is added in N.
● Now, we determine the least cost path of remaining vertices
through C.
a) Calculating the shortest path from A to F.
v = F, w = C
D(B) = min( D(F) , D(C) + c(C,F) )
= min( 4, 3+5)
= min(4,8)
The minimum value is 4. Therefore, the currently shortest path
from A to F is 4.
FINAL TABLE

Disadvantage:
Heavy traffic is created in Link state routing due to Flooding. Flooding can
cause an infinite looping, this problem can be solved by using Time-to-leave
field.
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.
The Distance vector algorithm is a dynamic algorithm.
It is mainly used in ARPANET, and RIP.
Each router maintains a distance table known as Vector.
Three Keys to understand the working of Distance Vector
Routing Algorithm
Knowledge about the whole network: Each router shares its
knowledge through the entire network. The Router sends its
collected knowledge about the network to its neighbors.
Routing only to neighbors: The router sends its knowledge
about the network to only those routers which have direct
links. The router sends whatever it has about the network
through the ports. The information is received by the router and
uses the information to update its own routing table.
Information sharing at regular intervals: Within 30 seconds,
the router sends the information to the neighboring routers.
Let dx(y) be the cost of the least-cost path from node x to node
y.
The least costs are related by Bellman-Ford equation,
dx(y) = minv{c(x,v) + dv(y)}
where the minv is the equation taken for all x neighbors.
After traveling from x to v, if we consider the least-cost path
from v to y, the path cost will be c(x,v)+dv(y).
The least cost from x to y is the minimum of c(x,v)+dv(y) taken
over all neighbors.
With the Distance Vector Routing algorithm, the node x
contains the following routing information:
○ For each neighbor v, the cost c(x,v) is the path cost from x
to directly attached neighbor, v.
○ The distance vector x, i.e., Dx = [ Dx(y) : y in N ],
containing its cost to all destinations, y, in N.
○ The distance vector of each of its neighbors, i.e.,
Dv = [ Dv(y) : y in N ] for each neighbor v of x.
Distance vector routing is an asynchronous algorithm in which
node x sends the copy of its distance vector to all its neighbors.
When node x receives the new distance vector from one of its
neighboring vector, v, it saves the distance vector of v and uses
the Bellman-Ford equation to update its own distance vector.
Algorithm
EXAMPLE

Step 1:
Each router prepares its routing table using its local knowledge.
At router A,
At router B,
At router C,
At router D,
Step 2:
● Each router exchanges its distance vector obtained in Step 1
with its neighbors.
● After exchanging the distance vectors, each router prepares a
new routing table.
At router A,
Router A receives distance vectors from its neighbors B and D.
Cost of reaching destination B from router A = min { 2+0 , 1+7 } =
2 via B.
Cost of reaching destination C from router A = min { 2+3 , 1+11 } =
5 via B.
Cost of reaching destination D from router A = min { 2+7 , 1+0 } =
1 via D.
Thus, the new routing table at router A is-
At router B,
Router B receives distance vectors from its neighbors A, C and D.
Cost of reaching destination A from router B = min { 2+0 , 3+∞ ,
7+1 } = 2 via A.
Cost of reaching destination C from router B = min { 2+∞ , 3+0 ,
7+11 } = 3 via C.
Cost of reaching destination D from router B = min { 2+1 , 3+11 ,
7+0 } = 3 via A.
Thus, the new routing table at router B is-
At router C,
Router C receives distance vectors from its neighbors B and D.
Cost of reaching destination A from router C = min { 3+2 , 11+1 } =
5 via B.
Cost of reaching destination B from router C = min { 3+0 , 11+7 } =
3 via B.
Cost of reaching destination D from router C = min { 3+7 , 11+0 } =
10 via B.
Thus, the new routing table at router C is-
At router D,
Router D receives distance vectors from its neighbors A, B and C.
Cost of reaching destination A from router D = min { 1+0 , 7+2 ,
11+∞ } = 1 via A.
Cost of reaching destination B from router D = min { 1+2 , 7+0 ,
11+3 } = 3 via A.
Cost of reaching destination C from router D = min { 1+∞ , 7+3 ,
11+0 } = 10 via B.
Thus, the new routing table at router D is-
Step 3:
● Each router exchanges its distance vector obtained in Step 2
with its neighboring routers.
● After exchanging the distance vectors, each router prepares a
new routing table.
At router A,
Router A receives distance vectors from its neighbors B and D.
Cost of reaching destination B from router A = min { 2+0 , 1+3 } =
2 via B.
Cost of reaching destination C from router A = min { 2+3 , 1+10 } =
5 via B.
Cost of reaching destination D from router A = min { 2+3 , 1+0 } =
1 via D.
Thus, the new routing table at router A is-
At router B,
Router B receives distance vectors from its neighbors A, C and D.
Cost of reaching destination A from router B = min { 2+0 , 3+5 ,
3+1 } = 2 via A.
Cost of reaching destination C from router B = min { 2+5 , 3+0 ,
3+10 } = 3 via C.
Cost of reaching destination D from router B = min { 2+1 , 3+10 ,
3+0 } = 3 via A.
Thus, the new routing table at router B is-
At router C,
Router C receives distance vectors from its neighbors B and D.
Cost of reaching destination A from router C = min { 3+2 , 10+1 } =
5 via B.
Cost of reaching destination B from router C = min { 3+0 , 10+3 } =
3 via B.
Cost of reaching destination D from router C = min { 3+3 , 10+0 } =
6 via B.
Thus, the new routing table at router C is-
At router D,
Router D receives distance vectors from its neighbors A, B and C.
Cost of reaching destination A from router D = min { 1+0 , 3+2 ,
10+5 } = 1 via A.
Cost of reaching destination B from router D = min { 1+2 , 3+0 ,
10+3 } = 3 via A.
Cost of reaching destination C from router D = min { 1+5 , 3+3 ,
10+0 } = 6 via A.
Thus, the new routing table at router D is-

These will be the final routing tables at each router.


● In Distance Vector Routing,
○ Only distance vectors are exchanged.
○ “Next hop”values are not exchanged.
○ This is because it results in exchanging the large amount of
data which consumes more bandwidth.
● While preparing a new routing table-
○ A router takes into consideration only the distance vectors it
has obtained from its neighboring routers.
○ It does not take into consideration its old routing table.
● The algorithm is called so because-
○ It involves exchanging of distance vectors between the
routers.
○ Distance vector is nothing but an array of distances.
● The algorithm keeps on repeating periodically and never stops.
○ This is to update the shortest path in case any link goes down
or topology changes.
● Routing tables are prepared total (n-1) times if there are n routers
in the given network.
○ This is because shortest path between any 2 nodes contains at
most n-1 edges if there are n nodes in the graph.
● Distance Vector Routing suffers from count to infinity problem.
● Distance Vector Routing uses UDP at transport layer.
COUNT TO INFINITY PROBLEM
● The Count to Infinity Problem is brought on by the routing loop
in the DVR network.
● When two routers deliver updates simultaneously or when an
interface goes down, routing loops frequently happen.
● Distance-vector routing has the drawback that while cost
increases (bad news) propagate slowly, cost decreases (positive
news) propagate quickly.
● Distance-vector routing takes some time for all other routers to
become aware of a broken connection (cost becomes infinity),
which is necessary for a routing protocol to function properly.
● Counting to infinity is the name given to the issue.
● A broken link's cost may not always be registered as infinite by
all routers until numerous updates have passed.
SOLUTIONS TO COUNT TO INFINITY PROBLEM
Split Horizon
● The split horizon is a method for resolving instability.
● Each node in this technique delivers a portion of its table across
each interface rather than flooding the table through all of them.
● If node B believes that the best way to go to X is through node
A, then node B need not inform node A of this information
because it has already been provided by node A (A already
knows).
● Confusion is brought on by receiving data from node A, altering
it, then sending it back to node A.
Poison Reverse
● The split-horizon approach has one disadvantage.
● If there is no news about a route after a certain amount of time,
the corresponding protocol typically employs a timer and
instructs the node to remove the route from its table.
● In the previous example, node A is unable to determine whether
node B's decision to remove the route to X from its
advertisement to node A is the result of the split-horizon
technique (the information came from A) or the fact that B has
not recently received any news concerning X.
● In the poison reverse technique, B can still state the value for X,
but if the information came from A, it can substitute infinite for
the distance as a warning: " Do not utilise this value; you are the
source of my knowledge regarding this route."
DIFFERENCE: LS AND DV ROUTING ALGORITHM
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.
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.
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.
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.
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.
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.
COMPARISON BETWEEN RIP, OSPF AND BGP
Thank you……

149

You might also like