ExercisesReviewforChapter5&65.5•ConsiderthesubnetofFig.5-12(a).Distancevectorroutingisused,andthefollowingvectorshavejustcomeintorouterC:fromB:(5,0,8,12,6,2);fromD:(16,12,6,0,9,10);andfromE:(7,6,3,9,0,4).ThemeasureddelaystoB,D,andE,are6,3,and5,respectively.WhatisC'snewroutingtable?Giveboththeoutgoinglinetouseandthecost.65DVR算法来自邻居们的消息B:(A5,B0,C8,D12,E6,F2);D:(A16,B12,C6,D0,E9,F10);E:(A7,B6,C3,D9,E0,F4).自己测量的delaysfromCtoB,D,andEare6,3,and5,GoingviaBgives(A11,B6,C14,D18,E12,F8).GoingviaDgives(19,15,9,3,9,10).GoingviaEgives(12,11,8,14,5,9).TakingtheminimumforeachdestinationexceptCgivesC:(11,6,0,3,5,8).(B,B,–,D,E,B)Theseareoutgoinglines.路由器C更新后的路由表说明:到A,最近距离为11,从B走;到B,距离为6,从B走;到C吗?就是我这里;……到F距离为8,从B走最近。65655.23Supposethatinsteadofusing16bitsforthenetworkpartofaclassBaddressoriginally,20bitshadbeenused.HowmanyclassBnetworkswouldtherehavebeen?假设B类地址用20bit作为网络号,而不是16bit,总共有多少个B类网?解答:•Witha2-bitprefix,therewouldhavebeen18bitsleftovertoindicatethenetwork.去除2bit类别号(“10”),还有20-2=18bit代表网络号•Consequently,thenumberofnetworkswouldhavebeen2^18or262,144.However,all0sandall1sarespecial,soonly262,142areavailable.2^18=262144,全0和全1是特殊地址,不分配给网络用,故共有262142个B类网5.24•ConverttheIPaddresswhosehexadecimalrepresentation十六进制表示isC22F1582todotteddecimalnotation点分十进制•Theaddressis194.47.21.130.5.25AnetworkontheInternethasasubnetmaskof255.255.240.0.Whatisthemaximumnumberofhostsitcanhandle?因特网上一个子网的掩码为255.255.240.0,它最多能容纳多少台主机?AclassBnetworkontheInternethasasubnetmaskof255.255.240.0.Howmanysubnetsinit?AndWhatisthemaximumnumberofhostseachsubnetcanhandle?Internet上的一个B类网络的子网掩码为255.255.240.0,问该网络划分了多少个子网?每个子网最多可以有多少台主机?解答:255.255.240.0=11111111.11111111.11110000.0000000020个1对应网络号和子网号;12个0对应主机编号。Themaskis20bitslong,sothenetworkpartis20bits.Theremaining12bitsareforthehost,so2^12=4096hostaddressesexist.•已知一台主机的IP地址为202.200.10.66,掩码为255.255.255.192。求:–该主机所在的网络分了多少个子网?2^2=4–它是位于哪个子网中?编号为01的子网–主机号是多少?•255.255.255.192=1111111,11111111,1111111,1100000•202.200.10.66=11001010.…………01000010C类网•默认掩码255.255.255.0=1111111,11111111,1111111,0000005.27AlargenumberofconsecutiveIPaddressareavailablestartingat198.16.0.0.Supposethatfourorganizations,A,B,C,andD,request4000,2000,4000,and8000addresses,respectively,andinthatorder.Foreachofthese,givethefirstIPaddressassigned,thelastIPaddressassigned,andthemaskinthew.x.y.z/snotation.•Answer:Tostartwith,alltherequestsareroundeduptoapoweroftwo.40004096,20002048.Thestartingaddress,endingaddress,andmaskareasfollows:•A:198.16.0.0–198.16.15.255writtenas198.16.0.0/20•B:198.16.16.0–198.16.23.255writtenas198.16.16.0/21IfCstartat198.16.24.0……Bendsat198.16.23.255,IfCstartat198.16.24.0=198.16.00011000.00000000~198.16.00011111.11111111only2K198.16.00100000.00000000~198.16.00100111.11111111another2k,enough.Butwhataboutitsmask?Themaskisthelengthofinvariablepartofitaddresses.So,hereare18bits.Thatistosay,Chas32-18=14bit-hostnumber,2^14=16Kaddresses!Cmuststartfrom198.16.00100000.00000000,andletlast12bitschangeashostnumber•C:198.16.32.0–198.16.47.255writtenas198.16.32.0/20•D:198.16.64.0–198.16.95.255writtenas198.16.64.0/19教材P465例子1)2048=2^1111bit作为主机号194.24.0.0~194.24.7.255/212)4096=2^12194.24.8.0=194.24.00001000.00000000后面的零位变化不够4k若从194.24.16.0=194.24.00010000.00000000开始,后面12位刚好够194.24.16.0~194.24.31.255/203)194.24.8.0~194.24.00001011.11111111=194.24.11.255/225.28ArouterhasjustreceivedthefollowingnewIPaddresses:57.6.96.0/21,57.6.104.0/21,57.6.112.0/21,and57.6.120.0/21.Ifallofthemusethesameoutgoingline,cantheybeaggregated?Ifso,towhat?Ifnot,whynot?•Theycanbeaggregatedto57.6.96/19sincetheirfirst19bitsarecommon.5.30Arouterhasthefollowing(CIDR)entriesinitsroutingtable:Address/maskNexthop135.46.56.0/22Interface0135.46.60.0/22Interface1192.53.40.0/23Router1DefaultRouter2ForeachofthefollowingIPaddresses,whatdoestherouterdoifapacketwiththataddressarrives?(a)135.46.63.10(b)135.46.57.14(c)135.46.52.2(d)192.53.40.7(e)192.53.56.7Thepacketsareroutedasfollows:(a)Interface1(b)Interface0(c)Router2(d)Router1(e)Router26.11•WhydoesUDPexist?WoulditnothavebeenenoughtojustletuserprocessessendrawIPpackets?•Answer:No.IPpacketscontainIPaddresses,whichspecifyadestinationmachine.Oncesuchapacketarrived,howwouldthenetworkhandlerknowwhichprocesstogiveitto?UDPpacketscontainadestinationport.Thisinformationisessentialsotheycanbedeliveredtothecorrectprocess.IP包的地址只能指定目标计算机。到达那台计算机后,把IP包交给哪个进程呢?UDP包包含了目标端口,那就是正确的接收进程。6.15BothUDPandTCPuseportnumberstoidentifythedestinationentitywhendeliveringamessage.GivetworeasonsforwhytheseprotocolsinventedanewabstractID(portnumbers),insteadofusingprocessIDs,whichalreadyexistedwhentheseprotocolsweredesigned.UDP和TCP传递消息时都使用端口号来标识目的实体。请给出2个理由,说明为什么这些协议发明一种抽象的ID号(端口号),而不使用进程ID这种在UDP和TCP协议设计之时早已存在的标识符。•First,processIDsareOS-specific.UsingprocessIDswouldhavemadetheseprotocolsOS-dependent.•Second,asingleprocessmayestablishmultiplechannelsofcommunications.AsingleprocessID(perprocess)asthedestinationidentifiercannotbeusedtodistinguishbetween•thesechannels.•Third,havingprocesseslistenonwell-knownportsiseasy,butwell-knownprocessIDsareimpossible.Answer