You are on page 1of 92

ITT350:

Computer Networks
Module 6: IP Addressing

Instructor: Dr. Iqra Altaf Gillani


Network layer
Source to destination delivery of data across multiple networks.

Responsibilities of Network layer:


Network layer
Source to destination delivery of data across multiple networks.

Responsibilities of Network layer:

1. Logical addressing
2. Routing
Internet Protocol (IP) address
It is a unique id used for communication over the Internet designed by IANA
(Internet Assigned numbers authority).

Two versions: IPv4 (32 bit) and IPv6 (128 bit)


IPv4 address
Total address space = 2^32 = 4,294,967,296

32 bit address - 4 octets separated by dots - dotted decimal notation


Hierarchy in addressing
32 bit address is hierarchical and divided into two parts:

● Ist part: Prefix or network bits (n)


● 2nd part: Suffix or host bits (h = 32-n)

Depending on whether your prefix length is fixed or variable we have two types of
addressing:

● Classful addressing
● Classless addressing or CIDR (Classless interdomain routing)
Classful addressing
IP addresses are defined in five classes from A-E.
Classful addressing
IP addresses are defined in five classes from A-E. Based on the first octet:
Classful addressing
IP addresses are defined in five classes from A-E. Based on the first octet:
Subnet mask
Prefix tells you no. of network or on bits and suffix represent the number of host or
off bits. Together on/off bits form a subnet mask.

Subnet mask defines the network and host portion for any IP address.

Example: 255.0.0.0
Subnet mask
Prefix tells you no. of network or on bits and suffix represent the number of host or
off bits. Together on/off bits form a subnet mask.

Subnet mask defines the network and host portion for any IP address.

Example: 255.0.0.0

No. of on bits = 8 and off bits = 32-8=24


Subnet mask
Prefix tells you no. of network or on bits and suffix represent the number of host or
off bits. Together on/off bits form a subnet mask.

Subnet mask defines the network and host portion for any IP address.

Example: 255.0.0.0

No. of on bits, n = 8 and off bits, h = 32-8=24

No. of networks = 2^(n-pb) where pb is number of priority or fixed bits.

No. of hosts per network = 2^h-2 where -2 is done as one address each is
reserved for network id and broadcast address.
Classful addresses
Classful addresses
Classless addressing or CIDR notation
Prefix length is variable.
Classless addressing or CIDR notation
Prefix length is variable.

CIDR uses slash notation: x.y.z.w/n where x.y.z.w is the IP address and n denotes
the network bits which will represent the subnet mask.

Example: 12.13.128.10/10
Classless addressing or CIDR notation
Prefix length is variable.

CIDR uses slash notation: x.y.z.w/n where x.y.z.w is the IP address and n denotes
the network bits which will represent the subnet mask.

Example: 12.13.128.10/10 Subnet mask: 225.192.0.0


Classless addressing or CIDR notation
Prefix length is variable.

CIDR uses slash notation: x.y.z.w/n where x.y.z.w is the IP address and n denotes
the network bits which will represent the subnet mask.

Example: 12.13.128.10/10 Subnet mask: 225.192.0.0

Default subnet masks for classful addressing:


Special addresses
● All zeros: 0.0.0.0 to 0.255.255.255
○ 0.0.0.0/0 - is used to identify all networks, and is referred to as the default route. If a default
route exists in a routing table, it will be used only if there is not a more specific route to a
particular destination.
○ 0.0.0.0/8 - If you set network bits to zero and leave host id alone: it is used to identify hosts on
the local network. Addresses in this range can only be used as a source address.
○ 0.0.0.0/32 - Also used by a host will use when dynamically attempting to learn its IP address
via Dynamic Host Configuration Protocol (DHCP).
● All ones
○ All 1s, i.e., 255.255.255.255 - limited broadcast address - not routable, send to all devices on
local network
○ If we replace all host bits by 1s it means all hosts on that network.
Special addresses
● 127.x.x.x/8 range is reserved for diagnostic purposes. The most commonly
used address in this range is 127.0.0.1, which identifies the local host, and is
referred to as the loopback or localhost address.
● Link local address: The 169.254.x.x/16 range is reserved for Automatic
Private IP Addressing (APIPA). A host assigns itself an address in this range,
if it cannot dynamically obtain an address from a DHCP server.
● The 224.x.x.x – 239.x.x.x ranges are reserved for multicast, and are referred
to as Class D addresses.
● The 240.x.x.x – 255.x.x.x ranges are reserved for future and experimental
use, and were formerly referred to as Class E addresses.
Private IP addresses
These are used on private network and are not routable through Internet.

