Tải bản đầy đủ - 0 (trang)
Chapter 9. Choosing Shipping Options When Transporting the Goods over the (Network) Roadway

Chapter 9. Choosing Shipping Options When Transporting the Goods over the (Network) Roadway

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

goodsshippedsavemoney,andtheshippersmakemoney.

Asimilarthinghappenswithapplicationlayerprotocolsand

transportlayerprotocolsinnetworking.Theapplicationlayer

protocolsneedtosendandreceivemessagestoandfrom

anothercomputer.AsseeninChapter8,"ShippingGoodsover

a(Network)Roadway,"someofthosemessagesarejust

overhead,andsomecontaintheactualenduserdata.Lotsof

applicationlayerprotocolsneedthesamebasicservicesto

transporttheirmessagesacrossthenetworktoanother

computer.Similartocompaniesthatuseshippers,the

applicationlayerprotocolsdonotwanttoworryaboutthe

detailsofhowthedatagetsbetweenthecomputers.Theyjust

wanttogivethedatatosomeoneelse,withtheexpectation

thatthedatawillbedeliveredtotheapplicationlayersoftware

atthedestinationcomputer.

Inthischapter,you'lllearnabouthowtransportlayerprotocols

performseveralimportantfunctionsonbehalfofthemyriadof

applicationlayerprotocols,includingthedeliveryofapplication

layermessagesanddatabetweentwocomputers.



"Hello,I'matYourService"

"Hello,thisisFredatFred'sShippingCompany.HowcanIhelp

youtoday?"Yep,Fred,theowner,isansweringthephonesat

hissmallshippingcompany.He'swaitingforthephonetoring

sothathecansendhisonedriver,Barney,inhisonetruckto

pickupapackageanddeliveritacrosstown.Tobereadyfor

thatfirstphonecall,Fredboughtatruck;hiredBarney;gotan

office,phonelines,andInternetwebsite;anddidsome

advertising.Finally,thephonerang,givingFredhisfirst

opportunitytoshipthegoodsandmakesomemoney.

LikeFred,transportlayerprotocolsmustbepreparedforwhen

anapplicationlayerprotocolneedsitsservices.Ifyouuse

TCP/IPapplications,theapplicationlayerprotocolsuseTCP/IP

transportlayerprotocolstosendtheirmessagesacrossthe

network.Whereastheapplicationlayerprotocolsaretypically

partoftheapplicationsoftware,thetransportlayerprotocols

aretypicallypartoftheoperatingsystem(OS)ofthe

computer.So,thetransportlayersoftwarehangsaround,

waitingontheapplicationprogramspecificallythepartofthe

applicationprogramthatimplementstheapplicationlayer

protocolstoaskittodosomething.Figure9-1depictsthe

generalidea.



Figure9-1.ApplicationProgramandApplication

LayerAskingtheTransportLayerforHelp



[Viewfullsizeimage]



AsshowninFigure8-4inthepreviouschapter,theapplication

programincludestheuserinterfaceandtheapplicationlayer

protocols.InFigure8-6,yousawsomeoftheSMTPmessages

thatwereusedtosende-mail.Thatfigureandseveralothersin

Chapter8showedthemessagesgoingbackandforthbetween

twoPCs.Inreality,whenane-mailclientliketheoneinFigure

9-1sendsthesetypesofmessages,itasksforatransportlayer

protocoltohelp.

Generallyspeaking,whenThoseWhoCameBeforeUscreated

networkingmodelslikeTCP/IP,theydefinedabunchof

protocols.Asitturnsout,theprotocolsatonelayerprovide

servicestotheprotocolsatonelayerabove.Conversely,

protocolsatonelayerexpectservicesfromprotocolsthatare

onelayerbelow.Inthischapter,you'llreadabouthowthe

applicationlayerprotocolssuchasSMTPexpectthetransport

layerprotocols,suchasTCP,toprovidetheserviceof

transportingthedataacrossthenetwork.



Full-ServiceShipping

Justlikeacompanycancreateitsownshippingdepartment,an

applicationlayerprotocolcouldavoidusingatransportlayer

protocol,butitalmostneverhappens.Why?Well,thetransport

layerprotocolsalreadyexist.Theyprovidegreatservicesthat

manyapplicationsneed.Ittakesalotlesstimeandeffortfor

theapplicationtouseatransportlayerprotocol.Inshort,it's

better,faster,cheaper,andsimplerforanapplicationtousea

transportlayerprotocol.

So,whatdothesetransportlayerprotocolsdoforthe

application?Thischapterfocusesononeofthoseprotocolsin

particularTransmissionControlProtocol(TCP),whichis

definedinRFC793.TCP/IPdoeshaveanothertransportlayer

protocolUserDatagramProtocol(UDP)butTCPismuchmore

