You are on page 1of 84

Network Layer

M A N O J K UM A R
A S S I S TA N T P R O F E S SO R
G J US & T, H I S A R
Contents
 Introduction to Network Layer
 Functionalities
 Design Issues
 Service Type
 Routing Algorithms
 Congestion Control Algorithms
 Admission Control
 Internetworking
 IPv4, IPv6
 IP Addressing- Classful addressing classless addressing, Public and Private IP addresses

 Routing Protocols- ARP, RARP, ICMP

5/19/2021 NETWORK LAYER 2


Introduction
 Network layer is Layer 3 in the OSI model.
 Its main work is Routing and providing service to Transport layer.
 It manages options pertaining to host and network addressing, managing
sub-networks, and internetworking.
 Network layer takes the responsibility for routing packets from source to
destination within or outside a subnet.
 It also has the responsibility to route the packets from source to destination,
mapping different addressing schemes and protocols.
 It also helps to communicate two different subnet may be operating on
different protocols which are not compatible with each other.
5/19/2021 NETWORK LAYER 3
Functionalities
 Network Layer mainly focus on Routing.
 It determine which route is suitable from source to destination and this function of network
layer is known as routing. Routing may include following goals:
 Addressing devices and networks.
 Populating routing tables or static routes.
 Queuing incoming and outgoing data and then forwarding them according to quality of service
constraints set for those packets.
 Internetworking between two different subnets.
 Delivering packets to destination with best efforts.
 Provides connection oriented and connection less mechanism.

 Logical Addressing: In order to identify each device on internetwork uniquely, network


layer defines an addressing scheme. The sender & receiver’s IP address are placed in the
header by network layer.
5/19/2021 NETWORK LAYER 4
Design Issues
 Network layer consider many design issues for providing services in network as:
 Routing
 Flow Control
 Error Control
 Addressing
 Reliability
 Scalability
 Quality of Service
 Resource Allocation
 Statistical Multiplexing
 Security

5/19/2021 NETWORK LAYER 5


Design Issues
 Along with the issues mentioned previously network layer performs the following operations
described as follows:
 Store and Forward packet switching: The host sends the packet to the nearest router. This
packet is stored there until it has fully arrived, once the link is fully processed by verifying
the checksum then it is forwarded to the next router till it reaches the destination. This
mechanism is called “Store and Forward packet switching.”
 Services provided to Transport Layer: Through the network/transport layer interface, the
network layer transfers its services to the transport layer. These services are described below.
But before providing these services to the transport layer following goals must be kept in
mind:-
 Offering services must not depend on router technology.
 The transport layer needs to be protected from the type, number and topology of the
available router.
 The network addresses for the transport layer should use uniform numbering pattern also
at LAN and WAN connections.

5/19/2021 NETWORK LAYER 6


Service Type and Switching Techniques
 Based on the connections there are 2 types of services provided:
 Connection-Oriented – When Subnet must offer reliable service and all the
packets must be transmitted over a single route.
 Connectionless – The routing and insertion of packets into subnet is done
individually. No added setup is required.
 Switching Techniques: Switching is the technique by which nodes control or switch
data to transmit it between specific points on a network. There are 3 common
switching techniques:
 Circuit Switching
 Packet Switching
 Message Switching

5/19/2021 NETWORK LAYER 7


Connection Oriented Service
 A connection-oriented service is one that establishes a dedicated connection
between the communicating entities for data transmission. To use a
connection-oriented service, we follow three phases:
 Connection establishment
 Data transfer
 Connection release
 In connection-oriented services, the data packets are delivered to the receiver
in the same order in which they have been sent by the sender. For example – A
telephone system.
 It uses circuit switching technique is used for connection and data
transmission.
 It provides reliable data transmission.

5/19/2021 NETWORK LAYER 8


Connection Oriented Service – Circuit
Switching Technique
 Circuit switching is a switching technique that establishes a dedicated path between
sender and receiver.
 In the Circuit Switching Technique, once the connection is established then the dedicated
path will remain to exist until the connection is terminated.

5/19/2021 NETWORK LAYER 9


Connection Oriented Service – Circuit
Switching Technique
 Circuit switching in a network operates in a similar way as the telephone works.
 A complete end-to-end path must exist before the communication takes place.
 When any user wants to send data, voice, video, a request signal is sent to the
receiver then the receiver sends back the acknowledgment to ensure the
availability of the dedicated path. After receiving the acknowledgment,
dedicated path transfers the data.
 Circuit switching is used in public telephone network.
 Fixed data can be transferred at a time in circuit switching technology.

5/19/2021 NETWORK LAYER 10


Connection Oriented Service – Circuit
Switching Technique
Circuit Switching technique have some pros and cons:
 Advantages of Circuit Switching
 Once path is set up, the only delay is in data transmission speed
 No problem of congestion or garbled message
 Disadvantages of Circuit Switching
 Long set up time is required
 A request token must travel to the receiver and then acknowledged before any
transmission can happen
 Line may be held up for a long time

5/19/2021 NETWORK LAYER 11


Connection Oriented Service
 Advantages of Connection-Oriented Services –
 This is mostly a reliable connection.
 Congestions are less frequent.
 Sequencing of data packets is guaranteed.
 Problems related to duplicate data packets are alleviated.
 Suitable for long connection.
 Disadvantages of Connection-Oriented Services –
 Resource allocation is needed before communication. This often leads to under-utilized
network resources.
 The lesser speed of connection due to the time is taken for establishing and relinquishing the
connection.
 In the case of router failures or network congestions, there are no alternative ways to continue
communication.

5/19/2021 NETWORK LAYER 12


Connectionless Service
A Connectionless service is a data communication between two nodes where the sender
sends data without ensuring whether the receiver is available to receive the data.
Here, each data packet (datagram) has the destination address and is routed
independently irrespective of the other packets.
Data packets may follow different paths to reach the destination. There’s no need to
setup connection before sending a message and relinquish it after the message has been
sent. The data packets in a connectionless service are usually called datagrams.
When the message size that has to be transmitted is 4 times (larger) the size of the
packet, then the network layer divides message into 4 packets and transmits each packet
to router via. few protocol. For example - Postal system.
It uses Packet switching technique for data transmission.

