Sei sulla pagina 1di 51

IP addressing

Computer Networks
Lecture 4: Network layer
Presenter: Vo Thi Luu Phuong, PhD
Contents:
1. Introduction
2. IP addresses
3. IP subnetting technique and CIDR

Network Layer 4-2


1. Introduction
Internet protocol stack

application

transport

network

link

physical

Network Layer 4-4


Network layer
application
transport
network

 network layer
data link
physical
network network

protocols in every network


data link
data link
physical
data link
physical

host, router
physical network network
data link data link
physical physical

 router examines network network

header fields in all IP


data link data link
physical physical
network

datagrams passing
data link
physical

through it
application
network transport
data link network network
network physical data link data link
data link physical physical
physical

Network Layer 4-5


IP datagram format
32 bits

ver head. type of length


len service
fragment
16-bit identifier flgs
offset
time to upper header
live layer checksum
32 bit source IP address
32 bit destination IP address

options (if any)


data
(variable length,
typically a TCP
or UDP segment)

Network Layer 4-6


Binary to Decimal Review

27 26 25 24 23 22 21 20
128 64 32 16 8 4 2 1
1 1 1 1 1 1 1 1 255
0 1 1 1 1 1 1 1 127
1 1 0 0 0 0 0 0 192
1 0 1 1 1 1 1 1 191
1 1 0 1 1 1 1 1 223
1 1 1 0 0 0 0 0 224

Network Layer 4-7


2. IP addreses
IP Addresses (RFC 791)

223.1.1.1
 IP address is a unique
32-bit number (04 bytes
223.1.2.1
223.1.1.2
in decimal). 223.1.1.4 223.1.2.9

 Netid identifies the 223.1.2.2


223.1.1.3 223.1.3.27
network.
 Hostid identifies the
host within the network. 223.1.3.1 223.1.3.2
 IP addresses associated
with each interface.
223.1.1.1 = 11011111 00000001 00000001 00000001

223 1 1 1 Network Layer 4-9


IP Address of Your Computer

Network Layer 4-10


IP Address Classes

Network Layer 4-11


Examples
What are the classes of the following IP
addresses:
 203.162.8.2
 111.65.248.132 (vnexpress.net)
 134.170.185.46 (microsoft.com)
 72.163.4.161 (cisco.com)
Special addresses
 Each network has two special address:
network and broadcast addresses which
cannot be used for a physical interface

netid hostid meaning


xxx All 0 Identifies a network. It is used in routing tables.
xxx All 1 Broadcast in the networks xxx.
All 0 All 0 Identifies “this host” in “this net”. Used as source
address in configuration protocols, e.g., DHCP.
All 1 All 1 Broadcast in “this net”. Used as destination
address in configuration protocols, e.g. DHCP.
127 xxx Loopback: interprocess communication with TCP/IP.
Network Layer 4-13
1. Transform the following decimal numbers
Quiz to binaries: 200, 192, 128, 255, 240
2. Transform the binaries decimals:
10000111, 11100000, 11110000
3. Which are the valid IP addresses. Please
classify them:
1. 300.3.2.300
2. 100.100.100.100
3. 156.258.100.1
4. 0.0.0.0
5. 255.255.255.255
6. 2.2.2.3.2
7. 200.200.200.200
8. 150.15.150.15

Network Layer 4-14


1. Transform the following decimal numbers
Quiz to binaries: 200=11001000,
192=11000000, 128=10000000,
255=11111111, 240=11110000
2. Transform the following binaries to
decimals: 10000111=10001000-1= 128+8-
1=135, 11100000=128+64+32=224,
11110000=255-15=240
3. Which are the valid IP addresses. Please
classify them:
1. 300.3.2.300 no
2. 100.100.100.100 yes, class A
3. 156.258.100.1 no
4. 0.0.0.0 no
5. 255.255.255.255 no
6. 2.2.2.3.2 no
7. 200.200.200.200 yes, class C Network Layer 4-15
Class A Addresses

 Structure
 Network.node.node.node

 Class A Valid Host IDs


 10.0.0.0 All host bits off
 10.255.255.255 All host bits on
 Valid hosts = 10.0.0.1 - 10.255.255.254

• 224-2 valid hosts

Network Layer 4-16


Class B Addresses

 Structure
 Network.Network.node.node

 Class B Valid Host IDs


 172.16.0.0 All host bits off
 172.16.255.255 All host bits on
 Valid hosts = 172.16.0.1 - 172.16.255.254

• 216-2 valid hosts

Network Layer 4-17


