Module 4
Network Layer
19-1 IPv4 ADDRESSES
An IPv4 address is a 32-bit address that uniquely and
universally defines the connection of a device (for
example, a computer or a router) to the Internet..
Topics discussed in this section:
Address Space
Notations
Classful Addressing
Classless Addressing
Network Address
Translation (NAT)
19.2
The IPv4 addresses are unique
and universal.
An IPv4 address is 32 bits long.
The address space of IPv4 is
232
or 4,294,967,296.
19.3
Figure 19.1 Dotted-decimal notation and binary notation for an IPv4
address
19.4
19.5
19.6
Example 19.1
Change the following IPv4 addresses from
binary notation to dotted-decimal notation.
Solution
We replace each group of 8 bits with its equivalent
decimal number (see Appendix B) and add dots for
separation
19.7
Example 19.2
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Solution
We replace each decimal number with its binary
equivalent (see Appendix B).
19.8
Example 19.3
Find the error, if any, in the following IPv4 addresses.
Solution
a. There must be no leading zero (045).
b. There can be no more than four numbers.
c. Each number needs to be less than or equal to 255.
d. A mixture of binary notation and dotted-decimal
notation is not allowed.
19.9
CLASSFUL ADDRESSING
• Introduced in 1981, with classful routing, IPv4
addresses were divided into 5 classes(A to E).
• Classes A-C: unicast addresses
• Class D: multicast addresses
• Class E: reserved for future use
• The first three classes, Class A, B, and C, are used for "public
addressing", in which communication is always one-to-one
between source and destination. It implies that when data is
transmitted from a source, it will only be sent to a single network
host.
• The reserved categories include Class D and Class E, with Class
D being utilized for multicast and Class E being saved for future
usage exclusively.
19.
10
Note
In classful addressing, the address
space is divided into five classes:
A, B, C, D, and E.
19.11
CLASS A
• In a class A address, the first bit of the first octet
is always ‘0’.
• Thus, class A addresses range from [Link] to
[Link] (as 01111111 in binary converts
to 127 in decimal).
• The first 8 bits or the first octet denote the
network portion and the rest 24 bits or the 3
octets belong to the host portion.
• Its Subnet mask is [Link].
19.
12
CLASS B
• In a class B address, the first octet would always
start with ’10’.
• Thus, class B addresses range from [Link] to
[Link].
• The first 16 bits or the first two octets denote the
network portion and the remaining 16 bits or two
octets belong to the host portion.
• Its Subnet mask is [Link].
• Example: [Link]
19.
13
CLASS C
• In a class C address, the first octet would always
start with ‘110’.
• Thus, class C addresses range from [Link] to
[Link].
• The first 24 bits or the first three octets denote
the network portion and the rest 8 bits or the
remaining one octet belong to the host portion.
• Its Subnet mask is [Link].
• Example: [Link]
19.
14
CLASS D
• Class D is used for multicast addressing and in a
class D address the first octet would always start
with ‘1110’.
• Thus, class D addresses range from [Link] to
[Link].
• Its Subnet mask is not defined.
• Example: [Link]
• Class D addresses are used by routing protocols
like OSPF, RIP, etc.
19.
15
CLASS E
• Class E addresses are reserved for research
purposes and future use.
• The first octet in a class E address starts with
‘1111’.
• Thus, class E addresses range from [Link] to
[Link].
• Its Subnet mask is not defined.
19.
16
Figure 19.2 Finding the classes in binary and dotted-decimal notation
19.17
Example 19.4
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. [Link]
d. [Link]
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.18
Disadvantage of Classful Addressing
• Class A with a mask of [Link] can support 128
Network, 16,777,216 addresses per network and a
total of 2,147,483,648 addresses.
• Class B with a mask of [Link] can support
16,384 Network, 65,536 addresses per network
and a total of 1,073,741,824 addresses.
• Class C with a mask of [Link] can support
2,097,152 Network, 256 addresses per network
and a total of 536,870,912 addresses.
19.
19
Note
In classful addressing, a large part of the
available addresses were wasted.
19.20
Disadvantage of Classful Addressing
• But what if someone requires 2000 addresses ?
• One way to address this situation would be to
provide the person with class B network. But that
would result in a waste of so many addresses.
• Another possible way is to provide multiple class
C networks, but that too can cause a problem as
there would be too many networks to handle.
• To resolve problems like the one mentioned above
CIDR was introduced.
19.
21
Classless Inter-Domain Routing
(CIDR)
CLASSLESS ADDRESSING
• CIDR or Class Inter-Domain Routing was
introduced in 1993 to replace classful addressing.
• It allows the user to use VLSM or Variable Length
Subnet Masks.
19.
22
Note
Classful addressing, which is almost
obsolete, is replaced with classless
addressing.
19.23
CIDR notation
• In CIDR subnet masks are denoted by /X.
• For example a subnet of [Link] would be
denoted by /24.
• To work a subnet mask in CIDR, we have to first
convert each octet into its respective binary
value. For example, if the subnet is of
[Link]. then :
• First Octet – 255 has 8 binary 1's when converted
to binary
• Second Octet – 255 has 8 binary 1's when
converted to binary
• Third Octet – 255 has 8 binary 1's when converted
to binary
19.
24 • Fourth Octet – 0 has 0 binary 1's when converted
Note
In IPv4 addressing, a block of
addresses can be defined
as
x.y.z.t /n
in which x.y.z.t defines one of the
addresses and the /n defines the mask.
19.25
Table 19.2 Default masks for classful addressing
19.26
Difference between Classful
Addressing and Classless Addressing
19.
27
Difference between Classful
Addressing and Classless Addressing
19.
28
Note
The first address in the block can
be found by setting the rightmost
32 − n bits to 0s.
19.29
Example 19.6
A block of addresses is granted to a small organization.
We know that one of the addresses is [Link]/28.
What is the first address in the block?
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
19.30 [Link].
Note
The first address in a block is
normally not assigned to any device;
it is used as the network address that
represents the organization
to the rest of the world.
19.31
Note
The last address in the block can be
found by setting the rightmost
32 − n bits to 1s.
19.32
Example 19.7
Find the last address for the block in Example 19.6.
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
[Link]
This is actually the block
shown in Figure 19.3.
19.33
Note
The number of addresses in the block
can be found by using the formula
232−n.
19.34
Example 19.8
Find the number of addresses in Example 19.6.
Solution
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
19.35
Note
Each address in the block can be
considered as a two-level
hierarchical structure:
the leftmost n bits (prefix) define
the network;
the rightmost 32 − n bits define
the host.
19.36
Figure 19.6 A frame in a character-oriented protocol
19.37
Figure 19.7 Configuration and addresses in a subnetted network
19.38
Figure 19.8 Three-level hierarchy in an IPv4 address
19.39
Example 19.10
An ISP is granted a block of addresses starting with
[Link]/16 (65,536 addresses). The ISP needs to
distribute these addresses to three groups of customers as
follows:
a. The first group has 64 customers; each needs
256 addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs
64 addresses.
Design the subblocks and find out how many addresses
are still available after these allocations.
19.40
Example 19.10
19.42
Example 19.10
An ISP is granted a block of addresses starting with
[Link]/16 (65,536 addresses). The ISP needs to
distribute these addresses to three groups of customers as
follows:
a. The first group has 64 customers; each needs
256 addresses.
b. The second group has 128 customers; each needs 128
addresses.
c. The third group has 128 customers; each needs
64 addresses.
Design the subblocks and find out how many addresses
are still available after these allocations.
19.43
Figure 19.9 An example of address allocation and distribution by an ISP
19.44
Table 19.3 Addresses for private networks
19.45
Network Address Translation (NAT)
• To access the Internet, one public IP address is needed
• The idea of NAT is to allow multiple devices to access the
Internet through a single public address.
• To achieve this, the translation of a private IP address to a public
IP address is required.
• Network Address Translation (NAT) is a process in which
one or more local IP address is translated into one or more
Global IP address and vice versa in order to provide Internet
access to the local hosts.
• Also, it does the translation of port numbers i.e. masks the port
number of the host with another port number, in the packet that
will be routed to the destination.
• It then makes the corresponding entries of IP address and port
number in the NAT table.
19.46
Figure 19.10 A NAT implementation
19.47
Figure 19.11 Addresses in a NAT
19.48
Figure 19.12 NAT address translation
19.49
19-2 IPv6 ADDRESSES
Despite all short-term solutions, address depletion is
still a long-term problem for the Internet. This and
other problems in the IP protocol itself have been the
motivation for IPv6.
Topics discussed in this section:
Structure
Address Space
19.50
Note
An IPv6 address is 128 bits long.
19.51
Figure 19.14 IPv6 address in binary and hexadecimal colon notation
19.52
Figure 19.15 Abbreviated IPv6 addresses
19.53
Example 19.11
Expand the address 0:15::1:12:1213 to its original.
Solution
We first need to align the left side of the double colon to
the left of the original pattern and the right side of the
double colon to the right of the original pattern to find
how many 0s we need to replace the double colon.
This means that the original address is.
19.54
Table 19.5 Type prefixes for IPv6 addresses
19.55
Table 19.5 Type prefixes for IPv6 addresses (continued)
19.56
Figure 19.16 Prefixes for provider-based unicast address
19.57
Figure 19.18 Reserved addresses in IPv6
19.58
Figure 19.17 Multicast address in IPv6
19.59
Figure 19.19 Local addresses in IPv6
19.60
Network Layer:
IPV4 and IPV6 Header Format
20.1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
20-2 IPv4
The Internet Protocol version 4 (IPv4) is the delivery
mechanism used by the TCP/IP protocols.
Topics discussed in this section:
Datagram
Fragmentation
Checksum
Options
20.
62
Figure 20.4 Position of IPv4 in TCP/IP protocol
suite
20.63
Figure 20.5 IPv4 datagram
format
20.64
Table 20.2 Default types of service
20.65
Note
The total length field defines the total
length of the datagram including the
header.
20.66
Figure 20.7 Encapsulation of a small datagram in an Ethernet
frame
20.67
Figure 20.8 Protocol field and encapsulated data
20.68
Table 20.4 Protocol values
20.69
Figure 20.9 Maximum transfer unit
(MTU)
20.70
Table 20.5 MTUs for some
networks
20.71
Figure 20.10 Flags used in fragmentation
20.72
Figure 20.11 Fragmentation example
20.73
Figure 20.12 Detailed fragmentation example
20.74
Figure 20.14 Taxonomy of options in IPv4
20.75
20-3 IPv6
The network layer protocol in the TCP/IP protocol
suite is currently IPv4. Although IPv4 is well designed,
data communication has evolved since the inception
of IPv4 in the 1970s. IPv4 has some deficiencies that
make it unsuitable for the fast-growing Internet..
Topics discussed in this section:
Advantages
Packet Format
Extension Headers
20.76
Figure 20.15 IPv6 datagram header and
payload
20.77
Figure 20.16 Format of an IPv6
datagram
20.78
Table 20.6 Next header codes for
IPv6
20.79
Table 20.7 Priorities for congestion-controlled traffic
20.80
Table 20.8 Priorities for noncongestion-controlled traffic
20.81
Table 20.9 Comparison between IPv4 and IPv6 packet
headers
20.82
Figure 20.17 Extension header types
20.83
Table 20.10 Comparison between IPv4 options and IPv6 extension
headers
20.84