5/19/2021 NETWORK LAYER 13


Connectionless Service - Packet Switching
Technique
 Main problem with circuit switching is that it needs a dedicated line for
transmission. In packet switching, data is broken down into small packets with
each packet having source and destination addresses, travelling from one router
to the next router.

5/19/2021 NETWORK LAYER 14


Connectionless Service - Packet Switching
Technique
 The packet switching is a switching technique in which the message is sent in one go, but
it is divided into smaller pieces, and they are sent individually.
 The message splits into smaller pieces known as packets and packets are given a unique
number to identify their order at the receiving end.
 Every packet contains some information in its headers such as source address, destination
address and sequence number.
 Packets will travel across the network, taking the shortest path as possible.
 All the packets are reassembled at the receiving end in correct order.
 If any packet is missing or corrupted, then the message will be sent to resend the message.
 If the correct order of the packets is reached, then the acknowledgment message will be
sent.
5/19/2021 NETWORK LAYER 15
Connectionless Service - Packet Switching
Technique
 Advantages Of Packet Switching:
 Cost-effective: In packet switching technique, switching devices do not require massive secondary
storage to store the packets, so cost is minimized to some extent. Therefore, we can say that the packet
switching technique is a cost-effective technique.
 Reliable: If any node is busy, then the packets can be rerouted. This ensures that the Packet Switching
technique provides reliable communication.
 Efficient: Packet Switching is an efficient technique. It does not require any established path prior to
the transmission, and many users can use the same communication channel simultaneously, hence
makes use of available bandwidth very efficiently.
 Disadvantages Of Packet Switching:
 Packet Switching technique cannot be implemented in those applications that require low delay and
high-quality services.
 The protocols used in a packet switching technique are very complex and requires high implementation
cost.
 If the network is overloaded or corrupted, then it requires retransmission of lost packets. It can also lead
to the loss of critical information if errors are nor recovered.

5/19/2021 NETWORK LAYER 16


Connectionless Service
 Advantages of Connectionless Services-
 It has low overhead.
 It enables to broadcast and multicast messages, where the sender sends messages to multiple recipients.
 It is simpler and has low overhead.
 It does not require any time for circuit setup.
 In case of router failures or network congestions, the data packets are routed through alternate paths.
Hence, communication is not disrupted.
 Disadvantages of Connectionless Services
 It is not a reliable connection. It does not guarantee that there will not be a loss of packets, wrong
delivery, out – of – sequence delivery or duplication of packets.
 Each data packet requires longer data fields since it should hold all the destination address and the
routing information.
 They are prone to network congestions.

5/19/2021 NETWORK LAYER 17


Message Switching Technique
 Message Switching is a switching technique in which a message is transferred as a
complete unit and routed through intermediate nodes at which it is stored and
forwarded.
 In Message Switching technique, there is no establishment of a dedicated path between
the sender and receiver.
 The destination address is appended to the message. Message Switching provides a
dynamic routing as the message is routed through the intermediate nodes based on the
information available in the message.
 Message switches are programmed in such a way so that they can provide the most
efficient routes.
 Each and every node stores the entire message and then forward it to the next node.
This type of network is known as store and forward network.
5/19/2021 NETWORK LAYER 18
Message Switching Technique
 Message switching treats each message as an independent entity.

5/19/2021 NETWORK LAYER 19


Message Switching Technique
 During communication sender and receiver are not directly connected. There are a number of
intermediate nodes which transfer data and ensure that the message reaches its destination. Message
switched data networks are hence called hop-by-hop systems. They provide 2 distinct and important
characteristics:
 Store and forward – The intermediate nodes have the responsibility of transferring the entire
message to the next node.
 Hence, each node must have storage capacity. A message will only be delivered if the next hop
and the link connecting it are both available, otherwise it’ll be stored indefinitely.
 A store-and-forward switch forwards a message only if sufficient resources are available and the
next hop is accepting data. This is called the store-and-forward property.
 Message delivery – This implies wrapping the entire information in a single message and
transferring it from the source to the destination node.
 Each message must have a header that contains the message routing information, including the
source and destination.
5/19/2021 NETWORK LAYER 20
Advantages and Disadvantages Of Message
Switching
 Advantages: Data channels are shared among the communicating devices that improve the
efficiency of using available bandwidth.
 Traffic congestion can be reduced because the message is temporarily stored in the nodes.
 Message priority can be used to manage the network.
 The size of the message which is sent over the network can be varied. Therefore, it supports
the data of unlimited size.
 Disadvantages: The message switches must be equipped with sufficient storage to enable
them to store the messages until the message is forwarded.
 The Long delay can occur due to the storing and forwarding facility provided by the message
switching technique.

5/19/2021 NETWORK LAYER 21


Routing Algorithms
Routing is the process of forwarding of a packet in a network so that it reaches its
intended destination. The routing algorithms may be classified as follows:

Routing Algorithms

Adaptive Non-Adaptive

Centralized Isolated Distributed Flooding Random Walk

5/19/2021 NETWORK LAYER 22


Adaptive Routing Algorithms
Adaptive Routing Algorithms: Algorithms which change their routing
decisions whenever network topology or traffic load changes. The changes in
routing decisions are reflected in the topology as well as traffic of the network.
These algorithms are also known as dynamic routing.
These make use of dynamic information such as current topology, load, delay,
etc. to select routes.
Optimization parameters are distance, number of hops and estimated transit
time.

5/19/2021 NETWORK LAYER 23


Adaptive Routing Algorithms cont..
 Further these are classified as follows:
 Centralized – In this method, a centralized node has entire information about the network
and makes all the routing decisions. Advantage of this is only one node is required to keep the
information of entire network and disadvantage is that if central node goes down the entire
network is done.
 Distributed – In this method, the node receives information from its neighbors and then
takes the decision about routing the packets. Disadvantage is that the packet may be delayed
if there is change in between interval in which it receives information and sends packet.
 Isolated – In this method each, node makes its routing decisions using the information it has
