0% found this document useful (0 votes)
6 views

CNE Lec4 Network layer - IP_Addressing updated

The document provides an overview of IPv4 addressing, including classful addressing, CIDR, and NAT. It explains the structure of IPv4 addresses, the concept of subnetting, and the implications of address exhaustion. Additionally, it discusses the Internet registry structure and the allocation of IP addresses in Vietnam.

Uploaded by

tranngoctu10a5
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

CNE Lec4 Network layer - IP_Addressing updated

The document provides an overview of IPv4 addressing, including classful addressing, CIDR, and NAT. It explains the structure of IPv4 addresses, the concept of subnetting, and the implications of address exhaustion. Additionally, it discusses the Internet registry structure and the allocation of IP addresses in Vietnam.

Uploaded by

tranngoctu10a5
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 90

IPv4 Addressing

Computer Networks
Faculty of Information Technology
Hanoi University
Content

1. Introduction
2. IPv4 Classful addressing
3. IPv4 CIDR
4. NAT
1. Introduction to IPv4
TCP/IP Model
Host A Host B

Application Application
username username

Transport Transport
username + port Router username + port

Network Network
username + port + IP username + port + IP username + port + IP

Data link Data link


username + port + IP +MAC username + port + IP +MAC
Physical Physical

IP, MAC IP, MAC IP, MAC IP, MAC


Logical
Addressing
IPv4: Packet Encapsulation
 The data is sent down the protocol stack
 Each layer adds to the data by prepending headers

22Bytes20Bytes20Bytes 4Bytes

64 to 1500 Bytes
IPv4 header
Example
 Envelope data length
 To dst IP add
 From src IP add
 time to live
 version
 Stamp service type
 Book protocol type
 Header check sum
 options
 fragment
IPv4 Addresses
 32-bit Address
 Uniquely and universally identifies a host
 Address space is the total number of
addresses used by the protocol
 232 = 4,294,967,296 addresses
 Notation
 Binary
 Dotted decimal
What is the IP address of
fit.hanu.vn?
What is my IP?
Which ISP my IP belongs to?
Internet Registry Structure
Internet Registry Structure

ICANN

IANA
ASO

APNIC ARIN LACNIC RIPE NCC AfriNIC

NIR LIR LIR ISP ISP ISP ISP LIR LIR LIR LIR

LIR ISP ISP ISP ISP ISP ISP ISP ISP ISP ISP
How many IP address in
Vietnam?
 Allocated IP address (VNNIC) (March 2020)
 IPv4: ~16 million
 IPv6: 408 billion/64
(
https://www.thongkeinternet.vn/jsp/trangchu/index.js
p
)
2. IPv4 classful
addressing
Classful Addressing
 Five classes; A, B, C, D and E
 Each class occupies some part of the address
space
Network Address & Default
Mask
Why do we need Mask?
 Mask together with an IP defines the range of IP
block.
 Example 1
 IP: 192.168.5.7
 Mask: 255.255.255.0 /24 – C 254
 => IP block: 192.168.5.0 – 192.168.5.255
 IP range from 192.168.5.1 – 192.168.5.254
 Example 2
 IP 18.202.1.6
 Mask: 255.0.0.0 /8 –A
 What is the IP block? 18.0.0.0-18.255.255.255
Finding the class
Network address

 Network address is the first address in the


block
 We don’t use the first and the last
address of the block for real host.
 Given the whole address, can we find the
network address?
1. Find the class
2. Apply the default mask
3. We have the network address !
Example 3
Given the network address 220.34.76.0, find the class, the
block, and the range of the addresses.
Solution
The class is C because the first byte is between 192
and 223. The block has a netid of 220.34.76. The
addresses range from 220.34.76.0 to 220.34.76.255.
Host range: 220.34.76.1 to 220.34.76.254

Address in binary: 11011100 00100010 01001100 00000000


C-mask: 11111111 11111111 11111111 00000000
IP block : 11011100 00100010 01001100 00000000 (220.34.76.0)
- 11011100 00100010 01001100 11111111 (220.34.76.255)
The center of the Internet
based on IPv4
 MIT owns one Class A (18.*.*.*)

 China owns 3 Class A

 Vietnam owns 64 Class B


