Network Layer: Internet Protocol
exercises
1. What is the difference between the delivery of a frame in the
data link layer and the delivery of a packet in the network
layer?
Ans:
The delivery of a frame in the data link layer is node-to-node.
The delivery of a packet at the network layer is host-to-host.
2. Define fragmentation and explain why the IPv4 and IPv6
protocols need to fragment some packets. Is there any
difference between the two protocols in this matter?
Ans:
Each data link layer protocol has a limit on the size of the
packet it can carry. When a datagram is encapsulated in a
frame, the total size of the datagram must be less than this
limit. Otherwise, the datagram must be fragmented. IPv4
allows fragmentation at the host and any router; IPv6 allows
fragmentation only at the host.
3. List three transition strategies to move from IPv4 to IPv6.
Explain the difference between tunneling and dual stack
strategies during the transition period. When is each
strategy used?
Ans:
The three transition strategies are dual stack, tunneling, and
header translation.
In tunneling the IPv6 packet is encapsulated in an IPv4 packet
when it enters the region, and it leaves its capsule when it exits
the region. Tunneling is a strategy used when two computers
using IPv6 want to communicate with each other and the
packet must pass through a region that uses IPv4. In header
translation, the header format must be totally changed from
IPv4 to IPv6. Header translation is necessary when the
majority of the Internet has moved to IPv6 but some systems
still use IPv4.
4. Calculate the HLEN (in IPv4) value if the total length is 1200
bytes, 1176 of which is data from the upper layer.
Ans:
Header Length = Total Length - Data Length = 1200 − 1176 = 24
HLEN = 24/4 = 6 (in decimal) → 0110 (in binary)
5. Given a fragmented datagram (in IPv4) with an offset of 120,
how can you determine the first and last byte numbers?
Ans:
The first byte number can be calculated from the offset itself.
If the offset is 120, that means that 120 × 8 or 960 bytes (bytes
0 through 959) were sent before this fragment. The first byte
number is therefore 960. The last byte number can be
calculated by adding the total length field and subtracting one.
6. Can the value of the header length in an IPv4 packet be less
than 5? When is it exactly 5?
Ans:
The value of the header length field of an IP packet
can never be less than 5 because every IP datagram must
have at least a base header that has a fixed size of 20 bytes.
The value of HLEN field, when multiplied by 4, gives the
number of bytes contained in the header. Therefore the
minimum value of this field is 5. This field has a value of
exactly 5 when there are no options included in the header.
7. The value of HLEN in an IPv4 datagram is 7. How many
option bytes are present?
Ans:
If the value of the HLEN field is 7, there are 28 (since 7 × 4 =
28) bytes included in the header. There are 20 bytes in the
base header, so the total number of option bytes must be 8.
8. The size of the option field of an IPv4 datagram is 20 bytes.
What is the value of HLEN? What is the value in binary?
Ans:
If the size of the option field is 20 bytes, then the total length
of the header is 40 bytes (20 byte base header plus 20 bytes
of options). The HLEN field will be the total number of bytes
in the header divided by 4, in this case ten (1010 in binary).
9. The value of the total length field in an IPv4 datagram is 36,
and the value of the header length field is 5. How many bytes
of data is the packet carrying?
Ans:
The datagram must contain 16 bytes of data:
36 yte total length – (5 HLEN field × 4) = 36 – 20 = 16 bytes
10. An IPv4 datagram is carrying 1024 bytes of data. If there
is no option information, what is the value of the header
length field? What is the value of the total length field?
Ans:
Since there is no option information, the header length is 20,
which means that the value of HLEN field is 5 or 0101 in
binary. The value of total length is 1024 + 20 or 1044 (00000100
00010100 in binary).
11. A host is sending 100 datagrams to another host. If the
identification number of the first datagram is 1024, what is
the identification number of the last (in IPv4)?
Ans:
The identification field is incremented for each non-
fragmented datagram. If the first is 1024, then the last is
1024 + 99 = 1123
12. An IPv4 datagram arrives with fragmentation offset of 0
and an M bit (more fragment bit) of 0. Is this a first
fragment, middle fragment, or last fragment?
Ans:
If the M (more) bit is zero, this means that the datagram is
either the last fragment or the it is not fragmented at all.
Since the offset is 0, it cannot be the last fragment of a
fragmented datagram. The datagram is not fragmented.
13. An IPv4 fragment has arrived with an offset value of 100.
How many bytes of data were originally sent by the source
before the data in this fragment?
Ans:
Since the offset field shows the offset from the beginning of
the original datagram in multiples of 8 bytes, an offset of 100
indicates that there were 800 bytes of data sent before the
data in this fragment.
14. In an IPv4 datagram, the M bit is 0, the value of HLEN is
5, the value of total length is 200, and the offset value is 200.
What is the number of the first byte and number of the last
byte in this datagram? Is this the last fragment, the first
fragment, or a middle fragment?
Ans:
Data size = 200 − (5 × 4) = 180 bytes
The number of the first byte = offset value × 8= 1600
The number of the last byte = offset value + data size − 1 = 1779
M = 0, offset ≠ 0 → last fragment