locally without seeking information from other nodes. The sending nodes doesn’t have
information about status of particular link. Disadvantage is that packet may be sent through a
congested network which may result in delay. Examples: Hot potato routing, backward
learning.

5/19/2021 NETWORK LAYER 24


Non-Adaptive Routing Algorithms
 Non-Adaptive Routing Algorithms: These are the algorithms which do not change
their routing decisions once they have been selected. This is also known as static
routing as route to be taken is computed in advance and downloaded to routers when
router is booted.
 Further these are classified as follows:
 Flooding – This adapts the technique in which every incoming packet is sent on every
outgoing line except from which it arrived. One problem with this is that packets may go in
loop and as a result of which a node may receive duplicate packets. These problems can be
overcome with the help of sequence numbers, hop count and spanning tree.
 Random walk – In this method, packets are sent host by host or node by node to one of its
neighbors randomly. This is highly robust method which is usually implemented by sending
packets onto the link which is least queued.

5/19/2021 NETWORK LAYER 25


Routing v/s Flooding

Sr. No. Routing Flooding

1 Routing table is required No routing table required


2 May give shortest path Always gives shortest path
3 Less reliable More reliable
4 Less Traffic High Traffic
5 No duplicate packets Duplicate packets presents

5/19/2021 NETWORK LAYER 26


Hierarchical Routing
 Hierarchical Routing: In this method of routing the nodes are divided into regions based on
hierarchy.
 A particular node can communicate with nodes at the same hierarchical level or the nodes at
a lower level and directly under it.
 Here, the path from any source to a destination is fixed and is exactly one if the hierarchy is a
tree.
 Networks can be organized in hierarchies of many levels; e.g. local networks of a city at one
level, the cities of a country at a level above it, and finally the network of all nations.
 In Hierarchical routing, the interfaces need to store information about:
 All nodes in its region which are at one level below it.
 Its peer interfaces.
 At least one interface at a level above it, for outgoing packages.
5/19/2021 NETWORK LAYER 27
Hierarchical Routing
 Advantages of Hierarchical Routing-
 Smaller sizes of routing tables.
Substantially lesser calculations and updates of routing tables.
 Disadvantage of Hierarchical Routing-
 Once the hierarchy is imposed on the network, it is followed and possibility of direct
paths is ignored.
 This may lead to sub optimal routing.

5/19/2021 NETWORK LAYER 28


Optimality Principle
 We can make a general statement about optimal routes without regard to network topology or
traffic which is known as optimality principle.
 It states that if router J is on the optimal path from router I to router K, then the optimal path
from J to K also falls along the same route. To check this, imagine the route from I to J as r1 and
rest of the route as r2. If a route better than r2 existed from J to K, it could be concatenated with
r1 to improve the route from I to K, contradicting our statement that r1-r2 is optimal.
 As a direct consequence of the optimality principle, one can see that the set of optimal routes
from all sources to a given destination from a tree rooted at the destination. Such a tree is called
as sink tree and is illustrated in figure on next slide, where the distance metric is number of
hops.
 Note that a sink tree is not necessarily unique, other trees with same path lengths may exists.
The goal of all routing algorithms is to discover and use the sink tree for all routers.

5/19/2021 NETWORK LAYER 29


Optimality Principle
 Since, a sink tree is indeed a tree, it does not contain any loop, so each packet will be delivered within a
finite and bounded number of hops.
 Links and routers can go down and come back up during operation, so different routers may have different
ideas about the current topology.
 The optimality principle and the sink tree provide a benchmark against which other routing algorithms can
be measured.

Figure: (a) A subnet (b) a sink tree for router B


5/19/2021 NETWORK LAYER 30
Shortest path Routing Algorithm
 'How to determine the optimal path for routing?'
 We need to calculate a shortest path that is optimal.
 Various algorithms are used to determine the optimal routes with respect to some
predetermined criteria.
 A network is represented as a graph, with its terminals as nodes and the links as edges. A
'length' is associated with each edge, which represents the cost of using the link for
transmission.
 Lower the cost, more suitable is the link. The cost is determined depending upon the criteria to
be optimized. Some of the important ways of determining the cost are:
 Minimum number of hops: If each link is given a unit cost, the shortest path is the one with
minimum number of hops. Such a route is easily obtained by a breadth first search method. This is
easy to implement but ignores load, link capacity etc.

5/19/2021 NETWORK LAYER 31


Shortest path Routing Algorithm
 Transmission and Propagation Delays: If the cost is fixed as a function of transmission and propagation
delays, it will reflect the link capacities and the geographical distances. However these costs are essentially
static and do not consider the varying load conditions.
 Queuing Delays: If the cost of a link is determined through its queuing delays, it takes care of the varying
load conditions, but not of the propagation delays.
 Routing decision in networks, are mostly taken on the basis of cost between source and destination.
Hop count plays major role here. Shortest path is a technique which uses various algorithms to decide
a path with minimum number of hops.
 Common shortest path algorithms are:
 Dijkstra's algorithm
 Bellman Ford algorithm
 Floyd Warshall’s algorithm

5/19/2021 NETWORK LAYER 32


Flooding
 Flooding is simplest method packet forwarding. When a packet is received, the routers send it
to all the interfaces except the one on which it was received.
 It creates too much burden on the network and lots of duplicate packets wandering in the
network.
 Time to Live (TTL) can be used to avoid infinite looping of packets. There exists another
approach for flooding, which is called Selective Flooding to reduce the overhead on the
network. In this method, the router does not flood out on all the interfaces, but selective ones.
 Advantages of Flooding:
 Highly Robust, emergency or immediate messages can be sent (e.g. military applications)
 Set up route in virtual circuit
 Flooding always chooses the shortest path
 Broadcast messages to all the nodes

5/19/2021 NETWORK LAYER 33


Distance Vector Routing Algorithm
Distance Vector Routing is one of the dynamic routing algorithm.
It is suitable for packet switched network.
In distance vector routing, each router maintains a routing table.
It contains one entry for each router in the subnet. This entry has two parts:
 The first part shows the preferred outgoing line to be used to reach the destination.
 Second part gives an estimate of the time or distance to the destination.

5/19/2021 NETWORK LAYER 34


Distance Vector Routing Algorithm
In distance vector routing, a node tells its neighbor about its distance to every
other node in the network.
Distance vector algorithm is iterative, asynchronous and distributed in nature.
 Distributed: It is distributed in that each node receives information from one or more of its
directly attached neighbors, performs calculation and then distributes the result back to its
neighbors.
 Iterative: It is iterative in that its process continues until no more information is available to
be exchanged between neighbors.
 Asynchronous: It does not require that all of its nodes operate in the lock step with each
other.

5/19/2021 NETWORK LAYER 35


Distance Vector Routing Algorithm
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.

5/19/2021 NETWORK LAYER 36


Link State Routing Algorithm
 Link state is a dynamic routing algorithm in which each router shares knowledge of its neighbors with
every other router in the network.
 A router sends its information about its neighbors only to all the routers through flooding.
 Information sharing takes place only whenever there is a change.
 It makes use of Dijkistra’s Algorithm for making routing tables.
 Keys to understand Link state routing:
 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.

5/19/2021 NETWORK LAYER 37


Link State Routing Algorithm cont…
 Link State Routing Phases:
 Reliable Flooding
 Initial state: Each node knows the cost of its neighbors.
 Final state: Each node knows the entire graph.
 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.

5/19/2021 NETWORK LAYER 38


Distance Vector v/s Link state Routing
Sr. No. Distance Vector Routing Link State Routing
Less bandwidth needed due to local sharing, small High bandwidth needed due to flooding and
1
packets and no flooding sending of large link state packets

It have local knowledge and updates table based on It have global knowledge and keeps
2
information from neighbors information about whole network
3 Uses Bellman ford algorithm Uses Dijkistra’s algorithm
4 Less traffic More traffic
Converges slowly i.e. good news spread fast and
5 Converges faster
bad news spread slowly
6 It has Count to infinity problem No issue of count to infinity problem
Persistent looping problem i.e., loop will be there
7 No Persistent looping only transient loops
forever
8 Implemented in – RIP, IGRP Implemented in- OSPF, ISIS
5/19/2021 NETWORK LAYER 39
Count to Infinity Problem
 Problem with distance vector routing is whenever a link is broken, other routers unknowingly
gives information that they know how to reach a disconnected node. This false information will
propagate to all routers. This problem is known as count to infinity.
 One of the important issue in Distance Vector Routing is Count to Infinity Problem.
 Counting to infinity is just another name for a routing loop.
 In distance vector routing, routing loops usually occur when an interface goes down.
 It can also occur when two routers send updates to each other at the same time.

5/19/2021 NETWORK LAYER 40


Congestion Control Algorithms
 A state occurring in network layer when the message traffic is so heavy that it slows down
network response time is called as congestion.
 Effects of Congestion:
 As delay increases, performance decreases.
 If delay increases, retransmission occurs, making situation worse.

 Congestion control algorithms:


 Leaky Bucket Algorithm
 Token bucket Algorithm

5/19/2021 NETWORK LAYER 41


Congestion Control Algorithms contd..
 Leaky Bucket Algorithm: Imagine a bucket with a small
hole in the bottom. No matter at what rate water enters the
bucket, the outflow is at constant rate. When the bucket is
full with water additional water entering spills over the sides
and is lost.
 Similarly, each network interface contains a leaky bucket and
the following steps are involved in leaky bucket algorithm:
 When host wants to send packet, packet is thrown into the
bucket.
 The bucket leaks at a constant rate, meaning the network
interface transmits packets at a constant rate.
 Bursty traffic is converted to a uniform traffic by the leaky
bucket.
 In practice the bucket is a finite queue that outputs at a finite
rate. Figure: Leaky Bucket example

5/19/2021 NETWORK LAYER 42


Congestion Control Algorithms contd..
 Token bucket Algorithm: The leaky bucket algorithm enforces
output pattern at the average rate, no matter how bursty the
traffic is.
 In order to deal with the bursty traffic we need a flexible
algorithm so that the data is not lost.
 One such algorithm is token bucket algorithm.
 Steps of this algorithm can be described as follows:
 In regular intervals tokens are thrown into the bucket. Ƒ
 The bucket has a maximum capacity.
 If there is a ready packet, a token is removed from the bucket, and
the packet is sent.
 If there is no token in the bucket, the packet cannot be sent.

5/19/2021 NETWORK LAYER 43


Congestion Control Techniques
 Congestion control refers to the techniques used to control or prevent congestion.
Congestion control techniques can be broadly classified into two categories:
 Open Loop Congestion Control
 Closed Loop Congestion Control
 Open loop congestion control policies are applied to prevent congestion before it
happens. The congestion control is handled either by the source or the destination.
Open loop control loop have following policies:
 Retransmission Policy
 Window Policy
 Discarding Policy
 Acknowledgment Policy
 Admission Policy

5/19/2021 NETWORK LAYER 44


Congestion Control Techniques
 Closed Loop Congestion Control: Closed loop congestion control technique is used to treat or
alleviate congestion after it happens. Several techniques are used by different protocols; some of
them are:
 Backpressure
 Choke Packet Technique
 Implicit Signaling
 Explicit Signaling

5/19/2021 NETWORK LAYER 45


InterNetworking
 Internetworking term in computer networking explains how computer networks connect with each
other through Internetworking devices.
 Computer networks are basically built from three components:
 End Devices: -Computer, laptop, data server and tablet
 Networking Devices: -Switches, Routers, HUB, Bridges, firewalls and modems
 Media: -Copper cables, fiber cable and wireless signals

 For internetworking, IP address (Internet Protocol address) plays a crucial role.


 It is a numerical representation that uniquely identifies a specific interface on the network. It is a
logical identifier for an interface that is connected to the network.
 Two versions of IP are currently in use:
 IPv4 address
 IPv6 address

5/19/2021 NETWORK LAYER 46


IPv4 Address
 An IPv4 address is an address used in order to uniquely identify a device on an
network.
 It allows for a maximum of 4,294,967,296 -- (232) unique addresses.
 IPv4 address is made up of 32 binary bits, which can be divisible into a network
