IP Datagram Structure

7,018 views 6 slides Nov 26, 2017
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

IP Datagram Structure


Slide Content

1


Hitesh Mohapatra / Class Note / VSSUT, Burla, India
Internet Protocol

 The Internet Protocol (IP) is the method or protocol by which data is sent from one
computer to another on the Internet.

 Each computer (known as a host) on the Internet has at least one IP address that
uniquely identifies it from all other computers on the Internet.
 When you send or receive data (for example, an e-mail or a Web page), the message
gets divided into little chunks called packets. Each of these packets contains both the
sender's Internet address and the receiver's address.
 Any packet is sent first to a gateway computer that reads the destination address and
forwards the packet to an adjacent gateway that in turn reads the destination address
and so on so forth across the Internet until one gateway recognizes the packet as
belonging to a computer within destination’s immediate neighbourhood or domain.
That gateway then forwards the packet directly to the computer whose address is
specified (destination address).
 Because a message is divided into a number of packets, each packet can, if necessary,
be sent by a different route across the Internet. Packets can arrive in a different order
than the order they were sent in. The Internet Protocol just delivers them. It's up to
another protocol, the Transmission Control Protocol (TCP) to put them back in the
right order. It is a connection-oriented protocol that keeps track of the packet
sequence in a message.
 IP is a connectionless protocol, which means that there is no continuing connection
between the end points that are communicating. Each packet that travels through the
Internet is treated as an independent unit of data without any relation to any other unit
of data. In the Open Systems Interconnection (OSI) communication model, IP is
in layer 3, the Networking Layer.
 The most widely used version of IP today is Internet Protocol Version 4 (IPv4).
However, IP Version 6 (IPv6) is also beginning to be supported. IPv6 provides for

2

much longer addresses and therefore for the possibility of many more Internet users.
IPv6 includes the capabilities of IPv4 and any server that can support IPv6 packets
can also support IPv4 packets.
The IP Datagram Structure


 The format of data that can be recognized by IP is called an IP datagram.
 It consists of two components, namely, the header and data, which need to be
transmitted. The fields in the datagram, except the data, have specific roles to perform
in the transmission of data.
 Every field in the IP datagram has a fixed size except for the IP Options field, which
can be 20–60 bytes in length.
The header has a 20 bytes fixed part and a variable length optional part.
The IP datagram header format

Version
 Which version of the protocol the datagram belongs to.
 The current version number is 4.
 Next version: 6

3

IHL
 The number of 32-bit words in the header
 Because this is 4 bits, the max header length is 15 words (i.e. 60 bytes)
 The header is at least 20 bytes, but options may make it bigger
Type of Service
 Contains a 3-bit precedence field (that is ignored today), 4 service bits, and 1 unused
bit.
 The four service bits can be:
o 1000 - minimize delay
o 0100 - maximize throughput
o 0010 - maximize reliability
o 0001 - minimize monetary cost
 This is a "hint" of what characteristics of the physical layer to use
 The Type of Service is not supported in most implementations. However, some
implementations have extra fields in the routing table to indicate delay, throughput,
reliability, and monetary cost.
Total Length
 Total length of the datagram in bytes.
 we know where the data starts by the header length
 we know the size of the data by computing "total length - header length"
Identification
 Uniquely identifies the datagram.
 Usually incremented by 1 each time a datagram is sent.
 All fragments of a datagram contain the same identification value.
 This allows the destination host to determine which fragment belongs to which
datagram.
Flags and Fragmentation Offset
 Used for fragmentation
 DF means do not fragment. It is a request to routers not to fragment the datagram
since the destination is incapable of putting the pieces back together.
 MF means more fragments to follow. All fragments except the last one have this bit
set. It is needed to know if all fragments of a datagram have arrived.
Fragment offset

4

This field solves the problem of sequencing fragments by indicating to the recipient device
where in the overall message each particular fragment should be placed.
Time to Live
 decremented by each router that processes the datagram,
 Router discards the datagram when TTL reaches 0.
Protocol
 Tells IP where to send the datagram up to.
 6 means TCP
 17 means UDP
Header checksum
Inserted by the sender and updated whenever the packet header is modified by a router - Used
to detect processing errors introduced into the packet inside a router. Packets with an invalid
checksum are discarded.
Source IP address
The IP address of the original sender of the packet
Destination IP address
The IP address of the final destination of the packet
Options
 Optional data.
 Some examples include having the router put in a IP address of router and a time
stamp so the final destination knows how long it took to get to each hop.
The source and destination in the IP header is the original source and the final destination!
The physical layer addresses pass the datagram from router to router. So, while the physical
layer addresses change from router to router, the source and destination IP addresses in the IP
datagram remain constant.
IP Fragmentation
 IP must fragment packets if it is of large size.
 When an IP datagram is fragmented, each fragment is treated as a separate datagram.
o It is reassembled at the final destination, not at a router
o It does that because the router may have to fragment it again

5

 Each fragment has its own header.
 The identification number is copied into each fragment.
 One bit in the "flags" field says "more fragments are coming. If that bit is 0, then it
signifies this is the last fragment.
 The "fragment offset" field contains the offset of the data.
o Fragment offset is measured in units of 8 bytes (64 bits).
The entire flags field looks like this:
--------------------------
| bit 0 | bit 1 | bit 2 |
--------------------------

bit 0: not used
bit 1: if 1, it means "don't fragment".
If IP must fragment the packet and this bit is set, IP throws away the datagram.
bit 2: The fragment flag.
Example:
 Suppose we have a physical layer that can transmit a maximum of 660 bytes. And,
suppose IP wants to send 1460 bytes of data. So, the IP datagram is a total of 1480
bytes, including the 20 byte IP header:
---------------------------------------------
| 20-byte IP HEADER | 1460 bytes of data |
---------------------------------------------
 Here is what IP sends:
First packet:
Bytes: 20 640
---------------------------------------------
| IP header | first 640 bytes of data |
---------------------------------------------
 In that packet, "fragment flag" is 1, offset is 0.
Second packet:
Bytes: 20 640
---------------------------------------------
| IP header | second 640 bytes of data |
---------------------------------------------

6

 In that packet, "fragment flag" is 1, offset is 80. The offset is 80 because (80 * 8) is
640, so the offset of that data is 640 byes.

Third packet:
Bytes: 20 640
---------------------------------------------
| IP header | third 180 bytes of data |
---------------------------------------------
 In that packet, "fragment flag" is 0, offset is 160. The offset is 160 because (160 * 8)
is 1280, so the offset of that data is 1280 byes.
 IMPORTANT: The routers see 3 separate packets. The final destination reassembles
the packet before passing the packet to the upper layers.