Class C Addresses

 Structure
 Network.Network.Network.node

 Class C Valid Host IDs


 192.168.100.0 All host bits off
 192.168.100.255 All host bits on
 Valid hosts = 192.168.100.1 - 192.168.100.254

• 28-2 valid hosts

Network Layer 4-18


IP addresses
 Internet assigned number authority
(IANA) assigns address blocks to Regional
Internet Registries (RIR) :
 RIPE:Europe
 ARIN: USA
 APNIC: Asia
 LACNIC: Latin

 RIR assigns addresses to ISPs and ISPs


assign addresses to their customers

Network Layer 4-19


Private IP Addresses (RFC 1918)

Address Class Reserved address space

Class A 10.0.0.0 through 10.255.255.255


Class B 172.16.0.0 through 172.31.255.255
Class C 192.168.0.0 through 192.168.255.255

Network Layer 4-20


NAT: Network Address Translation

rest of local network


Internet (e.g., home network) 192.168.1.1
192.168.1.0/24
192.168.1.4
192.168.1.2
138.76.29.7

192.168.1.3

All datagrams leaving local Datagrams with source or


network have same single source NAT IP destination in this network
address: 138.76.29.7, have 192.168.1.0/24 address for
different source port numbers source, destination (as usual)

Network Layer 4-21


NAT: Network Address Translation
NAT translation table
2: NAT router WAN side addr LAN side addr 1: host 192.168.1.1
changes datagram138.76.29.7,5001 192.168.1.1,3345 sends datagram to
source addr from…… …… 128.119.40, 80
192.168.1.1, 3345 to S: 192.168.1.1, 3345
138.76.29.7, 5001, D: 128.119.40.186, 80
192.168.1.1
updates table 1
S: 138.76.29.7, 5001
2 D: 128.119.40.186, 80 192.168.1.4
192.168.1.2
138.76.29.7 S: 128.119.40.186, 80

S: 128.119.40.186, 80
D: 192.168.1.1, 3345 4
D: 138.76.29.7, 5001 3 192.168.1.3
4: NAT router
3: Reply arrives
changes datagram
dest. address:
dest addr from
138.76.29.7, 5001
138.76.29.7, 5001 to 192.168.1.1, 3345
Network Layer 4-22
IP Addresses: How to Get One?
 hard-coded by system admin in a file
 DHCP: Dynamic Host Configuration Protocol:
dynamically get address from as server
 “plug-and-play”

Network Layer 4-23


Network Layer 4-24
3. Subnetting and CIDR
Two concerns in IP addressing
 Address space utilization
 Scalability in routing

Network Layer 4-26


Without subnetting

-Address assignment inefficiency;


-Cannot divide into group.

Network Layer 4-27


Subnetting

A Network with Three Levels of Hierarchy

Network Layer 4-28


Subnets
 IP address: 223.1.1.1

 subnet part (high 223.1.2.1


223.1.1.2
order bits) 223.1.1.4 223.1.2.9
 host part (low order
bits) 223.1.1.3
223.1.2.2
223.1.3.27
 What’s a subnet ?
 device interfaces with LAN
same subnet part of IP 223.1.3.1 223.1.3.2
address
 can physically reach
each other without
intervening router network consisting of 3 subnets

Network Layer 4-29


Subnets 223.1.1.2

How many subnets ? 223.1.1.1 223.1.1.4

How many IP addresses 223.1.1.3


for WAN connections ?
223.1.9.2 223.1.7.0

223.1.9.1 223.1.7.1
223.1.8.1 223.1.8.0

223.1.2.6 223.1.3.27

223.1.2.1 223.1.2.2 223.1.3.1 223.1.3.2

Network Layer 4-30


How To Create Subnets

Network Layer 4-31


How To Create Subnets
1. Determine the number of required
subnets,
2. Determine the number of required host
per subnet,
3. Based on above requirements:
 Determine number of subnet bits
 Assign subnet IDs to the network segments
 Assign the range of valid host ID to hosts in
each subnet.

Network Layer 4-32


Subnet Masks

 Used to define which part of the host


address will be used as the subnet address.
 A 32-bit value that allows the recipient of
IP packets to distinguish the network ID
portion of the IP address from the host ID
portion.

Network Layer 4-33


Default Subnet Masks
 Class A: 255.0.0.0
 Class B: 255.255.0.0
 Class C: 255.255.255.0

Network Layer 4-34


Class C 192 mask examples

Subnet Host Meaning


00 000000 = 0 The network (do this first)
00 000001 = 1 The first valid host
00 111110 = 62 The last valid host
00 111111 = 63 The broadcast address (do this second)

Subnet Host Meaning

01 000000 = 64 The network


