You are on page 1of 8

2/22/2008

Outline

15-441 Computer Networking z Traditional IP addressing


Lecture 9 – IP Protocol
z CIDR IP addressing
Peter Steenkiste
Departments of Computer Science and z Forwarding examples
Electrical and Computer Engineering
z IP packet format
15-441 Networking, Spring 2008
http://www.cs.cmu.edu/~dga/15-441/S08
1 2 2

Hop-by-Hop Packet
Internetworking Forwarding in the Internet
z Multiple networks connected by routers.
z Networks share some features
» IP protocol, addressing, ..
Mixed
z But differ in many other ways Host Ethernet WAN Host
Ethernet
» Technology, ownerships, usage policies, scale, ..

Host Host
7
..
Host 3
Host

2
Host Host 1

3 4

IP Packet Forwarding Router Table Size

z Each packet has an IP destination address


z One entry for every host on the Internet
z Each router has forwarding table with
» 440M (7/06) entries, doubling every 2.5 years
destination Æ next hop mappings
z One entry for every LAN
» Similar to Ethernet bridges
g and switches
» Every host on LAN shares prefix
» What is different???
» Still too many and growing quickly
z Forwarding table is created by a routing
protocol z One entry for every organization
» Every host in organization shares prefix
» Manual solution would be error-prone
» Requires careful address allocation
» How is this done for Ethernet??
» Still grows very quicklyQ!

5 6 6

1
2/22/2008

Addressing Considerations IP Addresses


z Fixed length: 32 bits
z Hierarchical vs. flat z Initial classful structure (1981) (not relevant now!!!)
» Pennsylvania / Pittsburgh / Oakland / CMU / CS z Total IP address size: 4 billion
vs.
CS: (412)268-0000 » Class A: 128 networks, 16M hosts
z Scaling is key challenge » Class B: 16K networks, 64K hosts
» How well does Ethernet solution scale?? » Class C: 2M networks, 256 hosts
» Hierarchy is a known effective solution
z Also want local administration -> hierarchical High Order Bits Format Class
z What type of Hierarchy? 0 7 bits of net, 24 bits of host A
» How many levels? 10 14 bits of net, 16 bits of host B
» Same hierarchy depth for everyone? 110 21 bits of net, 8 bits of host C
» Same segment size for similar partition?

7 7 8 8

IP Address Classes
(Some are Obsolete)
Original IP Route Lookup

z Address specifies prefix for forwarding table


Network ID Host ID
8 16 24 32 » Simple lookup
Class A 0 Network ID Host ID z www.cmu.edu address 128.2.11.43
Class B 10
» Class B address + network is 128.2
» Lookup 128.2 in forwarding table
Class C 110 » Prefix – part of address that really matters for
routing
Class D 1110 Multicast Addresses z Forwarding table contains
Class E 1111 Reserved for experiments » List of class+network entries
» A few fixed prefix lengths (8/16/24)
z Large tables
9 9 » 2 Million class C networks 10 10

Subnet Addressing
RFC917 (1984) Subnetting
z Add another layer to hierarchy
z Class A & B networks too big
z Variable length subnet masks
» Very few LANs have close to 64K hosts
»Could subnet a class B into several chunks
» For electrical/LAN limitations, performance or
administrative reasons
z Bridging has scaling limitations
Network Host
» What are they?
z Need simple way to get multiple “networks” Network Subnet Host
» Multiple IP networks within a single network –
Subnet
often called subnets 111111111111111111111111 00000000
Mask
» Networks often follow organization boundaries
11 11 12 12

2
2/22/2008

Subnetting Example Forwarding Example


• Assume a packet arrives with address
z Assume an organization was assigned 150.100.12.176
address 150.100 • Step 1: AND address with class + subnet mask
z Assume < 100 hosts per subnet 150.100.12.154 150.100.12.176

z How many host bits do we need? H1 H2

»Seven 150.100.12.128

z What is the network mask? 150.100.12.129 150.100.12.24 150.100.12.55


150.100.0.1
»11111111 11111111 11111111 R1 H3 H4
To Internet
10000000 150.100.12.4

»255.255.255.128 150.100.12.0

13 13 14 14

Important Concepts Outline

z Hierarchical addressing critical for scalable z Traditional IP addressing


system
»Don’t require everyone to know z CIDR IP addressing
everyone else
l
»Forwarding based on prefix z Forwarding examples
»Reduces number of updates when
something changes z IP packet format

15 15 16 16

IP Address Problem (1991) IP Address Utilization (‘97)

z Address space depletion


