IPv4 Header Format | Gate Vidyalay

文章推薦指數: 80 %
投票人數:10人

IPv4 | IPv4 Header | IPv4 Header Format · IPv4 short for Internet Protocol Version 4 is the fourth version of the Internet Protocol (IP). · Version is a 4 bit ... HomeGATESubjectsDatabaseManagementSystemComputerNetworksOperatingSystemComputerOrganization&ArchitectureDataStructuresTheoryofAutomata&ComputationCompilerDesignGraphTheoryDesignandAnalysisofAlgorithmsDigitalDesignNumberSystemMathematicsPropositionalLogicProgrammingLanguagesCoreJavaB.TechSubjectsComputerGraphicsMachineLearningArtificialIntelligencePatternRecognitionSoftwareEngineeringGATE2022GATECSEBooksJobOpportunitiesContactUsSubscribe ComputerNetworksInternetProtocolVersion4- IPv4shortforInternetProtocolVersion4isthefourthversionoftheInternetProtocol(IP).IPisresponsibletodeliverdatapacketsfromthesourcehosttothedestinationhost.ThisdeliveryissolelybasedontheIPAddressesinthepacketheaders.IPv4isthefirstmajorversionofIP.IPv4isaconnectionlessprotocolforuseonpacket-switchednetworks. Inthisarticle,wewilldiscussaboutIPv4Header.  IPv4Header- ThefollowingdiagramrepresentstheIPv4header-  LetusdiscusseachfieldofIPv4headeronebyone.  1.Version- Versionisa4bitfieldthatindicatestheIPversionused.ThemostpopularlyusedIPversionsareversion-4(IPv4)andversion-6(IPv6).OnlyIPv4usestheaboveheader.So,thisfieldalwayscontainsthedecimalvalue4. NOTESItisimportanttonote-Datagramsbelongingtodifferentversionshavedifferentstructures.So,theyareparseddifferently.IPv4datagramsareparsedbyversion-4parsers.IPv6datagramsareparsedbyversion-6parsers. 2.HeaderLength- Headerlengthisa4bitfieldthatcontainsthelengthoftheIPheader.Ithelpsinknowingfromwheretheactualdatabegins. MinimumAndMaximumHeaderLength- ThelengthofIPheaderalwaysliesintherange-[20bytes,60bytes] Theinitial5rowsoftheIPheaderarealwaysused.So,minimumlengthofIPheader=5x4bytes=20bytes.Thesizeofthe6throwrepresentingtheOptionsfieldvary.ThesizeofOptionsfieldcangoupto40bytes.So,maximumlengthofIPheader=20bytes+40bytes=60bytes. ConceptofScalingFactor- Headerlengthisa4bitfield.So,therangeofdecimalvaluesthatcanberepresentedis[0,15].Buttherangeofheaderlengthis[20,60].So,torepresenttheheaderlength,weuseascalingfactorof4. Ingeneral, Headerlength=Headerlengthfieldvaluex4bytes Examples- Ifheaderlengthfieldcontainsdecimalvalue5(representedas0101),then-Headerlength=5x4=20bytesIfheaderlengthfieldcontainsdecimalvalue10(representedas1010),then-Headerlength=10x4=40bytesIfheaderlengthfieldcontainsdecimalvalue15(representedas1111),then-Headerlength=15x4=60bytes NOTESItisimportanttonote-HeaderlengthandHeaderlengthfieldvaluearetwodifferentthings.Therangeofheaderlengthfieldvalueisalways[5,15].Therangeofheaderlengthisalways[20,60]. Whilesolvingquestions-Ifthegivenvalueliesintherange[5,15]thenitmustbetheheaderlengthfieldvalue.Thisisbecausetherangeofheaderlengthisalways[20,60]. 3.TypeOfService- Typeofserviceisa8bitfieldthatisusedforQualityofService(QoS).Thedatagramismarkedforgivingacertaintreatmentusingthisfield. 4.TotalLength- Totallengthisa16bitfieldthatcontainsthetotallengthofthedatagram(inbytes). Totallength=Headerlength+Payloadlength Minimumtotallengthofdatagram=20bytes(20bytesheader+0bytesdata)Maximumtotallengthofdatagram=Maximumvalueof16bitword=65535bytes 5.Identification- Identificationisa16bitfield.ItisusedfortheidentificationofthefragmentsofanoriginalIPdatagram. WhenanIPdatagramisfragmented,Eachfragmenteddatagramisassignedthesameidentificationnumber.Thisnumberisusefulduringthereassemblyoffragmenteddatagrams.IthelpstoidentifytowhichIPdatagram,thefragmenteddatagrambelongsto. 6.DFBit- DFbitstandsforDoNotFragmentbit.Itsvaluemaybe0or1. WhenDFbitissetto0, Itgrantsthepermissiontotheintermediatedevicestofragmentthedatagramifrequired. WhenDFbitissetto1,ItindicatestheintermediatedevicesnottofragmenttheIPdatagramatanycost.Ifnetworkrequiresthedatagramtobefragmentedtotravelfurtherbutsettingsdoesnotallowitsfragmentation,thenitisdiscarded.Anerrormessageissenttothesendersayingthatthedatagramhasbeendiscardedduetoitssettings. 7.MFBit- MFbitstandsforMoreFragmentsbit.Itsvaluemaybe0or1. WhenMFbitissetto0,Itindicatestothereceiverthatthecurrentdatagramiseitherthelastfragmentinthesetorthatitistheonlyfragment. WhenMFbitissetto1,Itindicatestothereceiverthatthecurrentdatagramisafragmentofsomelargerdatagram.Morefragmentsarefollowing.MFbitissetto1onallthefragmentsexceptthelastone. 8.FragmentOffset- FragmentOffsetisa13bitfield.ItindicatesthepositionofafragmenteddatagramintheoriginalunfragmentedIPdatagram.Thefirstfragmenteddatagramhasafragmentoffsetofzero. Fragmentoffsetforagivenfragmenteddatagram=Numberofdatabytesaheadofitintheoriginalunfragmenteddatagram ConceptOfScalingFactor- Weuseascalingfactorof8forthefragmentoffset.Fragmentoffsetfieldvalue=FragmentOffset/8 NeedOfScalingFactorForFragmentOffset InIPv4header,thetotallengthfieldcomprisesof16bits.Totallength=Headerlength+Payloadlength.Minimumheaderlength=20bytes.So,maximumamountofdatathatcanbesentinthepayloadfield=216–20bytes.Inworstcase,adatagramcontaining216–20bytesofdatamightbefragmentedinsuchawaythatthelastfragmenteddatagramcontainsonly1byteofdata.Then,fragmentoffsetforthelastfragmenteddatagramwillbe(216–20)–1=216-21≅216(ifnoscalingfactorisused)Now,thisfragmentoffsetvalueof216cannotberepresented.Thisisbecausethefragmentoffsetfieldconsistsofonly13bits.Using13bits,amaximumnumberof213canberepresented.So,torepresent216weusetheconceptofscalingfactor.Scalingfactor=216/213=23=8. 9.TimeToLive- Timetolive(TTL)isa8bitfield.Itindicatesthemaximumnumberofhopsadatagramcantaketoreachthedestination.ThemainpurposeofTTListopreventtheIPdatagramsfromloopingaroundforeverinaroutingloop. ThevalueofTTLisdecrementedby1when-Datagramtakesahoptoanyintermediatedevicehavingnetworklayer.Datagramtakesahoptothedestination. IfthevalueofTTLbecomeszerobeforereachingthedestination,thendatagramisdiscarded. NOTESItisimportanttonote-BothintermediatedeviceshavingnetworklayeranddestinationdecrementstheTTLvalueby1.IfthevalueofTTLisfoundtobezeroatanyintermediatedevice,thenthedatagramisdiscarded.So,atanyintermediatedevice,thevalueofTTLmustbegreaterthanzerotoproceedfurther.IfthevalueofTTLbecomeszeroatthedestination,thenthedatagramisaccepted.So,atthedestination,thevalueofTTLmaybegreaterthanorequaltozero. 10.Protocol- Protocolisa8bitfield.IttellsthenetworklayeratthedestinationhosttowhichprotocoltheIPdatagrambelongsto.Inotherwords,ittellsthenextlevelprotocoltothenetworklayeratthedestinationside.ProtocolnumberofICMPis1,IGMPis2,TCPis6andUDPis17. WhyProtocolNumberIsAPartOfIPHeader? Consider-AnIPdatagramissentbythesendertothereceiver.Whendatagramreachesattherouter,it’sbufferisalreadyfull. Insuchacase,Routerdoesnotdiscardthedatagramdirectly.Beforediscarding,routerchecksthenextlevelprotocolnumbermentionedinitsIPheader.IfthedatagrambelongstoTCP,thenittriestomakeroomforthedatagraminitsbuffer.Itcreatesaroombyeliminatingoneofthedatagramshavinglowerpriority.ThisisbecauseitknowsthatTCPisareliableprotocolandifitdiscardsthedatagram,thenitwillbesentagainbythesender.Theorderinwhichroutereliminatethedatagramsfromitsbufferis-ICMP>IGMP>UDP>TCP Ifprotocolnumberwouldhavebeeninsidethedatagram,then-Routercouldnotlookintoit.Thisisbecauserouterhasonlythreelayers-physicallayer,datalinklayerandnetworklayer. Thatiswhy,protocolnumberismadeapartofIPheader. 11.HeaderChecksum- Headerchecksumisa16bitfield.Itcontainsthechecksumvalueoftheentireheader.Thechecksumvalueisusedforerrorcheckingoftheheader. Ateachhop,Theheaderchecksumiscomparedwiththevaluecontainedinthisfield.Ifheaderchecksumisfoundtobemismatched,thenthedatagramisdiscarded.Routerupdatesthechecksumfieldwheneveritmodifiesthedatagramheader. Thefieldsthatmaybemodifiedare-TTLOptionsDatagramLengthHeaderLengthFragmentOffset NOTEItisimportanttonote-ComputationofheaderchecksumincludesIPheaderonly.Errorsinthedatafieldarehandledbytheencapsulatedprotocol. AlsoRead-Checksum 12.SourceIPAddress- SourceIPAddressisa32bitfield.Itcontainsthelogicaladdressofthesenderofthedatagram. 13.DestinationIPAddress- DestinationIPAddressisa32bitfield.Itcontainsthelogicaladdressofthereceiverofthedatagram. 14.Options- Optionsisafieldwhosesizevaryfrom0bytesto40bytes.Thisfieldisusedforseveralpurposessuchas-RecordrouteSourceroutingPadding 1.RecordRoute- ArecordrouteoptionisusedtorecordtheIPAddressoftheroutersthroughwhichthedatagrampassesonitsway.Whenrecordrouteoptionissetintheoptionsfield,IPAddressoftheroutergetsrecordedintheOptionsfield. NOTE ThemaximumnumberofIPv4routeraddressesthatcanberecordedintheRecordRouteoptionfieldofanIPv4headeris9. Explanation- InIPv4,sizeofIPAddresses=32bits=4bytes.MaximumsizeofOptionsfield=40bytes.So,itseemsmaximumnumberofIPAddressesthatcanberecorded=40/4=10.Butsomespaceisrequiredtoindicatethetypeofoptionbeingused.Also,somespaceistobeleftbetweentheIPAddresses.So,thespaceof4bytesisleftforthispurpose.Therefore,themaximumnumberofIPaddressesthatcanberecorded=9. 2.SourceRouting- Asourceroutingoptionisusedtospecifytheroutethatthedatagrammusttaketoreachthedestination.Thisoptionisgenerallyusedtocheckwhetheracertainpathisworkingfineornot.Sourceroutingmaybelooseorstrict. 3.Padding- Additionofdummydatatofillupunusedspaceinthetransmissionunitandmakeitconformtothestandardsizeiscalledaspadding.Optionsfieldisusedforpadding. Example- Whenheaderlengthisnotamultipleof4,extrazeroesarepaddedintheOptionsfield.Bydoingso,headerlengthbecomesamultipleof4.Ifheaderlength=30bytes,2bytesofdummydataisaddedtotheheader.Thismakesheaderlength=32bytes.Then,thevalue32/4=8isputintheheaderlengthfield.Inworstcase,3bytesofdummydatamighthavetobepaddedtomaketheheaderlengthamultipleof4.  AlsoRead-TCPHeader|UDPHeader TogainbetterunderstandingaboutIPv4Header,WatchthisVideoLecture NextArticle-IPFragmentation|Examples GetmorenotesandotherstudymaterialofComputerNetworks.WatchvideolecturesbyvisitingourYouTubechannelLearnVidFun.Summary ArticleNameIPv4|IPv4Header|IPv4HeaderFormatDescriptionIPv4shortforInternetProtocolVersion4isoneofthepopularlyusedIPversions.IPv4HeaderistheheaderofIPdatagram.IPv4HeaderFormatconsistsofseveralfieldsasshowninthediagram.IPv4headercontainsthenecessaryinformationrequiredduringtransmission.AuthorAkshaySinghalPublisherNameGateVidyalayPublisherLogo FollowusonFacebookFollowusonInstagramComputerNetworksNotesIntroduction TypesofDelaysSimplex|HalfDuplex|FullDuplex FlowControl StopandWaitProtocolStopandWaitARQProblemsOnStopandWaitProtocolSlidingWindowProtocolProblemsOnSlidingWindowProtocolGobackNProtocolProblemsOnGoBackNProtocolSelectiveRepeatProtocolProblemsOnSRProtocolComparisonofFlowControlProtocolsProblemsOnFlowControlProtocols ErrorControl SingleParityCheckCyclicRedundancyCheckChecksum AccessControl AccessControlMethodsTimeDivisionMultiplexingPollingCSMA/CDBackOffAlgorithmProblemsOnCSMA/CDTokenPassingProblemsOnTokenPassingAloha|PureAloha|SlottedAloha LANTechnologies Ethernet|EthernetFrameFormatProblemsOnEthernet Switching CircuitSwitchingMessageSwitchingPacketSwitchingCircuitSwitchingVsPacketSwitching RoutingAlgorithms DistanceVectorRouting IPAddress ClassesofIPAddressTypesofCastingProblemsOnIPAddressesClasslessInterDomainRouting Subnetting IPv4SubnettingHowtoCalculateSubnetMaskProblemsOnSubnetMaskRoutingTableUseofSubnetMask InternetProtocols IPv4HeaderFragmentationinNetworkLayerPracticeProblemsOnFragmentation TransportLayerProtocols CharacteristicsOfTCPTCPHeaderSequenceNumbers|WrapAroundConceptThreeWayHandshakeTCPRetransmissionTCPConnectionTerminationProblemsOnTCPTCPCongestionControlProblemsOnTCPCongestionControlTCPTimersTimeOutTimer|ComputationAlgorithmsSillyWindowSyndromeUserDatagramProtocol ApplicationLayerProtocols DomainNameServiceHyperTextTransferProtocolSimpleMailTransferProtocolPostOfficeProtocol|POPVsIMAPFileTransferProtocolComparisonofProtocols NetworkSecurity SymmetricKeyCryptographyRSAAlgorithmDiffieHellmanKeyExchangeAlgorithmDigitalSignaturesPopularGATEBooksLookInsideThisBook LookInsideThisBook ChooseyourSubject GATESubjectsDatabaseManagementSystemComputerNetworksOperatingSystemComputerOrganization&ArchitectureDataStructuresTheoryofAutomata&ComputationCompilerDesignGraphTheoryDesign&AnalysisofAlgorithmsDigitalDesignNumberSystemDiscreteMathematics B.TechSubjectsComputerGraphicsMachineLearningArtificialIntelligencePatternRecognitionSoftwareEngineeringJobOpportunitiesRecommendedBooks WhyThisBook? PopularGateBooksSubscribetogetEmailNotificationsFirstNameLastNameEmailAddressSubmitGATEExamCornerImportantTopicsForGATEExamStandardGATETextbooksGateVidyalay©2020ManagedbyMetaDivSystems



請為這篇文章評分?