Upload
others
View
7
Download
0
Embed Size (px)
Citation preview
IPAddressingandForwardingCOS461:ComputerNetworks
Spring2010(MW3:00‐4:20inCOS105)
MichaelFreedman
hIp://www.cs.princeton.edu/courses/archive/spring10/cos461/
1
GoalsofToday’sLecture• IPaddresses
– DoIed‐quadnotaUon– IPprefixesforaggregaUon
• AddressallocaUon– Classfuladdresses– ClasslessInterDomainRouUng(CIDR)– GrowthinthenumberofprefixesoverUme
• Packetforwarding– Forwardingtables– Longest‐prefixmatchforwarding– Whereforwardingtablescomefrom
2
IPAddress(IPv4)• Aunique32‐bitnumber• IdenUfiesaninterface(onahost,onarouter,…)• RepresentedindoIed‐quadnotaUon
3
00001100 00100010 10011110 00000101
12 34 158 5
GroupingRelatedHosts• TheInternetisan“inter‐network”
– Usedtoconnectnetworkstogether,nothosts– Needswaytoaddressanetwork(i.e.,groupofhosts)
4
host host host
LAN 1
... host host host
LAN 2
...
router router router WAN WAN
LAN = Local Area Network
WAN = Wide Area Network
ScalabilityChallenge• Supposehostshadarbitraryaddresses
– TheneveryrouterwouldneedalotofinformaUon
– …toknowhowtodirectpacketstowardeveryhost
5
host host host ... host host host ...
router router router
1.2.3.4 5.6.7.8 2.4.6.8 1.2.3.5 5.6.7.9 2.4.6.9
1.2.3.4
1.2.3.5
forwarding table
LAN 1 LAN 2 WAN WAN
a.k.a. FIB (forwarding information base)
ScalabilityChallenge• Supposehostshadarbitraryaddresses
– TheneveryrouterwouldneedalotofinformaUon
– …toknowhowtodirectpacketstowardeveryhost
• BackofenvelopcalculaUons– 32‐bitIPaddress:4.29billion(232)possibiliUes– Howmuchstorage?
• Minimum:4Baddress+2Bforwardinginfoperline
• Total:24.58GBjustforforwardingtable– Whathappensifanetworklinkgetscut?
6
StandardCSTrick
Haveascalabilityproblem?
Introducehierarchy…
7
HierarchicalAddressinginU.S.Mail• AddressingintheU.S.mail
– Zipcode:08540– Street:OldenStreet– Buildingonstreet:35– Roominbuilding:308 – Nameofoccupant:MikeFreedman
• ForwardingtheU.S.mail– DeliverleIertothepostofficeinthezipcode– AssignleIertomailmancoveringthestreet– DropleIerintomailboxforthebuilding/room– GiveleIertotheappropriateperson
8
???
HierarchicalAddressing:IPPrefixes• IPaddressescanbedividedintotwoporUons
– Network(lei)andhost(right)• 12.34.158.0/24isa24‐bitprefix
– Whichcovers28addresses(e.g.,upto255hosts)
9
00001100 00100010 10011110 00000101
Network (24 bits) Host (8 bits)
12 34 158 5
ExpressingIPprefixes
10
00001100 00100010 10011110 00000101
12 34 158 5
11111111 11111111 11111111 00000000
255 255 255 0
Address
Mask
IPprefix=IPaddress(AND)subnetmask
ScalabilityImproved• Numberrelatedhostsfromacommonsubnet
– 1.2.3.0/24ontheleiLAN– 5.6.7.0/24ontherightLAN
11
host host host
LAN 1
... host host host
LAN 2
...
router router router WAN WAN
1.2.3.4 1.2.3.7 1.2.3.156 5.6.7.8 5.6.7.9 5.6.7.212
1.2.3.0/24
5.6.7.0/24
forwarding table
EasytoAddNewHosts• Noneedtoupdatetherouters
– E.g.,addinganewhost5.6.7.213ontheright– Doesn’trequireaddinganewforwarding‐tableentry
12
host host host
LAN 1
... host host host
LAN 2
...
router router router WAN WAN
1.2.3.4 1.2.3.7 1.2.3.156 5.6.7.8 5.6.7.9 5.6.7.212
1.2.3.0/24
5.6.7.0/24
forwarding table
host
5.6.7.213
AddressAllocaUon
13
ClassfulAddressing• Intheoldendays,onlyfixedallocaUonsizes
– ClassA:0*• Verylarge/8blocks(e.g.,MIThas18.0.0.0/8)
– ClassB:10*• Large/16blocks(e.g,.Princetonhas128.112.0.0/16)
– ClassC:110*• Small/24blocks(e.g.,AT&TLabshas192.20.225.0/24)
– ClassD:1110*• MulUcastgroups
– ClassE:11110*• Reservedforfutureuse
• ThisiswhyfolksusedoIed‐quadnotaUon!14
ClasslessInter‐DomainRouUng(CIDR)
15
IP Address : 12.4.0.0 IP Mask: 255.254.0.0
00001100 00000100 00000000 00000000
11111111 11111110 00000000 00000000
Address
Mask
for hosts Network Prefix
Use two 32-bit numbers to represent a network. Network number = IP address + Mask
Written as 12.4.0.0/15 Introducedin1993RFC1518‐1519
CIDR:HierarchalAddressAllocaUon
16
12.0.0.0/8
12.0.0.0/16
12.254.0.0/16
12.1.0.0/16 12.2.0.0/16 12.3.0.0/16
: : :
12.3.0.0/24 12.3.1.0/24
: :
12.3.254.0/24
12.253.0.0/19 12.253.32.0/19 12.253.64.0/19 12.253.96.0/19 12.253.128.0/19 12.253.160.0/19
: : :
• Prefixes are key to Internet scalability – Address allocated in contiguous chunks (prefixes) – Routing protocols and packet forwarding based on prefixes – Today, routing tables contain ~200,000 prefixes (vs. 4B)
Scalability:AddressAggregaUon
17
Provider is given 201.10.0.0/21
201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23
Provider
RoutersinrestofInternetjustneedtoknowhowtoreach201.10.0.0/21.ProvidercandirectIPpackets
toappropriatecustomer.
But,AggregaUonNotAlwaysPossible
18
201.10.0.0/21
201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23
Provider 1 Provider 2
Mul0‐homedcustomer(201.10.6.0/23)hastwoproviders.OtherpartsoftheInternetneedtoknow
howtoreachthesedesUnaUonsthroughbothproviders.
ScalabilityThroughHierarchy• Hierarchicaladdressing
– CriUcalforscalablesystem– Don’trequireeveryonetoknoweveryoneelse– ReducesamountofupdaUngwhensomethingchanges
• Non‐uniformhierarchy– Usefulforheterogeneousnetworksofdifferentsizes– IniUalclass‐basedaddressingwasfartoocoarse– ClasslessInterDomainRouUng(CIDR)helps
• Nextfewslides– Historyofthenumberofglobally‐visibleprefixes– Plotsare#ofprefixesvs.Ume
19
Pre‐CIDR(1988‐1994):SteepGrowth
20
Growthfasterthanimprovementsinequipmentcapability
CIDRDeployed(1994‐1996):MuchFlaIer
21
Effortstoaggregate(evendecreasesaierIETFmeeUngs!)
CIDRGrowth(1996‐1998):RoughlyLinear
22
GooduseofaggregaUon,andpeerpressureinCIDRreport
BoomPeriod(1998‐2001):SteepGrowth
23 InternetboomandincreasedmulU‐homing
Long‐TermView(1989‐2005):Post‐Boom
24
ObtainingaBlockofAddresses• SeparaUonofcontrol
– Prefix:assignedtoaninsUtuUon– Addresses:assignedbytheinsUtuUontotheirnodes
• Whoassignsprefixes?– InternetCorp.forAssignedNamesandNumbers(IANA)
• AllocateslargeaddressblockstoRegionalInternetRegistries– RegionalInternetRegistries(RIRs)
• E.g.,ARIN(AmericanRegistryforInternetNumbers)• Allocatesaddressblockswithintheirregions• AllocatedtoInternetServiceProvidersandlargeinsUtuUons
– InternetServiceProviders(ISPs)• Allocateaddressblockstotheircustomers• Whomay,inturn,allocatetotheircustomers…
25
FiguringOutWhoOwnsanAddress• Addressregistries
– PublicrecordofaddressallocaUons– InternetServiceProviders(ISPs)shouldupdatewhengivingaddressestocustomers
– However,recordsarenotoriouslyout‐of‐date• Waystoquery
– UNIX:“whois–hwhois.arin.net128.112.136.35”– hIp://www.arin.net/whois/– hIp://www.geektools.com/whois.php– …
26
ExampleOutputfor128.112.136.35OrgName: PrincetonUniversityOrgID: PRNUAddress: OfficeofInformaUonTechnologyAddress: 87ProspectAvenueCity: PrincetonStateProv: NJPostalCode: 08540Country: US
NetRange: 128.112.0.0‐128.112.255.255CIDR: 128.112.0.0/16NetName: PRINCETONNetHandle: NET‐128‐112‐0‐0‐1Parent: NET‐128‐0‐0‐0‐0NetType: DirectAllocaUonNameServer:DNS.PRINCETON.EDUNameServer:NS1.FAST.NETNameServer:NS2.FAST.NETNameServer:NS1.UCSC.EDUNameServer:ARIZONA.EDUNameServer:NS3.NIC.FR
Comment:RegDate: 1986‐02‐24Updated: 2007‐02‐27
27
Are32‐bitAddressesEnough?• Notallthatmanyuniqueaddresses
– 232=4,294,967,296(justoverfourbillion)– Plus,somearereservedforspecialpurposes– And,addressesareallocatedinlargerblocks
• Myfraternity/dormatMIThadasmanyIPaddrsasPrinceton!
• And,manydevicesneedIPaddresses– Computers,PDAs,routers,tanks,toasters,…
• Long‐termsoluUon:alargeraddressspace– IPv6has128‐bitaddresses(2128=3.403×1038)
• Short‐termsoluUons:limpingalongwithIPv4– Privateaddresses(RFC1918):
• 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16– NetworkaddresstranslaUon(NAT)– Dynamically‐assignedaddresses(DHCP)
28
HardPolicyQuesUons• Howmuchaddressspacepergeographicregion?
– Equalamountpercountry?– ProporUonaltothepopulaUon?– Whataboutaddressesalreadyallocated?
• MITsUllhas>>IPaddressesthanmostcountries?
• Addressspaceportability?– Keepyouraddressblockwhenyouchangeproviders?– Pro:avoidhavingtorenumberyourequipment– Con:reducestheeffecUvenessofaddressaggregaUon
• Keepingtheaddressregistriesuptodate?– WhataboutmergersandacquisiUons?– DelegaUonofaddressblockstocustomers?– Asaresult,theregistriesarehorriblyoutofdate
29
PacketForwarding
30
Hop‐by‐HopPacketForwarding• Eachrouterhasaforwardingtable
– MapsdesUnaUonaddresses…
– …tooutgoinginterfaces• Uponreceivingapacket
– InspectthedesUnaUonIPaddressintheheader– Indexintothetable– Determinetheoutgoinginterface– Forwardthepacketoutthatinterface
• Then,thenextrouterinthepathrepeats– AndthepackettravelsalongthepathtodesUnaUon
31
SeparateTableEntriesPerAddress• IfarouterhadaforwardingentryperIPaddr
– Matchdes0na0onaddressofincomingpacket– …totheforwarding‐tableentry– …todeterminetheoutgoinginterface
32
host host host
LAN 1
... host host host
LAN 2
...
router router router WAN WAN
1.2.3.4 5.6.7.8 2.4.6.8 1.2.3.5 5.6.7.9 2.4.6.9
1.2.3.4
1.2.3.5
forwarding table
SeparateEntryPer24‐bitPrefix• Iftherouterhadanentryper24‐bitprefix
– Lookonlyatthetop24bitsofthedesUnaUonaddress– Indexintothetabletodeterminethenext‐hopinterface
33
host host host
LAN 1
... host host host
LAN
...
router router router WAN WAN
1.2.3.4 1.2.3.7 1.2.3.156 5.6.7.8 5.6.7.9 5.6.7.212
1.2.3.0/24
5.6.7.0/24
forwarding table
SeparateEntryClassfulAddress• Iftherouterhadanentryperclassfulprefix
– MixtureofClassA,B,andCaddresses– DependsonthefirstcoupleofbitsofthedesUnaUon
• IdenUfythemaskautomaUcallyfromtheaddress– Firstbitof0:classAaddress(/8)– Firsttwobitsof10:classBaddress(/16)– Firstthreebitsof110:classCaddress(/24)
• Then,lookintheforwardingtableforthematch– E.g.,1.2.3.4mapsto1.2.3.0/24– Then,lookuptheentryfor1.2.3.0/24– …toidenUfytheoutgoinginterface
• Sofar,everythingisexactmatching34
CIDRMakesPacketForwardingHarder• There’snosuchthingasafreelunch
– CIDRallowsefficientuseoflimitedaddressspace– But,CIDRmakespacketforwardingmuchharder
• Forwardingtablemayhavemanymatches– E.g.,entriesfor201.10.0.0/21and201.10.6.0/23– TheIPaddress201.10.6.17wouldmatchboth!
35
201.10.0.0/21
201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23
Provider 1 Provider 2
LongestPrefixMatchForwarding• ForwardingtablesinIProuters
– MapseachIPprefixtonext‐hoplink(s)• DesUnaUon‐basedforwarding
– PackethasadesUnaUonaddress– RouteridenUfieslongest‐matchingprefix– Cutealgorithmicproblem:veryfastlookups
36
4.0.0.0/8 4.83.128.0/17 201.10.0.0/21 201.10.6.0/23 126.255.103.0/24
201.10.6.17 destination
forwarding table
Serial0/0.1 outgoing link
AnotherreasonFIBsgetlarge
37
201.10.0.0/21
201.10.0.0/22 201.10.4.0/24 201.10.5.0/24 201.10.6.0/23
Provider 1 Provider 2
• Ifcustomer201.10.6.0/23preferstoreceivetrafficfromProvider1(itmaybecheaper),thenP1needstoannounce201.10.6.0/23,not201.10.0.0/21
• Can’talwaysaggregate![See“GeographicLocalityofIPPrefixes”M.Freedman,M.Vutukuru,N.Feamster,andH.Balakrishnan.InternetMeasurementConference(IMC),2005
SimplestAlgorithmisTooSlow• ScantheforwardingtableoneentryataUme
– SeeifthedesUnaUonmatchestheentry– Ifso,checkthesizeofthemaskfortheprefix– Keeptrackoftheentrywithlongest‐matchingprefix
• Overheadislinearinsizeoftheforwardingtable– Today,thatmeans200,000entries!– HowmuchUmedoyouhavetoprocess?
• Consider10Gbpsroutersand64Bpackets• 10,000,000,000/8/64:19,531,250packetspersecond• 51nanosecondsperpacket
• Needgreaterefficiencytokeepupwithlinerate– BeIeralgorithms– HardwareimplementaUons
38
PatriciaTree(1968)• Storetheprefixesasatree
– Onebitforeachlevelofthetree– Somenodescorrespondtovalidprefixes– ...whichhavenext‐hopinterfacesinatable
• Whenapacketarrives– TraversethetreebasedonthedesUnaUonaddress– Stopuponreachingthelongestmatchingprefix
39
0 1
00 10 11
100 101 00*
0*
11*
EvenFasterLookups• Patriciatreeisfasterthanlinearscan
– ProporUonaltonumberofbitsintheaddress• Patriciatreecanbemadefaster
– Canmakeak‐arytree• E.g.,4‐arytreewithfourchildren(00,01,10,and11)
– Fasterlookup,thoughrequiresmorespace• Canusespecialhardware
– ContentAddressableMemories(CAMs)– Allowslook‐upsonakeyratherthanflataddress
• HugeinnovaUonsinthemid‐to‐late1990s– AierCIDRwasintroduced(in1994)– …andlongest‐prefixmatchwasamajorboIleneck
40
WheredoForwardingTablesComeFrom?
• Routershaveforwardingtables– Mapprefixtooutgoinglink(s)
• EntriescanbestaUcallyconfigured– E.g.,“map12.34.158.0/24toSerial0/0.1”
• But,thisdoesn’tadapt– Tofailures– Tonewequipment– Totheneedtobalanceload– …
• Thatiswhereothertechnologiescomein…– RouUngprotocols,DHCP,andARP(laterincourse)
41
HowDoEndHostsForwardPackets?
• Endhostwithsinglenetworkinterface– PCwithanEthernetlink– Laptopwithawirelesslink
• Don’tneedtorunarouUngprotocol– Packetstothehostitself(e.g.,1.2.3.4/32)
• Deliveredlocally– PacketstootherhostsontheLAN(e.g.,1.2.3.0/24)
• Sentouttheinterface:Broadcastmedium!– Packetstoexternalhosts(e.g.,0.0.0.0/0)
• Sentoutinterfacetolocalgateway• HowthisinformaUonislearned
– StaUcse|ngofaddress,subnetmask,andgateway– DynamicHostConfiguraUonProtocol(DHCP)
42
WhatAboutReachingtheEndHosts?• HowdoesthelastrouterreachthedesUnaUon?
• Eachinterfacehasapersistent,globalidenUfier– MAC(MediaAccessControl)address– BurnedintotheadaptorsRead‐OnlyMemory(ROM)– Flataddressstructure(i.e.,nohierarchy)
• ConstrucUnganaddressresoluUontable– MappingMACaddressto/fromIPaddress– AddressResoluUonProtocol(ARP)
43
host host host
LAN
...
router
1.2.3.4 1.2.3.7 1.2.3.156
Conclusions• IPaddress
– A32‐bitnumber– Allocatedinprefixes– Non‐uniformhierarchyforscalabilityandflexibility
• Packetforwarding– BasedonIPprefixes– Longest‐prefix‐matchforwarding
• Nextlecture– TransmissionControlProtocol(TCP)
• We’llcoversometopicslater– RouUngprotocols,DHCP,andARP
44