interesting.TCPprovidesalotoffeatures,andUDPdoesn't.You

canthinkofTCPasprovidingpremiumserviceandUDPas

providingcheapservice.

ThischapterwillhitthehighpointsofTCP,suchas

Deliveringapplicationdatathroughencapsulation

Breakinglargeshipmentsintomanageablesizesusing

segmentation

Ensuringdeliverythrougherrorrecovery

Gettingthedatatotherightindividualprogram,notjust

therightcomputer,byusingportnumbers

Simplifyingthecreationofapplicationsbyhidingthedetails

ofdatadeliveryfromtheapplication



You'lllearnabouteachofthesefeaturesinthenextfour

sectionsofthischapter.



ShippingBasics:ControllingShipmentsUsing

ShippingLabels

Whenyoudecidetoshipapackageusinganywell-known

shippingcompany,youfilloutashippinglabel,attachittothe

package,andleavethepackagewheretheshipperwillfindit

whenhestopsbythatday.Inshort,youtelltheshipperwhere

tosendthepackageandthenchooseamongseveraloptionsfor

delivery.Magically,thepackageappearsatthecorrect

destination.

Althoughyoumightthinkthatshippinglabelsareratherboring,

thereareacoupleofkeyfactsaboutthemthatarepractically

identicaltoTCP.Forinstance,shippinglabels

Includetheshipper'saddressontheform

Includetherecipient'saddressontheform

Specifyotheroptions,suchasspeedofdelivery,insurance,

andphonenumbersincasethereisaproblem

Puteachbitofinformationinthesameplace,everytime

Ensurethateveryonewhotouchesthepackageatvarious

pointsinitstripknowsexactlywhattodowiththepackage

Okay,backtonetworking.Theterm"encapsulation"refersto

thesamegeneralideafornetworkingasdoestheshippinglabel

forshippingpackages.Forexample,Figure9-2illustratesa

moredetailedexampleofasimpleHTTPGETrequestfora



homepage,withTCPencapsulationshown.Keith'sbrowser

requeststhehomepage.However,thebrowserdoesnot

actuallysendtherequestoverthenetwork;itsimplyasksthe

TCPsoftwareonKeith'scomputertosendthedataforit.(In

thischapter,Iamignoringothernetworkdetailssuchasthe

physicaltransmissionbutthatdoeshappenaswell.)



Figure9-2.AddingShippingInformationtoData

byEncapsulatinginaTCPHeader



[Viewfullsizeimage]



Keith'sTCPsoftware,whichistypicallyjustapartoftheOS,is

inchargeofdeliveringthedatatothewebserver.TCPprovides

severalservices,soitneedsaplacetorecordsomeinformation

aboutthoseservices.Therefore,TCPdefinesaheader.As

mentionedinChapter5,"RulesoftheRoad:HowtoUsethe

Local(Network)Roadway,"aheaderisabunchofoverheadbits

thatanetworkingprotocoladdstosomedata.Theprotocolthat

addstheheaderTCPinthiscaseusesthosebitstorecordthings

itneedstoknowtodoitsjob.Manyoftheupcomingfeatures

coveredinthischapterrecordinformationintheTCPheaderto

performsomeusefulfunction.



TheprocessofaddingtheTCPheadertotheapplicationdatais

calledencapsulation.RefertoChapter5forareviewof

encapsulation.

ImaginethatPauldrivesatruckfortheshippingcompany.He

getstoworkeachmorning,andsomeonehasloadedthetruck.

Hegetsin,startsdriving,andstopstodropoffandpickup

packages.

Pauldoesn'tcarewhat'sinsidethepackages.Hemightcarea

littleaboutthesizeofthepackages,particularlyifapackageis

toolargeorheavytomove.Really,hejustcaresaboutwhat's

ontheshippinglabelandmakingsurehedeliversthepackage

totherightplace.

Similarly,TCPdoesn'treallycarewhatdatait'sdeliveringto

anothercomputer.Figure9-3showsTCP'sperspectiveonwhat

reallyhappensinFigure9-2.



Figure9-3.TCPTreatsAlltheDataasData



TCPjustneedstoworryabouttheTCPheaderanddoingwhatit

says.Inthiscase,aslongasTCPgetsthefirstchunkofdatato

theserverandthesecondchunkbackfromtheservertothe

browser,itsjobisfinished.

TCPcallstheTCPheaderandthedatabehinditaTCP

segment.Laterinthischapter,inthesectiontitled"BigBox,

SmallTruckWhatDoYouDo?,"itwillbeclearwhythepeople

whomadeupTCPchosetocallitasegment.



Oneofthelargestbenefitsofalayerednetworkingmodel

relatestohowTCPbehavesinFigure9-3.ThefactthatTCP

doesn'thavetothinkaboutwhatHTTPistryingtodomeans

