Você está na página 1de 8

HowTCP/IPWorks

ByJoeCasad
Date:Jan18,2012
SampleChapterisprovidedcourtesyofSamsPublishing.
Returntothearticle
ThischapterdescribestheTCP/IPprotocolsystemandshowshowthecomponentsofTCP/IPworktogetherto
sendandreceivedataacrossthenetwork.
WhatYoullLearninThisHour:
TCP/IPprotocolsystem
TheOSImodel
Datapackages
HowTCP/IPprotocolsinteract
TCP/IPisasystem(orsuite)ofprotocols,andaprotocolisasystemofrulesandprocedures.Forthemostpart,
thehardwareandsoftwareofthecommunicatingcomputerscarryouttherulesofTCP/IPcommunicationsthe
userdoesnothavetogetinvolvedwiththedetails.Still,aworkingknowledgeofTCP/IPisessentialifyouwantto
navigatethroughtheconfigurationandtroubleshootproblemsyoullfacewithTCP/IPnetworks.
ThishourdescribestheTCP/IPprotocolsystemandshowshowthecomponentsofTCP/IPworktogethertosend
andreceivedataacrossthenetwork.
Atthecompletionofthishour,youwillbeableto
DescribethelayersoftheTCP/IPprotocolsystemandthepurposeofeachlayer
DescribethelayersoftheOSIprotocolmodelandexplainhowtheOSIlayersrelatetoTCP/IP
ExplainTCP/IPprotocolheadersandhowdataisenclosedwithheaderinformationateachlayerofthe
protocolstack
NamethedatapackageateachlayeroftheTCP/IPstack
DiscusstheTCP,UDP,andIPprotocolsandhowtheyworktogethertoprovideTCP/IPfunctionality

TheTCP/IPProtocolSystem
BeforelookingattheelementsofTCP/IP,itisbesttobeginwithabriefreviewoftheresponsibilitiesofaprotocol
system.
AprotocolsystemsuchasTCP/IPmustberesponsibleforthefollowingtasks:
Dividingmessagesintomanageablechunksofdatathatwillpassefficientlythroughthetransmission
medium.
Interfacingwiththenetworkadapterhardware.
Addressing:Thesendingcomputermustbecapableoftargetingdatatoareceivingcomputer.The
receivingcomputermustbecapableofrecognizingamessagethatitissupposedtoreceive.
Routingdatatothesubnetofthedestinationcomputer,evenifthesourcesubnetandthedestination
subnetaredissimilarphysicalnetworks.
Performingerrorcontrol,flowcontrol,andacknowledgment:Forreliablecommunication,thesendingand
receivingcomputersmustbeabletoidentifyandcorrectfaultytransmissionsandcontroltheflowofdata.
Acceptingdatafromanapplicationandpassingittothenetwork.
Receivingdatafromthenetworkandpassingittoanapplication.
Toaccomplishtheprecedingtasks,thecreatorsofTCP/IPsettledonamodulardesign.TheTCP/IPprotocol
systemisdividedintoseparatecomponentsthattheoreticallyfunctionindependentlyfromoneanother.Each
componentisresponsibleforapieceofthecommunicationprocess.

Theadvantageofthismodulardesignisthatitletsvendorseasilyadapttheprotocolsoftwaretospecifichardware
andoperatingsystems.Forinstance,theNetworkAccesslayer(asyoulearninHour3,TheNetworkAccess
Layer)includesfunctionsrelatingtothespecificationanddesignofthephysicalnetwork.BecauseofTCP/IPs
modulardesign,avendorsuchasMicrosoftdoesnothavetobuildacompletelydifferentsoftwarepackagefor
TCP/IPonanopticalfibernetwork(asopposedtoTCP/IPonanordinaryethernetnetwork).Theupperlayersare
notaffectedbythedifferentphysicalarchitectureonlytheNetworkAccesslayermustchange.
TheTCP/IPprotocolsystemissubdividedintolayeredcomponents,eachofwhichperformsspecificduties(see
Figure2.1).Thismodel,orstack,comesfromtheearlydaysofTCP/IP,anditissometimescalledtheTCP/IP
model.TheofficialTCP/IPprotocollayersandtheirfunctionsaredescribedinthefollowinglist.Comparethe
functionsinthelistwiththeresponsibilitieslistedearlierinthissection,andyoullseehowtheresponsibilitiesof
theprotocolsystemaredistributedamongthelayers.