Intended for security but these also save IP address space.


Private IP addresses
These are used on private network and are not routable through Internet.

Intended for security but these also save IP address space.

How do we then connect to Internet via these addresses?


Private IP addresses
These are used on private network and are not routable through Internet.

Intended for security but these also save IP address space.

How do we then connect to Internet via these addresses? Network Address


Translation (NAT)
Address depletion
Classful addressing became obsolete as the distribution was not proper.

● Class A address: too many hosts


● Class C address: too less hosts
Address depletion
Classful addressing became obsolete as the distribution was not proper.

● Class A address: too many hosts


● Class C address: too less hosts

To alleviate address depletion, one choice is to move to IPV6. Other strategies:


subnetting, supernetting.
Subnetting
Subnetting is the method of dividing a large IP network into small units called
subnets.
Subnetting
Subnetting is the method of dividing a large IP network into small units called
subnets.

To create subnets:

1. Determine no. of NIDs/subnets required.


2. Based on requirements create a subnet mask
3. Allocate hosts IP addresses in given range
Subnetting
Subnetting is the method of dividing a large IP network into small units called
subnets.

To create subnets:

1. Determine no. of NIDs/subnets required.


2. Based on requirements create a subnet mask
3. Allocate hosts IP addresses in given range

Applicable for both classful and classless addressing.


Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask
Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets
Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value
Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value

255.255.255.11100000 = 255.255.255.224

4. Block size= 256 - Effective octet value


Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value

255.255.255.11100000 = 255.255.255.224

4. Block size= 256 - Effective octet value = 256-224=32

0-32-64-96-128-...

5. IP address implementation
Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value

255.255.255.11100000 = 255.255.255.224

4. Block size= 256 - Effective octet value = 256-224=32

0-32-64-96-128-...

5. IP address implementation

194.168.100.0 - NID 1

194.168.100.32 - NID 2
Example: 194.168.100.0 for 5 subnets
1. Identify class and get the default subnet mask: C - 255.255.255.0
2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value

255.255.255.11100000 = 255.255.255.224

4. Block size= 256 - Effective octet value = 256-224=32

0-32-64-96-128-...

5. IP address implementation

194.168.100.0 - NID 1 194.168.100.31 - BID 1

194.168.100.32 - NID 2
Example: 194.168.100.0 for 5 subnets

1. Identify class and get the default subnet mask: C - 255.255.255.0


2. Identify the no. of network bits required: 2^n>= No. of required subnets ⇒ n=3
3. Create new subnet mask - change the effective octet value

255.255.255.11100000 = 255.255.255.224

4. Block size= 256 - Effective octet value = 256-224=32

0-32-64-96-128-...

5. IP address implementation

194.168.100.0 - NID 1 194.168.100.30 -Last valid host 194.168.100.31 - BID 1

194.168.100.32 - NID 2 194.168.100.62 -Last valid host 194.168.100.63 - BID 2


Example: 194.168.100.0 for 5 subnets
No. of subnets = 2^ no. of subnetting bits = 2^3=8 subnets

No. of hosts per subnet = 2^total off bits -2= 2^5-2=30 hosts /subnet
Classless addressing or CIDR
Class privilege was removed to compensate for address depletion. Prefix length is
variable.

CIDR uses slash notation: x.y.z.w/n where x.y.z.w is the IP address and n denotes
the network bits which will represent the subnet mask.

Valid subnet masks: /8 to /30

What about /31 and /32?


Classless addressing or CIDR
Class privilege was removed to compensate for address depletion. Prefix length is
variable.

CIDR uses slash notation: x.y.z.w/n where x.y.z.w is the IP address and n denotes
the network bits which will represent the subnet mask.

Valid subnet masks: /8 to /30

What about /31 and /32? Not possible.


Variable length subnet mask (VLSM)
It is done only for classless. This is a type of subnetting based on host requirement.
It is very efficient way to reduce wastage of host address space.
Example: 192.168.1.0/25 with host requirements of
20,62,120
Sort in Descending order: 120, 62, 20
Example: 192.168.1.0/25 with host requirements of
20,62,120
Sort in Descending order: 120, 62, 20

For 120:

1. Find the host bits, 2^h>=120 ⇒ h=7, so n=32-7=25


2. Subnet mask: /25 = 255.255.255.128
3. Block size=256-128=128 i.e., 0-128-255
4. IP address allocation

192.168.1.0 - NID 1

192.168.1.128 - NID 2
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 62:

1. Find the host bits, 2^h>=62 ⇒


2. Subnet mask:
3. Block size=
4. IP address allocation
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 62:

1. Find the host bits, 2^h>=62 ⇒h=6. So, n=32-6=26


2. Subnet mask: /26=255.255.255.192
3. Block size=256-192=64, i.e., 0-62-128-192-256
4. IP address allocation
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 62:

1. Find the host bits, 2^h>=62 ⇒h=6. So, n=32-6=26


2. Subnet mask: /26=255.255.255.192
3. Block size=256-192=64, i.e., 0-62-128-192-256
4. IP address allocation

192.168.1.128 NID 2

192.168.1.192 NID 3
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 20:

1. Find the host bits, 2^h>=20 ⇒


2. Subnet mask:
3. Block size=
4. IP address allocation
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 20:

1. Find the host bits, 2^h>=20 ⇒ h=5, So, n=32-5=27


2. Subnet mask: /27=255.255.255.224
3. Block size=256-224=32, i.e., 0-32-64-96-128-160-192-224-256
4. IP address allocation
Example: 192.168.1.0/25 with host requirements of
20,62,120
For 20:

1. Find the host bits, 2^h>=20 ⇒ h=5, So, n=32-5=27


2. Subnet mask: /27=255.255.255.224
3. Block size=256-224=32, i.e., 0-32-64-96-128-160-192-224-256
4. IP address allocation

192.168.1.192 NID 3

192.168.1.224 NID 4
Hierarchical addressing in IPV4
Hierarchical addressing in IPV4
Hierarchical addressing in IPV4 with subnetting
Hierarchical addressing in IPV4 with subnetting
Example: 167.199.170.82/27. What is the NID, BID?
Example: 167.199.170.82/27. What is the NID, BID?
Soln: Subnet mask=255.255.255.224

Block size=256-224=32

0-32-64-96-128
Example: 167.199.170.82/27. What is the NID, BID?
Soln: Subnet mask=255.255.255.224

Block size=256-224=32

0-32-64-96-128

NID: 167.199.170.64

BID: 167.199.170.95
Alternate methods
First address in block: Any address in block AND Subnet Mask

Last address in block: Any address in block OR (Not (Subnet Mask))

No. of addresses in block: (Not (Subnet Mask))_10 +1


Alternate methods
First address in block: Any address in block AND Subnet Mask

Given address x.y.z.w/n: This is like keep n leftmost bits same and set 32-n
rightmost bits to 0.

Last address in block: Any address in block OR (Not (Subnet Mask))

No. of addresses in block: (Not (Subnet Mask))_10 +1


Alternate methods
First address in block: Any address in block AND Subnet Mask
Last address in block: Any address in block OR (Not (Subnet Mask))

Given address x.y.z.w/n: This is like keep n leftmost bits same and set 32-n
rightmost bits to 1.
No. of addresses in block: (Not (Subnet Mask))_10 +1
Alternate methods
First address in block: Any address in block AND Subnet Mask

Last address in block: Any address in block OR (Not (Subnet Mask))

No. of addresses in block: (Not (Subnet Mask))_10 +1


Example: 167.199.170.82/27. What is the NID, BID?
Soln: Subnet mask=255.255.255.224

Block size=256-224=32

0-32-64-96-128

NID: 167.199.170.64

BID: 167.199.170.95

Try out the alternate methods!


Example: 194.172.168.171/28
NID:

BID:

No. of valid host addresses:

No. of networks:
Example: 194.172.168.171/28
NID: 194.172.168.160

BID: 194.172.168.175

No. of valid host addresses: 16 -2 =14

No. of networks: 16
Example: An ISP has following chunk of IP addresses
available 245.248.128.0/20. ISP wants to give half of
this to Organization A and quarter to Organization B
and retain rest with itself. Find a valid allocation.
Example: An ISP has following chunk of IP addresses
available 245.248.128.0/20. ISP wants to give half of
this to Organization A and quarter to Organization B
and retain rest with itself. Find a valid allocation.
Soln: 245.248.128.0/21 - Org A

245.248.136.0/22 - Org B
Network Address Translation (NAT)
Distribution of addresses through ISPs results in problems. Suppose ISP assigns
addresses to a small business and later that business grows. ISP can't allocate
same range IP addresses.

Moreover, in private networks all PCs don't need Internet connectivity. Idea is to
use IP address for both internal and universal communication but without wasting
routable addresses.
Network Address Translation (NAT)
Distribution of addresses through ISPs results in problems. Suppose ISP assigns
addresses to a small business and later that business grows. ISP can't allocate
same range IP addresses.

Moreover, in private networks all PCs don't need Internet connectivity. Idea is to
use IP address for both internal and universal communication but without wasting
routable addresses.

