Module-4.1-IP Addressing
Module-4.1-IP Addressing
IP Addresses: Classful
Addressing
Internet
IPv4
•Every computer on network has an IP address that represent its
•
l ocation on network.
•Two devices in the Internet can never have the same address at
the same time.
•An address may be assigned to a device for a time period and
then taken away and assigned to another device.
•If a device operating at the network layer has m connections to
the Internet, it needs to have m address.(e.g. router)
IPv4 Address Space
IPV4 address space is the total number of addresses used by the
protocol.
Binary notation:
Dotted-decimal notation:
Written in decimal form with a decimal point( dot) separating the bytes.
Example: 117.149.29.2
9
Example-1
Solution
Replace each group of 8 bits with its equivalent decimal
number and add dots for separation.
Example -2
Solution
Replace each decimal number with its binary equivalent.
IPv4 Classes
Class A address: designed for large organizations with a large
number of attached hosts or routers. (wasted and not used)
15
Hosts for Classes of IP Addresses
•The 32-bit address is divided into netid and hostid.
• These part are of varying lengths, depending on the class.
•Dose not apply to classes D and E.
24 *
Class A (24 bits for hosts) 2 - 2 = 16,777,214 maximum hosts
16 *
Class B (16 bits for hosts) 2 - 2= 65,534 maximum hosts
8 *
Class C (8 bits for hosts) 2 - 2 = 254 maximum hosts
*
Subtracting the network and broadcast reserved address
IPv4 Address Classes Range
Class D Addresses
A Class D address begins with binary 1110 in the first octet.
First octet range 224 to 239.
Class D address can be used to represent a group of hosts called a
host group, or multicast group.
Class E 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.
Example -4
Solution
a. The first bit is 0. This is a class Aaddress.
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.
Network IDs and Broadcast Addresses
An IP address such as 176.10.0.0 that has all binary 0s in the host bit positions is
reserved for the network address.
An IP address such as 176.10.255.255 that has all binary 1s in the host bit positions is
reserved for the broadcast address.
Special Addresses
0 [Zero] i.e 0.0.0.0.is reserved and represents all IP
addresses.
127.0.0.1 is a reserved address and is used for testing, like a
loop back on an interface.
255.255.255.255 is a reserved address and is used for
broadcasting purposes.
Private Addresses
22
Default Mask
Is a 32 bits long address used to distinguish between network address and host
address in IP address.
Subnet mask is always used with IP address.
Subnet mask has only one purpose, to identify which part of an IP address is
network address and which part is host address.
For example how will we figure out network address and host address from
IP address 192.168.1.10 ?
Here we need default mask to get details about network address and host address.
In decimal notation:
IP address 192.168.1.10
Default mask 255.255.255.0
Network address is 192.168.1 and host address is 10.
In binary notation:
Class A has default subnet mask 255.0.0.0. that means first octet of the
subnet mask has all on bits. In slash notation it would be written as /8,
means address has 8 bits on.
Class B has default subnet mask 255.255.0.0. that means first two octets
of the subnet mask have all on bits. In slash notation it would be
written as /16, means address has 16 bits on.
Class C has default subnet mask 255.255.255.0. that means first three
octets of the subnet mask have all on bits. In slash notation it would be
written as /24, means address has 24 bits on.
Helps to find the netid and hostid. Does not apply to classes D and E.
Default Mask for Classful Addressing
Note
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.
Last address for the block:
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
Number of addresses:
The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
Example -7
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.
Example -7 (continued)
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 -7 (continued)
Solution
The class is B. The first 2 bytes defines the netid. We can find the
network address by replacing the hostid bytes (17.85) with 0s.
132.6.0.0.
The class is A. Only the first byte defines the netid. We can find the
network address by replacing the hostid bytes (56.7.91) with 0s.
Therefore, the network address is 23.0.0.0.
IP Address Class NID DBA FBA
250.0.1.2 D X X X
300.1.2.3 X X X X
IP addresses are designed with
two levels of hierarchy.
Two-level Hierarchy: No subnetting
IP address can define only two levels of hierarchy when not
subnetted.
Private Addressing
340,282,366,920,938,463,463,374,607,431,768,211,456
possible addresses.
IPv6 will most likely coexist with IPv4 for years to come.
Some experts believe IPv4 will remain for more than 10 years.
CLASSLESS
ADDRESSING
Variable-length subnetting
Rules:
** The number of blocks must be a power of 2 (1,
2, 4, 8, 16, . . .).
** The blocks must be contiguous in the address
space (no gaps between the blocks).
** The third byte of the first address in the
superblock must be evenly divisible by the number
of blocks. In other words, if the number of blocks is
N, the third byte must be divisible by N.
Rules : Beginning Address
The beginning address must be evenly divisible by
the number of addresses.
For example, if a block contains 4 addresses, the
beginning address must be divisible by 4.
If the block has less than 256 addresses, we need to
check only the rightmost byte.
If it has less than 65,536 addresses, we need to check
only the two rightmost bytes, and so on.
19.67
Variable-length blocks
Solution:
The prefix length is 27, which means that we
must keep the first 27 bits as is and change the
remaining bits (5) to 0s.
The 5 bits affect only the last byte.
The last byte is 01010010. Changing the last 5
bits to 0s, we get 01000000 or 64.
The network address is 167.199.170.64/27.
An organization is granted the block 130.34.12.64/26.
The organization needs to have four subnets. What are
the subnet addresses and the range of addresses for each
subnet?
Solution: