Professional Documents
Culture Documents
IP Addressing
Basic IP addressing
• Each host connected to the internet is
identified by a unique IP address
• An IP address is a 32 bit quantity
– Expressed as a dotted decimal notation
W.X.Y.Z where dots are used to separate
each of the four octets of the address.
– Consists of two logical parts:
• A network number
• A host number
Dotted Decimal Notation
• Network bits: 7
– Number of networks = 27 – 1 = 127
• Host bits = 24
– Number of hosts = 224 – 2 = 16,777,214
• Address ranges
– 0.0.0.0 to 127.255.255.255
Class B Address
• Network bits: 14
• Number of networks = 214 – 1 = 16,383
• Host bits = 16
– Number of hosts = 216 – 2 = 65,534
• Address ranges
– 128.0.0.0 to 191.255.255.255
Class C Address
• Network bits: 21
• Number of networks = 221 – 1 = 2,097,151
• Host bits = 8
– Number of hosts = 28 – 2 = 254
• Address ranges
– 192.0.0.0 to 223.255.255.255
Class D Address
• Address ranges
– 224.0.0.0 to 239.255.255.255
Special Purpose IP Addresses
• Reserved for private use
– 10.x.x.x (class A)
– 172.16.x.x – 172.31.x.x (class B)
– 192.168.x.x (class c)
• Loopback/local address
– 127.0.0.0 – 127.255.255.255
• Default network
– 0.0.0.0
• Limited broadcast
– 255.255.255.255
Some conventions
• Within a particular network (class A, B or
C), the first and last addresses serve
special functions
– The first address represents the network
number
• For example 118.0.0.0
– The last address represents the directed
broadcast address of the network
• For example: 118.255.255.255
Example
• 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
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.
IP subnet
• Basic concept
– A subnet is a logical subdivision of an IP network.
– The practice of dividing a network into two or
more networks is called subnetting
– A subset of a class A, B or C network
• IP addresses that do not use subnets consists of
– A network portion and
– A host portion
– Represents a static two-level hierarchical
addressing model
Cont.
• IP subnets introduces a third level of hierarchy
– A network portion
– A subnet portion
– A host portion
• Allow more efficient (and structured)
utilization of the addresses
• Uses network masks
– Natural (default network masks)
– Custom: subnet networks
Con…
Masking concept
Mask
Decimal Binary
IP address: 10.0.0.20 00001010 00000000 00000000 00010100
Mask : 255.0.0.0 11111111 00000000 00000000 00000000
Network Host
• The network address is the beginning
address of each block. It can be found by
applying the default mask to any of the
addresses in the block (including itself).
It retains the net id of the block and sets
the host id to zero.
• Given the address 23.56.7.91, find the
beginning address (network address).
• Solution
The default mask is 255.0.0.0, which means
that only the first byte is preserved and the
other 3 bytes are set to 0s. The network
address is 23.0.0.0.
• Given the address 132.6.17.85, find the
beginning address (network address).
• Solution
The default mask is 255.255.0.0, which means
that the first 2 bytes are preserved and the
other 2 bytes are set to 0s. The network
address is 132.6.0.0.
Creating subnets using masks
• Masks are very flexible
– Using masks, networks can be divided into smaller
subnets
• How ?
– By extending the network portion of the address
into the host portion
• Advantage gained
– We can create a large number of subnets from one
network
– Can have less number of hosts per network
Example: Subnets
• Network mask 255.255.0.0 is applied to a
class A network 10.0.0.0
– This divides the IP address 10.5.0.20 into
• A network portion of 10
• A subnet portion of 5 and
• A host portion of 20
– The 255.255.0.0 mask borrows a portion of
the host space, and applies it to network
space
Example (cont..)
• The 255.255.0.0 mask borrows a 8 bit portion
of the host space and applies it to network
space
Subnet = 2n = 28 = 256
From 10.0.0.0 to 10.255.0.0.
• The number of new hosts per subnet
= 216 – 2 = 65534
• Total hosts
= 256 * 65534 = 16,776,704
Example (cont..)
Decimal Binary
IP address: 10.5.0.20 00001 010 00000101 00000000 00010100
Mask : 255.255.0.0 11111111 11111111 00000000 00000000
Network Subnet Host
Example (cont..)
Default Mask
255.255.0.0
IP Address
Network Address
144.16.72.57
144.16.0.0
AND
Mask
255.255.192.0
IP Address
Network Address
144.16.72.57
144.16.64.0
AND
Variable length subnet masks
(VLSM)
• Basic concept
– The same network can be configured with different
masks
– Can have subnets of different sizes
– Allows better utilization of available addressees
Example: VLSM
• Suppose we are assigned a class C
network 192.203.17.0
– To be divided into three subnets
• Corresponding to three departments
• With 115,45 and 50 hosts respectively
D1 D2 D3
(115) (40) (50)
Example (cont..)
• Available subnet options
– The network mask will be the class C natural mask
255.255.255.0
– The subnet masks of the form 255.255.255.X
• Can be use to divide the network into more subnets
Example (cont..)
The VLSM options
• Basic concept
– First use the mask 255.255.255.128
(11111111 11111111 11111111 10000000) to
divide the network address into two subnets
with 128 hosts each
• 192.203.17.0 (0 to 127)
• 192.203.17.0 (128 to 256)
Example (cont..)
• Next subnet (the second 128 subnet using
a mask of 255.255.255.192 (11111111
11111111 11111111 11000000)
–Creates two subnets, 64 hosts each
• 255.255.255.128 (128 to .191)
• 255.255.255.128 (192 to .255)
Example (cont..)
192.203.17.0
Mask 255.255.255.128
Solution
The first address in the block can be found by setting the
rightmost
32 − n bits to 0s.
• 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.
Examples cont..
• Find the last address for the above Example.
Solution
The last address in the block can be found by setting the rightmost
32 − n bits to 1s.
Solution
• The number of addresses in the block can be
found by using the formula
232−n.
• The value of n is 28, which means that number
of addresses is 2 32−28 or 16.
Example cont.…
• 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.
Example cont.…
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 cont.…