Lecture 7
Lecture 7
Lecture 7
IP (Internet Protocol)
Datagram Format:
The key fields in the IPv4 datagram are the following:
1-Version number. These 4 bits specify the IP protocol version of the datagram. By
looking at the version number, the router can determine how to interpret the remainder
of the IP datagram. Different versions of IP use different datagram formats.
2-Header length. Because an IPv4 datagram can contain a variable number of options
(which are included in the IPv4 datagram header), these 4 bits are needed to determine
where in the IP datagram the data actually begins. Most IP datagrams do not contain
options, so the typical IP datagram has a 20-byte header.
3-Type of service. The type of service (TOS) bits were included in the IPv4 header to
allow different types of IP datagrams (for example, datagrams particularly requiring
low delay, high throughput, or reliability) to be distinguished from each other.
4-Datagram length. This is the total length of the IP datagram (header plus data),
measured in bytes. Since this field is 16 bits long, the theoretical maximum size of the
IP datagram is 65,535 bytes. However, datagrams are rarely larger than 1,500 bytes.
5-Identifier, flags, fragmentation offset. These three fields have to do with so-called IP
fragmentation, the new version of IP, IPv6, does not allow for fragmentation at routers.
6-Time-to-live.The time-to-live (TTL) field is included to ensure that datagrams do
not circulate forever (due to, for example, a long-lived routing loop) in the network.
This field is decremented by one each time the datagram is processed by a router. If
the TTL field reaches 0, the datagram must be dropped.
7-Protocol.This field is used only when an IP datagram reaches its final destination.
The value of this field indicates the specific transport-layer protocol to which the data
portion of this IP datagram should be passed. For example, a value of 6 indicates that
Networks Fundemantals 3
Lecture 7 Network layer and Internet Protocol
the data portion is passed to TCP, while a value of 17 indicates that the data is passed
to UDP.
8-Header checksum. The header checksum aids a router in detecting bit errors in a
received IP datagram. The header checksum is computed by treating each 2 bytes in
the header as a number and summing these numbers using 1s complement arithmetic.
9-Source and destination IP addresses
10-Options
11-Data (payload).
Networks Fundemantals 4
Lecture 7 Network layer and Internet Protocol
IP Datagram Fragmentation:
Let’s consider an example:
A datagram of 4,000 bytes (20 bytes of IP header plus 3,980 bytes of IP payload)
arrives at a router and must be forwarded to a link with an MTU of 1,500 bytes. This
implies that the 3,980 data bytes in the original datagram must be allocated to three
separate fragments (each of which is also an IP datagram). Suppose that the original
datagram is stamped with an identification number of 777. The characteristics of the
three fragments are shown in the Table below. The values reflect the requirement that
the amount of original payload data in all but the last fragment be a multiple of 8 bytes,
and that the offset value be specified in units of 8-byte chunks.
At the destination, the payload of the datagram is passed to the transport layer only
after the IP layer has fully reconstructed the original IP datagram. If one or more of the
fragments does not arrive at the destination, the incomplete datagram is discarded and
not passed to the transport layer. But, if TCP is being used at the transport layer, then
TCP will recover from this loss by having the source retransmit the data in the original
datagram.
We have just learned that IP fragmentation plays an important role in gluing together
the many disparate link-layer technologies. But fragmentation also has its costs. First,
it complicates routers and end systems, which need to be designed to accommodate
datagram fragmentation and reassembly. Second, fragmentation can be used to create
lethal DoS attacks, whereby the attacker sends a series of bizarre and unexpected
fragments. A classic example is the Jolt2 attack, where the attacker sends a stream of
small fragments to the target host, none of which has an offset of zero. The target can
collapse as it attempts to rebuild datagrams out of the degenerate packets. Another
class of exploits sends overlapping IP fragments, that is, fragments whose offset values
are set so that the fragments do not align properly. Vulnerable operating systems, not
knowing what to do with overlapping fragments, can crash.
Networks Fundemantals 5
Lecture 7 Network layer and Internet Protocol