Chapter 04-Network Layer
Chapter 04-Network Layer
Network Layer
19.1
Outline
Introduction
Network layer overview
IPv4 address
IPv4 Protocol
Network routing
2
Figure 1 Links between two hosts
19.3
Figure 2 Network layer in an internetwork
19.4
Figure 3 Network layer at the source, router, and destination
19.5
Figure 4 Network layer at the source, router, and destination (continued)
19.6
Note
19.7
IPv4 ADDRESSES
19.8
Note
19.9
Note
19.10
Note
19.11
Figure 5 Dotted-decimal notation and binary notation for an IPv4 address
19.12
Note
19.13
Example 1
Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation.
19.14
Note
19.15
Figure 6 Finding the classes in binary and dotted-decimal notation
19.16
Example 2
Solution
a. The first bit is 0. This is a class A address.
b. The first 2 bits are 1; the third bit is 0. This is a class C
address.
c. The first byte is 14; the class is A.
d. The first byte is 252; the class is E.
19.17
Table 1 Number of blocks and block size in classful IPv4 addressing
19.18
Note
19.19
Note
19.20
Note
19.21
Note
19.22
Example 3
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32−28 rightmost bits to 0, we get
11001101 00010000 00100101 0010000
or
205.16.37.32.
This is actually the block shown in Figure 19.3.
19.23
Note
19.24
Example 4
Solution
The binary representation of the given address is
11001101 00010000 00100101 00100111
If we set 32 − 28 rightmost bits to 1, we get
11001101 00010000 00100101 00101111
or
205.16.37.47
This is actually the block shown in Figure 19.3.
19.25
Note
19.26
Example 5
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
19.27
Example 6
Another way to find the first address, the last address, and
the number of addresses is to represent the mask as a 32-
bit binary (or 8-digit hexadecimal) number. This is
particularly useful when we are writing a program to find
these pieces of information. In Example 19.5 the /28 can
be represented as
11111111 11111111 11111111 11110000
(twenty-eight 1s and four 0s).
Find
a. The first address
b. The last address
c. The number of addresses.
19.28
Example 6
Solution
a. The first address can be found by ANDing the given
addresses with the mask. ANDing here is done bit by
bit. The result of ANDing 2 bits is 1 if both bits are 1s;
the result is 0 otherwise.
19.29
Example 6 (continued)
19.30
Example 6 (continued)
19.31
Note
19.32
Note
19.33
Figure 6 Three-level hierarchy in an IPv4 address
19.34
Example 7
Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each
host. The prefix length is then 32 − 7 = 25. The addresses
are
19.36
Example 7 (continued)
Solution
Figure 19.9 shows the situation.
Group 1
For this group, each customer needs 256 addresses. This
means that 8 (log2 256) bits are needed to define each
host. The prefix length is then 32 − 8 = 24. The addresses
are
19.37
Example 7 (continued)
Group 2
For this group, each customer needs 128 addresses. This
means that 7 (log2 128) bits are needed to define each
host. The prefix length is then 32 − 7 = 25. The addresses
are
19.38
Example 7 (continued)
Group 3
For this group, each customer needs 64 addresses. This
means that 6 (log264) bits are needed to each host. The
prefix length is then 32 − 6 = 26. The addresses are
19.41
Figure 8 IPv4 datagram format Security
Strict source routi
Loose source rout
Record route
Timestamp
19.42
Figure 9 Service type or differentiated services
19.43
Note
19.44
Table 2 Types of service
19.45
Table 3 Default types of service
19.46
Table 4 Values for codepoints
19.47
Note
19.48
Figure 10 Encapsulation of a small datagram in an Ethernet frame
19.49
Figure 11 Protocol field and encapsulated data
19.50
Table 12 Protocol values
19.51
Example 8
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.
19.52
Example 9
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.
19.53
Example 10
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).
19.54
Example 11
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.
19.55
Figure 12 Maximum transfer unit (MTU)
19.56
Table 5 MTUs for some networks
19.57
Figure 13 Flags used in fragmentation
19.58
Figure 14 Fragmentation example
19.59
Figure15 Detailed fragmentation example
19.60
Example 10
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.
19.61
Example 11
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).
19.62
Example 12
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.
19.63
Example 13
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.
19.64
Example 14
19.65
19.66