thattheTCPsoftwaredoesnotneedtoknowanythingabout

howHTTPworks.So,thepersonwhowritestheTCPsoftware

cankeepitsimple.ThepersonwhowritesHTTPsoftwareand

anyotherapplicationprotocolthatintendstouseTCPcankeep

itsimpleaswell,relyingonTCPtodeliverthedata.

Ifyou'refeelingalittleuncomfortableaboutTCPatthispoint,

it'sokay.Sofar,thischapterhasdescribedsomemechanisms

thatTCPuses,butithasn'texplainedmuchaboutwhyTCPis

usefultoapplications.Inthenextsection,you'lllearnabout

errorrecoveryoneofthemostimportantfeaturesofTCP.



PurchasingInsuranceforYour(Network)

Shipment

Whenyoushipsomethingvaluable,youmightchoosetospend

someextramoneytobuyinsurance.Then,iftheshipperloses

ordamagesthepackage,theshipperpaysyoutoreplacewhat

youshipped.

WithTCP,yougetsomethingalittlebetter.Witharealphysical

package,ifitgetslost,it'slost.Ifyouloseabunchofbits,

though,youcanmakemore!Infact,Chapter3,"Buildinga

Network:ItAllStartswithaPlan,"coveredthebasicidea,

whichI'llrepeatinFigure9-4foraquickreview.



Figure9-4.AssuringDataDelivery



InFigure9-4,Wilma'scomputerissendingthreeTCPsegments

toFred.Thesecondsegmentexperiencedsomeerrorsduring

transmission,andFrednoticedthaterrorshadoccurred.How

didheknowerrorshadoccurred?Well,youmightrecallthe

framechecksequence(FCS)fieldinEthernetthattellsyou

whethersomethingtransmittedoveraLANhaderrors.Although

thischapterdoesn'tconsiderEthernetmuch,imaginethatan

Ethernetisinuse,andthatFreddoesindeednoticethatthe

framehadanerror.

Theprocessissimple:Thesender(Wilma)numberedthe

segmentssothatifonegotlost,Fredcouldnotonlyknowthat

onesegmenthaderrors,buthecouldaskforthemissing

numberedsegment.So,FredasksWilmatoresendsegment2.

Inthenexttwosections,you'llreadabouthowTCPdetermines

whichsegmentsweredeliveredsuccessfully,andthenhowTCP

noticesthatsegmentswerelostandneedtoberecovered.



TheMechanicsofDeliveryConfirmation

TCPusesthesamemechanismstobothconfirmthatdatawas



delivered,aswellastonoticewhendatawasn'tdeliveredand

thentoperformerrorrecovery.Todoallthesethings,TCPputs

theinterestinginformationinFigure9-5intotheTCPheader.

First,lookatafullTCPheaderinFigure9-5.ThenI'lltellyou

aboutthepartsoftheheaderthatareusedforerrorrecovery.



Figure9-5.TheFormatoftheShippingLabel:TCP

Headers



WhenTCPaddstheheader,ithasseveraldifferentfieldstouse.

Forerrorrecovery,itusesthesequencenumberand

acknowledgmentnumberfields.Thesequencenumber

identifiesthesegment,andtheacknowledgementnumberis

usedwhenanerroroccurs.

Figure9-6showsthesequenceandacknowledgementnumber

fieldsinaction,whennoerrorsoccur.



Figure9-6.DeliveryConfirmation,NoErrors



InFigure9-6,TCPconfirmsdeliveryofeachsegmentusingthe

sequenceandacknowledgmentnumberfields.However,the

acknowledgmentnumberlooksalittlefunny.Wilmanumbered

thesegments1,2,and3,butnoticethatFredsentbackan

ACKfieldof4.TheACKfieldmeansthatthisnumberisthe

numberofthenextsegmentFredexpectstoreceive.So,Fred

isreallymeaning,"Igoteverythinguptonumber4,sosend

me4next."Byimplication,Fredgot1,2,and3,respectively,

becausehesettheacknowledgmentfieldtothenextnumber4

inthiscase.Theuseoftheacknowledgmentfieldtoimplythe

nextsegmentthatshouldbereceivediscalledforward

acknowledgment.

Byusingthesequencenumberfieldinthesegmentsitsends

andwatchingtheacknowledgmentnumberfieldinthesegment

itreceives,Wilma'sTCPsoftwarecanknowthatallthree

segmentsweredeliveredsuccessfullytoFred.Next,you'llsee

howWilmadealswiththelossofasegment.



LoseAllYouWantWe'llMakeMore

So,backtoerrorrecovery.Figure9-7showsacaseinwhicha

segmenthaserrors(segmenttwo),withFredsendinga

segmentwithACKof2.



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

Chapter 9. Choosing Shipping Options When Transporting the Goods over the (Network) Roadway

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

×