Unit-3 - IP Protocol (1)
Unit-3 - IP Protocol (1)
UNIT-3
IPv4 is an unreliable and connectionless datagram protocol which provides a best-effort delivery
service.
The term best-effort means that IPv4 provides no error control or flow control (except for error detection
on the header).
If reliability is important, IPv4 must be paired with a reliable protocol such as TCP.
IPv4 is also a connectionless protocol that uses the datagram approach. This means that each datagram is
handled independently, and each datagram can follow a different route to the destination.
IPV4 Datagram format
1. Version(VER):
This 4 bit field tells the IP software
running in the processing machine that
the datagram has the format of IP
version 4 protocol.
All other fields must be interpreted as
specified in the fourth version of the
protocol.
If the machine is using some other
version of IP, the datagram is discarded
rather than interpreted incorrectly.
IPV4 Datagram Header fields
3. Services.
IETF has changed the interpretation and name
of this 8-bit field. This field, previously called
service type, is now called differentiated
services.
Service Type
In this interpretation, the first 3 bits are called precedence bits. The next 4 bits are called
type of service (TOS) bits, and the last bit is not used.
a. Precedence is a 3-bit subfield ranging from 0 (000 in binary) to 7 (111 in binary). The
precedence defines the priority of the datagram in issues such as congestion. If a router
is congested and needs to discard some datagrams, those datagrams with lowest
precedence are discarded first.
b. TOS bits
It is a 4-bit subfield with each bit having a special
meaning.
Although a bit can be either 0 or 1, one and only one
of the bits can have the value of 1 in each datagram.
4. Total length.
This is a 16-bit field that defines the total length (header
plus data) of the IPv4 datagram in bytes.
Length of data =total length - header length
The header length can be found by multiplying the value
in the HLEN field by 4.
Since the size of “total length” field is 16 bits, the total
length of the IPv4 datagram is limited to 65,535 (2 16 - 1)
bytes, of which 20 to 60 bytes are the header and the rest
is data from the upper layer.
IPV4 Datagram Header fields
8. Time to live.
A datagram has a limited lifetime in its
travel through an internet.
This field holds a timestamp, which was
decremented by each visited router. The
datagram was discarded when the value
became zero.
IPV4 Datagram Header fields
9. Protocol.
This 8-bit field defines the higher-level protocol that
uses the services of the n/w layer.
An IPv4 datagram can encapsulate data from several
higher-level protocols such as TCP, UDP, ICMP, and
IGMP.
In other words, since the IPv4 protocol carries data from
different other protocols, the value of this field helps
the receiving network layer know to which protocol the
data belong.
10. Checksum.
The checksum is used to secure the IPv4 header.
Source address. This 32-bit field defines the IPv4
address of the source.
Destination address. This 32-bit field defines the
IPv4 address of the destination.
Source and destination field must remain unchanged
during the time the IPv4 datagram travels from the
source host to the destination host
Options. The header of the IPv4 datagram is made
of two parts: a fixed part and a variable part. The
fixed part is 20 bytes long. The variable part
comprises the options that can be a maximum of
40 bytes.
Options, as the name implies, are not required for
a datagram. They can be used for network testing
and debugging.
Encapsulation of IP packet
in a frame at data link
layer
To make the IPv4 protocol independent of the physical network , we have to set the
maximum length of the IPv4 datagram equal to 65,535 bytes.
However, for other physical networks, if datagram size is above this limit, then we must
divide the datagram to make it possible to pass through these networks. This is called
fragmentation
When a datagram is fragmented, each fragment has its own header with most of
the fields repeated, but with some changed.
A fragmented datagram may itself be fragmented if it encounters a network with
an even smaller MTU. In other words, a datagram can be fragmented several times
before it reaches the final destination.
In IPv4, a datagram can be fragmented by the source host or any router in the
path although there is a tendency to limit fragmentation only at the source.
The reassembly of the datagram, however, is done only by the destination
host because the fragmented datagrams can travel through different routes, and we
can never control or guarantee which route a fragmented datagram may take, all the
fragments belonging to the same datagram should finally arrive at the destination
host. So it is logical to do the reassembly at the final destination.
When a datagram is fragmented, required parts of the header must be
copied by all fragments. The option field may or may not be copied.
The host or router that fragments a datagram must change the values of
three fields: flags, fragmentation offset, and total length.
The rest of the fields must be copied
The fields that are related to fragmentation and reassembly of an IPv4 datagram are:
1. identification
2. flags
3. fragmentation offset
Identification:
This 16-bit field identifies a datagram originating from the source host.
The combination of the identification and source IPv4 address must uniquely define a datagram as it leaves
the source host.
When a datagram is fragmented, the value in the identification field is copied to all fragments. In other
words, all fragments have the same identification number, the same as the original datagram.
The identification number helps the destination in reassembling the datagram. It knows that all fragments
having the same identification value must be assembled into one datagram.
Flags : This is a 3-bit field.
The first bit is reserved.
The second bit is called the do not fragment bit. If its value is 1, the machine must
not fragment the datagram. If it cannot pass the datagram through any available
physical network, it discards the datagram and sends an ICMP error message to the
source host. If its value is 0, the datagram can be fragmented if necessary.
The third bit is called the more fragment bit. If its value is 1, it means the datagram
is not the last fragment; there are more fragments after this one. If its value is 0, it
means this is the last or only fragments.
Fragmentation offset.
This 13-bit field shows the relative position of this fragment with respect to the whole datagram. It is the
offset of the data in the original datagram measured in units of 8 bytes.
Figure 20.11 shows a datagram with a data size of 4000 bytes fragmented into three fragments. The
bytes in the original datagram are numbered 0 to 3999.
The first fragment carries bytes 0 to 1399. The offset for this datagram is 0/8 =0.
The second fragment carries bytes 1400 to 2799; the offset value for this fragment is 1400/8 =
175.
Finally, the third fragment carries bytes 2800 to 3999. The offset value for this fragment is 2800/8
=350.
Even if each fragment follows a
different path and arrives out of order,
the final destination host can
reassemble the original datagram from
the fragments received (if none of them
is lost) by using the following strategy:
1. The first fragment has an offset field
value of zero.
2. Divide the length of the first fragment by
8. The second fragment has an offset
value equal to that result.
3. Divide the total length of the first and
second fragments by 8. The third
fragment has an offset value equal to
that result.
4. Continue the process. The last fragment
has a more bit value of 0.
Notice the value of the identification field is the same in all fragments. Notice the value
of the flags field with the more bit set for all fragments except the last. Also, the value
of the offset field for each fragment is shown.
The figure also shows what happens if a fragment itself is fragmented. In this case the
value of the offset field is always relative to the original datagram.
For example, in the figure, the second fragment is itself fragmented later to two
fragments of 800 bytes and 600 bytes, but the offset shows the relative position of the
fragments to the original data.
Que:- Suppose IPv4 packet is reached at destination node
with following information :
0x45 00 00 60 00 02 46 40 18 11 00 00 6D 3C 02 01 C3
0D 1F 01
Field name Hexadeci Decimal value Field Hexadec Decimal
mal name imal value
digits digits
Version(4bits): (0x4) 4 TTL(8 18 24
Header 5 (5*4)= 20 bytes bits)
length(4bits): protocol 11 17(UDP)
Service(8 bits): 00 (000-
precedence ERROR Checksu No error
0000 -normal present m(0000)
0- unused) or not?
Total length(16 bits): 0060 (96 bytes) Source 6D 3C 02 109.60.2.1
ip? 01
Size of Data 96-20=76 bytes
(Total length- HLEN) Destinati C30D1F0 195.13.31.1
on ip? 1
Identification no.(16 0002 2
IPV6
Although IPv4 is well designed, IPv4 has some deficiencies (listed below) that make it
unsuitable for the fast-growing Internet.
1. Despite all short-term solutions, such as subnetting, classless addressing, and NAT,
address depletion is still a long-term problem in the Internet.
2. The Internet must accommodate real-time audio and video transmission. This type of
transmission requires minimum delay strategies and reservation of resources not
provided in the IPv4 design.
3. The Internet must accommodate encryption and authentication of data for some
applications. No encryption or authentication is provided by IPv4.
To overcome these deficiencies, IPv6 (Internetworking Protocol, version 6), was proposed and
is now a standard.
Advantages of IPV6:
The next-generation IP, or IPv6, has some advantages over IPv4 that can be
summarized as follows: -
Larger address space. An IPv6 address is 128 bits long, Compared with the 32-bit address of IPv4,
this is a huge increase in the address space.
Better header format. IPv6 uses a new header format in which options are separated from the
base header and inserted, when needed, between the base header and the upper-layer data. This
simplifies and speeds up the routing process because most of the options do not need to be checked
by routers.
New options. IPv6 has new options to allow for additional functionalities.
Allowance for extension. IPv6 is designed to allow the extension of the protocol if required by new
technologies or applications.
Support for resource allocation. In IPv6, the type-of-service field has been removed, but a
mechanism (called Flow label) has been added to enable the source to request special handling of
the packet. This mechanism can be used to support traffic such as real-time audio and video.
Support for more security. The encryption and authentication options in IPv6 provide
Packet Format