1 Network Layer 2 IPv4 Addresses q 32 bits long q Identifier for host, router interface q Notation: v Each byte is written in decimal in MSB order, separated by dots v Example: 128.195.1.80 3 Types of IPv4 Addresses q Unicast Address v Destination is a single host q Multicast address v Destination is a group of hosts q Broadcast address v 255.255.255.255 v Destination is all hosts 4 IPv4 Address Classes (old) 0 Net 32 bits Host 10 Net Host 110 Net Host 1110 Multicast address 11110 Reserved A B C D E Class
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Network Layer
2
IPv4 Addresses q 32 bits long q Identifier for host, router interface q Notation:
v Each byte is written in decimal in MSB order, separated by dots
v Example: 128.195.1.80
3
Types of IPv4 Addresses q Unicast Address
v Destination is a single host q Multicast address
v Destination is a group of hosts q Broadcast address
v 255.255.255.255 v Destination is all hosts
4
IPv4 Address Classes (old)
0 Net
32 bits
Type of Serv. Host
10 Net Host
110 Net Host
1110 Multicast address
11110 Reserved
A
B
C
D
E
Class
2
5
IP Address Classes q Class A:
v For very large organizations v 16 million hosts allowed
q Class B: v For large organizations v 65 thousand hosts allowed
q Class C v For small organizations v 255 hosts allowed
q Class D v Multicast addresses v No network/host hierarchy
6
IP Address Hierarchy q Class A, B, C addresses support two levels
of hierarchy q However, the host portion can be further
split into “subnets” by the address class owner v more than 2 levels of hierarchy
7
Subnetting
Host id Subnet id Network id
Example: Class B address with 8-bit subnetting
165.230 .24 .8
16 bits 8 bits 8 bits
Example Address:
8
Subnet Masks
Subnet masks allow hosts to determine if another IP address is on the same subnet or the same network
Host id Subnet id Network id 16 bits 8 bits 8 bits
1111111111111111 11111111 00000000 Mask:
255.255 .255 .0
3
9
Subnet Masks (cont’d)
Are IP addresses A and B on the same subnet?
1. Compute (A and M). 2. Compute (B and M). 3. If (A and M) = (B and M) then A and B are on the same subnet.
Assume IP addresses A and B share subnet mask M.
Example: A and B are class B addresses A = 165.230.82.52 B = 165.230.24.93 M = 255.255.255.0
Same network? Same subnet?
10
IP Addressing in network
223.1.1.1
223.1.1.2
223.1.1.3
223.1.1.4 223.1.2.9
223.1.2.2
223.1.2.1
223.1.3.2 223.1.3.1
223.1.3.27
11
Problems with Class-based Routing
q Too many small networks requiring multiple class C addresses
q Running out of class B addresses, not enough nets in class A
q Addressing strategy must allow for greater diversity of network sizes
12
IP addressing: CIDR
CIDR: Classless InterDomain Routing v subnet portion of address of arbitrary length v address format: a.b.c.d/x, where x is # bits in
subnet portion of address
11001000 00010111 00010000 00000000
subnet part
host part
200.23.16.0/23
4
13
CIDR
q An ISP can obtain a block of addresses and partition this further to its customers v Say an ISP has 200.8.4.24/24 address (256
addresses). He has another customer who needs only 4 addresses from 200.8.4.24 then that block can be specified as 200.8.4.24/30
14
Reducing Routing Table Size
service provider
200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0
200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0
Routing table
Without CIDR:
service provider
200.71.0.0 200.71.1.0 200.71.2.0 ….. 200.71.255.0
Routing table
With CIDR:
200.71.0.0/16
15
Hierarchical addressing: route aggregation
“Send me anything with addresses beginning 200.23.16.0/20”
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7 Internet
Organization 1
ISPs-R-Us “Send me anything with addresses beginning 199.31.0.0/16”
200.23.20.0/23 Organization 2
. . .
. . .
Hierarchical addressing allows efficient advertisement of routing information:
16
Hierarchical addressing: more specific routes
ISPs-R-Us has a more specific route to Organization 1 Longest prefix match will be used to route IP packets
“Send me anything with addresses beginning 200.23.16.0/20”
200.23.16.0/23
200.23.18.0/23
200.23.30.0/23
Fly-By-Night-ISP
Organization 0
Organization 7 Internet
Organization 1
ISPs-R-Us “Send me anything with addresses beginning 199.31.0.0/16 or 200.23.18.0/23”
Decentralized switching: q queuing: if datagrams arrive
faster than forwarding rate into switch fabric
Physical layer: bit-level reception
Data link layer: e.g., Ethernet see chapter 5
23
Three types of switching fabrics
24
Output Ports
q Buffering required when datagrams arrive from fabric faster than the transmission rate
q Scheduling discipline chooses among queued datagrams for transmission
7
25
0 224 232-1
128.9.0.0/16
65.0.0.0
142.12.0.0/19
65.0.0.0/8
65.255.255.255
Example Forwarding Table
Destination IP Prefix Outgoing Port65.0.0.0/8 3
128.9.0.0/16 1
65.0.0.128/25 4
142.12.0.0/19 7
IP prefix: 0-32 bits Longest prefix match
Prefix length
128.9.16.14
26
Longest prefix match q With CIDR, route entries are prefixes <prefix, CIDR mask> q Can be aggregated q We need to find the longest matching prefix that matches
the destination address q Need to search all prefixes of all length (in order) and
among prefixes of the same length
128.8.0/16
128.8.2/24
192.2.0/16
128.8.0.24128.8.2.128
192.2.2.128
27
Prefixes can Overlap
128.9.16.0/21 128.9.172.0/21
128.9.176.0/24
Routing lookup: Find the longest matching prefix (the most specific route) among all prefixes that match the destination address.
0 232-1
128.9.0.0/16 142.12.0.0/19 65.0.0.0/8
128.9.16.14
Longest matching prefix
28
Key Network-Layer Functions
q forwarding: move packets from router’s input to appropriate router output
q routing: determine route taken by packets from source to dest.
v Routing algorithms
analogy:
q routing: process of planning trip from source to destination
q forwarding: process of getting through single interchange
RARP q Reverse Address Resolution Protocol q RARP performs the inverse action of ARP q RARP returns an IP address for a given
MAC sublayer address q Need MAC address à IP address q Host have no permanent storage q On reboot? Need to figure IP address q Operationally, RARP is the same as ARP
40
ICMP
q Protocol for error detection and reporting • tightly coupled with IP, unreliable
q ICMP messages delivered in IP packets q ICMP functions:
v Announce network errors v Announce network congestion v Assist trouble shooting v Announce timeouts
11
41
ICMP MSG
IP header Source, Destination Address, TTL, ...
ICMP MSG Message type, Code, Checksum,
Data
IPV4 Header for ICMP
42
1
ICMP header Protocol Field value=1
43 44
ICMP: Internet Control Message Protocol Type Code description 0 0 echo reply (ping) 3 0 dest. network unreachable 3 1 dest host unreachable 3 2 dest protocol unreachable 3 3 dest port unreachable 3 6 dest network unknown 3 7 dest host unknown 4 0 source quench (congestion control - not used) 8 0 echo request (ping) 9 0 route advertisement 10 0 router discovery 11 0 TTL expired 12 0 bad IP header
12
45
Specific uses of ICMP
q Echo request reply v Can be used to check if a host is alive
q Destination unreachable v Invalid address and/or port
q TTL expired v Routing loops, or too far away
46
Ping q Uses ICMP echo request/reply q Source sends ICMP echo request message to the destination
address q Destination replies with an ICMP echo reply message
containing the data in the original echo request message q Source can calculate round trip time (RTT) of packets q If no echo reply comes back then the destination is
unreachable
47
Ping (cont’d)
R1 R2 R3 A B Tim
e
Echo request
Echo reply
48
Traceroute q Traceroute records the route that packets take q A clever use of the TTL field q When a router receives a packet, it decrements TTL q If TTL=0, it sends an ICMP time exceeded message back to
the sender q To determine the route, progressively increase TTL
v Every time an ICMP time exceeded message is received, record the sender’s (router’s) address
v Repeat until the destination host is reached or an error message occurs
13
49
Traceroute (cont’d)
R1 R2 R3 A B TTL=1, Dest = B, port = invalid
TTL=2, Dest = B
TTL=3, Dest = B
TTL=4, Dest = B
Te (R1)
Te (R2)
Te (R3)
Pu (B)
Time
Te = Time exceeded Pu = Port unreachable
50
Traceroute Examle 1 lcsr-gw (128.6.13.21) 1.206 ms 0.973 ms 0.782 ms 2 rucs-gw (165.230.212.129) 0.697 ms 0.569 ms 0.571 ms 3 transition2-gw (165.230.12.145) 2.786 ms 0.994 ms 0.769 ms 4 rutgers-gw.Rutgers.EDU (198.151.130.209) 1.726 ms 2.048 ms Vl1000-sr02-hil l012-svcs.Rutgers.EDU (198.151.130.14) 1.278 ms 5 rutgers-gw.Rutgers.EDU (198.151.130.209) 1.755 ms 1.241 ms 1.828 ms 6 198.151.130.226 (198.151.130.226) 2.748 ms 3.070 ms 2.640 ms 7 clev-nycm.abilene.ucaid.edu (198.32.8.29) 15.162 ms 14.619 ms 14.663 ms 8 ipls-clev.abilene.ucaid.edu (198.32.8.25) 21.220 ms 22.497 ms 21.450 ms 9 kscy-ipls.abilene.ucaid.edu (198.32.8.5) 30.257 ms 30.604 ms 30.969 ms 10 dnvr-kscy.abilene.ucaid.edu (198.32.8.13) 40.823 ms 41.181 ms 41.076 ms 11 snva-dnvr.abilene.ucaid.edu (198.32.8.1) 65.436 ms 66.068 ms 65.569 ms 12 198.32.249.161 (198.32.249.161) 65.673 ms 65.771 ms 66.006 ms 13 BERK--SUNV.POS.calren2.net (198.32.249.13) 67.183 ms 67.131 ms 66.858 ms 14 pos1-0.inr-000-eva.Berkeley.EDU (128.32.0.89) 67.192 ms 66.749 ms 67.720 ms 15 vlan198.inr-201-eva.Berkeley.EDU (128.32.0.194) 67.373 ms 67.067 ms 67.82 1 ms 16 fast8-0-0.inr-210-cory.Berkeley.EDU (128.32.255.122) 67.634 ms 68.735 ms 68.413 ms 17 GE.cory-gw.EECS.Berkeley.EDU (169.229.1.46) 67.575 ms 68.222 ms 67.772 ms 18 gig8-1.snr1.CS.Berkeley.EDU (169.229.3.66) 67.454 ms 67.988 ms 67.177 ms
19 now.CS.Berkeley.EDU (128.32.44.96) 67.892 ms * 67.818 ms
IP bootstrap & NAT
52
IP addresses: bootStrap?
Q: How does host get IP address? q hard-coded by system admin in a file
v Wintel: control-panel->network->configuration->tcp/ip->properties
v UNIX: /etc/rc.config q DHCP: Dynamic Host Configuration Protocol:
dynamically get address from as server v “plug-and-play”
14
More Internet Protocols DHCP, NAT, IPv6
54
DHCP (Ch 4.4) q DHCP stands for dynamic host configuration protocol q DHCP is client-server q DHCP offers a number of more features
v Dynamic IP address allocation v IP addresses can be leased for a certain time v Useful where there are a limited number of IP addresses v Useful for temporary connections (testing, laptops, mobile
networks)
55
DHCP (cont’d)
q DHCP has two components: v A protocol for delivering bootstrap information
from the server to the clients v An algorithm for dynamically assigning
addresses to clients
56
Address Allocation Modes
q DHCP supports three modes of allocation v Automatic allocation: Server assigns a permanent address
to a host v Dynamic allocation: Server assigns a host an IP address
with a finite “lease” v Manual allocation: Server assigns host an IP address
chosen by the network administrator
15
IPV4 Header for DHCP
57
17
Source Port Destination port=67
DHCP PACKET
58
DHCP Packets (cont’d)
Number of seconds Flags
Transaction ID
Request/Reply Hardware type Hardware address length in bytes Hop count
Client hardware address (16 bytes)
Your IP address
Server IP address
Gateway IP address
Server hostname (64 bytes)
Boot filename (128 bytes)
Options (312+ bytes)
Client IP address
0 7 8 15 16 23 24 31
Request=1 Reply=2
59
Definitions of address fields
q ciaddr Client IP address; only filled in if client is in BOUND, RENEW or REBINDING state and can respond to ARP requests.
q yiaddr 'your' (client) IP address. The IP address, server is assigning to client
q siaddr IP address of server to use in the netx step of the bootstrap process; returned in DHCPOFFER, DHCPACK by server.
q giaddr Relay agent IP address, used in booting via a relay agent.
q chaddr Client hardware address used for identification.
60
DHCP Packet Fields q All fields are same as BOOTP except:
v Flags: One flag currently defined • Broadcast (bit 0): Clients can request that all DHCP server
messages be broadcast to it v Options:
• All DHCP packets must use the “DHCP message type” option, which defines the “type” of DHCP message being sent:
q DHCP message types v DHCP Discover: Client broadcasts to locate a server v DHCP Offer: Server responds with proposal of parameters v DHCP Request: Client broadcasts its choice of server. All other
servers are implicitly declined. v DHCP ACK: Selected server responds to client with address v DHCP NAK: Selected server rejects the client’s request v DHCP Decline: Client declines server’s parameters v DHCP Release: Client releases its assigned address
v Client may specify preference of a lease and/or IP address q Many servers may respond with offers
v Client chooses one server from them q Client broadcasts DHCP request with id of chosen server q Selected server sends DHCP ACK or NAK q Client begins using offered IP address once it receives ACK q If the client finds a problem, it sends a DHCP Decline message to
the server and starts over again q Client may choose to release the address before lease expires by
sending a DHCP Release message to the server
64
DHCP Relay Agents q Similar to BOOTP Relay Agents q DHCP relay agents allow DHCP servers to handle requests
from other subnets
DHCP Relay Agent
Client IP
Gateway Router
IP Gateway Router
DHCP Server
17
65
Summary
q DHCP allow “ignorant” hosts to receive IP addresses (and more) at start-up time
q IP addresses don’t have to be manually configured into hosts
66
NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
10.0.0.4
138.76.29.7
local network (e.g., home network)
10.0.0/24
rest of Internet
All datagrams leaving local network have same single source
NAT IP address: 138.76.29.7, different source port numbers
67
NAT: Network Address Translation
10.0.0.1
10.0.0.2
10.0.0.3
S: 10.0.0.1, 3345 D: 128.119.40.186, 80
1 10.0.0.4
138.76.29.7
1: host 10.0.0.1 sends datagram to 128.119.40.186, 80
NAT translation table WAN side addr LAN side addr 138.76.29.7, 5001 10.0.0.1, 3345 …… ……
S: 128.119.40.186, 80 D: 10.0.0.1, 3345
4
S: 138.76.29.7, 5001 D: 128.119.40.186, 80 2
2: NAT router changes datagram source addr from 10.0.0.1, 3345 to 138.76.29.7, 5001, updates table