Problem with Classfull
Addressing (IPv4)
 Major Problem: Running out of addresses

 Class C is too small, class B widely used, but host


size too large
 Temporary solutions
 NAT (Network Address Translation)
 CIDR (Classless Inter Domain Routing)
 The best Solutions is IPv6.
3. CIDR
(Classless Inter Domain
Routing)
CIDR / Subnets
 Use a single network address for the entire
organization, and internally divide the host
address space into a subnet address and a
host id
Subnetting and Subnet Mask

 Number of subnets = 23
 Number of addresses per subnet = 213
Terminology

 Prefix = netID
 The common part of the address
 Prefix Length = length (# of bits) of the prefix
 denoted by /n
 Suffix = hostID
 Suffix length = length (# of bits) of the suffix
 calculated by (32 - n)
Prefix Lengths
Subnet Masks
a class B network subnetted into 64 subnets

Address: 130.50.15.6/22
Subnet Mask: 255.255.252.0
CIDR/Subnetting

A set of IP address assignments

5-59
Finding the Address block

 Given the address and the mask, we can find


 the first address
 the last address
 the number of addresses
Example 4: Finding the first
address
What is the first address in the block if one of the
addresses is 140.120.84.24/20?

Solution
The prefix length is 20, which means that we must
keep the first 20 bits as is and change the remaining
bits (12) to 0’s. The following shows the process:
Address in binary: 10001100 01111000 01010100 00011000
Keep the left 20 bits: 10001100 01111000 01010000 00000000
Result in CIDR notation: 140.120.80.0/20
Finding the last address in
the block :
3 ways
1. Keep constant n first bits, change 32-n last
bits to all 1 (best way)
2. add the number of addresses to the 1st
address, minus one
3. Add the first address to the complement of
the mask
Remember:
We don’t use the first and the last address
for real host
Example 4
Find the number of addresses in the block if one of
the addresses is 140.120.84.24/20.

Solution 1:
The prefix length is 20, which means that we must
keep the first 20 bits as is and change the remaining
bits (12) to 0’s. The following shows the process:
Address in binary: 10001100 01111000 01010100 00011000
Keep the left 20 bits: 10001100 01111000 01011111 11111111
Result in CIDR notation: 140.120.95.255/20
Example 4
Find the number of addresses in the block if one of
the addresses is 140.120.84.24/20.

Solution 2:
The prefix length is 20. The number of addresses in
the block is 232−20 or 212 or 4096
Example 4

Find the last address in the block if one of the


addresses is 140.120.84.24/20.

Solution 2
We found in the previous examples that the first
address is 140.120.80.0/20 and the number of
addresses is 4096. To find the last address, we need to
add 4095 (4096 − 1) to the first address (last one is the
broadcast address):
Example 4
Solution 2
To keep the format in dotted-decimal notation, we
write 4095 as 15.255. We then add the first address to
this number (in base 255) to obtain the last address as
shown below:

140 . 120 . 80 . 0
15 . 255
-------------------------
140 . 120 . 95 . 255
The last address is 140.120.95.255/20.
Example 4
Find the last address in the block if one of the
addresses is 140.120.84.24/20.
Solution 3:
The mask has twenty 1s and twelve 0s. The
complement of the mask has twenty 0s and twelve 1s.
In other words, the mask complement is
00000000 00000000 00001111 11111111
or 0.0.15.255. We add the mask complement to the
beginning address to find the last address.
Example 4
Find the last address in the block if one of the
addresses is 140.120.84.24/20.
Solution 3:

140 . 120 . 80 . 0
15 . 255
-------------------------
140 . 120 . 95 . 255
The last address is 140.120.95.255/20.
Example 5

 Find the block if one of the addresses is


190.87.140.202/29
Example 5
The first address is 190.87.140.200/29, the last address is
190.87.140.207/29. There are only 8 addresses in this block.
Real host:
190.87.140.201/29 - 190.87.140.206/29
Creating Subnets

 Network formula
 2x, where x is the number of 1s added to the
subnet mask from the previous or default subnet
mask
 Hosts formula
 2y - 2, where y is the number of 0s in the subnet
mask , y = 32-n
Example 6
Given the Class C network of 204.15.5.0/24, subnet the given network
Example 6
Solution 1:
A: 204.15.5.0/27 (mask 255.255.255.224)
IP range 204.15.5.0 to 204.15.5.31
host address range 204.15.5.1 to 204.15.5.30
B: 204.15.5.32/27 (mask 255.255.255.224)
IP range 204.15.5.32 to 204.15.5.63
host address range 204.15.5.33 to 204.15.5.62
C: 204.15.5.64/27 (mask 255.255.255.224)
IP range 204.15.5.64 to 204.15.5.95
host address range 204.15.5.65 to 204.15.5.94
D: 204.15.5.96/27 (mask 255.255.255.224)
IP range 204.15.5.96 to 204.15.5.127
host address range 204.15.5.97 to 204.15.5.126
E: 204.15.5.128/27 (mask 255.255.255.224)
IP range 204.15.5.128 to 204.15.5.159
host address range 204.15.5.129 to 204.15.5.158
Solution 1:
 Class C (/24) Network (254 hosts) Split
Into 8 Subnets /27 (32 IPs - 30 hosts)
Another solution: VLSM
(Variable Length Subnet
 VLSM allows using different masks for each
Masks)
subnet, thereby using address space
efficiently

 CIDR/VLSM network addresses are now


used throughout the public Internet
Example 6
Solution 2:
A (14 hosts): 204.15.5.0/28 (255.255.255.240)
IP range 204.15.5.0 - 204.15.5.15
host address range 204.15.5.1 - 204.15.5.14
D (7 hosts): 204.15.5.16/28 (255.255.255.240 )
IP range 204.15.5.16 - 204.15.5.31
host address range 204.15.5.17 - 204.15.5.30
B (28 hosts): 204.15.5.32/27 (255.255.255.224 )
IP range 204.15.5.32 - 204.15.5.63
host address range 204.15.5.33 - 204.15.5.62
E (28 hosts): 204.15.5.64/27 (255.255.255.224 )
IP range 204.15.5.64 - 204.15.5.95
host address range 204.15.5.65 - 204.15.5.94
C (2 hosts): 204.15.5.96/30 (255.255.255.252 )
IP range 204.15.5.96 - 204.15.5.99
host address range 204.15.5.97 - 204.15.5.98
Example 6

 Solution 2:
Example 6
Solution 3: The easiest way to assign the subnets
is to assign the largest first
B (28 hosts): 204.15.5.0/27 (255.255.255.224)
IP range 204.15.5.0 - 204.15.5.31
host address range 204.15.5.1 to 204.15.5.30
E (28 hosts): 204.15.5.32/27 (255.255.255.224)
IP range 204.15.5.32 - 204.15.5.63
host address range 204.15.5.33 to 204.15.5.62
A (14 hosts): 204.15.5.64/28 (255.255.255.240)
IP range 204.15.5.64 - 204.15.5.79
host address range 204.15.5.65 to 204.15.5.78
D (7 hosts): 204.15.5.80/28 (255.255.255.240)
IP range 204.15.5.80 - 204.15.5.95
host address range 204.15.5.81 to 204.15.5.94
C (2 hosts): 204.15.5.96/30 (255.255.255.252)
IP range 204.15.5.96 - 204.15.5.99
host address range 204.15.5.97 to 204.15.5.98
Example 6

 Solution 3:
Example 6
 Solution 1:
204.15.5.0-204.15.5.159 => good not the
best solution
 Solution 2 & 3:
204.15.5.0-204.15.5.99 => better than
solution 1. IP address space can be used
economically.
The best way to solve this problem is to
assign IP addresses the largest network first
(Follow solution 3)
CIDR

 The advantages of CIDR over the classful IP


addressing are:
 CIDR can be used to effectively manage the
available IPv4 address space
 As a result of the deployment of CIDR/VLSM, it is now
estimated that IPv4 addresses would be depleted
around 2008
 CIDR reduces the number of routing table entries
by creating a 3-level hierarchy
How to assign IP for KTX
202.151.161.128/26
Network D4 ? distribution switch
12 hosts

D6 distribution switch

Access switches
Access switches Access switches

20 hosts 6 hosts

Guest house
distribution switch
Core switch
IP block 202.151.161.128/26
First:202.151.161.128/26 – last:
202.151.161.191/26
 D6 (20 hosts): 255.255.255. 224
202.151.161.128/27 - 202.151.161.159/27
 D4 (12 hosts): 255.255.255. 240
202.151.161.160/28 - 202.151.161.175/28
 GH (6 hosts): 255.255.255. 248
202.151.161.176/29 - 202.151.161.183/29
4. NAT
(Network Address
Translation)
NAT – Network Address
Translation
 Reserve a single IP address for local
networks that operate behind a special router
(which can also operate as a firewall), and
allow only outgoing connections
 To make this scheme possible, 3 ranges of IP
addresses have been declared private
 10.0.0.0 – 10.255.255.255/8 (16,777,216 hosts)
 172.16.0.0 – 172.31.255.255/12 (1,048,576 hosts)
 192.168.0.0 – 192.168.255.255/16 (65,536 hosts)
10.0.0.5 10.0.0.7
10.0.0.6 router

10.0.0.1
GW 198.60.42.12

10.0.0.2
10.0.0.4
10.0.0.3
NAT – Network Address
Translation
Placement and operation of a NAT box.
NAT – Network Address
Translation
Drawbacks and advantages of NAT:
What do you think?
5. Special IP addresses
Internet Multicasting
 Ability to send IP datagram's to a large no. of
receivers simultaneously
 Updating replicated databases
 Transmitting stock quotes to multiple brokers
 Multiparty video conferencing
 Class D addresses
 224.0.0.0 – 239.255.255.255
 The 28 bits after the leading “1110” in the IP
address define the multicast group address (228
groups)
 There is no specific concept of a network ID and
host ID as in classes A, B and C
Internet Multicasting
 Two kinds of group addresses are supported
 Permanent addresses
 No need to set up permanent addresses
 Range is from 224.0.0.0 – 224.0.0.255
 224.0.0.0 Reserved; not used
 224.0.0.1 All systems on a LAN
 224.0.0.2 All routers on a LAN
 224.0.0.3 Reserved
 224.0.0.4 All routers using DVMRP
 224.0.0.5 All OSPF routers on a LAN
 224.0.0.6 Designated routers using OSPF
 224.0.0.9 Designated routers using RIP-2
 224.0.0.11 Mobile agents (for Mobile IP)
 224.0.0.12 DHCP Server / Relay Agent
Internet Multicasting

 Temporary addresses
 Globally-scoped multicast addresses
 Multicasting is implemented by special
multicast routers, using a special protocol
IGMP (Internet Group Management Protocol)
Special IP Addresses
Loopback address

 A loopback address is a distinct


reserved IP address range that starts
from 127.0.0.0 ends at
127.255.255.255 though
127.255.255.255 is the broadcast
address for 127.0.0.0/8.
 The loopback addresses are built into
the IP domain system, enabling devices
to transmit and receive the data
packets.
 The loopback address 127.0.0.1 is
Loopback interface

 A loopback interface is a virtual interface in


our network device that is always up and
active after it has been configured.
 Like our physical interface, we assign a
special IP address which is called a loopback
address or loopback IP address.
6. Some protocols
(reading)
ICMP
ICMP (Internet Control Message
Protocol)
 We need to inform hosts and routers when things go
wrong, or, likewise, should be able to send queries
to get status information

R3 only sends the ICMP message back to A, not to R2 or R1


ICMP Encapsulation
ICMP Message Types
 Each individual kind of message in ICMP is given its
own unique Type and Code values, which are put
into the 8 bit fields in the ICMP common message
format
 Ping

 Nmap

 tracert
ICMP Echo
ICMP Echo Reply
ICMP Echo with TTL = 1
ICMP TTL Exceeded
ARP
ARP (Address Resolution
Protocol)
Problem: Logical-to-Physical address mapping
 Static Solution: a mapping database
 Dynamic Solution: ARP
 Broadcast request/Unicast reply
ARP Broadcast Request
ARP Unicast Reply
DHCP
Dynamic Host Configuration
Protocol
 DHCP allows both manual and automatic

address assignments
Dynamic Host Configuration
Protocol
DHCP may not be reachable by broadcasting, so

a DHCP Relay Agent is needed on each LAN


Dynamic Host Configuration
Protocol
DHCP may not be reachable by broadcasting, so

a DHCP Relay Agent is needed on each LAN

You might also like