Chapter 4 P2
Chapter 4 P2
IP is the primary protocol in the Internet Layer of the Internet Protocol Suite
and has the task of delivering distinguished protocol datagrams (packets)
from the source host to the destination host solely based on their addresses.
For this purpose the Internet Protocol defines addressing methods and
structures for datagram encapsulation.
4
IPv4 Addresses
Two devices on the Internet can never have the same address at the
same time.
5
Address Space
A protocol such as IPv4 that defines addresses has an address space.
An address space is the total number of addresses used by the protocol.
because each bit can have two different values (0 or 1) and N bits can have
N
2 values.
IPv4 uses 32-bit addresses, which means that the address space is 2 32
or
4,294,967,296 (more than 4 billion). This means that, theoretically, if there
were no restrictions, more than 4 billion devices could be connected to the
Internet.
We will see shortly that the actual number is much less because of the
restrictions imposed on the addresses.
6
Notations
There are two prevalent notations to show an 1Pv4 address: binary
notation and dotted-decimal notation.
Binary Notation
In binary notation, the IPv4 address is displayed as 32 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 or a 4-byte address. The following is an
example of an IPv4 address in binary notation:
01110101 10010101 00011101 00000010
Dotted-Decimal Notation
To make the IPv4 address more compact and easier to read, Internet
addresses are usually written in decimal form with a decimal point (dot)
separating the bytes. The following is the dotted-decimal notation of the
above address:
117.149.29.2
7
Example: Dotted-decimal notation and
binary notation for an IPv4 address
8
Example 1
Solution
We replace each group of 8 bits with its equivalent decimal
number and add dots for separation.
9
Example 2
Solution
We replace each decimal number with its binary equivalent.
10
Example 3
Solution
a. There must be no leading zero (045).
b. They 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.
11
Classful Addressing
IPv4 addressing, at its inception, used the concept of classes. This
architecture is called classful addressing.
12
Example 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.
13
Network ID and Host ID
In classful addressing, an IP address in class A, B, or C
is divided into network ID and host ID.
These parts are of varying lengths, depending on
the class of the address.
st nd rd th
1 octet 2 octet 3 octet 4 octet
Class A Network Host Host Host
The mask can help us to find the network ID and the host ID. For
example, the mask for a class A address has eight 1s, which means the
first 8 bits of any address in class A define the network ID; the next 24 bits
define the host ID.
15
Address Depletion
The flaws in classful addressing scheme combined with the fast growth of
the Internet led to the near depletion of the available addresses.
Yet the number of devices on the Internet is much less than the 2 32
address space.
We have run out of class A and B addresses, and a class C block is too
small for most midsize organizations.
One solution that has alleviated the problem is the idea of classless
addressing.
16
Subnetting
During the era of classful addressing, subnetting was introduced.
If an organization was granted a large block in class A or B, it could
divide the addresses into several contiguous groups and assign each group
to smaller networks (called subnets) or, in rare cases, share part of the
addresses with neighbors.
Subnetting does NOT give you more hosts, but actually costs you hosts.
17
Contd.
Network Network Host Host
172 16 0 0
You lose two host IP Addresses for each subnet, and perhaps one
for the subnet IP address and one for the subnet broadcast IP
address.
You lose the last subnet and all of it’s hosts’ IP addresses as the
broadcast for that subnet is the same as the broadcast for the
network.
In older networks, you would have lost the first subnet, as the
subnet IP address is the same as the network IP address. (This
subnet can be used in most networks.)
18
Classless Addressing
To overcome address depletion and give more organizations access to the
Internet, classless addressing was designed and implemented.
In this scheme, there are no classes, but the addresses are still granted in
blocks.
Address Blocks
In classless addressing, when an entity, small or large, needs to be
connected to the Internet, it is granted a block (range) of addresses.
The size of the block (the number of addresses) varies based on the
nature and size of the entity.
For example, a household may be given only two addresses; a large
organization may be given thousands of addresses.
An ISP, as the Internet service provider, may be given thousands or
hundreds of thousands based on the number of customers it may serve.
19
Restriction
To simplify the handling of addresses, the Internet authorities
impose three restrictions on classless address blocks:
1. The addresses in a block must be contiguous, one after another.
20
Contd.
We can see that the restrictions are applied to this block. The
addresses are contiguous. The number of addresses is a power
4
of 2 (16 = 2 ), and the first address is divisible by 16. The first
address, when converted to a decimal number, is 3,440,387,360,
which when divided by 16 results in 215,024,210.
21
Classless addressing Mask
A better way to define a block of addresses is to select any address in the block and
the mask.
As we discussed before, a mask is a 32-bit number in which the n leftmost bits are 1s
and the 32 - n rightmost bits are 0s.
However, in classless addressing the mask for a block can take any value from 0 to
32. It is very convenient to give just the value of n preceded by a slash (CIDR –
Classless Inter Domain Routing notation).
The address and the /n notation completely define the whole block (the first address,
the last address, and the number of addresses).
22
Q1:Find the number subnet and valid host
The given network 192.168.1.0 and subnet mask
255.255.255.240/28
I. What is the class of the given network?
II. Find the subnet Mask?
III. find valid host?
Answer
Change in two binary notion
11111111 11111111 11111111 11110000
I. Class C Network because the first binary is 111
II. to find subnet Mask 2 , 24 =16
27
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 the above example 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.
28
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.
29
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.
30
c. The number of addresses can be found by
complementing the mask, interpreting it as a decimal
number, and adding 1 to it.
31
Examples
There are three types of Subnetting examples
32
Subnetting when given a required number of networks
Example 1: A service provider has given you the Class C network
range 209.50.1.0. Your company must break the network into 20
separate subnets.
Step 1. Determine the number of subnets and convert to binary
In this example, the binary representation of 20 = 00010100.
Step 2. Reserve required bits in subnet mask and find incremental value
The binary value of 20 subnets tells us that we need at least 5 network bits to
satisfy this requirement (since you cannot get the number 20 with any less than 5
bits – 10100)
Our original subnet mask is 255.255.255.0 (Class C subnet)
The full binary representation of the subnet mask is as follows:
255.255.255.0 = 11111111.11111111.11111111.00000000
33
Cont…
We must “convert” 5 of the client bits (0) to network bits (1) in order
to satisfy the requirements:
New Mask = 11111111.11111111.11111111.11111000
If we convert the mask back to decimal, we now have the subnet
mask that will be used on all the new networks – 255.255.255.248
Our increment bit is the last possible network bit, converted back to a
binary number:
Start with your given network address and add your increment to the sub
netted octet: 209.50.1.0
209.50.1.8
209.50.1.16 …etc
You can now fill in your end ranges, which is the last possible IP
address before you start the next range. 209.50.1.0 – 209.50.1.7
209.50.1.8 – 209.50.1.15
You can then assign these ranges to your networks! Remember the first
and last address from each range (network / broadcast IP) are unusable.
35
36
?