» In danger of running out of classes A and B
» Why?
– Class C too small for most domains
– Very few class A – very careful about giving them
out
– Class B – greatest problem
z Class B sparsely populated
» But people refuse to give it back
z Large forwarding tables
» 2 Million possible class C groups

http://www.caida.org/outreach/resources/learn/ipv4space/
17 17 18 18

3
2/22/2008

Classless Inter-Domain Routing


Size of Complete Routing Table (CIDR) – RFC1338

z Allows arbitrary split between network & host


» Source: www.cidr-
report.org
part of address
» Shows that CIDR has » Do not use classes to determine network ID
kept # table entries in
check » Use common p
part of address as network number
– Currently require
124,894 entries for
» E.g., addresses 192.4.16 - 192.4.31 have the first 20
a complete table bits in common. Thus, we use these 20 bits as the
– Only required by network number Æ 192.4.16/20
backbone routers
z Enables more efficient usage of address
space (and router tables) Æ How?
» Use single entry for range in forwarding tables
» Combined forwarding entries when possible
19 20 20

CIDR Example IP Addresses: How to Get One?

Network (network portion): Get allocated


z Network is allocated 8 class C chunks,
200.10.0.0 to 200.10.7.255 portion of ISP’s address space:
»Allocation uses 3 bits of class C
space ISP's block 11001000 00010111 00010000 00000000 200.23.16.0/20

»Remaining 20 bits are network Organization 0 11001000 00010111 00010000 00000000 200.23.16.0/23

number, written as 201.10.0.0/21 Organization 1 11001000 00010111 00010010 00000000 200.23.18.0/23


z Replaces 8 class C routing entries with 1 Organization 2 11001000 00010111 00010100 00000000 200.23.20.0/23
combined entry ... ….. …. ….

»Routing protocols carry prefix with Organization 7 11001000 00010111 00011110 00000000 200.23.30.0/23
destination network address
»Longest prefix match for forwarding
21 21 22 22

IP Addresses: How to Get One? CIDR Illustration

z How does an ISP get block of addresses?


Provider is given 201.10.0.0/21
» From Regional Internet Registries (RIRs)
– ARIN (North America, Southern Africa), APNIC (Asia- Provider
Pacific), RIPE (Europe, Northern Africa), LACNIC
((South America))
z How about a single host?
» Hard-coded by system admin in a file, or
201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23
» DHCP: Dynamic Host Configuration Protocol:
dynamically get address: “plug-and-play”
– Host broadcasts “DHCP discover” msg
– DHCP server responds with “DHCP offer” msg
– Host requests IP address: “DHCP request” msg
– DHCP server sends address: “DHCP ack” msg
23 23 24 24

4
2/22/2008

CIDR Implications Outline

z Longest prefix match!! z Traditional IP addressing

z CIDR IP addressing
201.10.0.0/21 201.10.6.0/23

Provider 1 Provider 2 z Forwarding examples

z IP packet format

201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23 or Provider 2 address

25 25 26 26

Aside: Interaction with Link


Addressing in IP Layer

z IP addresses are names of interfaces z How does one find the Ethernet address of a IP
host?
»E.g., 128.2.1.1 z ARP: Address Resolution Protocol
z Domain Name System (DNS) names are » Broadcast search for IP address
names of hosts – E.g., “who-has 128.2.184.45 tell 128.2.206.138” sent
to Ethernet broadcast (all FF address)
»E.g., www.cmu.edu
» Destination responds (only to requester using
z DNS binds host names to interfaces unicast) with appropriate 48-bit Ethernet
z Routing binds interface names to paths address
– E.g, “reply 128.2.184.45 is-at 0:d0:bc:f2:18:58” sent
to 0:c0:4f:d:ed:c6

27 27 28 28

Host Routing Table Example Routing to the Network

Destination Gateway Genmask Iface • Packet to 10.1.1.3 10.1.1.2


10.1.1.4 10.1.1.3
128.2.209.100 0.0.0.0 255.255.255.255 eth0 arrives at R2 from H1 H2
128.2.0.0 0.0.0.0 255.255.0.0 eth0
127.0.0.0 0.0.0.0 255.0.0.0 lo provider 10.1.1/24

0.0.0.0 128.2.254.36 0.0.0.0 eth0 10.1.0.2


• Path is R2 – R1 – 10.1.0.1
10 1 1 1
10.1.1.1 R1 H3
10.1.2.2
z From “netstat –rn” H1 – H2 10.1.0/24

z Host 128.2.209.100 when plugged into CS ethernet 10.1.2/23


10.1/16
R2 10.1.8/24
z Dest 128.2.209.100 Æ routing to same machine Provider
10.1.8.1

