Tải bản đầy đủ - 0 (trang)
Chapter 10. Delivering the Goods to the Right Street (IP) Address

Chapter 10. Delivering the Goods to the Right Street (IP) Address

Tải bản đầy đủ - 0trang

computertoanother.So,althoughahumanmightprefertouse

nameslikehttp://www.cisco.com,computersandroutersprefer

toforwarddatatohttp://www.cisco.comusingtheserver's

numericaddress,suchas198.133.219.25.

Intheprevioustwochapters,youfocusedonapplication

protocolsandhowtheyuseTCPforsomecommonfunctions.

However,tofocusonthoseprotocols,thosechaptersavoided

severalissues.Forinstance,whenausertypes

http://www.cisco.com,howdoessheknowwheretheweb

serveris?HowdoesthePCknowwheretosendthedata?

AssumingCisco'swebserverisonadifferentLANwhichis

likelyhowdoothernetworkingdevices,suchasrouters,know

howtodeliverthebitstothewebserver?

Thenextfourchaptersfinallygetaroundtoansweringthose

questions.Inthischapter,youlearnsomeimportantdetails

abouttheInternetProtocol(IP),includinghowIPaddresses

work.



NavigationBasics:DrivingtotheRight

Destination

Whenyouwanttodrivesomewherenearyourhouse,yougetin

yourcar,driveonthelocalroads,andgetthere.Whenyou

needtodrivealongerdistance,saytoanothertown,you

probablystartoffonthosesamelocalroadsbutthengetona

highway.Afteryoudrivefarenoughtogettothattown,youget

offthehighwayandusethetown'slocalroadstogettowhere

youwanttogo.

Now,imaginethatyouhaveavisitorstayingatyourhouse,and

hewantstodrivetothatnexttown.Youcouldtellhimtodrive

downtheroadthatrunspastyourhouseuntilhereachesthe

firstintersection,andthenfollowtheroadsigns.Yourfriend

couldsimplylookattheroadsignatthatintersection,which

tellshimwheretoturn.Ifhereadstheroadsignateach

intersection,hemightmakealotofturns,buthewilleventually

getwherehewantstogo,aslongastheroadsignslistthe

towntowhichhewantstodrive.

InTCP/IPnetworks,routersactasintersections,withtherouter

makingthechoiceaboutwhatdirectiontoforwarddata

packets.Inatypicallargenetwork,manyroutersandLAN

switchessitbetweenaclientPCandaserver.Whenone

computersendsdatatoanothercomputer,theroutersmake

decisionsaboutwheretoforwardthedatasothatitreachesthe

correctdestination.Forexample,inFigure10-1,auser

(Hannah)onaLANinMasonwantstogetawebpagefroma

webserver(http://www.cisco.com)onaLANinCincinnati.At

somepoint,Hannah'sPCsendstheinitialHTTPGETrequestto

thewebserver.Thefigureshowsthatinitialrequest,withthe

routersdecidingwheretoforwardthedatasothatitreaches

thewebserver.



Figure10-1.Navigating(Routing)WhenGoing

fromMasonandCincinnati



[Viewfullsizeimage]



Thecylindricaliconsinthefigurerepresentrouters,andthe

rectangulariconsrepresentEthernetLANswitches.Routersare

networkingdevicesthatconnecttomultiplephysicalnetworks,

suchasthemultipleEthernetnetworksinthefigure.Routers

alsoforwarddatafromonenetworktothenext.Whenyou

driveinyourcarandreachanintersection,theroadsignstell

youwheretoturn;innetworking,therouterscreatethe

equivalentofaroadsign,buttheroutertellsthedatapackets

whichwaytoturn.Thecompleteprocessbywhichacomputer

sendsthedata,passingthoughalltheroutersandeventually

arrivingatthedestination,iscalledrouting.Thefollowinglist

showsthethreemainroutingstepsinFigure10-1:

1. HannahsendsherdatatoR1,muchlikeadrivermightdrive

towherehecangetontheinterstatehighway.Tosendthe

datatoR1,Hannah'sPCsendsanEthernetframetoR1's

MACaddress,muchlikeadrivermightuselocalroadsto

reachtheon-ramptothehighway.



2. R1knowsthattogetthedatatoacomputerinCincinnati,it

mustforwardthedatatoR2,insteadofsendingthedatato

R3next.Thisprocessismuchlikeadriverchoosingwhich

directiontogoontheinterstatehighway,basedontheroad

signs.(BecausethephysicalnetworkbetweenR1andR2is

anEthernet,R1forwardsthedatatoR2usinganEthernet

frame.)

3. R2sendsthedatatothedestinationcomputerovertheLAN

muchlikethedriverfinisheshistripbygettingoffthe

interstatehighwayanddrivingoverthelocalroadsin

Cincinnati.



Ifyouconsiderthesestepsalittlemoreclosely,threedevices

needtoforwardthedataatsomepoint:Hannah,R1,andR2,in

succession.Eachtime,togetthedatatothenextdevice,the

devicesneedtosendthedataoveranEthernetLANandyou

alreadyknowhowthatworksfromreadingChapters4,"Howto

BuildaLocal(Network)Roadway,"through7,"AddingLocal

(Network)RoadwaysforNoExtraMoney."Insequence,Hannah

usesEthernettosendthedatatoR1;R1usesthesecond

EthernetnetworktosendthedatatoR2;finally,R2usesthe

thirdEthernettosendthedatatothewebserver.



note

AsImentionedbefore,theword"network"canbeusedinalotof

differentways.Inonewayofthinking,Figure10-1showsasingle

network,butinanotherwayofthinking,itshowsfourEthernet

networks,whicharethenseparatedbythreerouters.Anotherrelated

term,calledinternetwork,issometimesusedwhenyouneedamore

exactterm.IfyouconsidereachofthefourEthernetsinFigure10-1as

individualnetworks,youcanthinkofthewholediagramasan

internetwork,whichisshortfor"interconnectednetworks."Keepin

mindthatpeopleusetheterm"network"inalotofdifferentways.



AlthoughFigure10-1showsonlyLANs,therouterscouldbe

connectedtoawide-areanetwork(WAN).Infact,oneofthe

mainbenefitsofrouters,besideshelpingforwarddatathrough

thenetwork,istoconnecttomanydifferenttypesofphysical

networks.Inlaterchapters,particularlyinChapters14,

"Leasinga(Network)RoadwayBetweenTwoPoints,"and

Chapter15,"Leasinga(Network)RoadwayBetweenLotsof

Places,"youwilllearnhowroutersuseWANstotransmitdata,

muchliketheycanuseLANstotransmitdata.Regardless,the

basicprocessofroutinghappensthesameway,whetheryou

useLANs,WANs,oracombinationofthetwo.Infact,oneof

thereasonsthatroutersarepopularisbecausetheycan

connectmanydifferenttypesofphysicalnetworkswithease.

Thisfirstsimpleexampleportraystheconceptsofrouting,

whichistheoverallprocessbywhichcomputersandrouters

togetherforwardthedatatothecorrectdestination.To

appreciatemoreofthedetailsofrouting,youneedtohavea

betterunderstandingofIP,IPaddresses,andhowtheyaffect

routing.



IPasthePostmasterGeneraloftheNetwork

TheU.S.PostalService(USPS)usesanaddresssystemthat

consistsofanumber,streetnameonwhichthebuildingis

located,townorcity,state,andzipcode.TheUSPSintended

foreachaddressinthecountrytobeuniqueinsomeway.Ina

givenstate,alltownsmusthavedifferentnames.Ineachtown,

eachstreetmusthaveadifferentname.Finally,oneachstreet,

eachbuildingmusthaveadifferentnumber.Thissystemallows

eachaddressinthecountrytobeunique.Byhavingunique

addresses,thepostalservicedoesn'tgetconfusedaboutwhere

tosendaletter.

Thepostalserviceincludesinformationintheaddresssothat

sortingthemailismadeaseasyaspossible.Apostalworkerin

GeorgiacanseealetteraddressedtosomeoneinOhioand

makeachoicetoimmediatelysortthatletterintothebagthat's

beingsenttoOhio.AftertheletterisinOhio,themailsorter

canlookforthenameofthetownandsendtheletterthere.At

thelocalpostofficeforthattown,thepostalsortercanlookat

thestreetaddress.So,theprocessofsortingissimplifiedby

theinformationintheaddress.

IPistheTCP/IPprotocolthatmostcloselymatchesLayer3in

theOSInetworkingmodel.IPdefinesaddressing,aswellas

routing,includingtheunderlyingdetailsoftheroutingexample

inFigure10-1.Likethepostalservice,IPdefinesaddressesso

thattheyhavestructure,allowingeasyroutingthenetworking

equivalentofmailsorting.IPalsostatesthateveryoneshould

haveauniqueIPaddress(justliketheUSPSrequiresunique

postaladdresses)toavoidconfusionwhentryingtodeliverdata

tothataddress.Thepostalservicedefinesaddressingdetailsso

thatlettercarrierscaneasilyandefficientlydeliverthemail;

similarly,IPdefinesIPaddressingdetailstofacilitateeasyand

efficientforwardingofIPpackets.

EachnetworkinterfaceonacomputerneedsanIPaddress.A



networkinterfaceissimplyacardinsideacomputerthathas

aphysicalconnectorforsometypeofnetwork,suchasan

Ethernetnetworkinterfacecard(NIC).TheNICtakescareof

TCP/IPnetworkinterfacelayerdetails,whicharetheequivalent

ofOSILayers1and2.TheTCP/IPinternetworkinglayer,

implementedbytheIPprotocol,definestheselogicalIP

addresses.Mostendusercomputershaveasinglenetwork

interface,meaningthatthecomputerhasonlyoneIPaddress.

However,anydevicethathasatleastoneIPaddresscansend

andreceiveIPpacketsandisconsideredtobeaTCP/IPhost,

orsimplyhost.

Devicesthathavemorethanonenetworkinterfacehavemore

thanoneIPaddress.Routerstypicallyhavemultiplenetwork

interfaces,andsomeservershavemultipleinterfacesaswell.

IPaddressesare32-bitbinarynumbers,butbecausehumans

wouldfinditinconvenienttowritedown32-bitnumbers,the

addressesarewrittenindecimal.TheformatofIPaddressesis

oftencalledcanonicalformat;sometimesit'scalleddotted

decimalformat.Forexample,thenexttwolinesshowthe

binaryversionofanIPaddress,followedbythesameIP

addresswrittenasadotted-decimalnumber.It'sobviousfrom

comparingthetwothat,givenachoice,it'smucheasiertowork

withthedecimalversion:

000010000000010000000010000000001

8.4.2.1

EachofthedecimalnumbersinanIPaddressiscalledan

octet.(Thetermoctetisjustanothertermforthewordbyte.)

So,eachdecimaloctetrepresents8bitsoftheIPaddress,and

with4octets(separatedbyperiods),thewholedotteddecimal

IPaddressrepresents32bits.

AppendixB,"ConvertingIPAddressesBetweenDecimaland



Binary,"explainshowyoucanconvertbackandforthbetween

thebinaryanddecimalversionsofanIPaddress.Youreally

don'tneedtothinkaboutIPaddressesinbinarytolearnwhat's

coveredinthischapter.However,ifyouwouldliketo

understandmoreaboutconvertingbetweenbinaryanddecimal

formatsofIPaddresses,feelfreetoreadAppendixB.



KnowingtheAddressBeforeDrivingtothe

Destination

Let'sgetbacktothemoreimportantconceptualdetails.When

youuseashippingcompanytosendapackagetosomeone,

youfilloutashippinglabel,whichincludesthestreetaddressto

whichyouaresendingthepackage.Ifyoufilloutthewhole

label,youalsoputyourreturnaddressonthelabel,soincase

there'saproblem,theshippercanreturnthepackagetoyou.

Similarly,IPdefinesaheaderthatincludesasourceand

destinationIPaddress.So,tosenddatafromonecomputerto

theother,thesenderputsthedestinationcomputer'sIP

addressintothedestinationIPaddressfieldintheIPheader.

Similarly,thesenderputsitsownIPaddressinthesourceIP

addressfieldintheheader.

Figure10-2showsthesamenetworkasFigure10-1,butitnow

showsHannah'sIPaddress,aswellthewebserver's.Itshowsa

singleIPpacket,sentbyHannah,totheserver.



Figure10-2.UsingAddressesonthe(IP)

ShippingLabel



[Viewfullsizeimage]



IPdefinesa20-bytelongheader,whichincludesa4-byte

sourceIPaddressanda4-bytedestinationIPaddress.AnIP

packetincludestheIPheader,alongwithanydatathatfollows

theIPheader.AlthoughotherpartsoftheIPheaderare

interesting,theaddressfieldsarecrucial.



note

YoumightrecallthatEthernetincludesasourceanddestination

EthernetaddressfieldintheEthernetheader,andthatthoseaddresses

are6byteslongeach.TheIPaddressesmentionedhereareindeed

differentaddresses,andtheyareusedtoallownetworkingdevicesto

senddataoveralargenetworkthatincludesothertypesofphysical

networksbesidesEthernet.



Whensendingapacket,thedestinationIPaddressfieldinthe

IPheaderdefineswherethepacketshouldbesent.The

computers,andtheroutersbetweenthem,understandthatthe

packetshouldbeforwardedbasedonthedestinationIP

address.ThesourceIPaddressintheheaderisalsoimportant

becauseafterthepacketisdeliveredtothedestination

computer,itwillwanttoreply.ThatcomputerknowstheIP

addressofthecomputerthatsenttheoriginalpacketbylooking

atthesourceIPaddress.Forinstance,inFigure10-2,whenthe

webservergetsthepacketandneedstorespond,itknowsto

sendtheresponsepacketto1.1.1.1.

Theterm"packet"hasaspecificmeaninginnetworking.It

impliessomedatathatincludestheLayer3header,plusany

encapsulateddata.IntheTCP/IPnetworkingmodel,IPisthe

Layer3protocol,soanIPheaderandthedatathatfollowsit

areIPpackets.Theterm"segment,"whichyoureadaboutin

Chapter9,"ChoosingShippingOptionsWhenTransporting

Goodsoverthe(Network)Roadway,"referstodatathat

includestheLayer4header(TCP)andanyencapsulateddata.

Thedifferencebetweenapacketandasegmentisthata

segmentdoesnotincludetheLayer3header,butapacket

does.



Asareminder,youmightalsorecallfromChapter5,"Rulesof

theRoad:HowtoUsetheLocal(Network)Roadway,"thatthe

term"frame"referstoadatalinkheaderanditsencapsulated

data.Inthatchapter,anEthernetheaderandtrailer

encapsulatedsomedatatosendthedataoveranEthernetLAN.

It'scommontousetheterm"frame"torefertothedatalink

header,trailer,anddata;"packet"torefertothenetworklayer

(IP)headeranddata;and"segment"torefertothetransport

layer(TCP)headeranddata.

Whensendingdata,theIPsoftwareonacomputer(Hannahin

thisexample)encapsulatesthehigher-layerdatainsideanIP

packet.Foramoredetailedappreciationofthatconcept,think

backtotheHTTPcoverageinChapter8,"ShippingGoodsover

a(Network)Roadway,"andChapter9'scoverageofTCP.For

Hannahtogetthewebpage,shemustsendanHTTPGET

request.TosendHTTPmessages,shemustuseTCP.Asitturns

out,todelivertheTCPsegmenttotheothercomputer,TCP

mustuseIP.Figure10-3showstheprocessofgettingahome

pagewithmoredetail,includingtheIPheadersandIPpackets.



Figure10-3.IPPackets,IncludingDetailsAbout

theData



[Viewfullsizeimage]



Onasinglecomputer,thedifferentlayersintheTCP/IPmodel



Tài liệu bạn tìm kiếm đã sẵn sàng tải về

Chapter 10. Delivering the Goods to the Right Street (IP) Address

Tải bản đầy đủ ngay(0 tr)

×