Tải bản đầy đủ - 0 (trang)
5 Network Protocols II — TCP/IP Network Architecture

5 Network Protocols II — TCP/IP Network Architecture

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

11.5NetworkProtocolsII—TCP/IPNetwork

Architecture

WhiletheISOandtheCCITTwerehagglingoverthefinerpointsofthe

perfectprotocolstack,TCP/IPwasrapidlyspreadingacrosstheglobe.

Bythesheerweightofitspopularitywithintheacademicandscientific

communicationscommunities,TCP/IPquietlybecamethedefactoglobal

datacommunicationstandard.

Althoughitdidn'tstartoutthatway,TCP/IPisnowaleanandeffective

protocolstack.Ithasthreelayersthatcanbemappedtofiveoftheseven

layersintheOSImodel.TheselayersareshowninFigure11.4.Because

theIPlayerislooselycoupledwithOSI'sDataLinkandPhysicallayers,

TCP/IPcanbeusedwithanytypeofnetwork,evendifferenttypesof

networkswithinasinglesession.Thesingularrequirementisthatallof

theparticipatingnetworksmustberunning—atminimum—Version4of

theInternetProtocol(IPv4).



Figure11.4:TheTCP/IPProtocolStack

VersustheOSIProtocolStack

TherearetwoversionsoftheInternetProtocolinusetoday,Version4

andVersion6.IPv6addressesmanyofthelimitationsofIPv4.Despite

themanyadvantagesofIPv6,thehugeinstalledbaseofIPv4ensures

thatitwillbesupportedformanyyearstocome.Someofthemajor

differencesbetweenIPv4andIPv6areoutlinedinSection11.5.5.But

first,wetakeadetailedlookatIPv4.



11.5.1TheIPLayerforVersion4



TheIPlayeroftheTCP/IPprotocolstackprovidesessentiallythesame

servicesastheNetworkandDataLinklayersoftheOSIReference

Model:ItdividesTCPpacketsintoprotocoldataunitscalleddatagrams,

andthenattachestheroutinginformationrequiredtogetthedatagrams

totheirdestinations.Theconceptofthedatagramwasfundamentalto

therobustnessofARPAnet,andnow,theInternet.Datagramscantake

anyrouteavailabletothemwithoutinterventionbyahumannetwork

manager.Take,forexample,thenetworkshowninFigure11.5.If

intermediatenodeXbecomescongestedorfails,intermediatenodeY

canroutedatagramsthroughnodeZuntilXisbackuptofullspeed.

RoutersaretheInternet'smostcriticalcomponents,andresearchersare

continuallyseekingwaystoimprovetheireffectivenessandperformance.

WelookatroutersindetailinSection11.6.7.





Figure11.5:DatagramRoutinginIP

ThebytesthatconstituteanyoftheTCP/IPprotocoldataunitsarecalled

octets.ThisisbecauseatthetimetheARPAnetprotocolswerebeing

designed,thewordbytewasthoughttobeaproprietarytermforthe8-bit

groupsusedbyIBMmainframes.MostTCP/IPliteratureusestheword

octet,butweusebyteforthesakeofclarity.

TheIPVersion4DatagramHeader



EachIPv4datagrammustcontainatleast40bytes,whichincludea

24-byteheaderasshownabove.Thehorizontalrowsrepresent32-bit

words.Uponinspectionofthefigure,youcansee,forexample,that

theTypeofServicefieldoccupiesbits8through15,whilethePacket

Identificationfieldoccupiesbits32through47oftheheader.The

Paddingfieldshownasthelastfieldoftheheaderassuresthatthe

datathatfollowstheheaderstartsonaneven32-bitboundary.The

Paddingalwayscontainszeroes.TheotherfieldsintheIPv4header

are:

Version—SpecifiestheIPprotocolversionbeingused.The

versionnumbertellsallofthehardwarealongthewaythe

lengthofthedatagramandwhatcontenttoexpectinits

headerfields.ForIPv4,thisfieldisalways0100(because

01002=410).

HeaderLength—Givesthelengthoftheheaderin32-bit

words.ThesizeoftheIPheaderisvariable,dependingonthe

valueoftheIPOptionsfields,buttheminimumvaluefora

correctheaderis5.

TypeofService—Controlstheprioritythatthedatagramis

givenbyintermediatenodes.Valuescanrangefrom"routine"



(000)to"critical"(101).Networkcontroldatagramsare

indicatedwith110and111.