portion and host portion with the help of a subnet mask.
 IP address contains information about the host and its network. To distinguish both,
routers use Subnet Mask, which is as long as the size of the network address (32-bits)
in the IP address.
 The 32 binary bits are broken into four octets (1 octet = 8 bits).

5/19/2021 NETWORK LAYER 47


IPv4 Address Representation
 A IP address can be presented in binary and decimal form.
 Decimal representation: 10 . 1 . 23 . 19
 Binary representation 00001010.00000001.00010111.00010011
 IP address consist of 4 octets. Each octet have 8 bits.
 An IP address may range in 0.0.0.0 to 255.255.255.255
 In binary it can vary from 00000000 to 11111111 in one octet
 To convert from binary to decimal
(MSB) (LSB)
1 1 1 1 1 1 1 1
128 64 32 16 8 4 2 1 (128+64+32+16+8+4+2+1=255)
27 26 25 24 23 22 21 20

5/19/2021 NETWORK LAYER 48


IPv4 Address Class
 IPv4 have divided the IP addresses into 5 classes based on requirement.

First Octet First Octet Value in Default Subnet


Class Range
Value Binary Mask
00000000 - 01111111 0.0.0.0 –
A 0-127 255.0.0.0
127..255.255.255
10000000 - 10111111 128.0.0.0 –
B 128-191 255.255.0.0
191.255.255.255
11000000 - 11011111 192.0.0.0 –
C 192-223 255.255.255.0
223.255.255.255

D 224-239
11100000 - 11101111 224.0.0.0-
-
239.255.255.255
240.0.0.0-
E 240-255 11110000 - 11111111 255.255.255.255
-

5/19/2021 NETWORK LAYER 49


Reserved IP Address
 Few reserved IPv4 address spaces which cannot be used on the internet. These
addresses serve special purpose and cannot be routed outside the Local Area Network.
 Private IP Addresses: Every class of IP, (A, B & C) has some addresses reserved as Private
IP addresses.
 These IPs can be used within a network, campus, company and are private to it. These
addresses cannot be routed on the Internet, so packets containing these private addresses are
dropped by the Routers.
 The ranges in each class are shown below in table:
Class Range Default Subnet Mask
A 10.0.0.0 – 10.255.255.255 255.0.0.0
B 172.16.0.0 – 172.31.255.255 255.255.0.0
C 192.168.0.0 – 192.168.255.255 255.255.255.0

5/19/2021 NETWORK LAYER 50


Reserved IP Address
 Loopback IP Address: IP address range 127.0.0.0 – 127.255.255.255 is reserved for loopback, i.e. a
Host’s self-address, also known as local host address.
 This loopback IP address is managed entirely by and within the operating system. Loopback
addresses, enable the Server and Client processes on a single system to communicate with each other.
 Data sent on loopback is forwarded by the operating system to a virtual network interface within
operating system.
 This address is mostly used for testing purposes like client-server architecture on a single machine.
 Other than that, if a host machine can successfully ping 127.0.0.1 or any IP from loopback range,
implies that the TCP/IP software stack on the machine is successfully loaded and working.

5/19/2021 NETWORK LAYER 51


Reserved IP Address
 Link-local Addresses: In case a host is not able to acquire an IP address from the DHCP server
and it has not been assigned any IP address manually, the host can assign itself an IP address
from a range of reserved Link-local addresses.
 Link local address ranges from 169.254.0.0 - 169.254.255.255.

5/19/2021 NETWORK LAYER 52


IPv4 Addressing Modes
 IPv4 supports three different types of addressing modes. −
 Unicast Addressing Mode- In this mode, data is sent only to one destined host.
 The Destination Address field contains 32-bit IP address of the destination host. Here the
client sends data to the targeted server.
 Broadcast Addressing Mode- In this mode, the packet is addressed to all the hosts in a
network segment. The Destination Address field contains a special broadcast address,
i.e. 255.255.255.255. When a host sees this packet on the network, it is bound to process
it. Here the client sends a packet, which is entertained by all the Servers.
 Multicast Addressing mode - This mode is a mix of the previous two modes, i.e. the
packet sent is neither destined to a single host nor all the hosts on the segment. In this
packet, the Destination Address contains a special address which starts with 224.x.x.x and
can be entertained by more than one host.

5/19/2021 NETWORK LAYER 53


IPv4 Packet Header Format
 IPv4 takes data from above layer and add the header.
 IPv4 header size ranges from 20 to 60 byte.

5/19/2021 NETWORK LAYER 54


IPv4 Packet Header Format contd…
 Version: Version is a 4 bit field that indicates the IP version used always contain value
(0100).
 The most popularly used IP versions are version-4 (IPv4) and version-6 (IPv6).
 Only IPv4 uses the above header.
 Header Length: Header length is a 4 bit field that contains the length of the IP header.
 So, the range of decimal values that can be represented is [0, 15].
 To represent the header length, we use a scaling factor of 4.
 The initial 5 rows of the IP header are always used.
 So, minimum length of IP header = 5 x 4 bytes = 20 bytes.
 The size of the 6th row representing the Options field vary.
 The size of Options field can go up to 40 bytes.
 So, maximum length of IP header = 20 bytes + 40 bytes = 60 bytes.

5/19/2021 NETWORK LAYER 55


IPv4 Packet Header Format contd…
 Types of Service:
 Type of service is a 8 bit field that is used for Quality of Service (QoS).
 The datagram is marked for giving a certain treatment using this field.
 Total Length:
 Total length is a 16 bit field that contains the total length of the datagram (in bytes).
 Total length = Header length + Payload length
 Minimum total length of datagram = 20 bytes (20 bytes header + 0 bytes data)
 Maximum total length of datagram = Maximum value of 16 bit word = 65535 bytes
 Identification:
 Identification is a 16 bit field.
 It is used for the identification of the fragments of an original IP datagram.
 When an IP datagram is fragmented,
 Each fragmented datagram is assigned the same identification number.
 This number is useful during the re assembly of fragmented datagrams.

5/19/2021 NETWORK LAYER 56