z Dest 128.2.0.0 Æ other hosts on same ethernet 10.1.2.1


10.1.16.1
H4
10.1.8.4
z Dest 127.0.0.0 Æ special loopback address
z Dest 0.0.0.0 Æ default route to rest of Internet
» Main CS router: gigrouter.net.cs.cmu.edu (128.2.254.36)
29 29 30 30

5
2/22/2008

Routing Within the Subnet Routing Within the Subnet

• Packet to 10.1.1.3 10.1.1.2


10.1.1.4 10.1.1.3 • Packet to 10.1.1.3 10.1.1.2
10.1.1.4 10.1.1.3

H1 H2 H1 H2
• Matches 10.1.0.0/23 10.1.1/24
• Matches 10.1.1.1/31 10.1.1/24

Routing table at R2 10.1.0.1


10 1 1 1
10.1.1.1 R1
10.1.0.2
H3
• Longest prefix match 10.1.0.1
10 1 1 1
10.1.1.1 R1
10.1.0.2
H3
Destination Next Hop Interface
10.1.2.2 R ti ttable
Routing bl att R1 10.1.2.2
10.1.0/24 10.1.0/24
127.0.0.1 127.0.0.1 lo0 Destination Next Hop Interface

Default or 0/0 provider 10.1.16.1


10.1.2/23 127.0.0.1 127.0.0.1 lo0 10.1.2/23
10.1/16 10.1/16
R2 10.1.8/24 R2 10.1.8/24
10.1.8.0/24 10.1.8.1 10.1.8.1 Default or 0/0 10.1.2.1 10.1.2.2

10.1.2.0/23 10.1.2.1 10.1.2.1 10.1.8.1 10.1.0.0/24 10.1.0.1 10.1.0.1 10.1.8.1


10.1.2.1 H4 10.1.2.1 H4
10.1.0.0/23 10.1.2.2 10.1.2.1 10.1.16.1 10.1.1.0/24 10.1.1.1 10.1.1.4 10.1.16.1
10.1.8.4 10.1.8.4
10.1.2.0/23 10.1.2.2 10.1.2.2
10.1.1.2/31 10.1.1.2 10.1.1.2

31 31 32 32

Routing Within the Subnet Outline

• Packet to 10.1.1.3 10.1.1.2


10.1.1.4 10.1.1.3
z Traditional IP addressing
H1 H2
• Direct route 10.1.1/24

• Longest prefix match 10.1.0.1


10 1 1 1
10.1.1.1 R1
10.1.0.2
H3
z CIDR IP addressing
10.1.2.2
Routing table at H1 10.1.0/24
Destination Next Hop Interface
127.0.0.1 127.0.0.1 lo0 10.1/16
10.1.2/23 z Forwarding examples
R2 10.1.8/24
Default or 0/0 10.1.1.1 10.1.1.2
10.1.8.1
10.1.1.0/24 10.1.1.2 10.1.1.1 10.1.2.1
10.1.16.1
H4
10.1.1.3/31 10.1.1.2 10.1.1.2 10.1.8.4 z IP packet format

33 33 34 34

IP Service Model IPv4 Header Fields


z Datragram service model provided by Internet 0 4 8 12 16 19 24 28
3 z Version: IP Version
ver- 1
HLe
sio TOS Length
» Each packet self-contained n
n
Identifier
Fl
ag Offset » 4 for IPv4
s
TTL Protocol Checksum
– All information needed to get to destination Source Address

Destination Address
z HLen: Header Length
– No advance setup or connection maintenance Options (if any)
» 32-bit words (typically 5)
» Analogous to letter or telegram Data

0 4 8 12 16 19 24 28 31 z TOS: Type of Service


version HLen TOS Length » Priority information
z Length: Packet Length
IPv4 Identifier Flag Offset
» Bytes (including header)
Packet TTL Protocol Checksum Header
Format
Source Address
z Header format can change with versions
» First byte identifies version
Destination Address

Options (if any)


z Length field limits packets to 65,535 bytes
» In practice, break into much smaller packets for network
Data performance considerations
35 35 36 36

6
2/22/2008

IPv4 Header Fields IPv4 Header Fields


z Identifier, flags, fragment offset Æ used primarily for 0 4 8 12 16 19 24 28 31

fragmentation 0
ver-
4 8 12 16 19 24 28
3
1
ver-
sion
HLen

Identifier
TOS
Fla
gs
Length

Offset
z Source Address
HLe
z Time to live sio
n
TOS Length TTL Protocol Checksum
n
Identifier
Fl
ag
s
Offset Source Address
» 32-bit IP address of sender
» Must be decremented at each router TTL Protocol Checksum Destination Address