01 000001 = 65 The first valid host
01 111110 = 126 The last valid host
01 111111 = 127 The broadcast address
Network Layer 4-35
Class C 192 mask examples
Subnet Host Meaning

10 000000 = 128 The subnet address


10 000001 = 129 The first valid host
10 111110 = 190 The last valid host
10 111111 = 191 The broadcast address

Subnet Host Meaning

11 000000 = 192 The subnet address


11 000001 = 193 The first valid host
11 111110 = 254 The last valid host
11 111111 = 255 The broadcast address

Network Layer 4-36


Classless Inter-Domain Routing
(RFC 1519)
CIDR: Classless InterDomain Routing
▪ subnet portion of address of arbitrary
length
▪ address format: a.b.c.d/x, where x is #
bits in subnet portion of address
subnet host
part part
11001000 00010111 00010000 00000000
200.23.16.0/23

Network Layer 4-37


CIDR – route aggregation
 When the number of network stated
growing exponentially, routing table size
started exploding.
 In order to reducing table size, CIDR
propose a “rational geographical-based
distribution” of IP addresses to be able to
summarize routes and uses masks instead
of classes.
 E.g., 200.1.10.0/24 and 200.1.11.0/24
→ 200.1.10.0/23
Network Layer 4-38
IP addresses: how to get one?
Q: How does host get IP address?
 hard-coded by system admin in a file
 Windows: control-panel->network->configuration-
>tcp/ip->properties
 Linux/Unix:
• /etc/rc.config
• /etc/sysconfig/network-scripts/ifcfg-ethx
• ifconfig
 DHCP: Dynamic Host Configuration Protocol:
dynamically get address from as server
 “plug-and-play”

Network Layer 4-39


Quiz
How many hosts and subnets are possible if
you have an IP class B of 172.16.0.0/16
with a subnet mask of 255.255.254.0?
 A. 510 subnets and 126 hosts
 B. 512 subnets and 128 hosts
 C. 126 subnets and 512 hosts
 D. 128 subnets and 510 hosts

Network Layer 4-40


Quiz_answer
How many hosts and subnets are possible if
you have an IP class B of 172.16.0.0/16
with a subnet mask of 255.255.254.0?
 A. 510 subnets and 126 hosts
 B. 512 subnets and 128 hosts
 C. 126 subnets and 512 hosts
 D. 128 subnets and 510 hosts

 Answer: D

Network Layer 4-41


Quiz
1. Given the range 10.8.0.0/16, assign the IP
addresses for a network with 05 subnets.
2. Given the range 10.8.0.0/16, assign the IP
addresses for a network in which each
subnet can support up to 1000 IP
addresses.

Network Layer 4-42


Summary
 IP address structure
 IP address classes
 IP subnetting technique
 CIDR

Network Layer 4-43


Questions & Answers
4. Quizes
Quiz_01
How many hosts and subnets are possible if
you have an IP class B of 172.16.0.0/16
with a subnet mask of 255.255.254.0?
 A. 510 subnets and 126 hosts
 B. 512 subnets and 128 hosts
 C. 126 subnets and 512 hosts
 D. 128 subnets and 510 hosts

Network Layer 4-46


Quiz_01_answer
How many hosts and subnets are possible if
you have an IP class B of 172.16.0.0/16
with a subnet mask of 255.255.254.0?
 A. 510 subnets and 126 hosts
 B. 512 subnets and 128 hosts
 C. 126 subnets and 512 hosts
 D. 128 subnets and 510 hosts

 Answer: D

Network Layer 4-47


Quiz_03
If a host on a network has the address 172
.16.45.14/30, what is the address of the
subnetwork to which this host belongs?
 A. 172.16.45.0
 B. 172.16.45.4
 C. 172.16.45.8
 D. 172.16.45.12
 E. 172.16.45.18
Quiz_03_answer
If a host on a network has the address
172.16.45.14/30, what is the address of the
sub-network to which this host belongs?
 A. 172.16.45.0
 B. 172.16.45.4
 C. 172.16.45.8
 D. 172.16.45.12
 E. 172.16.45.18
 Answer: D
 The last octet in binary form is 00001110. Only 6
bits of this octet belong to the subnet mask.
Hence, the sub-network is 172.16.45.12.

Network Layer 4-49


Quiz_4
 Aggregate the following subnets:
 203.162.1.0/30
 203.162.1.4/30
 203.162.1.8/30
 203.162.1.12/30

Network Layer 4-50


Quiz_4_answer
 Summarize the following networks:
 203.162.0.0/30
 203.162.0.4/30
 203.162.0.8/30
 203.162.0.12/30

 Answer: 203.162.1.0/28

Network Layer 4-51

Potrebbero piacerti anche