IPv4 Packet Header Format contd…
 DF Bit :DF bit stands for Do Not Fragment bit.
 Its value may be 0 or 1.
 DF 0, means fragment allow, if required.
 DF 1, means fragmentation not allowed.
 MF Bit: MF bit stands for More Fragments bit.
 Its value may be 0 or 1.
 MF 0, indicates last or only fragment.
 MF 1, indicates current datagram is fragment of other larger datagram.
 Fragment Offset: Fragment Offset is a 13 bit field.
 It indicates the position of a fragmented datagram in the original unfragmented IP datagram.
 The first fragmented datagram has a fragment offset of zero.

5/19/2021 NETWORK LAYER 57


IPv4 Packet Header Format contd…
 Time To Live (TTL): Time to live (TTL) is a 8 bit field.
 It indicates the maximum number of hops a datagram can take to reach the destination.
 The main purpose of TTL is to prevent the IP datagrams from looping around forever in a routing loop.
 If the value of TTL becomes zero before reaching the destination, then datagram is discarded.

 Protocol: Protocol is a 8 bit field.


 It tells the network layer at the destination host to which protocol the IP datagram belongs to.
 In other words, it tells the next level protocol to the network layer at the destination side.

 Header Checksum: Header checksum is a 16 bit field.


 It contains the checksum value of the entire header.
 The checksum value is used for error checking of the header.
 At each hop: -
 The header checksum is compared with the value contained in this field.
 If header checksum is found to be mismatched, then the datagram is discarded.
 Router updates the checksum field whenever it modifies the datagram header.

5/19/2021 NETWORK LAYER 58


IPv4 Packet Header Format contd…
 Source IP Address: Source IP Address is a 32 bit field.
 It contains the logical address of the sender of the datagram.
 Destination IP Address: Destination IP Address is a 32 bit field.
 It contains the logical address of the receiver of the datagram.
 Options: Options is a field whose size vary from 0 bytes to 40 bytes.
 This field is used for several purposes such as-
 Record route
 Source routing
 Padding

5/19/2021 NETWORK LAYER 59


IPv6 Address
 Internet Protocol version 6 (IPv6) is the latest revision of the Internet Protocol (IP) and the
first version of the protocol to be widely deployed.
 IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-
anticipated problem of IPv4 address exhaustion.
 It is a 128-bit alphanumeric string that identifies an endpoint device in the Internet Protocol
Version 6 (IPv6) addressing scheme.
 IPv6 addresses are preferred by professional users such as network engineers, tech companies,
datacenters and mobile carriers.
 The IPv6 format was created to enable the trillions of new IP addresses required to connect
not only an ever-greater number of computing devices but also the rapidly expanding
numbers of items with embedded connectivity.

5/19/2021 NETWORK LAYER 60


In the Internet of Things (IoT) scenario, objects, animals and people are provided
with unique identifiers and the ability to automatically transfer data over a network
without requiring human-to-human or human-to-computer interaction.
IPv6 expands the available address space sufficiently to enable anything conceivable to
have an IP address.
The number of potential IPv6 addresses has been calculated as over 3.4* 1038 =(340
undecillion).
We can provide IPv6 address for each atom on the surface of the planet-- with enough
left over for more than 100 more similar planets.

5/19/2021 NETWORK LAYER 61


Types of IPv6 Address
 Unicast: An identifier for a single interface. A packet sent to a unicast address is delivered to the
interface identified by that address. (E.g. Telephone communication).
 Anycast: An identifier for a set of interfaces (typically belonging to different nodes). A packet sent
to an anycast address is delivered to one of the interfaces identified by that address (the "nearest"
one, according to the routing protocols' measure of distance). (E.g. –Google established various
servers all around the world having same anycast IP address. When we send any request on google, it
will be delivered to nearest server to us and the response will delivered back.)
 Multicast: An identifier for a set of interfaces (typically belonging to different nodes). A packet sent
