Internet Protocol (IP)
The Internet Protocol (IP) is the heart of the Internet. IP is the
protocol that enables various networks to talk to each other
globally.
IP is a connectionless datagram protocol for packet switching
network because each packet is handled independently.
IP also specifies the addressing and routing mechanisms.
IP does its best to deliver a packet to its destination, but with
no guarantees. The packets may be lost if there is congestion,
though "best-effort" is made for the delivery. The packets may
not be received in sequence; packets may be duplicated.
IP uses an error detection mechanism (Checksum) and
discards the packet if it is corrupted.
IP is unreliable.
IP needs to rely on TCP layer for reliable delivery.
IP also defines the rules for discarding packets (TTL field), and
how hosts and routers should process the packets
(fragmentation and reassembly).
IP is implemented as software. This software must run on
every end system and on every router.
There are two versions of IP: IP version 4 (IPv4) and IP version 6
(IPv6).
IPv4 was the first version of Internet Protocol used to take into
account Internet traffic and there are just over 4 billion IPv4
addresses while IPv6 is a newer numbering system that provides a
much larger address pool than IPv4. It was deployed in 1999 and
should meet the world’s IP addressing needs well into the future.
Internet Addressing Scheme
Each end system on the network has to be uniquely identified. For
this, the addressing scheme is very important. Since each end system
is a node on a network, the addressing scheme should be such that
the address contains both an ID for the network and an ID for the
host. This scheme is followed in the IP addressing scheme. Each
node on a TCP/IP network is identified by a 32-bit address. The
address consists of the network ID and the host ID.
IP Addressing Class
Rule for Class Determination
Class Class Range of First Octet Decimal
Identifier equivalent
A 0 00000001 – 01111110 1-126
B 10 10000000 - 10111111 128-191
C 110 11000000 - 11011111 192-223
D 1110 11100000 - 11101111 224-239
E 1111 11110000-11111111 240-255
Fig.2. IP Address Formats
IP Addresses - Class A
• 32-bit global internet address
• Network part and host part
• Class A
— Used when site contains a small number of networks and
each network has many host (node)
— Start with binary 0
— All 0 reserved
— 01111111 (127) reserved
— Range 1.x.x.x to 126.x.x.x i.e., 1.0.0.0. to 126.255.255.255
— All allocated
IP Addresses - Class B
• Used for medium number of networks and each network has
more than 256 but less than 65536 hosts
• Start 10
• Range 128.x.x.x to 191.x.x.x i.e., 128.0.0.0 to 191.255.255.255
• 214 = 16,384 class B addresses
• All allocated
IP Addresses - Class C
• Used for large number of networks and each network has less
256 hosts
• Start 110
• Range 192.x.x.x to 223.x.x.x i.e., 192.0.0.0 to 223.255.255.255
• Second and third octet also part of network address
• 221 = 2,097,152 addresses
• Nearly all allocated
IP Addresses - Class D
used when multicasting is required, such as when a datagram
has to be sent to multiple hosts simultaneously.
Address range 224.0.0.0 to 239.255.255.255
IP Addresses -Class E
These addresses are reserved for future use.
Address range 240.0.0.0 to 255.255.255.255
In the IP address, if the host address bits are all zeros, the IP
address represents the network address. If the host address bits are
all ones, the IP address is the broadcast address—the packet is
addressed to all hosts on the network.
Dotted Decimal Notation
IP address if it is written in 32-bit format, dotted decimal notation
is used. If the IP address is
it can be represented as 128.11.5.31 for easy readability.
IP Datagram Format (IPv4)
Fig.3. IPv4 Datagram
Fig.4. IPv4 Header
Version number (4 bits): Version number of the IP. The version
presently running in most of the systems is Version 4. Version 6 is
now slowly being deployed. This field ensures that the correct
version of the software is used to process the datagram. All
machines check the version field before processing the datagram.
Internet Header length (4 bits): Length of the IP header in 32-bit
words. All fields except IP options and padding have fixed length.
The minimum length (without option and padding) of the header is
20 bytes.
Service type (8 bits): These bits specify how the datagram has to be
handled by systems. The 4th, 5th, and 6th bits are called D, T, and R
bits. Setting D bit is to request low delay, setting T bit is to request
high throughput, and setting R bit is to request high reliability.
However, it is only a request; there is no guarantee that the request
will be honored. Note that these bits are to set the quality of service
(QoS) parameters. There is no guarantee that the required QoS will
be provided. Actually "IP does not guarantee a desired QoS".
Note: The type of service is specified with the parameters
Precedence, Delay, Throughput and Reliability.
Precedence – An independent measure of the importance of the
datagram.
Delay – Prompt delivery is important for datagram with this
indication.
Throughput – High data rate is important for datagram with this
indication.
Reliability – A higher level of effort to ensure delivery is important for
datagram with this indication.
Length (16 bits): Total length of the datagram in bytes including
header and data. The length of the data field is calculated by
subtracting the header length from the value of this field. The
maximum size of an IP datagram is limited to 65,535 bytes.
The IP datagram size is much larger than can be accommodated by
a LAN that can handle only 1526 bytes in one frame for instance. In
such a case, the datagram has to be fragmented and sent over the
network. The minimum datagram size that every host and router
must handle is 576 bytes. Each fragment contains most of the
original datagram header. The fragmentation is done at routers, but
the reassembly is done at the destination.
Identification (16 bits): Unique ID to identify the datagram. An
identifying value assigned by the sender to aid in assembling the
fragments of the datagram. The source address, destination address,
and identification together uniquely identify the datagram on the
Internet. When the datagram is fragmented, these fields are copied
into the fragments so that the destination will know which
fragments belong to which datagram.
Flags (3 bits): Various Control Flags.
Bit 0: Reserved, must be zero
Bit 1(DF i.e., “do not fragment”): This bit specifies whether the
datagram is to be fragmented. 0 = May Fragment, 1 = Don’t
Fragment.
Bit 2 (MF i.e., “more fragments”): This bit specifies whether the
fragment contains data from the middle of the datagram. 0 = Last
Fragment, 1= More Fragments.
Fragment offset (13 bits): Specifies the offset of the fragment in the
datagram, starting at offset 0. The destination receives all the
fragments and reassembles the fragments using the offset value,
starting with 0 to the highest value.
Time-to-live (8 bits): A packet on the Internet may go round and
round without reaching the destination. To avoid such unnecessary
traffic, this field is very useful. This field contains the number of
hops a packet can travel. At every router, this field is decremented
by 1, and either the packet reaches the destination before the field
becomes 0 or, if it reaches 0 earlier, it is discarded. The default hop
count is 64—the packet can traverse at most through 64 routers.
Protocol (8-bits): The protocol field specifies which higher layer
protocol is encapsulated in the data area of the IP datagram.
Common protocols and their decimal values are:
1: Internet Control Message Protocol (ICMP)
6: Transport Control Protocol (TCP)
17: User Datagram Protocol (UDP)
Header checksum (16 bits): The 16-bit checksum field is used for
error-checking of the header. Since a router changes the content of
TTL and Offset fields, header checksum field is recomputed by
every router when it forwards a packet. At each hop, the checksum
of the header must be compared. If a header checksum is found to
be mismatched, then the packet is discarded.
Source IP address (32 bits): This field contains the IP address of the
source that is sending the datagram.
Destination IP addresses (32 bits): This field contains the IP address
of the final destination.
Option: This is a variable-length field. This field contains data for
network testing and debugging. These options are for operations
such as recording the route of a datagram, and source routing that
specifies the route to be taken by the datagram.
When the record route option is set, each router adds its IP address
in the options field and then forwards it. When the source route
option is set and the IP addresses of all the hops are mentioned in
the options field, the datagram takes only that route. The source
route option provides a way for the sender to dictate the path
through the internet.
Padding (8 bits): To make the IP header an exact multiple of 32 bits,
the padding bits are added if required.
Data (variable): This is a variable field whose length is specified in
the datagram header.
Carries user data from the next layer up.
Integer multiple of 8 bits (octet).
Max length of the datagram (header + data) 65,535 octets.