2. 19.2
IPv4 ADDRESSES
IPv4 ADDRESSES
An
An IPv4 address
IPv4 address is a
is a 32-bit
32-bit address that uniquely and
address that uniquely and
universally defines the connection of a device (for
universally defines the connection of a device (for
example, a computer or a router) to the Internet.
example, a computer or a router) to the Internet.
Address Space
Notations
Classful Addressing
Classless Addressing
Network Address Translation (NAT)
Topics discussed in this section:
Topics discussed in this section:
7. 19.7
Change the following IPv4 addresses from binary notation
to dotted-decimal notation.
Example
Solution
We replace each group of 8 bits with its equivalent decimal
number (see Appendix B) and add dots for separation.
8. 19.8
Change the following IPv4 addresses from dotted-decimal
notation to binary notation.
Example
Solution
We replace each decimal number with its binary equivalent
9. 19.9
In classful addressing :the address space is divided into five classes:
A, B, C, D, and E.
Finding the classes in binary and dotted-decimal notation
10. Number of networks /hosts in classful
addressing
0Network host
A 1.0.0.0 to
127.255.255.255
2^7 networks as 7 bits represent network id
2^(24) interfaces/hosts as 24 bits represent host id
10 network host
B 128.0.0.0 to
191.255.255.255
2^(14) networks as 14 bits represent network id
2^(16) interfaces /hosts as 16 bits represent host id
110 network host
C 192.0.0.0 to
223.255.255.255
2^(21) networks
2^(8) interfaces
11. Classful addressing
E.g., Class C networks can accommodate only 2^8-2 = 254 hosts (2 are
reserved). Small for most medium to large organizations.
However Class B supports 65,634 hosts – too large. An organization
with 2000 hosts ended up with class B addressing – address space was
ill used.
Therefore in 1993, Classless Interdomain Routing (CIDR) was
introduced.
12. 19.12
Find the class of each address.
a. 00000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
c. 14.23.120.8
d. 252.5.15.111
Example 19.4
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.
17. 19.17
In IPv4 classless 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.
Note
18. IP addressing: CIDR
• CIDR: Classless InterDomain Routing
– network portion of address of arbitrary length
– address format: a.b.c.d/x, where x is # bits in network portion of
address
• CIDR addressing example:
– CIDR: Network part: 21 bits. Host part: 2^11 = 2048 hosts.
19. 19.19
The first address in the block can be found by setting the rightmost
32 − n bits to 0s.
Note
20. 19.20
A block of addresses is granted to a small organization. We
know that one of the addresses is 205.16.37.39/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
205.16.37.32.
Example 1
21. 19.21
The last address in the block can be found by setting the rightmost
32 − n bits to 1s.
Note
22. 19.22
Find the last address for the block in previous Example
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.
Example
23. 19.23
The number of addresses in the block can be found by using the formula
232−n
.
Note
24. 19.24
Find the number of addresses in Example .
Example
Solution
The value of n is 28, which means that number
of addresses is 2 32−28
or 16.
25. 19.25
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. /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.
Example
26. 19.26
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.
Example (continued)
27. 19.27
b. The last address can be found by ORing the given
addresses with the complement of the mask. ORing
here is done bit by bit. The result of ORing 2 bits is 0 if
both bits are 0s; the result is 1 otherwise. The
complement of a number is found by changing each 1
to 0 and each 0 to 1.
Example (continued)
29. 19.29
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.
Note
30. 19.30
IPv6 ADDRESSES
IPv6 ADDRESSES
Despite all short-term solutions, address depletion is
Despite all short-term solutions, address depletion is
still a long-term problem for the Internet. This and
still a long-term problem for the Internet. This and
other problems in the IP protocol itself have been the
other problems in the IP protocol itself have been the
motivation for IPv6.
motivation for IPv6.
Structure
Address Space
Topics discussed in this section:
Topics discussed in this section:
34. 19.34
Expand the address 0:15::1:12:1213 to its original.
Example
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.
35. IPv4 Addressing Concepts and
Their IPv6 Equivalents
IPv4 Address IPv6 Address
Address Length – 32 bits 128 bits
Address Representation - decimal hexadecimal
Internet address classes Not applicable in IPv6
Multicast addresses (224.0.0.0/4) IPv6 multicast addresses (FF00::/8)
Broadcast addresses Not applicable in IPv6
Unspecified address is 0.0.0.0 Unspecified address is ::
Loopback address is 127.0.0.1 Loopback address is ::1
Public IP addresses Global unicast addresses
Private IP addresses (10.0.0.0/8,
172.16.0.0/12, and 192.168.0.0/16)
Site-local addresses (FEC0::/10)
Autoconfigured addresses (169.254.0.0/16) Link-local addresses (FE80::/64)
IPv6 Packet Format
35