You are on page 1of 51

Lecture 4

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

IP address:01000010 10001000 00110000 01111110

(66) (136) (48) (126)

Dotted Decimal Notation: 66.136.48.126


Hierarchical addressing
• A computer on the internet is addressed using a
two-tuple:
– The network number
• Assigned and managed by central authority
– The host number
• Assigned and managed by local network
administrator
• When routing a packet to the destination network,
only the network number is looked at
IP Address Classes
• There are five defined IP address classes
– Class A UNICAST
– Class B UNICAST
– Class C UNICAST
– Class D MULTICAST
– Class E RESERVED
• Identified by the first few bits in the IP address
• There also exists some special-purpose IP
addresses
Con….

• The class based addressing is also


known as the classfull model
• Different network classes
represent different network-to-
hosts ratio
Class A Address

0 Network Host Host Host

• 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

10 Network Network Host Host

• 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

110 Network Network Network Host

• 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

1110 Multicast 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

An Address AND Beginning


in the block operation address
(subnet address)
Natural mask
• Natural masks are default network masks for each
class
• Class A, B, and C addresses
– Have fixed division of network and host portions
– Can be expressed as masks
• Called natural masks
Class Mask in binary Mask in dotted
decimal
A 11111111 00000000 00000000 00000000 255.0.0.0

B 11111111 11111111 00000000 00000000 255.255.0.0


C 11111111 11111111 11111111 00000000 255.255.255.0
Natural mask con…
• Provide a mechanism to split the IP address
10.0.0.20 into
– A network portion of 10 and
– A host portion of 20

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

192.203.17.0 (0 to 127) 192.203.17.0 (128 to 255)


Mask
255.255.255.192

192.203.17.128 (128 to 191)

192.203.17.128 (192 to 255)


Running out of IP addresses
• Growing demand for IP addresses
– Sever strain on the classful model
– Due to wastage of address space
• Measure taken
– Creative allocation of IP addresses
– Classless Intr-domain routing (CIDR)
– Classless addresses, and Network Address
Translation (NAT)
– IP version (IPV6)
CIDR: Introduction
• The size of the global routing tables have
grown very fast in recent years
– Caused routers to become saturated
• CIDR is a new concept to manage IP networks
– Classless inter domain routing
– No concept of class A,B and C networks
– Reduces size of routing tables
Basic Idea Behind CIDR
• An IP address is represented by a prefix, which is
the IP address of the network
• It is followed by a slash, followed by a number M
• In IPv4 addressing, a block of addresses can be
defined as
• x.y.z.t /M
• in which x.y.z.t defines one of the addresses and
the /M defines the mask
– M: number of leftmost contiguous bits to be used for
the network mask
– Example: 144.16.192.57/18
CIDR: An Important Rule
• The number of addresses in each block must
be a power of 2
• The beginning address in each block must be
divisible by the number of addresses in the
block
• A block that contains 16 addresses cannot have
beginning address as 144.16.223.36
• But the address 144.16.192.64 is possible
An example: CIDER
• An organization is allotted a block with
beginning address:
• 144.16.192.24/29
• What is the range of the block?
• Start Addr: 10010000 00011000 11000000 00011000
• End Addr: 10010000 00011000 11000000 00011111
• There are (23 = 8) addresses in the block:
144.16.192.24 to 144.16.192.31
Recent Trends
• Move on to CIDR addressing
• Existing classful networks can also be
represented using this notation
• There are five defined IP address classes
– Class A W.X.Y.Z/8
– Class B W.X.Y.Z/16
– Class C W.X.Y.Z/24
• Recent router support CIDR
Examples
• 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 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.

• 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 cont.…
• Find the number of addresses for the above
Example

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.…

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 cont.…

A network configuration for the block 205.16.37.32/28


Example cont.…
• 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
Summary
• A frame in a character-oriented protocol
Summary cont.…
• Each address in the block can be considered as
a two-level hierarchical structure: the
leftmost n bits (prefix) define the network; the
rightmost 32 − n bits define the host.
Summary cont.…
Figure: Configuration and addresses in a subnetted
network
Summary cont.…
• Figure: Three-level hierarchy in an IPv4
address
Exercise
• An ISP is granted a block of addresses starting
with 190.100.0.0/16 (65,536 addresses). The ISP
needs to distribute these addresses to three groups
of customers as follows:
a) The first group has 64 customers; each needs 256
addresses.
b) The second group has 128 customers; each needs 128
addresses.
c) The third group has 128 customers; each needs 64
addresses.
d) Design the subblocks and find out how many
addresses are still available after these allocations.

You might also like