Figure2.1TheTCP/IPmodelsprotocollayers.
BytheWay:ManyModels
ThefourlayermodelshowninFigure2.1isacommonmodelfordescribingTCP/IPnetworking,butitisntthe
onlymodel.TheARPAnetmodel,forinstance,asdescribedinRFC871,describesthreelayers:theNetwork
Interfacelayer,theHosttoHostlayer,andtheProcessLevel/Applicationslayer.OtherdescriptionsofTCP/IPcall
forafivelayermodel,withPhysicalandDataLinklayersinplaceoftheNetworkAccesslayer(tomatchOSI).
StillothermodelsmightexcludeeithertheNetworkAccessortheApplicationlayer,whicharelessuniformand
hardertodefinethantheintermediatelayers.
Thenamesofthelayersalsovary.TheARPAnetlayernamesstillappearinsomediscussionsofTCP/IP,andthe
InternetlayerissometimescalledtheInternetworklayerortheNetworklayer.
Thisbookusesthefourlayermodel,withnamesshowninFigure2.1.
NetworkAccesslayer:Providesaninterfacewiththephysicalnetwork.Formatsthedataforthe
transmissionmediumandaddressesdataforthesubnetbasedonphysicalhardwareaddresses.Provides
errorcontrolfordatadeliveredonthephysicalnetwork.
Internetlayer:Provideslogical,hardwareindependentaddressingsothatdatacanpassamongsubnets
withdifferentphysicalarchitectures.Providesroutingtoreducetrafficandsupportdeliveryacrossthe
internetwork.(Theterminternetworkreferstoaninterconnected,greaternetworkoflocalareanetworks
(LANs),suchaswhatyoufindinalargecompanyorontheInternet.)Relatesphysicaladdresses(usedat
theNetworkAccesslayer)tologicaladdresses.
Transportlayer:Providesflowcontrol,errorcontrol,andacknowledgmentservicesfortheinternetwork.
Servesasaninterfacefornetworkapplications.
Applicationlayer:Providesapplicationsfornetworktroubleshooting,filetransfer,remotecontrol,and
Internetactivities.Alsosupportsthenetworkapplicationprogramminginterfaces(APIs)thatenable
programswrittenforaparticularoperatingenvironmenttoaccessthenetwork.
LaterhoursprovidemoredetaileddescriptionsoftheactivitiesateachoftheseTCP/IPprotocollayers.
WhentheTCP/IPprotocolsoftwarepreparesapieceofdatafortransmissionacrossthenetwork,eachlayeron
thesendingmachineaddsalayerofinformationtothedatathatisrelevanttothecorrespondinglayeronthe
receivingmachine.Forinstance,theInternetlayerofthecomputersendingthedataaddsaheaderwithsome
informationthatissignificanttotheInternetlayerofthecomputerreceivingthemessage.Thisprocessis

sometimesreferredtoasencapsulation.Atthereceivingendtheseheadersareremovedasthedataispassedup
theprotocolstack.
BytheWay:Layers
Thetermlayerisusedthroughoutthecomputerindustryforprotocolcomponentlevelssuchastheonesshownin
Figure2.1.Headerinformationisappliedinlayerstothedataasitpassesthroughthecomponentsoftheprotocol
stack.(Youlllearnmoreaboutthislaterinthishour.)Whenitcomestothecomponentsthemselves,however,
thetermlayerissomewhatmetaphorical.
DiagramssuchasFigure2.1aremeanttoshowthatthedatapassesacrossaseriesofinterfaces.Aslongas
theinterfacesaremaintained,theprocesseswithinonecomponentarenotaffectedbytheprocessesinother
components.IfyouturnedFigure2.1sideways,itwouldlookmorelikeanassemblyline,andthisisalsoauseful
analogyfortherelationshipoftheprotocolcomponents.Thedataproceedsthroughaseriesofstepsintheline
and,aslongasitarrivesateachstepasspecified,thecomponentscanoperateindependently.

