0% found this document useful (0 votes)
7 views

Lecture 5

Uploaded by

nawmanmoh17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Lecture 5

Uploaded by

nawmanmoh17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Chapter 5

IPv4 Addresses

TCP/IP Protocol Suite 2


Chapter
Outline

TCP/IP Protocol Suite 4


5-1 INTRODUCTION

The identifier used in the IP layer of the TCP/IP


protocol suite to identify each device connected
to the Internet is called the Internet address or
IP address. An IPv4 address is a 32-bit address
that uniquely and universally defines the
connection of a host or a router to the Internet;
an IP address is the address of the interface.
TCP/IP Protocol Suite 5
Note

An IPv4 address is 32 bits long.

Note

The IPv4 addresses are unique


and universal.

TCP/IP Protocol Suite 7


Address Space
A protocol IPv4 defines addresses has an
address space. It is the total number of
addresses used by the protocol.
If a protocol uses b bits to define an
address, the address space is 2^b because
each bit can have two different values (0
or 1).

TCP/IP Protocol Suite 8


Address Space
IPv4 uses 32-bit addresses, space is 2^32 or .
Theoretically, if there were no restrictions,
more than 4 billion devices could be
connected to the Internet.

The address space of IPv4 is


232 or 4,294,967,296.

TCP/IP Protocol Suite 9


Notation
There are three common notations to show an IPv4 address:
- binary notation (base 2),
- dotted-decimal notation (base 256),
- and hexadecimal notation (base 16).

Numbers in base 2, 16, and 256 are

TCP/IP Protocol Suite 10


Binary Notation: Base 2
In binary notation, an IPv4 address is displayed as 32 bits.
To make the address more readable, one or more spaces is
usually inserted between each octet (8 bits). Each octet is
often referred to as a byte. So it is common to hear an IPv4
address referred to as a 32-bit address, a 4-octet address, or a
4-byte address. The following is an example of an IPv4
address in binary notation:

TCP/IP Protocol Suite 11


Figure 5.1 Dotted-decimal notation

Dotted-Decimal Notation: Base 256


To make the IPv4 address more compact and easier to read,
an IPv4 address is usually written in decimal form with a
decimal point (dot) separating the bytes. This format is
referred to as dotted-decimal notation. an IPv4 address in
dotteddecimal notation. Note that because each byte (octet)
is only 8 bits, each number in the dotted-decimal notation is
between 0 and 255.

TCP/IP Protocol Suite 12


Example

Change the following IPv4 addresses from


binary notation to dotted-decimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111
Solution
We replace each group of 8 bits with its
equivalent decimal number and add dots for
separation:
a. 129.11.11.239
b. 193.131.27.255

TCP/IP Protocol Suite 13


Example

Change the following IPv4 addresses from binary


notation to dotted-decimal notation.
c. 11100111 11011011 10001011 01101111
d. 11111001 10011011 11111011 00001111

Solution
We replace each group of 8 bits with its
equivalent decimal number and add dots for
separation:
c. 231.219.139.111
d. 249.155.251.15

TCP/IP Protocol Suite 14


Example

Change the following IPv4 addresses from


dotted-decimal notation to binary notation.
a. 111.56.45.78
b. 221.34.7.82
Solution
We replace each decimal number with its
binary equivalent:
a. 01101111 00111000 00101101 01001110
b. 11011101 00100010 00000111 01010010

TCP/IP Protocol Suite 15


Example
Change the following IPv4 addresses from
dotted-decimal notation to binary notation.
c. 241.8.56.12
d. 75.45.34.78

Solution
We replace each decimal number with its
binary equivalent:
c. 11110001 00001000 00111000 00001100
d. 01001011 00101101 00100010 01001110

TCP/IP Protocol Suite 16


Example

Find the error, if any, in the following IPv4


addresses:
a. 111.56.045.78
b. 221.34.7.8.20

Solution
a. There should be no leading zeroes (045).
b. We may not have more than 4 bytes in an
IPv4 address.

TCP/IP Protocol Suite 17


Example
Find the error, if any, in the following IPv4 addresses:

c. 75.45.301.14
d. 11100010.23.14.67

Solution

c. Each byte should be less than or equal to 255.


d. A mixture of binary notation and dotted-decimal
notation.

TCP/IP Protocol Suite 18


Hexadecimal Notation: Base 16
We sometimes see an IPv4 address in hexadecimal
notation. Each hexadecimal digit is equivalent to
four bits. This means that a 32-bit address has 8
hexadecimal digits. This notation is often used in
network programming.

TCP/IP Protocol Suite 19


Example
Change the following IPv4 addresses from binary notation to
hexadecimal notation.
a. 10000001 00001011 00001011 11101111
b. 11000001 10000011 00011011 11111111

Solution
We replace each group of 4 bits with its hexadecimal
equivalent. Note that 0X (or 0x) is added at the beginning or the
subscript 16 at the end.
a. 0X810B0BEF or 810B0BEF16
b. 0XC1831BFF or C1831BFF16

TCP/IP Protocol Suite 20


Example
Find the number of addresses in a range if the first address is
146.102.29.0 and the last address is 146.102.32.255.

Solution
We can subtract the first address from the last address in base
256 .The result is 0.0.3.255 in this base. To find the number of
addresses in the range (in decimal), we convert this number to
base 10 and add 1 to the result..

TCP/IP Protocol Suite 21


Example
The first address in a range of addresses is 14.11.45.96. If the
number of addresses in the range is 32, what is the last
address?

Solution
We convert the number of addresses minus 1 to base 256,
which is 0.0.0.31. We then add it to the first address to get the
last address. Addition is in base 256.

TCP/IP Protocol Suite 22

You might also like