TotalLength—GivesthelengthoftheentireIPdatagramin

bytes.Asyoucanseebythelayoutabove,2bytesare

reservedforthispurpose.Hence,thelargestallowableIP

datagramis216–1,or65,535.

PacketID—Eachdatagramisassignedaserialnumberasitis

placedonthenetwork.ThecombinationofHostIDandPacket

IDuniquelyidentifieseachIPdatagraminexistenceatany

timeintheworld.

Flags—Specifywhetherthedatagrammaybefragmented

(brokenintosmallerdatagrams)byintermediatenodes.IP

networksmustbeabletohandledatagramsofatleast576

bytes.MostIPnetworkscandealwithpacketsthatareabout

8KBlong.Withthe"Don'tFragment"bitset,an8KBdatagram

willnotberoutedoveranetworkthatsaysitcanhandleonly

2KBpackets,forexample.

FragmentOffset—Indicatesthelocationofafragmentwithina

certaindatagram.Thatis,ittellswhichpartofthedatagram

thefragmentcamefrom.

TimetoLive(TTL)—TTLwasoriginallyintendedtomeasure

thenumberofsecondsforwhichthedatagramwouldremain

valid.Shouldadatagramgetcaughtinaroutingloop,theTTL

would(theoretically)expirebeforethedatagramcould

contributetoacongestionproblem.Inpractice,theTTLfieldis

decrementedeachtimeitpassesthroughanintermediate

networknode,sothisfielddoesnotreallymeasurethenumber

ofsecondsthatapacketlives,butthenumberofhopsitis

allowedbeforeitreachesitsdestination.

ProtocolNumber—Indicateswhichhigher-layerprotocolis

sendingthedatathatfollowstheheader.Someofthe

importantvaluesforthisfieldare:



0=Reserved

1=InternetControlMessageProtocol(ICMP)

6=TransmissionControlProtocol(TCP)

17=UserDatagramProtocol(UDP)

TCPisdescribedinSection11.5.3.

HeaderChecksum—Thisfieldiscalculatedbyfirstcalculating

theone'scomplementsumofall16-bitwordsintheheader,

andthentakingtheone'scomplementofthissum,withthe

checksumfielditselforiginallysettoallzeroes.Theone's

complementsumisthearithmeticsumoftwoofthewordswith

the(seventeenth)carrybitaddedtothelowestbitpositionof

thesum.(SeeSection2.4.2.)Forexample,11110011+

10011010=110001101=10001110usingone'scomplement

arithmetic.WhatthismeansisthatifwehaveanIPdatagram

oftheformshowntotheright,eachwiisa16-bitwordinthe

IPdatagram.Thecompletechecksumwouldbecomputed

overtwo16-bitwordsatatime:w1+w2=S1;S1+w3=S2;.

..Sk+wk–2=Sk+1.



SourceandDestinationAddresses—Tellwherethedatagram

isgoing.Wehavemuchmoretosayaboutthese32-bitfields

inSection11.5.2.

IPOptions—Providesdiagnosticinformationandrouting



controls.IPOptionsare,well,optional.



11.5.2TheTroublewithIPVersion4

ThenumberofbytesallocatedforeachfieldintheIPheaderreflectsthe

technologicalerainwhichIPwasdesigned.BackintheARPAnetyears,

noonecouldhaveimaginedhowthenetworkwouldgrow,oreventhat

therewouldeverbeacivilianuseforit.

Withtheslowestnetworksoftodaybeingfasterthanthefastestnetworks

ofthe1960s,IP'spacketlengthlimitof65,536byteshasbecomea

problem.Thepacketssimplymovetoofastforcertainnetworkequipment

tobesurethatthepackethasn'tbeendamagedbetweenintermediate

nodes.(Atgigabitspeeds,a65,535-byteIPdatagrampassesovera

givenpointinlessthanonemillisecond.)

ByfarthemostseriousproblemwithIPv4headersconcernsaddressing.

Everyhostandroutermusthaveanaddressthatisuniqueoverthe

entireInternet.ToassurethatnoInternetnodeduplicatestheaddressof

anotherInternetnode,hostIDsareadministeredbyacentralauthority,

theInternetCorporationforAssignedNamesandNumbers(ICANN).

ICANNkeepstrackofgroupsofIPaddresses,whicharesubsequently

allocatedorassignedbyregionalauthorities.(TheICANNalso

coordinatestheassignmentofparametervaluesusedinprotocolssothat

everyoneknowswhichvaluesevokewhichbehaviorsovertheInternet.)

