CH 20
CH 20
Network Layer:
Internet Protocol
20.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
20-1 INTERNETWORKING
20.2
Figure 20.1 Links between two hosts
20.3
Figure 20.2 Network layer in an internetwork
20.4
Figure 20.3 Network layer at the source, router, and destination
20.5
Figure 20.3 Network layer at the source, router, and destination (continued)
20.6
Switched Networks
Note
20.8
Datagram Networks
In a packet-switched network, there is no resource reservation;
resources are allocated on demand
In a datagram network, each packet is treated independently of
all others. Sometimes referred to as connectionless networks
8-9
Note
20.10
20-2 IPv4
20.11
Figure 20.4 Position of IPv4 in TCP/IP protocol suite
20.12
IPv4 is an unreliable and connectionless
datagram protocol 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).
IPv4 assumes the unreliability of the underlying
layers and does its best to get a transmission
through to its destination, but with no
guarantees.
20.13
IPv4 is also a connectionless protocol for a packet-
switching network that uses the datagram approach.
Each datagram is handled independently, and each
datagram can follow a different route to the destination.
Packet could arrive out of order. Also, some could be
lost or corrupted during transmission.
IPv4 relies on a higher-level protocol to take care of all
these problems.
20.14
Figure 20.5 IPv4 datagram format (Packets in the IPv4 layer are called
datagrams)
Ox45 00 00 54 00 03 58 50 20 06 00 00 7C 4E 03 02 B4 OE OF 02
Ox45 00 00 54 00 03 58 50 20 06 00 00 7C 4E 03 02 B4
OE OF 02
20.17
Note
20.18
Table 20.2 Default types of service
only one of the bits can have the value of 1 in each datagram.
20.19
Table 20.3 Values for codepoints (Differential Services)
When the 3 rightmost bits are Os, the 3 leftmost bits are interpreted
the same as the precedence bits in the service type interpretation.
When the 3 rightmost bits are not all Os, the 6 bits define 64
services based on the priority assignment by the Internet or local
authorities
20.20
The total length field defines the total
length of the datagram including the
header.
To find the length of the data coming from the upper layer,
subtract the header length from the total length. The header length
can be found by multiplying the value in the HLEN field by 4.
the total length of the IPv4 datagram is limited to 65,535 (216 - 1)
bytes, of which 20 to 60 bytes are the header and the rest is data
from the upper layer.
Length of data =total length - header length
Ox45 00 00 54 00 03 58 50 20 06 00 00 7C 4E 03 02 B4 OE OF 02
Figure 20.7 Encapsulation of a small datagram in an Ethernet frame
20.22
Fragmentation
Divide the datagram to make it possible to pass through
the different networks 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.
20.23
Table 20.5 MTUs for some networks
20.24
Fields Related to Fragmentation
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. The identification
number helps the destination in reassembling
the datagram.
20.25
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 fragment
20.26
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. The value of
the offset is measured in units of 8 bytes. This is done
because the length of the offset field is only 13 bits and
cannot represent a sequence of bytes greater than 8191.
This forces hosts or routers that fragment datagrams to
choose a fragment size so that the first byte number is
divisible by 8.
20.27
Time to live
A datagram has a limited lifetime in its travel through an
internet
This field is used mostly to control the maximum number
of hops (routers) visited by the datagram.
When a source host sends the datagram, it stores a
number in this field.
This value is approximately 2 times the maximum
number of routes between any two hosts. Each router
that processes the datagram decrements this number by
1.
If this value, after being decremented, is zero, the router
discards the datagram.
20.28
Figure 20.8 Protocol field and encapsulated data
20.29
Table 20.4 Protocol values
20.30
Example 20.1
Solution
There is an error in this packet. The 4 leftmost bits (0100)
show the version, which is correct. The next 4 bits (0010)
show an invalid header length (2 × 4 = 8). The minimum
number of bytes in the header must be 20. The packet has
been corrupted in transmission.
20.31
Example 20.2
Solution
The HLEN value is 8, which means the total number of
bytes in the header is 8 × 4, or 32 bytes. The first 20 bytes
are the base header, the next 12 bytes are the options.
20.32
Example 20.3
Solution
The HLEN value is 5, which means the total number of
bytes in the header is 5 × 4, or 20 bytes (no options). The
total length is 40 bytes, which means the packet is
carrying 20 bytes of data (40 − 20).
20.33
Example 20.4
Solution
To find the time-to-live field, we skip 8 bytes. The time-to-
live field is the ninth byte, which is 01. This means the
packet can travel only one hop. The protocol field is the
next byte (02), which means that the upper-layer protocol
is IGMP.
20.34
Figure 20.10 Flags used in fragmentation
20.35
Figure 20.11 Fragmentation example
20.36
Figure 20.12 Detailed fragmentation example
20.37
Example 20.5
Solution
If the M bit is 0, it means that there are no more
fragments; the fragment is the last one. However, we
cannot say if the original packet was fragmented or not. A
non-fragmented packet is considered the last fragment.
20.38
Example 20.6
Solution
If the M bit is 1, it means that there is at least one more
fragment. This fragment can be the first one or a middle
one, but not the last one. We don’t know if it is the first
one or a middle one; we need more information (the
value of the fragmentation offset).
20.39
Example 20.7
Solution
Because the M bit is 1, it is either the first fragment or a
middle one. Because the offset value is 0, it is the first
fragment.
20.40
Example 20.8
Solution
To find the number of the first byte, we multiply the offset
value by 8. This means that the first byte number is 800.
We cannot determine the number of the last byte unless
we know the length.
20.41
Example 20.9
20.42
Example 20.10
20.43
Figure 20.13 Example of checksum calculation in IPv4
20.44
Options
Options, as the name implies, are not
required for a datagram. They can be
used for network testing and debugging.
Although options are not a required part
of the IPv4 header, option processing is
required of the IPv4 software.
20.45
A no-operation option is a I-byte option used as a filler between
options.
An end-of-option option is a I-byte option used for padding at the end of
the option field. It, however, can only be used as the last option
A record route option is used to record the Internet routers that handle
the datagram.
A strict source route option is used by the source to predetermine a
route for the datagram as it travels through the Internet (Service)
record the time of datagram processing by a router
20.46
20-3 IPv6
20.47
Header comparison
0 15 16 31
vers hlen TOS total length Removed (6)
identification flags flag-offset • ID, flags, flag offset
20 TTL protocol header checksum • TOS, hlen
bytes
source address • header checksum
destination address
destination address
Expanded
• address 32 to 128 bits
IPv6
Figure 20.15 IPv6 datagram header and payload
20.49
Figure 20.16 Format of an IPv6 datagram
20.50
Table 20.6 Next header codes for IPv6
20.51
Table 20.7 Priorities for congestion-controlled traffic
20.52
Table 20.8 Priorities for noncongestion-controlled traffic
20.53
Table 20.9 Comparison between IPv4 and IPv6 packet headers
20.54
Figure 20.17 Extension header types
20.55
Table 20.10 Comparison between IPv4 options and IPv6 extension headers
20.56
20-4 TRANSITION FROM IPv4 TO IPv6
20.58
Figure 20.19 Dual stack
Dual Stack :- A station must run IPv4 and IPv6 simultaneously until all the
Internet uses IPv6
20.59
Figure 20.20 Tunneling strategy
Thnneling 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.
20.60
Figure 20.21 Header translation strategy
The sender wants to use IPv6, but the receiver does not understand IPv6
The IPv6 mapped address is changed to an IPv4 address by extracting the
rightmost 32 bits..
20.61
Table 20.11 Header translation
20.62