TCP/IPandtheOSIModel
ThenetworkingindustryhasastandardsevenlayermodelfornetworkprotocolarchitecturecalledtheOpen
SystemsInterconnection(OSI)model.TheOSImodelrepresentsaneffortbytheInternationalOrganizationfor
Standardization(ISO),aninternationalstandardsorganization,tostandardizethedesignofnetworkprotocol
systemstopromoteinterconnectivityandopenaccesstoprotocolstandardsforsoftwaredevelopers.
TCP/IPwasalreadyonthepathofdevelopmentwhentheOSIstandardarchitectureappearedand,strictly
speaking,TCP/IPdoesnotconformtotheOSImodel.However,thetwomodelsdidhavesimilargoals,and
enoughinteractionoccurredamongthedesignersofthesestandardsthattheyemergedwithacertain
compatibility.TheOSImodelhasbeenveryinfluentialinthegrowthanddevelopmentofprotocolimplementations,
anditisquitecommontoseetheOSIterminologyappliedtoTCP/IP.
Figure2.2showstherelationshipbetweenthefourlayerTCP/IPstandardandthesevenlayerOSImodel.Note
thattheOSImodeldividesthedutiesoftheApplicationlayerintothreelayers:Application,Presentation,and
Session.OSIsplitstheactivitiesoftheNetworkAccesslayerintoaDataLinklayerandaPhysicallayer.This
increasedsubdivisionaddssomecomplexity,butitalsoaddsflexibilityfordevelopersbytargetingtheprotocol
layerstomorespecificservices.Inparticular,thedivisionatthelowerlevelintotheDataLinkandPhysicallayers
separatesthefunctionsrelatedtoorganizingcommunicationfromthefunctionsrelatedtoaccessingthe
communicationmedium.ThethreeupperOSIlayersofferagreatervarietyofalternativesforanapplicationto
interfacewiththeprotocolstack.

Figure2.2ThesevenlayerOSImodel.
ThesevenlayersoftheOSImodelareasfollows:

Physicallayer:Convertsthedataintothestreamofelectricoranalogpulsesthatwillactuallycrossthe
transmissionmediumandoverseesthetransmissionofthedata
DataLinklayer:Providesaninterfacewiththenetworkadaptermaintainslogicallinksforthesubnet
Networklayer:Supportslogicaladdressingandrouting
Transportlayer:Provideserrorcontrolandflowcontrolfortheinternetwork
Sessionlayer:Establishessessionsbetweencommunicatingapplicationsonthecommunicating
computers
Presentationlayer:Translatesdatatoastandardformatmanagesencryptionanddatacompression
Applicationlayer:Providesanetworkinterfaceforapplicationssupportsnetworkapplicationsforfile
transfer,communications,andsoforth
ItisimportanttorememberthattheTCP/IPmodelandtheOSImodelarestandards,notimplementations.Real
worldimplementationsofTCP/IPdonotalwaysmapcleanlytothemodelsshowninFigures2.1and2.2,andthe
perfectcorrespondencedepictedinFigure2.2isalsoamatterofsomediscussionwithintheindustry.
NoticethattheOSIandTCP/IPmodelsaremostsimilarattheimportantTransportandInternet(calledNetworkin
OSI)layers.Theselayersincludethemostidentifiableanddistinguishingcomponentsoftheprotocolsystem,and
itisnocoincidencethatprotocolsystemsaresometimesnamedfortheirTransportandNetworklayerprotocols.
Asyoulearnlaterinthisbook,theTCP/IPprotocolsuiteisnamedforTCP,aTransportlayerprotocol,andIP,an
Internet/Networklayerprotocol.