Options (if any)


Source Address
» Packets with TTL=0 are thrown away Destination Address
Options (if any)
Data
z Destination Address
» Ensure packets exit the network
z Protocol
Data
» 32-bit IP address of
» Demultiplexing to higher layer protocols destination
» TCP = 6, ICMP = 1, UDP = 17… z Like the addresses on an envelope
z Header checksum
» Ensures some degree of header integrity z Globally unique identification of sender &
» Relatively weak – 16 bit receiver
z Options
» E.g. Source routing, record route, etc.
» Performance issues - Poorly supported

37 37 38 38

IP Delivery Model IP Fragmentation


z Best effort service MTU =
2000 host
» Network will do its best to get packet to destination router
router MTU = 1500
z Does NOT guarantee: host
MTU = 4000
» Any maximum latency or even ultimate success
» Sender
S d will
ill be
b informed
i f d if packet
k t doesn’t
d ’t make
k it z Every network has own Maximum Transmission Unit
» Packets will arrive in same order as sent (MTU)
» Just one copy of packet will arrive » Largest IP datagram it can carry within its own packet frame
z Implications – E.g., Ethernet is 1500 bytes

» Scales very well » Don’t know MTUs of all intermediate networks in advance
» Higher level protocols must make up for shortcomings z IP Solution
– Reliably delivering ordered sequence of bytes Æ TCP » When hit network with small MTU, fragment packets
» Some services not feasible
– Latency or bandwidth guarantees 39 39 40 40

Fragmentation Related Fields IP Fragmentation Example #1

z Length router
host
» Length of IP fragment MTU = 4000
z Identification
» To match up
p with other fragments
g
Length = 3820, M=0
z Flags
IP IP
» Don’t fragment flag Header Data

» More fragments flag


z Fragment offset
» Where this fragment lies in entire IP datagram
» Measured in 8 octet units (13 bit field)

41 41 42 42

7
2/22/2008

IP Fragmentation Example #2 IP Fragmentation Example #3


MTU = Length = 1500, M=1, Offset = 0
2000
router host IP IP
router
router MTU = 1500 Header Data
Length = 2000, M=1, Offset = 0
Length = 3820, M=0 Length = 2000, M=1, Offset = 0
IP IP 1480 bytes
IP IP Header Data IP IP Length = 520
520, M=1
M=1, Offset = 1480
Header Data Header Data
IP IP
1980 bytes Header Data
3800 bytes 1980 bytes Length = 1500, M=1, Offset = 1980
Length = 1840, M=0, Offset = 1980
500 bytes
Length = 1840, M=0, Offset = 1980 IP IP
IP IP Header Data Length = 360, M=0, Offset = 3460
Header Data IP IP IP IP
Header Data Header Data
1480 bytes
1820 bytes
1820 bytes 340 bytes
43 43 44 44

Fragmentation and Reassembly


IP Reassembly Concepts
Length = 1500, M=1, Offset = 0 z Demonstrates many Internet concepts
z Fragments might arrive out-of-
IP IP z Decentralized
Header Data order
» Every network can choose MTU
Length = 520, M=1, Offset = 1480
» Don’t know how much memory
required until receive final fragment z Connectionless
IP IP
Header Data z Some fragments may be » Each (fragment of) packet contains full routing information
duplicated » Fragments can proceed independently and along different
Length = 1500, M=1, Offset = 1980
» Keep only one copy routes
IP IP
Header Data z Some fragments may never z Best effort
Length = 360, M=0, Offset = 3460 arrive » Fail by dropping packet
IP IP
» After a while, give up entire process » Destination can give up on reassembly
Header Data » No need to signal sender that failure occurred
IP IP IP IP
Data Data Data Data z Complex endpoints and simple routers
45 45 » Reassembly at endpoints 46 46

Fragmentation is Harmful Where to do Reassembly?


z Uses resources poorly
» Forwarding costs per packet z End nodes or at routers?
» Best if we can send large chunks of data z End nodes
» Worst case: packet just bigger than MTU » Avoids unnecessary work where large
z Poor end-to-end
end to end performance packets are fragmented multiple times
» Loss of a fragment » If any fragment missing, delete entire packet
z Path MTU discovery protocol Æ determines z Dangerous to do at intermediate nodes
minimum MTU along route » How much buffer space required at routers?
» Uses ICMP error messages » What if routes in network change?
z Common theme in system design – Multiple paths through network
» Assure correctness by implementing complete – All fragments only required to go through
destination
protocol
» Optimize common cases to avoid full complexity
47 47 48 48

You might also like