Computer Networks
CS F303
IP Addressing
Ashutosh Bhatia
Department of Computer Science and Information Systems
BITS Pilani Birla Institute of Technology and Science
Pilani|Dubai|Goa|Hyderabad
Pilani Campus, Pilani
BITS Pilani
Pilani|Dubai|Goa|Hyderabad
Outline
• IP addresses
• Subnetting
Problem Statement
• Flat Addressing: N hosts needs N entries
in the table (MAC addresses)
• Millions of hosts, address lookup in
forwarding becomes a bottleneck
• Need a method of reducing entries in the
forwarding table for scalability purposes
3
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution: Hierarchical Addressing
• Structure to addresses: Address captures location in the
network topology
• IP address (32 bits) consists of two parts: network and
host
– Network part identifies the network to which host is
connected
– Host part uniquely identifies each host in the network
netid hostid
• How does this help?
– An entire network (in some specific direction) could be
represented by a single entry at a router
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP addresses
• IP addresses are logical entities
• IP addresses usually refer to interfaces, not
machines
• Several interfaces: several IP addresses
• Same interface: multiple addresses possible
• It is also possible to have several interfaces,
but only one IP address
• 32 bit addresses in IPv4
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP addresses
• Netid: allocated to organizations
• Hostid: allocated by the organization
• How many bits for netid and hostid?
– Large corporations: many hosts, so many hostid
bits required
– Small organizations: few hosts, few hostid bits
• Single partitioning scheme will not work
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP addresses
• Possible scheme: find out the netid-hostid
partition by looking at the IP address
• Requires
– Breaking up the IP address space into disjoint sets
– Each set has a pre-defined number of bits
allocated to netid
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP addresses
Fixed Partitioning
0-3 4-7 8-11 12-15
Variable Partitioning
0-1 2-3 4-7 8-15
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP address classes
IP address space
Beginning with 0 : Class A 10 : Class B 110 : 1110 :
Class C Class
D
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP address classes
A: 0 7 bits 24 bits
netid
B: 10 14 bits 16 bits
netid
C: 110 21 bits 24 bits
netid
D: 1110 Multicast group id
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
IP Address
• Private IP addresses:
– A: 10.0.0.0 through 10.255.255.255
– B: 172.16.0.0 through 172.31.0.0
– C: 192.168.0.0 through 192.168.255.0.
– 127.0.0.1 is loopback address.
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Interconnected networks
Net A Net B Net C
Interconnected networks (“Internet”)
• Each n/w: a physical network, uses a certain technology
• Hosts can talk to one another using technology-specific
mechanisms
• Abstraction: Each network corresponds to a netid
• Routers maintain tables with “netid” and “next hop” mapping
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example: Class C
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Forwarding at Host
• If (NetNum of Dest = my NetNum) then
– deliver packet to destination directly
– use ARP to get MAC address corresponding to dest IP
address
• Else deliver packet to default router
– use ARP to get MAC address corresponding to router
IP address
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Forwarding at Router
• If (NetNum of Dest = NetNum of one of my
interfaces) then
– deliver packet to destination over that interface
Else if (NetNum of Dest is in my forwarding
table) then
– deliver packet to NextHop router
Else deliver packet to default router
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Summary
• Top concern: Scalability
• Handled via hierarchical addressing
– IP address has a network and a host part
– Significantly reduces entries in forwarding table
• Looked at how forwarding is done at host and
router based on the addressing scheme
• Ahead: Address assignment inefficiency
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem Statement
• Network part uniquely identifies a physical
network
• Network with just 2 hosts needs Class C address
– Efficiency: 2/2^8 = 0.7%
• Network with 256 hosts needs a Class B address
– Efficiency: 256/2^16 = 0.4 %
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Problem Statement
• Class B addresses in high demand (keeping
future needs in mind)
– Host addresses ~ 4 billion (232)
– Class B networks: 214 (~16000)
– Out of class B addresses, out of addresses to
hand out
• Need to solve “Address assignment
inefficiency”
– Challenge: Within IP framework (using 32-bits)
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Specific Scenario –1
• An organization has 30 different physical
networks, each network has about 2000 hosts
• Current Allocation: Allocate 30 class B
addresses
– Efficiency = 2000/2^16 = 3%
• Will one class B address suffice?
– Can support 216 = 65536 hosts > 30*2000
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution: Subnetting
• The bits in the hostid part are further divided:
netid hostid
subnetid hostid
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Subnet masks
• To extract the netid and subnetid parts from
the IP address
• String of 1-s with trailing 0-s in the hosted part
144 16 68 117
255 255 224 0
Bit-wise AND
144 16 64 0
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Subnet masks
• In the example, subnet mask is 19 bits wide
• Also written as
– 144.16.68.117 / 19
• Each interface having an IP address must have a subnet mask
also
• Used to determine the network to which the subnet
“belongs”, or , to which it is “directly connected”
• Putting 0’s in the hostid part yields:
– Netid-subnetid
• Putting 1’s in the hostid part provides:
– Subnet-directed broadcast address
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Subnetting: benefits
• “Internal”: The internal network structure of
an organization can be changed without
affecting the routing tables of external routers
– Hide unnecessary details from external routers
• “External”: Can lead to decrease in core
routers’ routing table sizes
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
.52.0 .53.0 .54.0 .55.0
R11 R12 R13 R14
.51.7
.51.1 .51.0
140.252.104.1 .2.0 next hop .1.9
.3.0 next hop .1.10
Gateway
To the .52.0 next hop .51.7
Internet .1.4 .1.0
.1.9
R1 R2 R3 R4
.2.0 .3.0 .4.0 .5.0
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Without Subnetting
Core Router Core Router
C1 C1
C2 C2
C3 Nw 2 C2
------- -------
C50 C50
Nw 1 Nw 2 Nw 50
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
With Subnetting
Core Router Core Router
B
B
Nw 2
B1
Edge Router B2
B3
-------
B50
Nw 1 Nw 2 Nw 50
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
• All routers outside organization have one entry
(190.23.0.0/16)
• Routers within organization have more detailed entries
corresponding to different subnets
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Forwarding at a Router
D = Destination IP Address
For each forwarding table entry
T = D & SubnetMask
If T == SubnetNum
If Nexthop is an interface
deliver datagram directly to destination
Else
deliver datagram to NextHop (router)
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Specific Scenario -- 2
• An organization has a physical network with
4000 hosts
• Current Solution: Give a class B address
– Efficiency: 4000/216 = 6%
• How about assigning multiple class C
addresses?
• Problem: 16 entries for same organization in
the routing table
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Solution
• Assign multiple contiguous class C addresses
& aggregate
• 222.7.16.* through 222.7.31.*, top 20 bits in
this range are the same (0001 bits, 20-bit
network number)
• Advertise 222.7.16.0/20 as the organization’s
network address
• Goes by the name supernetting
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Conclusions
• Subnetting: One class address shared among
many physical networks
• Supernetting: Multiple class addresses shared
among one physical network (Autonomous
system -- AS)
• Network portion can take on any length
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Classless Interdomain Routing (CIDR)
• Use a new notation to represent network
numbers (also called IP prefixes)
• Address block represented as A/X, where A is
the address prefix and X is the prefix length
– X can range from 2 till 32
– X is represented as a network mask as well
• E.g. 222.7.16/20 (Mask 255.255.240.0)
represents addresses in the range 222.7.16.0
to 222.7.31.255
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
• As an example, RFC 1466 recommends that new class C addresses
in Europe be in the range 194.0.0.0 through 195.255.255.255.
• This represents 65536 different class C network IDs, but they all
share the same high-order 7 bits.
• In countries other than Europe a single routing table entry with an
IP address of 194.0.0.0 and a 32-bit mask of 254.0.0.0 could be
used to route all of these 65536 class C network IDs to a single
point.
• Subsequent bits of the class C address can also be allocated
hierarchically, European routers using additional bits beyond the 7
high-order bits of the 32-bit mask.
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Longest Prefix Match
• Routers do a prefix match.
– Does destination address fall in the range of
addresses captured by prefix?
• Prefix match works if Internet topology is a
tree
– Shortest path between networks is unique
• Internet is a graph
– Many networks multi-home
– Many matching prefixes
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Example
• perhaps one service provider in Europe needs to use a different
entry point router than the rest of Europe.
• If that provider has been allocated the block of addresses
194.0.16.0 through 194.0.31.255 (16 class C network IDs), routing
table entries for just those networks would have an IP address of
194.0.16.0 and a mask of 255.255.240.0
• A datagram being routed to the address 194.0.22.1 would match
both this routing table entry and the one for the rest of the
European class C networks.
• But since the mask 255.255.240 is "longer" than the mask
254.0.0.0, the routing table entry with the longer mask is selected.
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956
Summary
• Class based addressing was found not to be
scalable
• Subnetting: Share a single class address among
multiple networks
• Supernetting: Share multiple class addresses on a
single network
• Lead to CIDR (classless addressing) and Longest
prefix match --- widely used now
BITS Pilani, Deemed to be University under Section 3 of UGC Act, 1956