DataPackages
TheimportantthingtorememberabouttheTCP/IPprotocolstackisthateachlayerplaysaroleintheoverall
communicationprocess.Eachlayerinvokesservicesthatarenecessaryforthatlayertoperformitsrole.Asan
outgoingtransmissionpassesdownthroughthestack,eachlayerincludesabundleofrelevantinformationcalled
aheaderalongwiththeactualdata.Thelittledatapackagecontainingtheheaderandthedatathenbecomes
thedatathatisrepackagedatthenextlowerlevelwiththenextlowerlayersheader.Thisprocessisshownin
Figure2.3.Thereverseprocessoccurswhendataisreceivedonthedestinationcomputer.Asthedatamovesup
throughthestack,eachlayerunpacksthecorrespondingheaderandusestheinformation.

Figure2.3Ateachlayer,thedataisrepackagedwiththatlayersheader.
Asthedatamovesdownthroughthestack,theeffectisalittlelikethenestedRussianwoodendollsyoumight
haveseentheinnermostdollisenclosedinanotherdoll,whichisthenenclosedinanotherdoll,andsoon.Atthe
receivingend,thedatapackagesareunpacked,onebyone,asthedataclimbsbackuptheprotocolstack.The
InternetlayeronthereceivingmachineusestheinformationintheInternetlayerheader.TheTransportlayeruses
theinformationintheTransportlayerheader.Ateachlayer,thepackageofdatatakesaformthatprovidesthe
necessaryinformationtothecorrespondinglayeronthereceivingmachine.Becauseeachlayerisresponsiblefor
differentfunctions,theformofthebasicdatapackageisverydifferentateachlayer.

BytheWay:TransportingDolls
Thenetworkingindustryhasasmanyanalogiesasithasacronyms,andtheRussiandollanalogy,likeanyofthe
others,illustratesapoint,butmustnotbetakentoofar.Itisworthnotingthatonaphysicalnetworksuchas
ethernet,thedataistypicallybrokenintosmallerunitsattheNetworkAccesslayer.Amoreaccurateanalogy
wouldcallforthislowestlayertobreaktheconcentricdollsystemintosmallerpieces,encapsulatethosepieces
intotinierdolls,andthengrindthosetinydollsintoapatternof1sand0s.The1sand0sarereceived,
reconstitutedintotinydolls,andrebuiltintotheconcentricdollsystem.Thecomplexityofthisscenariocauses
manytoeschewtheotherwisepromisinganalogyofthedolls.
Thedatapacketlooksdifferentateachlayer,andateachlayeritgoesbyadifferentname.Thenamesforthe
datapackagescreatedateachlayerareasfollows:
ThedatapackagecreatedattheApplicationlayeriscalledamessage.
ThedatapackagecreatedattheTransportlayer,whichencapsulatestheApplicationlayermessage,is
calledasegmentifitcomesfromtheTransportlayersTCPprotocol.Ifthedatapackagecomesfromthe
TransportlayersUserDatagramProtocol(UDP)protocol,itiscalledadatagram.
ThedatapackageattheInternetlayer,whichencapsulatestheTransportlayersegment,iscalleda
datagram.
ThedatapackageattheNetworkAccesslayer,whichencapsulatesandmaysubdividethedatagram,is
calledaframe.ThisframeisthenturnedintoabitstreamatthelowestsublayeroftheNetworkAccess
layer.
Youlearnmoreaboutthedatapackagesforeachlayerinlaterhours.