AsyoucanseebylookingattheIPheadershowninthesidebar,there

are232orabout4.3billionhostIDs.Itwouldbereasonabletothinkthat

therewouldbeplentyofaddressestogoaround,butthisisnotthecase.

Theproblemliesinthefactthattheseaddressesarenotlikeserial

numberssequentiallyassignedtothenextpersonwhoasksforone.It's

muchmorecomplicatedthanthat.

IPallowsforthreetypes,orclasses,ofnetworks,designatedA,B,andC.

Theyaredistinguishedfromeachotherbythenumberofnodes(called

hosts)thateachcandirectlysupport.ClassAnetworkscansupportthe



largestnumberofhosts;ClassC,theleast.

ThefirstthreebitsofanIPaddressindicatethenetworkclass.

AddressesforClassAnetworksalwaysbeginwith0,ClassBwith10,

andClassCwith110.Theremainingbitsintheaddressaredevotedto

thenetworknumberandthehostIDwithinthatnetworknumber,as

showninFigure11.6.





Figure11.6:IPAddressClasses

IPaddressesare32-bitnumbersexpressedindotteddecimalnotation,

forexample18.7.21.69or146.186.157.6.Eachofthesedecimal

numbersrepresents8bitsofbinaryinformationandcanthereforehavea

decimalvaluebetween0and255.127.x.x.xisaClassAnetworkbutis

reservedforloopbacktesting,whichcheckstheTCP/IPprotocol

processesrunningonthehost.Duringtheloopbacktestnodatagrams

enterthenetwork.The0.0.0.0networkistypicallyreservedforuseasthe

defaultrouteinthenetwork.

Allowingforthereservednetworks0and127,only126ClassAnetworks

canbedefinedusinga7-bitnetworkfield.ClassAnetworksarethe

largestnetworksofall,eachabletosupportabout16.7millionnodes.

AlthoughitisunlikelythataClassAnetworkwouldneedall16million

possibleaddresses,theClassAaddresses,1.0.0.0through

126.255.255.255,werelongagoassignedtoearlyInternetadopterssuch

asMITandtheXeroxCorporation.Furthermore,allofthe16,382ClassB

networkIDs(128.0.0.0to191.255.255.255)havealsobeenassigned.

EachClassBnetworkcancontain65,534uniquenodeaddresses.

Becauseveryfeworganizationsneedmorethan100,000addresses,



theirnextchoiceistoidentifythemselvesasClassCnetworkowners,

givingthemonly256addresseswithintheClassCspaceof192.0.0.0

through233.255.255.255.Thisisfarfewerthanwouldmeettheneedsof

evenamoderatelysizedcompanyorinstitution.Thus,manynetworks

havebeenunabletoobtainacontiguousblockofIPaddressessothat

eachnodeonthenetworkcanhaveitsownaddressontheInternet.A

numberofcleverworkaroundshavebeendevisedtodealwiththis

problem,buttheultimatesolutionliesinreworkingtheentireIPaddress

structure.WelookatthisnewaddressstructureinSection11.5.6.

(ClassesDandEdoexist,buttheyaren'tnetworksatall.Instead,they're

groupsofreservedaddresses.TheClassDaddresses,224through240,

areusedformulticastingbygroupsofhoststhatshareacommon

characteristic.TheClassEaddresses,241through248,arereservedfor

futureuse.)

Inadditiontotheeventualdepletionofaddressspace,thereareother

problemswithIPv4.Itsoriginaldesignersdidnotanticipatethegrowthof

theInternetandtheroutingproblemsthatwouldresultfromtheaddress

classscheme.Therearetypically70,000-plusroutesintheroutingtable

ofanInternetbackbonerouter.ThecurrentroutinginfrastructureofIPv4

needstobemodifiedtoreducethenumberofroutesthatroutersmust

store.Aswithcachememory,largerroutermemoriesresultinslower

routinginformationretrieval.Thereisalsoadefiniteneedforsecurityat

theIPlevel.AprotocolcalledIPSec(InternetProtocolSecurity)is

currentlydefinedfortheIPlevel.However,itisoptionalandhasn'tbeen

standardizedoruniversallyadopted.

TheTCPSegmentFormat



TheTCPsegmentformatisshownabove.Thenumbersatthetopof

thefigurearethebitpositionsspannedbyeachfield.Thehorizontal

rowsrepresent32-bitwords.Thefieldsaredefinedasfollows:

SourceandDestinationPorts—Specifiesinterfacesto

applicationsrunningaboveTCP.Theseapplicationsareknown

toTCPbytheirportnumber.

SequenceNumber—Indicatesthesequencenumberofthe

firstbyteofdatainthepayload.TCPassignseachtransmitted

byteasequencenumber.If100databyteswillbesent10

bytesatatime,thesequencenumberinthefirstsegment

mightbe0,thesecond10,thethird20,andsoforth.The

startingsequencenumberisnotnecessarily0,solongasthe

numberisuniquebetweenthesenderandreceiver.

AcknowledgementNumber—Containsthenextdatasequence

numberthatthereceiverisexpecting.TCPusesthisvalueto

determinewhetheranydatagramshavegottenlostalongthe

way.

DataOffset—Containsthenumberof32-bitwordsinthe

header,orequivalently,therelativelocationofthewordwhere

thedatastartswithinthesegment.Alsoknownastheheader

length.



Reserved—Thesesixbitsmustbezerountilsomeonecomes

upwithagooduseforthem.

Flags—Containssixbitsthatareusedmostlyforprotocol

management.Theyaresetto"true"whentheirvaluesare

nonzero.TheTCPflagsandtheirmeaningsare:

URG:Indicatesthaturgentdataexistsinthissegment.The

UrgentPointerfield(seebelow)pointstothelocationofthe

firstbytethatfollowstheurgentinformation.

ACK:IndicateswhethertheAcknowledgementNumberfield

(seeabove)containssignificantinformation.

PSH:TellsallTCPprocessesinvolvedintheconnectionto

cleartheirbuffers,thatis,"push"thedatatothereceiver.This

flagshouldalsobesetwhenurgentdataexistsinthepayload.

RST:Resetstheconnection.Usually,itforcesvalidationofall

packetsreceivedandplacesthereceiverbackintothe"listen

formoredata"state.

SYN:Indicatesthatthepurposeofthesegmentisto

synchronizesequencenumbers.Ifthesendertransmits[SYN,

SEQ#=x],itshouldsubsequentlyreceive[ACK,SEQ#=x+

1]fromthereceiver.Atthetimethattwonodesestablisha

connection,bothexchangetheirrespectiveinitialsequence

numbers.

FIN:Thisisthe"finished"flag.Itletsthereceiverknowthat

thesenderhascompletedtransmission,havingtheeffectof

startingclosedownproceduresfortheconnection.

Window—Allowsbothnodestodefinethesizeoftheir

respectivedatawindowsbystatingthenumberofbytesthat

eachiswillingtoacceptwithinanysinglesegment.For

example,ifthesendertransmitsbytesnumbered0to1023

andthereceiveracknowledgeswith1024intheACK#field

andawindowvalueof512,thesendershouldreplyby



sendingdatabytes1024through1535.(Thismayhappen

whenthereceiver'sbufferisstartingtofillupsoitrequeststhat

thesenderslowdownuntilthereceivercatchesup.)Notice

thatifthereceiver'sapplicationisrunningveryslowly,sayit's

pullingdata1or2bytesatatimefromitsbuffer,theTCP

processrunningatthereceivershouldwaituntiltheapplication

bufferisemptyenoughtojustifysendinganothersegment.If

thereceiversendsawindowsizeof0,theeffectis

acknowledgementofallbytesuptotheacknowledgement

number,andtostopfurtherdatatransmissionuntilthesame

acknowledgmentnumberissentagainwithanonzerowindow

size.

Checksum—Thisfieldcontainsthechecksumoverthefieldsin

theTCPsegment(exceptthedatapaddingandthechecksum

itself),alongwithanIPpseudoheaderasfollows:



AswiththeIPchecksumexplainedearlier,theTCPchecksum

isthe16-bitone'scomplementofthesumofall16-bitwordsin

theheaderandtextoftheTCPsegment.

UrgentPointer—Pointstothefirstbytethatfollowstheurgent

data.ThisfieldismeaningfulonlywhentheURGflagisset.

Options—Concerns,amongotherthings,negotiationof

windowsizesandwhetherselectiveacknowledgment(SACK)

canbeused.SACKpermitsretransmissionofparticular

segmentswithinawindowasopposedtorequiringtheentire

windowtoberetransmittedifasegmentfromsomewherein

themiddlegetslost.Thisconceptwillbeclearertoyouafter

ourdiscussionofTCPflowcontrol.



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

5 Network Protocols II — TCP/IP Network Architecture

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

×