to a multicast address is delivered to all interfaces identified by that address. (E.g.- Whatsapp group,
A message sent in a group will be delivered to all contacts in group, but not to all contacts in your
phone.
 There are no broadcast addresses in IPv6, their function being superseded by multicast addresses.

5/19/2021 NETWORK LAYER 62


IPv6 Address Structure
 An IPv6 address is made of 128 bits divided into eight 16-bits blocks. Each block is then
converted into 4-digit Hexadecimal numbers separated by colon symbols.
 Given below is a 128 bit IPv6 address represented in binary format and divided into eight 16-
bits blocks:
0010000000000001 0000000000000000 0011001000111000 1101111111100001 0000000001100011
0000000000000000 0000000000000000 1111111011111011

 Each block is then converted into Hexadecimal and separated by ‘:’ symbol:
2001:0000:3238:DFE1:0063:0000:0000:FEFB

5/19/2021 NETWORK LAYER 63


IPv6 Address Rules
 Even after converting into Hexadecimal format, IPv6 address remains long. IPv6 provides some
rules to shorten the address. The rules are as follows:
2001:0000:3238:DFE1:0063:0000:0000:FEFB
 Rule.1: Discard leading Zero(es):
 In Block 5, 0063, the leading two 0s can be omitted, such as (5th block):
2001:0000:3238:DFE1:63:0000:0000:FEFB

 Rule.2: If two of more blocks contain consecutive zeroes, omit them all and replace with double
colon sign ::, such as (6th and 7th block):
2001:0000:3238:DFE1:63::FEFB

Consecutive blocks of zeroes can be replaced only once by :: so if there are still blocks of zeroes
in the address, they can be shrunk down to a single zero, such as (2nd block):
2001:0:3238:DFE1:63::FEFB

5/19/2021 NETWORK LAYER 64


Reserved Addresses in IPv6
 IPv6 has reserved a few addresses and address notations
for special purposes. The type of an IPv6 address is
identified by the high-order bits of the address IPv6
Binary Prefix Address Type
Notation
 As shown in the table, the address 0:0:0:0:0:0:0:0/128 Unspecified
does not specify anything and is said to be an 0000.....0 (128 bits) ::/128
Address
unspecified address. After simplifying, all the 0s are
compacted to ::/128. 0000.....01 (128 bits) ::1/128 Loopback Address
 In IPv4, the address 0.0.0.0 with netmask 0.0.0.0
represents the default route. The same concept is also 0000….0 (128 bits) ::/0 Default route
applied to IPv6, address 0:0:0:0:0:0:0:0 with netmask all
0s represents the default route. After applying IPv6 rule, 11111111 FF00::/8 Multicast Address
this address is compressed to ::/0.
 Loopback addresses in IPv4 are represented by 1111111010 FE80::/10 Link-local unicast
127.0.0.1 to 127.255.255.255 series. But in IPv6, only
0:0:0:0:0:0:0:1/128 represents the Loopback address. Global Unicast
Remaining
After loopback address, it can be represented as ::1/128. Address

5/19/2021 NETWORK LAYER 65


Reserved Multicast Address for Routing Protocols
 The above table shows the reserved multicast addresses used by interior
routing protocol.
 The addresses are reserved following the same rules of IPv4.

IPv6 Address Routing Protocol

FF02::5 OSPF v3

FF02::5 OSPF v3 Designated router

FF02::9 RIPng

FF02::A EIGRP

5/19/2021 NETWORK LAYER 66


Structure of IPv6 Packet
 IPv6 packet has a fixed header of 40 bytes.
 It may have zero or more Optional (Extension) Headers.
 All the necessary information that is essential for a router is kept in the Fixed Header.
 The Extension Header contains optional information that helps routers to understand how to
handle a packet/flow.
 Upper layer protocol data unit (PDU) usually consists of an upper layer protocol header and
its payload (for example, an ICMPv6 message, a UDP message, or a TCP segment).
 Structure of IPv6 packet looks like as shown below:

IPv6 Header Extension Header Upper Layer Protocol Data Unit

5/19/2021 NETWORK LAYER 67


IPv6 Header
 An IPv6 address is 4 times larger than IPv4, but surprisingly, the header of an IPv6 address is
only 2 times larger than that of IPv4. IPv6 headers have one Fixed Header and may have zero or
more extension header.

Version (4-bits) Traffic class (8-bits) Flow Label (20-bits)


0-3 4-11 12-31
Payload Length (16-bits) Next Header (8-bits) Hop Limit (8-bits)
32-47 48-55 56-63
Source Address (128-bits)
64-191
Destination Address (128-bits)
192-319

5/19/2021 NETWORK LAYER 68


IPv6 Header contd…
 Version: 4 bits (0110) are used to indicate the version of IP and is set to 6.
 Traffic Class: Indicates the class or priority of the IPv6 packet.
 The size of this field is 8 bits.
 The Traffic Class field provides similar functionality to the IPv4 Type of Service field.
 Flow Label: Indicates that this packet belongs to a specific sequence of packets between a
source and destination, requiring special handling by intermediate IPv6 routers.
 The size of this field is 20 bits.
 The Flow Label is used for non-default quality of service connections, such as those
needed by real-time data (voice and video).
 For default router handling, the Flow Label is set to 0.
 There can be multiple flows between a source and destination, as distinguished by
separate non-zero Flow Labels.

5/19/2021 NETWORK LAYER 69


IPv6 Header contd…
 Payload Length: Indicates the length of the IPv6 payload.
 The size of this field is 16 bits.
 The Payload Length field includes the extension headers and the upper layer PDU.
 With 16 bits, an IPv6 payload of up to 65,535 bytes can be indicated.
 For payload lengths greater than 65,535 bytes, the Payload Length field is set to 0
and the Jumbo Payload option is used in the Hop-by-Hop Options extension
header.
 Next Header: Indicates either the first extension header (if present) or the protocol in
the upper layer PDU (such as TCP, UDP, or ICMPv6).
 The size of this field is 8 bits. When indicating an upper layer protocol above the
Internet layer, the same values used in the IPv4 Protocol field are used here.

5/19/2021 NETWORK LAYER 70


IPv6 Header contd…
 Hop Limit: Indicates the maximum number of links over which the IPv6 packet can travel
before being discarded.
 The size of this field is 8 bits.
 The Hop Limit is similar to the IPv4 TTL field except that there is no historical relation
to the amount of time (in seconds) that the packet is queued at the router.
 When the Hop Limit equals 0, an ICMPv6 Time Exceeded message is sent to the source
address and the packet is discarded.
 Source Address: Stores the IPv6 address of the originating host. The size of this field is 128
bits.
 Destination Address: Stores the IPv6 address of the current destination host.
 The size of this field is 128 bits.
 In most cases the Destination Address is set to the final destination address.
 However, if a Routing extension header is present, the Destination Address might be
set to the next router interface in the source route list.

5/19/2021 NETWORK LAYER 71


Features of IPv6
 IPv6 is designed to overcome the issues in IPv4. like address space, security, extensibility.
 It provides some more features over IPv4:
 New Header Format: IPv6 header has a new format to minimize header overhead.
 It has optimized header by moving the non-essential fields and optional fields to extension
headers that appear after the IPv6 header.
 IPv4 headers and IPv6 headers do not interoperate .
 Larger Address Space: IPv6 uses 4 times more bits than IPv4 to address a device on the
Internet.
 So 32*4 =128 bits can express over 3.4×1038 possible combinations.
 This address can accumulate the aggressive requirement of address allotment for almost
everything in this world.

5/19/2021 NETWORK LAYER 72


Features of IPv6 contd…
End-to-end Connectivity: Every system now has unique IP address and can traverse through the
Internet without using NAT or other translating components.
After IPv6 is fully implemented, every host can directly reach other hosts on the Internet, with
some limitations involved like Firewall, organization policies, etc.
Auto-configuration: IPv6 supports both stateful and stateless auto configuration mode of its host
devices.
This way, absence of a DHCP server does not put a halt on inter segment communication.
Faster Forwarding/Routing: Simplified header puts all unnecessary information at the end of
the header.
The information contained in the first part of the header is adequate for a Router to take routing
decisions, thus making routing decision as quickly as looking at the mandatory header.

5/19/2021 NETWORK LAYER 73


Features of IPv6 contd…
 Built-in Security: The IPv6 protocol suite requires support for IPSec.
 This requirement provides a standards-based solution for network security needs and promotes
interoperability between different IPv6 implementations.
 Better Support for QoS: New fields in the IPv6 header define how traffic is handled and
identified.
 Traffic identification (using a Flow Label field in the IPv6 header) allows routers to identify and
provide special handling for packets belonging to a flow, which is a series of packets between a
source and a destination.
 Because the IPv6 header identifies the traffic, QoS can be supported even when the packet
payload is encrypted through IPSec.

5/19/2021 NETWORK LAYER 74


Features of IPv6 contd…
 No Broadcast: Though Ethernet/Token Ring are considered as broadcast network because they
support Broadcasting, IPv6 does not have any broadcast support any more.
 It uses multicast to communicate with multiple hosts.
 Anycast Support: IPv6 has introduced Anycast mode of packet routing.
 In this mode, multiple interfaces over the Internet are assigned same Anycast IP address.
 Routers, while routing, send the packet to the nearest destination.
 Mobility: IPv6 was designed keeping mobility in mind.
 This feature enables hosts (such as mobile phone) to roam around in different geographical area
and remain connected with the same IP address.
 The mobility feature of IPv6 takes advantage of auto IP configuration and Extension headers.

5/19/2021 NETWORK LAYER 75


Features of IPv6 contd…
 Enhanced Priority Support: IPv4 used 6 bits DSCP (Differential Service Code Point) and 2
bits ECN (Explicit Congestion Notification) to provide Quality of Service but it could only be
used if the end-to-end devices support it, that is, the source and destination device and
underlying network must support it.
 In IPv6, Traffic class and Flow label are used to tell the underlying routers how to efficiently
process the packet and route it.
 Extensibility:IPv6 can easily be extended by adding extension headers after the IPv6 header.
 Unlike options in the IPv4 header, which can support only 40 bytes of options, the size of IPv6
extension headers is constrained only by the size of the IPv6 packet.

5/19/2021 NETWORK LAYER 76


Advantages of IPv6 addresses
 Converting to an IPv6 network, and thus, IPv6 addresses can bring a variety of benefits, including:
 More efficient routing with smaller routing tables and aggregation of prefixes.
 More simplified packet processing due to more streamlined packet headers.
 Support of multicast packet flows.
 Hosts can generate their own IP addresses.
 Eliminates the need for network address translation (NAT).
 Easier to implement services like peer-to-peer (P2P) networks, VoIP and stronger security.

5/19/2021 NETWORK LAYER 77


Disadvantages of IPv6 addresses
 Main drawback of using an IPv6 address is that IPv4 is still widely used.
 Communication between IPv4 and IPv6 machines is not possible directly and
requires gateway equipment.
 Switching from IPv4 to IPv6 also requires a lot of technical skill, effort and time.
 Additionally, IPv6 addresses are more complex, harder to read and difficult to
remember.

5/19/2021 NETWORK LAYER 78


IPv4 v/s IPv6 Header
IPv4 Header Field IPv6 Header Field
Version Same field but with different version numbers.
Removed in IPv6. IPv6 does not include a Header Length field because the IPv6
Internet Header Length header is always a fixed size of 40 bytes. Each extension header is either a fixed
size or indicates its own size.
Type of Service Replaced by the IPv6 Traffic Class field.
Replaced by the IPv6 Payload Length field, which only indicates the size of the
Total Length
payload.
Identification
Removed in IPv6. Fragmentation information is not included in the IPv6 header.
Fragmentation Flags
It is contained in a Fragment extension header.
Fragment Offset

5/19/2021 NETWORK LAYER 79


IPv4 v/s IPv6 Header
IPv4 Header Field IPv6 Header Field
Time to Live Replaced by the IPv6 Hop Limit field.
Protocol Replaced by the IPv6 Next Header field.
Removed in IPv6. In IPv6, bit-level error detection for the entire IPv6
Header Checksum
packet is performed by the link layer.
Source Address The field is the same except that IPv6 addresses are 128 bits in length.
Destination Address The field is the same except that IPv6 addresses are 128 bits in length.
Removed in IPv6. IPv4 options are replaced by IPv6 extension
Options
headers.

5/19/2021 NETWORK LAYER 80


IPv4 and IPv6 Addresses
Sr. No. IPv4 IPv6
1 IPv4 has 32-bit address length IPv6 has 128-bit address length
It Supports Manual and DHCP It supports Auto and renumbering address
2
address configuration configuration
In IPv4 end to end connection In IPv6 end to end connection integrity is
3
integrity is Unachievable Achievable
It can generate 4.29×109 address Address space of IPv6 is quite large it can
4
space produce 3.4×1038 address space
Security feature is dependent on IPSEC is inbuilt security feature in the IPv6
5
application protocol
Address representation of IPv4 in Address Representation of IPv6 is in
6
decimal hexadecimal

5/19/2021 NETWORK LAYER 81


IPv4 and IPv6 Addresses
Sr. No. IPv4 IPv6
Fragmentation performed by Sender and In IPv6 fragmentation performed only
7
forwarding routers by sender
In IPv4 Packet flow identification is not In IPv6 packet flow identification are
8 available Available and uses flow label field in the
header
9 In IPv4 checksum field is available In IPv6 checksum field is not available
It has broadcast Message Transmission In IPv6 multicast and any cast message
10
Scheme transmission scheme is available
In IPv4 Encryption and Authentication In IPv6 Encryption and Authentication
11
facility not provided are provided
12 IPv4 has header of 20-60 bytes. IPv6 has header of 40 bytes fixed

5/19/2021 NETWORK LAYER 82


References
1. Forouzan, B. A., & Mosharraf, F. (2012). Computer networks: a top-down
approach, McGraw-Hill.
2. https://www.tutorialspoint.com/
3. https://www.slideshare.net/
4 https://www.gatevidyalay.com/
5 https://www.computernetworkingnotes.com/

5/19/2021 NETWORK LAYER 83


Thank You!

5/19/2021 NETWORK LAYER 84

You might also like