AQuickLookatTCP/IPNetworking
Thepracticeofdescribingprotocolsystemsintermsoftheirlayersiswidespreadandnearlyuniversal.The
layeringsystemdoesprovideinsightsintotheprotocolsystem,anditsimpossibletodescribeTCP/IPwithout
firstintroducingitslayeredarchitecture.However,focusingsolelyonprotocollayersalsocreatessome
limitations.
First,talkingaboutprotocollayersratherthanprotocolsintroducesadditionalabstractiontoasubjectthatis
alreadyexcruciatinglyabstract.Second,itemizingthevariousprotocolsassubheadswithinthegreatertopicofa
protocollayercangivethefalseimpressionthatallprotocolsareofequalimportance.Infact,thoughevery
protocolhasaroletoplay,mostofthefunctionalityoftheTCP/IPsuitecanbedescribedintermsofonlyafewof
itsmostimportantprotocols.Itissometimesusefultoviewtheseimportantprotocolsintheforeground,against
thebackdropofthelayeringsystemdescribedearlierinthishour.
Figure2.4describesthebasicTCP/IPprotocolnetworkingsystem.Ofcourse,thereareadditionalprotocolsand
servicesinthecompletepackage,butFigure2.4showsmostofwhatisgoingon.

Figure2.4AquicklookatthebasicTCP/IPnetworkingsystem.
Thebasicscenarioisasfollows:
1. Datapassesfromaprotocol,networkservice,orapplicationprogramminginterface(API)operatingatthe
ApplicationlayerthroughaTCPorUDPporttoeitherofthetwoTransportlayerprotocols(TCPorUDP).
ProgramscanaccessthenetworkthrougheitherTCPorUDP,dependingontheprogramsrequirements:
TCPisaconnectionorientedprotocol.AsyoulearninHour6,TheTransportLayer,connection
orientedprotocolsprovidemoresophisticatedflowcontrolanderrorcontrolthanconnectionless
protocols.TCPgoestogreatefforttoguaranteethedeliveryofthedata.TCPismorereliablethan
UDP,buttheadditionalerrorcheckingandflowcontrolmeanthatTCPisslowerthanUDP.
UDPisaconnectionlessprotocol.ItisfasterthanTCP,butitisnotasreliable.UDPoffloadsmore
oftheerrorcontrolresponsibilitiestotheapplication.
2. ThedatasegmentpassestotheInternetlevel,wheretheIPprotocolprovideslogicaladdressing
informationandenclosesthedataintoadatagram.
3. TheIPdatagramenterstheNetworkAccesslayer,whereitpassestosoftwarecomponentsdesignedto
interfacewiththephysicalnetwork.TheNetworkAccesslayercreatesoneormoredataframesdesigned
forentryontothephysicalnetwork.InthecaseofaLANsystemsuchasethernet,theframemaycontain
physicaladdressinformationobtainedfromlookuptablesmaintainedusingtheInternetlayerARPprotocol.
(ARP,AddressResolutionProtocol,translatesIPaddressestophysicaladdresses.)
4. Thedataframeisconvertedtoastreamofbitsthatistransmittedoverthenetworkmedium.
Ofcourse,thereareendlessdetailsdescribinghoweachprotocolgoesaboutfulfillingitsassignedtasks.For
instance,howdoesTCPprovideflowcontrol,howdoesARPmapphysicaladdressestoIPaddresses,andhow
doesIPknowwheretosendadatagramaddressedtoadifferentsubnet?Thesequestionsareexploredlaterin
thisbook.

Summary
Inthishour,youlearnedaboutthelayersoftheTCP/IPprotocolstackandhowthoselayersinterrelate.Youalso
learnedhowtheclassicTCP/IPmodelrelatestothesevenlayerOSInetworkingmodel.Ateachlayerinthe
protocolstack,dataispackagedintotheformthatismostusefultothecorrespondinglayeronthereceivingend.
Thishourdiscussedtheprocessofencapsulatingheaderinformationateachprotocollayerandoutlinedthe
differenttermsusedateachlayertodescribethedatapackage.Finally,yougotaquicklookathowtheTCP/IP
protocolsystemoperatesfromtheviewpointofsomeofitsmostimportantprotocols:TCP,UDP,IP,andARP.