Main idea: Use unique private IP addresses (in ranges with starting address
10.0.0.0, 172.16.0.0.0, 192.168.0.0) for internal communication and a single (or
small set) of global routable addresses for communication over Internet. So, we
need a mapping to map private addresses to universal addresses.
Network Address Translation (NAT)
Single-level translation or using one IP address
Network Address Translation (NAT)
Single-level translation or using one IP address
Network Address Translation (NAT)
Single-level translation or using
one IP address
Network Address Translation (NAT)
Single-level translation or using
one IP address

● Able to use single global IP


for multiple PCs on Local
network as long as
destination is different.
● Useful when communication
initiated by private network.
Network Address Translation (NAT)
Single-level translation or using
one IP address

● Able to use single global IP


for multiple PCs on Local
network as long as
destination is different.
● Useful when communication
initiated by private network.
● What if multiple PCs want to
communicate to same
destination?
Network Address Translation (NAT)
Single-level translation or using
one IP address

● What if multiple PCs want to


communicate to same
destination?

Solution: Use pool of IP


addresses
Network Address Translation (NAT)
Single-level translation or using
one IP address

● What if multiple PCs want to


communicate to same
destination?

Solution: Use pool of IP


addresses

● What if destination is same


but processes are different?
Network Address Translation (NAT)
Single-level translation or using
one IP address

● What if multiple PCs want to


communicate to same
destination?

Solution: Use pool of IP


addresses

● What if destination is same


but processes are different?

Solution: Use both IP address


and port number
Network Address Translation (NAT)
Translation based on both port number and IP address.
Forwarding of IP Packets - across network boundary
IP is a connectionless protocol with forwarding based on destination address of IP
datagram or packet.

When a packet is received at a router, its routing or forwarding table is checked to


make next hop decision. Contents of table: NID, Next hop, interface.

Procedure: Search table row by row for the NID of the packet. If there is a match
in first column use other two columns to forward data packets.

Normally, last row is a default value which indicates destination addresses that did
not match previous rows.
Forwarding Example
Forwarding Example
Route summarization
Also known as prefix or route or address aggregation.

In this we combine multiple routes into a single subnet called supernet or common
subnet.

172.110.100.0/24

172.110.101.0/24

172.110.102.0/24

172.110.103.0/24

Common subnet:
Route summarization
Also known as prefix or route aggregation.

In this we combine multiple routes into a single subnet called supernet or common
subnet.

172.110.100.0/24

172.110.101.0/24

172.110.102.0/24

172.110.103.0/24

Common subnet: 172.110.100.0/22. Now, if you give router this address it will
allow traffic of all four paths. This also decreases entries in routing table.
Route summarization
Route summarization
Longest mask matching
Suppose in the contiguous supernet one of the organization is not geographically
close to others, so can’t be connect to same router. Can we still use address
aggregation?
Longest mask matching
Suppose in the contiguous supernet one of the organization is not geographically
close to others, so can’t be connect to same router. Can we still use address
aggregation?

Yes because of longest mask matching in routing or forwarding tables by which


the table is always sorted from longest mask to shortest mask. Example
/27,/26,/22,/16, etc.
Longest mask matching: Example
Consider a packet at
R2 with destination
address
140.24.7.200
Longest mask matching: Example
Consider a packet at
R2 with destination
address
140.24.7.200

If there was no
longest mask
matching packet
would be incorrectly
delivered.
Forwarding of IP Packets
● Within local network
● Across the network boundary
Forwarding of IP Packets
● Within local network - MAC address
● Across the network boundary - IP address

How do you check it?


Forwarding of IP Packets
● Within local network - MAC address
● Across the network boundary - IP address

How do you check it? Using NID of both source and destination
Forwarding of IP Packets
● Within local network
○ Use ARP to get the MAC address if not already available in ARP cache.
○ Send the message.
Forwarding of IP Packets
● Across network boundary
○ Use ARP to get the MAC address of default gateway if not already
available in ARP cache.
○ After that, each router forwards it based on their forwarding tables. At
each hop, layer 2 header is stripped and updated.
○ Once the destination network is directly connected network of a router it
again uses ARP to send message directly to that node.
References
● Chapter 19, 22 [BAF], 18 [BAF 5th edition]
● CCNA Routing guide
● Packet flow across Networks.
https://www.geeksforgeeks.org/packet-flow-in-different-network/ [Accessed
date: May 2021]
● Packet Tracking. https://www.youtube.com/watch?v=rYodcvhh7b8 [Accessed
date: May 2021]
● Note: Source of all images unless specified is [BAF] book (4th Edition).

You might also like