IP Addressing and Forwarding 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255 ether...
Transcript of IP Addressing and Forwarding 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255 ether...
IPAddressingandForwardingCOS461:ComputerNetworks
Spring2011
MikeFreedman
hAp://www.cs.princeton.edu/courses/archive/spring11/cos461/
1
GoalsofToday’sLecture• IPaddresses
– DoAed‐quadnotaPon– IPprefixesforaggregaPon
• AddressallocaPon– Classfuladdresses– ClasslessInterDomainRouPng(CIDR)– GrowthinthenumberofprefixesoverPme
• Packetforwarding– Forwardingtables– Longest‐prefixmatchforwarding– Whereforwardingtablescomefrom
2
IPAddress(IPv4)• Aunique32‐bitnumber• IdenPfiesaninterface(onahost,onarouter,…)• RepresentedindoAed‐quadnotaPon
3
00001100 00100010 10011110 00000101
12 34 158 5
GroupingRelatedHosts• TheInternetisan“inter‐network”
– Usedtoconnectnetworkstogether,nothosts– Needswaytoaddressanetwork(i.e.,groupofhosts)
4
LAN = Local Area Network
WAN = Wide Area Network
host host host host host host
router router router LAN 1 LAN 2
WAN WAN
ScalabilityChallenge• Supposehostshadarbitraryaddresses
– TheneveryrouterwouldneedalotofinformaPon
– …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
– TheneveryrouterwouldneedalotofinformaPon
– …toknowhowtodirectpacketstowardeveryhost
• BackofenvelopcalculaPons– 32‐bitIPaddress:4.29billion(232)possibiliPes– Howmuchstorage?
• Minimum:4Baddress+2Bforwardinginfoperline
• Total:24.58GBjustforforwardingtable– Whathappensifanetworklinkgetscut?
6
HierarchicalAddressinginU.S.Mail• AddressingintheU.S.mail
– Zipcode:08540– Street:OldenStreet– Building:35– Room:308 – Occupant:MikeFreedman
• ForwardingtheU.S.mail– Delivertopostofficeinzipcode– Assigntomailmancoveringstreet– Dropintomailboxforbuilding/room– Givetoappropriateperson
8
???
HierarchicalAddressing:IPPrefixes• IPaddressescanbedividedintotwoporPons
– 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
ScalabilityImproved• Numberrelatedhostsfromacommonsubnet
– 1.2.3.0/24ontheleiLAN– 5.6.7.0/24ontherightLAN
10
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
11
host host host
LAN 1
... host host host ...
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
LAN 2
ClassfulAddressing• Inoldendays,onlyfixedallocaPonsizes
– ClassA: 0*:Verylarge/8blocks(MIThas18.0.0.0/8)
– ClassB: 10*:Large/16blocks(Princetonhas128.112.0.0/16)
– ClassC:110*:Small/24blocks– ClassD: 1110*:MulPcastgroups– ClassE:11110*:Reservedforfutureuse
• WhyfolksusedoAed‐quadnotaPon!
• PosiPonof“first0”madeiteasytodetermineclassofaddressinhardware(hence,howtoparse)
13
ClasslessInter‐DomainRouPng(CIDR)14
00001100 00000100 00000000 00000000
11111111 11111110 00000000 00000000
Address
Mask
for hosts Network Prefix
Written as 12.4.0.0/15 Introducedin1993RFC1518‐1519
• IPprefix=IPaddress(AND)subnetmask• IPAddress:12.4.0.0,Mask:255.254.0.0
$ ifconfig en1: flags=8863<UP,BROADCAST,…,MULTICAST> mtu 1500 inet 192.168.1.1 netmask 0xffffff00 broadcast 192.168.1.255 ether 21:23:0e:f3:51:3a
CIDR:HierarchalAddressAllocaPon15
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.254.0.0/19 12.254.32.0/19 12.254.64.0/19 12.254.96.0/19 12.254.128.0/19 12.254.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 ~350,000 prefixes (vs. 4B)
Scalability:AddressAggregaPon16
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
• OtherInternetRoutersjustknowhowtoreach201.10.0.0/21• ProvidercandirectIPpacketstoappropriatecustomer
But,AggregaPonNotAlwaysPossible17
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
• OtherpartsofInternetneedtoknowhowtoreachdesPnaPonsthroughbothproviders
ScalabilityThroughHierarchy• Hierarchicaladdressing
– CriPcalforscalablesystem– Don’trequireeveryonetoknoweveryoneelse– ReducesamountofupdaPngwhensomethingchanges
• Non‐uniformhierarchy– Usefulforheterogeneousnetworksofdifferentsizes– IniPalclass‐basedaddressingwasfartoocoarse– ClasslessInterDomainRouPng(CIDR)helps
• Nextfewslides– Historyofthenumberofglobally‐visibleprefixes– Plotsare#ofprefixesvs.Pme
18
CIDRDeployed(1994‐1998):MuchFlaAer20
Effortstoaggregate(evendecreasesaierIETFmeePngs!)GooduseofaggregaPon,andpeerpressureinCIDRreport
BoomPeriod(1998‐2001):SteepGrowth21
InternetboomandincreasedmulP‐homing“Dot‐com”bubbleof2001sawslowdown
ObtainingaBlockofAddresses• SeparaPonofcontrol
– Prefix:assignedtoaninsPtuPon– Addresses:assignedbytheinsPtuPontotheirnodes
• Whoassignsprefixes?
23
InternetCorp.forAssignedNamesandNumbers(IANA)
RegionalInternetRegistries(RIRs)
InternetServiceProviders(ISPs)
FiguringOutWhoOwnsanAddress• Addressregistries
– PublicrecordofallocaPons– ISPsshouldupdatewhenallocaPngtocustomers
– Recordsoienout‐of‐date
• Waystoquery– UNIX:“whois–hwhois.arin.net128.112.136.35”
– hAp://www.arin.net/whois/– …
24
OrgName: PrincetonUniversityOrgID: PRNUAddress: OfficeofInfoTechAddress: 87ProspectAvenueCity: PrincetonStateProv: NJPostalCode: 08540Country: US
NetRange: 128.112.0.0– 128.112.255.255
CIDR: 128.112.0.0/16NetName: PRINCETONNetHandle: NET‐128‐112‐0‐0‐1Parent: NET‐128‐0‐0‐0‐0NetType: DirectAllocaPonNameServer: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
Are32‐bitAddressesEnough?• Notallthatmanyuniqueaddresses
– 232=4,294,967,296(justoverfourbillion)– Somearereservedforspecialpurposes– Addressesareallocatednon‐uniformly
• Myfraternity/dormatMIThasasmanyIPaddrsasPrinceton!
• Moredevicesneedaddr’s:smartphones,toasters,…
• Long‐termsoluPon:alargeraddressspace– IPv6has128‐bitaddresses(2128=3.403×1038)
• Short‐termsoluPons:limpingalongwithIPv4– Privateaddresses(RFC1918):
• 10.0.0.0/8,172.16.0.0/12,192.168.0.0/16– NetworkaddresstranslaPon(NAT)– Dynamically‐assignedaddresses(DHCP)
25
HardPolicyQuesPons• Howmuchaddressspacepergeographicregion?
– Equalamountpercountry?– ProporPonaltothepopulaPon?– Whataboutaddressesalreadyallocated?
• MITsPllhas>>IPaddressesthanmostcountries?
• Addressspaceportability?– Keepyouraddressblockwhenyouchangeproviders?– Pro:avoidhavingtorenumberyourequipment– Con:reducestheeffecPvenessofaddressaggregaPon
• Keepingtheaddressregistriesuptodate?– WhataboutmergersandacquisiPons?– DelegaPonofaddressblockstocustomers?– Asaresult,theregistriesarehorriblyoutofdate
27
SeparateEntryPerAddress• IfrouterhadaforwardingentryperIPaddr
– Matchdes0na0onaddrofincomingpacket– Uniquelydetermineoutgoinginterface
29
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• Ifrouterhadanentryper24‐bitprefix
– Lookonlyatthetop24bitsofdesPnaPonaddr– Indexintotabletodeterminenext‐hopinterface
30
host host host
LAN 1
... host host host
LAN 2
...
router router router WAN WAN
forwarding table
1.2.3.0/24
5.6.7.0/24
1.2.3.4 1.2.3.7 1.2.3.156 5.6.7.8 5.6.7.9 5.6.7.212
SeparateEntryClassfulAddress• Iftherouterhadanentryperclassfulprefix
– MixtureofClassA,B,andCaddresses– DependsonthefirstcoupleofbitsofthedesPnaPon
• IdenPfythemaskautomaPcallyfromtheaddress– Firstbitof0:classAaddress(/8)– Firsttwobitsof10:classBaddress(/16)– Firstthreebitsof110:classCaddress(/24)
• Then,lookintheforwardingtableforthematch– E.g.,Ifaddris1.2.3.4,lookupupentryfor1.2.3.0/24
• Sofar,everythingisexactmatching
31
CIDRMakesPacketForwardingHarder• Efficientuseofaddressspacevs.overlappingrules
• Forwardingtablemayhavemanymatches– 201.10.6.17matchesboth201.10.0.0/21and201.10.6.0/23– Entriesmaymaptodifferentoutgoinginterfaces
32
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
AnotherreasonFIBsgetlarge33
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
LongestPrefixMatchForwarding• HowtoresolvemulPplematches?
– RouteridenPfiesmostspecificprefix:longestprefixmatch(LPM)
– Cutealgorithmicproblemtoachievefastlookups
34
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
SimplestAlgorithmisTooSlow• ScantheforwardingtableoneentryataPme
– Keeptrackofentrywithlongest‐prefix(bynetmask)
• Overheadislinearinsizeofforwardingtable– Today,thatmeans350,000entries!– HowmuchPmedoyouhavetoprocess?
• Consider10Gbpsroutersand64Bpackets• 1010/8/64:19,531,250packetspersecond• 51nanosecondsperpacket
• Needgreaterefficiencytokeepupwithlinerate– BeAeralgorithms– HardwareimplementaPons
35
PatriciaTree(1968)• Storeprefixesasatree
– Onebitforeachleveloftree– Somenodescorrespondtovalidprefixes– ...whichhavenext‐hopinterfacesinatable
• Whenapacketarrives– TraversetreebasedondesPnaPonaddress– Stopuponreachinglongestmatchingprefix
36
0 1
00 10 11
100 101 00*
0*
11*
EvenFasterLookups• Patriciatreeisfasterthanlinearscan
– ProporPonaltonumberofbitsinaddress– Speed‐upfurtherbyPmevs.spacetradeoff
• Eachnodein4‐arytreehas4children,cutsdepthbyhalf
• SPllsomewhatslow,majorconcerninmid‐to‐late1990s– …aierCIDRwasintroducedandLPMmajorboAleneck– ReintroducPonofcircuitswitchingviapre‐establishedpaths:individualpathsnamedbylabelsaddedtopackets(MPLS)
• InnovaPonofspecialhardware– ContentAddressableMemories(CAMs):assoc.arrayinh/w
• Compareskeyinparalleltoeachentry– TernaryCAMs(TCAMS):Storeddatais0,1,<don’tcare>
• Leastsig.bitsrepresentedby<don’tcare>(netmask=0)
37
WheredoForwardingTablesComeFrom?
• EntriescanbestaPcallyconfigured– E.g.,“map12.34.158.0/24toSerial0/0.1”
• But,thisdoesn’tadapt– Tofailures,newequipment,…– Toneedtobalanceload,…
• Thatiswhereothertechnologiescomein…– RouPngprotocols,DHCP,andARP(laterincourse)
38
HowDoEndHostsForwardPackets?• Endhostwithsinglenetworkinterface• Don’tneedarouPngprotocol
– Packetstohostitself(e.g.,1.2.3.4/32)• Deliveredlocally
– PacketstootherhostsonLAN(e.g.,1.2.3.0/24)• Sentoutinterface:Broadcastmedium!
– Packetstoexternalhosts(e.g.,0.0.0.0/0)• Sentoutinterfacetolocalgateway
• HowisinformaPonlearned?– StaPcse{ngofaddress,subnetmask,andgateway– DynamicHostConfigProtocol(DHCP):Localservertellsyouse{ngswhenyoujoinnetwork
39
Conclusions• IPaddresses
– DoAed‐quadnotaPon– IPprefixesforaggregaPon
• AddressallocaPon– Classfuladdr’s,ClasslessrouPng(CIDR),FIBgrowth
• Packetforwarding– Forwardingtables– Longest‐prefixmatchforwarding– Whereforwardingtablescomefrom
• Nextlecture:Transportprotocols(UDPandTCP)• RouPngprotocolscomelater
40