Q&A
Q.WhataretheprincipaladvantagesofTCP/IPsmodulardesign?
A.BecauseofTCP/IPsmodulardesign,theTCP/IPprotocolstackcanadapteasilytospecifichardwareand
operatingenvironments.Breakingthenetworkingsoftwareintospecific,welldesignedcomponentsalsomakesit
easiertowriteprogramsthatinteractwiththeprotocolsystem.
Q.WhatfunctionsareprovidedattheNetwork Accesslayer?
A.TheNetworkAccesslayerprovidesservicesrelatedtothespecificphysicalnetwork.Theseservicesinclude
preparing,transmitting,andreceivingtheframeoveraparticulartransmissionmedium,suchasanethernetcable.
Q.WhichOSIlayercorrespondstotheTCP/IPInternetlayer?
A.TCP/IPsInternetlayercorrespondstotheOSINetworklayer.
Q.WhyisheaderinformationenclosedateachlayeroftheTCP/IPprotocolstack ?
A.Becauseeachprotocollayeronthereceivingmachineneedsdifferentinformationtoprocesstheincoming
data,eachlayeronthesendingmachineenclosesheaderinformation.

Workshop
Thefollowingworkshopiscomposedofaseriesofquizquestionsandpracticalexercises.Thequizquestionsare
designedtotestyouroverallunderstandingofthecurrentmaterial.Thepracticalexercisesareintendedtoafford
youtheopportunitytoapplytheconceptsdiscussedduringthecurrenthour,aswellasbuildupontheknowledge
acquiredinprevioushoursofstudy.Pleasetaketimetocompletethequizquestionsandexercisesbefore
continuing.RefertoAppendixA,AnswerstoQuizzesandExercises,foranswers.

Quiz
1.
2.
3.
4.
5.

WhattwoOSIlayersmapintotheTCP/IPNetworkAccesslayer?
WhatTCP/IPlayerisresponsibleforroutingdatafromonecomputertoanother?
WhataretheadvantagesanddisadvantagesofUDPascomparedtoTCP?
Whichlayerdealswithframes?
Whatdoesitmeantosaythatalayerencapsulatesdata?

Exercises
1.
2.
3.
4.

ListthefunctionsperformedbyeachlayerintheTCP/IPstack.
Listthelayer(s)thatdealwithdatagrams.
ExplainhowTCP/IPwouldhavetochangetouseanewlyinventedtypeofnetwork.
ExplainwhatitmeanstosaythatTCPisareliableprotocol.

KeyTerms
Reviewthefollowinglistofkeyterms:
AddressResolutionProtocol(ARP):AprotocolthatresolveslogicalIPaddressestophysicaladdresses.

Applicationlayer:ThelayeroftheTCP/IPstackthatsupportsnetworkapplicationsandprovidesan
interfacetothelocaloperatingenvironment.
Datagram:ThedatapackagepassedfromtheInternetlayertotheNetworkAccesslayer,oradata
packagepassedfromUDPattheTransportlayertotheInternetlayer.
Frame:ThedatapackagecreatedattheNetworkAccesslayer.
Header:Abundleofprotocolinformationattachedtothedataateachlayeroftheprotocolstack.
Internetlayer:ThelayeroftheTCP/IPstackthatprovideslogicaladdressingandrouting.
IP(InternetProtocol):TheInternetlayerprotocolthatprovideslogicaladdressingandroutingcapabilities.
Message:InTCP/IPnetworking,amessageisthedatapackagepassedfromtheApplicationlayertothe
Transportlayer.Thetermisalsousedgenericallytodescribeamessagefromoneentitytoanotheronthe
network.ThetermdoesntalwaysrefertoanApplicationlayerdatapackage.
NetworkAccesslayer:ThelayeroftheTCP/IPstackthatprovidesaninterfacewiththephysicalnetwork.
Segment:ThedatapackagepassedfromTCPattheTransportlayertotheInternetlayer.
TCP(TransmissionControlProtocol):Areliable,connectionorientedprotocoloftheTransportlayer.
Transportlayer:ThelayeroftheTCP/IPstackthatprovideserrorcontrolandacknowledgmentandserves
asaninterfacefornetworkapplications.
UDP(UserDatagramProtocol):Anunreliable,connectionlessprotocoloftheTransportlayer.

Você também pode gostar