IPv4 - Wikipedia
文章推薦指數: 80 %
Header IPv4 FromWikipedia,thefreeencyclopedia Jumptonavigation Jumptosearch Version4oftheInternetProtocol InternetProtocolversion4ProtocolstackIPv4packetPurposeinternetworkingprotocolDeveloper(s)DARPAIntroduction1981;41 yearsago (1981)OSIlayerNetworklayerRFC(s)RFC791 Internetprotocolsuite Applicationlayer BGP DHCP(v6) DNS FTP HTTP HTTPS IMAP LDAP MGCP MQTT NNTP NTP OSPF POP PTP ONC/RPC RTP RTSP RIP SIP SMTP SNMP SSH Telnet TLS/SSL XMPP more... Transportlayer TCP UDP DCCP SCTP RSVP QUIC more... Internetlayer IP IPv4 IPv6 ICMP(v6) NDP ECN IGMP IPsec more... Linklayer Tunnels PPP MAC more... vte InternetProtocolversion4(IPv4)isthefourthversionoftheInternetProtocol(IP).Itisoneofthecoreprotocolsofstandards-basedinternetworkingmethodsintheInternetandotherpacket-switchednetworks.IPv4wasthefirstversiondeployedforproductiononSATNETin1982andontheARPANETinJanuary1983.ItisstillusedtoroutemostInternettraffictoday,[1]evenwiththeongoingdeploymentofInternetProtocolversion6(IPv6),[2]itssuccessor. IPv4usesa32-bitaddressspacewhichprovides4,294,967,296(232)uniqueaddresses,butlargeblocksarereservedforspecialnetworkingpurposes.[3][4] Contents 1History 2Purpose 3Addressing 3.1Addressrepresentations 3.2Allocation 3.3Special-useaddresses 3.3.1Privatenetworks 3.4Link-localaddressing 3.5Loopback 3.6Firstandlastsubnetaddresses 3.7Addressresolution 3.8Unnumberedinterface 4Addressspaceexhaustion 5Packetstructure 5.1Header 5.2Data 6Fragmentationandreassembly 6.1Fragmentation 6.2Reassembly 7Assistiveprotocols 8Seealso 9Notes 10References 11Externallinks History[edit] InternetProtocolversion4isdescribedinIETFpublicationRFC791(September1981),replacinganearlierdefinitionofJanuary1980(RFC760).InMarch1982,theUSDepartmentofDefensedecidedontheInternetProtocolSuite(TCP/IP)asthestandardforallmilitarycomputernetworking.[5] Purpose[edit] TheInternetProtocolistheprotocolthatdefinesandenablesinternetworkingattheinternetlayeroftheInternetProtocolSuite.InessenceitformstheInternet.Itusesalogicaladdressingsystemandperformsrouting,whichistheforwardingofpacketsfromasourcehosttothenextrouterthatisonehopclosertotheintendeddestinationhostonanothernetwork. IPv4isaconnectionlessprotocol,andoperatesonabest-effortdeliverymodel,inthatitdoesnotguaranteedelivery,nordoesitassurepropersequencingoravoidanceofduplicatedelivery.Theseaspects,includingdataintegrity,areaddressedbyanupperlayertransportprotocol,suchastheTransmissionControlProtocol(TCP). Addressing[edit] Decompositionofthequad-dottedIPv4addressrepresentationtoitsbinaryvalue IPv4uses32-bitaddresseswhichlimitstheaddressspaceto4294967296(232)addresses. IPv4reservesspecialaddressblocksforprivatenetworks(~18millionaddresses)andmulticastaddresses(~270millionaddresses). Addressrepresentations[edit] IPv4addressesmayberepresentedinanynotationexpressinga32-bitintegervalue.Theyaremostoftenwrittenindot-decimalnotation,whichconsistsoffouroctetsoftheaddressexpressedindividuallyindecimalnumbersandseparatedbyperiods. Forexample,thequad-dottedIPaddress192.0.2.235representsthe32-bitdecimalnumber3221226219,whichinhexadecimalformatis0xC00002EB. CIDRnotationcombinestheaddresswithitsroutingprefixinacompactformat,inwhichtheaddressisfollowedbyaslashcharacter(/)andthecountofleadingconsecutive1bitsintheroutingprefix(subnetmask). Otheraddressrepresentationswereincommonusewhenclassfulnetworkingwaspracticed.Forexample,theloopbackaddress127.0.0.1iscommonlywrittenas127.1,giventhatitbelongstoaclass-Anetworkwitheightbitsforthenetworkmaskand24bitsforthehostnumber.Whenfewerthanfournumbersarespecifiedintheaddressindottednotation,thelastvalueistreatedasanintegerofasmanybytesasarerequiredtofillouttheaddresstofouroctets.Thus,theaddress127.65530isequivalentto127.0.255.250. Allocation[edit] IntheoriginaldesignofIPv4,anIPaddresswasdividedintotwoparts:thenetworkidentifierwasthemostsignificantoctetoftheaddress,andthehostidentifierwastherestoftheaddress.Thelatterwasalsocalledtherestfield.Thisstructurepermittedamaximumof256networkidentifiers,whichwasquicklyfoundtobeinadequate. Toovercomethislimit,themost-significantaddressoctetwasredefinedin1981tocreatenetworkclasses,inasystemwhichlaterbecameknownasclassfulnetworking.Therevisedsystemdefinedfiveclasses.ClassesA,B,andChaddifferentbitlengthsfornetworkidentification.Therestoftheaddresswasusedaspreviouslytoidentifyahostwithinanetwork.Becauseofthedifferentsizesoffieldsindifferentclasses,eachnetworkclasshadadifferentcapacityforaddressinghosts.Inadditiontothethreeclassesforaddressinghosts,ClassDwasdefinedformulticastaddressingandClassEwasreservedforfutureapplications. Dividingexistingclassfulnetworksintosubnetsbeganin1985withthepublicationofRFC 950.Thisdivisionwasmademoreflexiblewiththeintroductionofvariable-lengthsubnetmasks(VLSM)inRFC 1109in1987.In1993,basedonthiswork,RFC 1517introducedClasslessInter-DomainRouting(CIDR),[6]whichexpressedthenumberofbits(fromthemostsignificant)as,forinstance,/24,andtheclass-basedschemewasdubbedclassful,bycontrast.CIDRwasdesignedtopermitrepartitioningofanyaddressspacesothatsmallerorlargerblocksofaddressescouldbeallocatedtousers.ThehierarchicalstructurecreatedbyCIDRismanagedbytheInternetAssignedNumbersAuthority(IANA)andtheregionalInternetregistries(RIRs).EachRIRmaintainsapubliclysearchableWHOISdatabasethatprovidesinformationaboutIPaddressassignments. Special-useaddresses[edit] TheInternetEngineeringTaskForce(IETF)andIANAhaverestrictedfromgeneralusevariousreservedIPaddressesforspecialpurposes.[7]Notablytheseaddressesareusedformulticasttrafficandtoprovideaddressingspaceforunrestrictedusesonprivatenetworks. Specialaddressblocks Addressblock Addressrange Numberofaddresses Scope Description 0.0.0.0/8 0.0.0.0–0.255.255.255 16777216 Software Currentnetwork[8] 10.0.0.0/8 10.0.0.0–10.255.255.255 16777216 Private network Usedforlocalcommunicationswithinaprivatenetwork.[9] 100.64.0.0/10 100.64.0.0–100.127.255.255 4194304 Private network Sharedaddressspace[10]forcommunicationsbetweenaserviceprovideranditssubscriberswhenusingacarrier-gradeNAT. 127.0.0.0/8 127.0.0.0–127.255.255.255 16777216 Host Usedforloopbackaddressestothelocalhost.[8] 169.254.0.0/16 169.254.0.0–169.254.255.255 65536 Subnet Usedforlink-localaddresses[11]betweentwohostsonasinglelinkwhennoIPaddressisotherwisespecified,suchaswouldhavenormallybeenretrievedfromaDHCPserver. 172.16.0.0/12 172.16.0.0–172.31.255.255 1048576 Private network Usedforlocalcommunicationswithinaprivatenetwork.[9] 192.0.0.0/24 192.0.0.0–192.0.0.255 256 Private network IETFProtocolAssignments.[8] 192.0.2.0/24 192.0.2.0–192.0.2.255 256 Documentation AssignedasTEST-NET-1,documentationandexamples.[12] 192.88.99.0/24 192.88.99.0–192.88.99.255 256 Internet Reserved.[13]FormerlyusedforIPv6toIPv4relay[14](includedIPv6addressblock2002::/16). 192.168.0.0/16 192.168.0.0–192.168.255.255 65536 Private network Usedforlocalcommunicationswithinaprivatenetwork.[9] 198.18.0.0/15 198.18.0.0–198.19.255.255 131072 Private network Usedforbenchmarktestingofinter-networkcommunicationsbetweentwoseparatesubnets.[15] 198.51.100.0/24 198.51.100.0–198.51.100.255 256 Documentation AssignedasTEST-NET-2,documentationandexamples.[12] 203.0.113.0/24 203.0.113.0–203.0.113.255 256 Documentation AssignedasTEST-NET-3,documentationandexamples.[12] 224.0.0.0/4 224.0.0.0–239.255.255.255 268435456 Internet InuseforIPmulticast.[16](FormerClassDnetwork.) 233.252.0.0/24 233.252.0.0-233.252.0.255 256 Documentation AssignedasMCAST-TEST-NET,documentationandexamples.[16][17] 240.0.0.0/4 240.0.0.0–255.255.255.254 268435455 Internet Reservedforfutureuse.[18](FormerClassEnetwork.) 255.255.255.255/32 255.255.255.255 1 Subnet Reservedforthe"limitedbroadcast"destinationaddress.[8][19] Privatenetworks[edit] OftheapproximatelyfourbillionaddressesdefinedinIPv4,about18millionaddressesinthreerangesarereservedforuseinprivatenetworks.PacketsaddressesintheserangesarenotroutableinthepublicInternet;theyareignoredbyallpublicrouters.Therefore,privatehostscannotdirectlycommunicatewithpublicnetworks,butrequirenetworkaddresstranslationataroutinggatewayforthispurpose. ReservedprivateIPv4networkranges[9] Name CIDRblock Addressrange Numberofaddresses Classfuldescription 24-bitblock 10.0.0.0/8 10.0.0.0–10.255.255.255 16777216 SingleClassA. 20-bitblock 172.16.0.0/12 172.16.0.0–172.31.255.255 1048576 Contiguousrangeof16ClassBblocks. 16-bitblock 192.168.0.0/16 192.168.0.0–192.168.255.255 65536 Contiguousrangeof256ClassCblocks. Sincetwoprivatenetworks,e.g.,twobranchoffices,cannotdirectlyinteroperateviathepublicInternet,thetwonetworksmustbebridgedacrosstheInternetviaavirtualprivatenetwork(VPN)oranIPtunnel,whichencapsulatespackets,includingtheirheaderscontainingtheprivateaddresses,inaprotocollayerduringtransmissionacrossthepublicnetwork.Additionally,encapsulatedpacketsmaybeencryptedfortransmissionacrosspublicnetworkstosecurethedata. Link-localaddressing[edit] RFC3927definesthespecialaddressblock169.254.0.0/16forlink-localaddressing.Theseaddressesareonlyvalidonthelink(suchasalocalnetworksegmentorpoint-to-pointconnection)directlyconnectedtoahostthatusesthem.Theseaddressesarenotroutable.Likeprivateaddresses,theseaddressescannotbethesourceordestinationofpacketstraversingtheinternet.Theseaddressesareprimarilyusedforaddressautoconfiguration(Zeroconf)whenahostcannotobtainanIPaddressfromaDHCPserverorotherinternalconfigurationmethods. Whentheaddressblockwasreserved,nostandardsexistedforaddressautoconfiguration.MicrosoftcreatedanimplementationcalledAutomaticPrivateIPAddressing(APIPA),whichwasdeployedonmillionsofmachinesandbecameadefactostandard.Manyyearslater,inMay2005,theIETFdefinedaformalstandardinRFC3927,entitledDynamicConfigurationofIPv4Link-LocalAddresses. Loopback[edit] Mainarticle:Localhost TheclassAnetwork127.0.0.0(classlessnetwork127.0.0.0/8)isreservedforloopback.IPpacketswhosesourceaddressesbelongtothisnetworkshouldneverappearoutsideahost.Packetsreceivedonanon-loopbackinterfacewithaloopbacksourceordestinationaddressmustbedropped. Firstandlastsubnetaddresses[edit] Seealso:IPv4subnettingreference Thefirstaddressinasubnetisusedtoidentifythesubnetitself.Inthisaddressallhostbitsare0.Toavoidambiguityinrepresentation,thisaddressisreserved.[20]Thelastaddresshasallhostbitssetto1.Itisusedasalocalbroadcastaddressforsendingmessagestoalldevicesonthesubnetsimultaneously.Fornetworksofsize/24orlarger,thebroadcastaddressalwaysendsin255. Forexample,inthesubnet192.168.5.0/24(subnetmask255.255.255.0)theidentifier192.168.5.0isusedtorefertotheentiresubnet.Thebroadcastaddressofthenetworkis192.168.5.255. Binaryform Dot-decimalnotation Networkspace 11000000.10101000.00000101.00000000 192.168.5.0 Broadcastaddress 11000000.10101000.00000101.11111111 192.168.5.255 Inred,isshownthehostpartoftheIPaddress;theotherpartisthenetworkprefix.Thehostgetsinverted(logicalNOT),butthenetworkprefixremainsintact. However,thisdoesnotmeanthateveryaddressendingin0or255cannotbeusedasahostaddress.Forexample,inthe/16subnet192.168.0.0/255.255.0.0,whichisequivalenttotheaddressrange192.168.0.0–192.168.255.255,thebroadcastaddressis192.168.255.255.Onecanusethefollowingaddressesforhosts,eventhoughtheyendwith255:192.168.1.255,192.168.2.255,etc.Also,192.168.0.0isthenetworkidentifierandmustnotbeassignedtoaninterface.[21]Theaddresses192.168.1.0,192.168.2.0,etc.,maybeassigned,despiteendingwith0. Inthepast,conflictbetweennetworkaddressesandbroadcastaddressesarosebecausesomesoftwareusednon-standardbroadcastaddresseswithzerosinsteadofones.[22] Innetworkssmallerthan/24,broadcastaddressesdonotnecessarilyendwith255.Forexample,aCIDRsubnet203.0.113.16/28hasthebroadcastaddress203.0.113.31. Binaryform Dot-decimalnotation Networkspace 11001011.00000000.01110001.00010000 203.0.113.16 Broadcastaddress 11001011.00000000.01110001.00011111 203.0.113.31 Inred,isshownthehostpartoftheIPaddress;theotherpartisthenetworkprefix.Thehostgetsinverted(logicalNOT),butthenetworkprefixremainsintact. Asaspecialcase,a/31networkhascapacityforjusttwohosts.Thesenetworksaretypicallyusedforpoint-to-pointconnections.Thereisnonetworkidentifierorbroadcastaddressforthesenetworks.[23] Addressresolution[edit] Mainarticle:DomainNameSystem HostsontheInternetareusuallyknownbynames,e.g.,www.example.com,notprimarilybytheirIPaddress,whichisusedforroutingandnetworkinterfaceidentification.Theuseofdomainnamesrequirestranslating,calledresolving,themtoaddressesandviceversa.Thisisanalogoustolookingupaphonenumberinaphonebookusingtherecipient'sname. ThetranslationbetweenaddressesanddomainnamesisperformedbytheDomainNameSystem(DNS),ahierarchical,distributednamingsystemthatallowsforthesubdelegationofnamespacestootherDNSservers. Unnumberedinterface[edit] Aunnumberedpoint-to-point(PtP)link,alsocalledatransitlink,isalinkthatdoesn'thaveanyIPnetworkorsubnetnumberassociatedwithit,butstillhaveaIPaddress.Firstintroducedin1993.[24][25][26][27][28]Theonlypurposesofatransitlinkistoroutedatagrams. UnnumberedlinkisusedtofreeIPaddresses,whenhavingascarceIPaddressspace,orreducethemanagementofassigningIPandconfigurationofinterfaces.Previouseverylinkneedstodedicated/30or/31subnetusing2-4IPaddressesperpointtopointlink.Whenalinkisunnumberedarouter-idisused,router-idisIPaddress/32borrowedfromadefined(normallyaloopback)interface.Thesamerouter-idcanbeusedonmultipleinterfaces. Oneofthedisadvantagetounnumberedinterface,isthatishardertodoremotetestingandmanagement. PhilKarnfromQualcommiscreditasoriginaldesigner. Addressspaceexhaustion[edit] Mainarticle:IPv4addressexhaustion Sincethe1980s,itwasapparentthatthepoolofavailableIPv4addresseswasdepletingataratethatwasnotinitiallyanticipatedintheoriginaldesignofthenetwork.[29]ThemainmarketforcesthatacceleratedaddressdepletionincludedtherapidlygrowingnumberofInternetusers,whoincreasinglyusedmobilecomputingdevices,suchaslaptopcomputers,personaldigitalassistants(PDAs),andsmartphoneswithIPdataservices.Inaddition,high-speedInternetaccesswasbasedonalways-ondevices.Thethreatofexhaustionmotivatedtheintroductionofanumberofremedialtechnologies,suchas: ClasslessInter-DomainRouting(CIDR),forsmallerISPallocations Unnumberedinterface,removedtheneedontransitlinks. networkaddresstranslation,removedtheneedforend-to-endprinciple. Bythemid-1990s,pervasiveuseofnetworkaddresstranslation(NAT)innetworkaccessprovidersystems,andstrictusage-basedallocationpoliciesattheregionalandlocalInternetregistries. TheprimaryaddresspooloftheInternet,maintainedbyIANA,wasexhaustedon3February2011,whenthelastfiveblockswereallocatedtothefiveRIRs.[30][31]APNICwasthefirstRIRtoexhaustitsregionalpoolon15April2011,exceptforasmallamountofaddressspacereservedforthetransitiontechnologiestoIPv6,whichistobeallocatedunderarestrictedpolicy.[32] Thelong-termsolutiontoaddressexhaustionwasthe1998specificationofanewversionoftheInternetProtocol,IPv6.[33]Itprovidesavastlyincreasedaddressspace,butalsoallowsimprovedrouteaggregationacrosstheInternet,andofferslargesubnetworkallocationsofaminimumof264hostaddressestoendusers.However,IPv4isnotdirectlyinteroperablewithIPv6,sothatIPv4-onlyhostscannotdirectlycommunicatewithIPv6-onlyhosts.Withthephase-outofthe6boneexperimentalnetworkstartingin2004,permanentformaldeploymentofIPv6commencedin2006.[34]CompletionofIPv6deploymentisexpectedtotakeconsiderabletime,[35]sothatintermediatetransitiontechnologiesarenecessarytopermithoststoparticipateintheInternetusingbothversionsoftheprotocol. Packetstructure[edit] AnIPpacketconsistsofaheadersectionandadatasection.AnIPpackethasnodatachecksumoranyotherfooterafterthedatasection. TypicallythelinklayerencapsulatesIPpacketsinframeswithaCRCfooterthatdetectsmosterrors,manytransport-layerprotocolscarriedbyIPalsohavetheirownerrorchecking.[36] Header[edit] TheIPv4packetheaderconsistsof14fields,ofwhich13arerequired.The14thfieldisoptionalandaptlynamed:options.Thefieldsintheheaderarepackedwiththemostsignificantbytefirst(bigendian),andforthediagramanddiscussion,themostsignificantbitsareconsideredtocomefirst(MSB0bitnumbering).Themostsignificantbitisnumbered0,sotheversionfieldisactuallyfoundinthefourmostsignificantbitsofthefirstbyte,forexample. IPv4headerformat Offsets Octet 0 1 2 3 Octet Bit 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 0 0 Version IHL DSCP ECN TotalLength 4 32 Identification Flags FragmentOffset 8 64 TimeToLive Protocol HeaderChecksum 12 96 SourceIPAddress 16 128 DestinationIPAddress 20 160 Options(ifIHL>5) ⋮ ⋮ 56 448 Version ThefirstheaderfieldinanIPpacketisthefour-bitversionfield.ForIPv4,thisisalwaysequalto4. InternetHeaderLength(IHL) TheIPv4headerisvariableinsizeduetotheoptional14thfield(options).TheIHLfieldcontainsthesizeoftheIPv4header,ithas4bitsthatspecifythenumberof32-bitwordsintheheader.Theminimumvalueforthisfieldis5,[37]whichindicatesalengthof5×32bits=160bits=20bytes.Asa4-bitfield,themaximumvalueis15,thismeansthatthemaximumsizeoftheIPv4headeris15×32bits=480bits=60bytes. DifferentiatedServicesCodePoint(DSCP) Originallydefinedasthetypeofservice(ToS),thisfieldspecifiesdifferentiatedservices(DiffServ)perRFC2474.[a]Real-timedatastreamingmakesuseoftheDSCPfield.AnexampleisVoiceoverIP(VoIP),whichisusedforinteractivevoiceservices. ExplicitCongestionNotification(ECN) ThisfieldisdefinedinRFC3168andallowsend-to-endnotificationofnetworkcongestionwithoutdroppingpackets.ECNisanoptionalfeatureavailablewhenbothendpointssupportitandeffectivewhenalsosupportedbytheunderlyingnetwork. TotalLength This16-bitfielddefinestheentirepacketsizeinbytes,includingheaderanddata.Theminimumsizeis20bytes(headerwithoutdata)andthemaximumis65,535bytes.Allhostsarerequiredtobeabletoreassembledatagramsofsizeupto576bytes,butmostmodernhostshandlemuchlargerpackets.Linksmayimposefurtherrestrictionsonthepacketsize,inwhichcasedatagramsmustbefragmented.FragmentationinIPv4isperformedineitherthesendinghostorinrouters.Reassemblyisperformedatthereceivinghost. Identification ThisfieldisanidentificationfieldandisprimarilyusedforuniquelyidentifyingthegroupoffragmentsofasingleIPdatagram.SomeexperimentalworkhassuggestedusingtheIDfieldforotherpurposes,suchasforaddingpacket-tracinginformationtohelptracedatagramswithspoofedsourceaddresses,[38]butRFC6864nowprohibitsanysuchuse. Flags Athree-bitfieldfollowsandisusedtocontroloridentifyfragments.Theyare(inorder,frommostsignificanttoleastsignificant): bit0:Reserved;mustbezero.[b] bit1:Don'tFragment(DF) bit2:MoreFragments(MF) IftheDFflagisset,andfragmentationisrequiredtoroutethepacket,thenthepacketisdropped.Thiscanbeusedwhensendingpacketstoahostthatdoesnothaveresourcestoperformreassemblyoffragments.ItcanalsobeusedforpathMTUdiscovery,eitherautomaticallybythehostIPsoftware,ormanuallyusingdiagnostictoolssuchaspingortraceroute. Forunfragmentedpackets,theMFflagiscleared.Forfragmentedpackets,allfragmentsexceptthelasthavetheMFflagset.Thelastfragmenthasanon-zeroFragmentOffsetfield,differentiatingitfromanunfragmentedpacket. Fragmentoffset ThisfieldspecifiestheoffsetofaparticularfragmentrelativetothebeginningoftheoriginalunfragmentedIPdatagraminunitsofeight-byteblocks.Thefirstfragmenthasanoffsetofzero.The13bitfieldallowsamaximumoffsetof(213 –1)×8=65,528bytes,which,withtheheaderlengthincluded(65,528+20=65,548bytes),supportsfragmentationofpacketsexceedingthemaximumIPlengthof65,535bytes. Timetolive(TTL) Aneight-bittimetolivefieldlimitsadatagram'slifetimetopreventnetworkfailureintheeventofaroutingloop.Itisspecifiedinseconds,buttimeintervalslessthan1secondareroundedupto1.Inpractice,thefieldisusedasahopcount—whenthedatagramarrivesatarouter,therouterdecrementstheTTLfieldbyone.WhentheTTLfieldhitszero,therouterdiscardsthepacketandtypicallysendsanICMPtimeexceededmessagetothesender. TheprogramtraceroutesendsmessageswithadjustedTTLvaluesandusestheseICMPtimeexceededmessagestoidentifytherouterstraversedbypacketsfromthesourcetothedestination. Protocol ThisfielddefinestheprotocolusedinthedataportionoftheIPdatagram.IANAmaintainsalistofIPprotocolnumbersasdirectedbyRFC790. Headerchecksum The16-bitIPv4headerchecksumfieldisusedforerror-checkingoftheheader.Whenapacketarrivesatarouter,theroutercalculatesthechecksumoftheheaderandcomparesittothechecksumfield.Ifthevaluesdonotmatch,therouterdiscardsthepacket.Errorsinthedatafieldmustbehandledbytheencapsulatedprotocol.BothUDPandTCPhaveseparatechecksumsthatapplytotheirdata. Whenapacketarrivesatarouter,therouterdecreasestheTTLfieldintheheader.Consequently,theroutermustcalculateanewheaderchecksum. Sourceaddress ThisfieldistheIPv4addressofthesenderofthepacket.Notethatthisaddressmaybechangedintransitbyanetworkaddresstranslationdevice. Destinationaddress ThisfieldistheIPv4addressofthereceiverofthepacket.Aswiththesourceaddress,thismaybechangedintransitbyanetworkaddresstranslationdevice. Options Theoptionsfieldisnotoftenused.Packetscontainingsomeoptionsmaybeconsideredasdangerousbysomeroutersandbeblocked.[39]NotethatthevalueintheIHLfieldmustincludeenoughextra32-bitwordstoholdalltheoptionsplusanypaddingneededtoensurethattheheadercontainsanintegernumberof32-bitwords.IfIHLisgreaterthan5(i.e.,itisfrom6to15)itmeansthattheoptionsfieldispresentandmustbeconsidered.ThelistofoptionsmaybeterminatedwithanEOOL(EndofOptionsList,0x00)option;thisisonlynecessaryiftheendoftheoptionswouldnototherwisecoincidewiththeendoftheheader.Thepossibleoptionsthatcanbeputintheheaderareasfollows: Field Size(bits) Description Copied 1 Setto1iftheoptionsneedtobecopiedintoallfragmentsofafragmentedpacket. OptionClass 2 Ageneraloptionscategory.0isforcontroloptions,and2isfordebuggingandmeasurement.1and3arereserved. OptionNumber 5 Specifiesanoption. OptionLength 8 Indicatesthesizeoftheentireoption(includingthisfield).Thisfieldmaynotexistforsimpleoptions. OptionData Variable Option-specificdata.Thisfieldmaynotexistforsimpleoptions. ThetablebelowshowsthedefinedoptionsforIPv4.TheOptionTypecolumnisderivedfromtheCopied,OptionClass,andOptionNumberbitsasdefinedabove.[40] OptionType(decimal/hexadecimal) OptionName Description 0/0x00 EOOL EndofOptionList 1/0x01 NOP NoOperation 2/0x02 SEC Security(defunct) 7/0x07 RR RecordRoute 10/0x0A ZSU ExperimentalMeasurement 11/0x0B MTUP MTUProbe 12/0x0C MTUR MTUReply 15/0x0F ENCODE ENCODE 25/0x19 QS Quick-Start 30/0x1E EXP RFC3692-styleExperiment 68/0x44 TS TimeStamp 82/0x52 TR Traceroute 94/0x5E EXP RFC3692-styleExperiment 130/0x82 SEC Security(RIPSO) 131/0x83 LSR LooseSourceRoute 133/0x85 E-SEC ExtendedSecurity(RIPSO) 134/0x86 CIPSO CommercialIPSecurityOption 136/0x88 SID StreamID 137/0x89 SSR StrictSourceRoute 142/0x8E VISA ExperimentalAccessControl 144/0x90 IMITD IMITrafficDescriptor 145/0x91 EIP ExtendedInternetProtocol 147/0x93 ADDEXT AddressExtension 148/0x94 RTRALT RouterAlert 149/0x95 SDB SelectiveDirectedBroadcast 151/0x97 DPS DynamicPacketState 152/0x98 UMP UpstreamMulticastPkt. 158/0x9E EXP RFC3692-styleExperiment 205/0xCD FINN ExperimentalFlowControl 222/0xDE EXP RFC3692-styleExperiment Data[edit] Thepacketpayloadisnotincludedinthechecksum.ItscontentsareinterpretedbasedonthevalueoftheProtocolheaderfield. ListofIPprotocolnumberscontainsacompletelistofpayloadprotocoltypes.Someofthecommonpayloadprotocolsinclude: ProtocolNumber ProtocolName Abbreviation 1 InternetControlMessageProtocol ICMP 2 InternetGroupManagementProtocol IGMP 6 TransmissionControlProtocol TCP 17 UserDatagramProtocol UDP 41 IPv6encapsulation ENCAP 89 OpenShortestPathFirst OSPF 132 StreamControlTransmissionProtocol SCTP Fragmentationandreassembly[edit] Mainarticle:IPfragmentation TheInternetProtocolenablestrafficbetweennetworks.Thedesignaccommodatesnetworksofdiversephysicalnature;itisindependentoftheunderlyingtransmissiontechnologyusedinthelinklayer.Networkswithdifferenthardwareusuallyvarynotonlyintransmissionspeed,butalsointhemaximumtransmissionunit(MTU).WhenonenetworkwantstotransmitdatagramstoanetworkwithasmallerMTU,itmayfragmentitsdatagrams.InIPv4,thisfunctionwasplacedattheInternetLayerandisperformedinIPv4routerslimitingexposuretotheseissuesbyhosts. Incontrast,IPv6,thenextgenerationoftheInternetProtocol,doesnotallowrouterstoperformfragmentation;hostsmustperformPathMTUDiscoverybeforesendingdatagrams. Fragmentation[edit] Whenarouterreceivesapacket,itexaminesthedestinationaddressanddeterminestheoutgoinginterfacetouseandthatinterface'sMTU.IfthepacketsizeisbiggerthantheMTU,andtheDonotFragment(DF)bitinthepacket'sheaderissetto0,thentheroutermayfragmentthepacket. Therouterdividesthepacketintofragments.ThemaximumsizeofeachfragmentistheoutgoingMTUminustheIPheadersize(20bytesminimum;60bytesmaximum).Therouterputseachfragmentintoitsownpacket,eachfragmentpackethavingthefollowingchanges: Thetotallengthfieldisthefragmentsize. Themorefragments(MF)flagissetforallfragmentsexceptthelastone,whichissetto0. Thefragmentoffsetfieldisset,basedontheoffsetofthefragmentintheoriginaldatapayload.Thisismeasuredinunitsof8-byteblocks. Theheaderchecksumfieldisrecomputed. Forexample,foranMTUof1,500bytesandaheadersizeof20bytes,thefragmentoffsetswouldbemultiplesof 1,500 − 20 8 = 185 {\displaystyle{\frac{1{,}500-20}{8}}=185} (0,185,370,555,740,etc.). Itispossiblethatapacketisfragmentedatonerouter,andthatthefragmentsarefurtherfragmentedatanotherrouter.Forexample,apacketof4,520bytes,includinga20bytesIPheaderisfragmentedtotwopacketsonalinkwithanMTUof2,500bytes: Fragment Size(bytes) Headersize(bytes) Datasize(bytes) FlagMorefragments Fragmentoffset(8-byteblocks) 1 2,500 20 2,480 1 0 2 2,040 20 2,020 0 310 Thetotaldatasizeispreserved:2,480bytes+2,020bytes=4,500bytes.Theoffsetsare 0 {\displaystyle0} and 0 + 2,480 8 = 310 {\displaystyle{\frac{0+2{,}480}{8}}=310} . WhenforwardedtoalinkwithanMTUof1,500bytes,eachfragmentisfragmentedintotwofragments: Fragment Size(bytes) Headersize(bytes) Datasize(bytes) FlagMorefragments Fragmentoffset(8-byteblocks) 1 1,500 20 1,480 1 0 2 1,020 20 1,000 1 185 3 1,500 20 1,480 1 310 4 560 20 540 0 495 Again,thedatasizeispreserved:1,480+1,000=2,480,and1,480+540=2,020. Alsointhiscase,theMoreFragmentsbitremains1forallthefragmentsthatcamewith1inthemandforthelastfragmentthatarrives,itworksasusual,thatistheMFbitissetto0onlyinthelastone.Andofcourse,theIdentificationfieldcontinuestohavethesamevalueinallre-fragmentedfragments.Thisway,eveniffragmentsarere-fragmented,thereceiverknowstheyhaveinitiallyallstartedfromthesamepacket. Thelastoffsetandlastdatasizeareusedtocalculatethetotaldatasize: 495 × 8 + 540 = 3,960 + 540 = 4,500 {\displaystyle495\times8+540=3{,}960+540=4{,}500} . Reassembly[edit] Areceiverknowsthatapacketisafragment,ifatleastoneofthefollowingconditionsistrue: Theflagmorefragmentsisset,whichistrueforallfragmentsexceptthelast. Thefieldfragmentoffsetisnonzero,whichistrueforallfragmentsexceptthefirst. Thereceiveridentifiesmatchingfragmentsusingthesourceanddestinationaddresses,theprotocolID,andtheidentificationfield.ThereceiverreassemblesthedatafromfragmentswiththesameIDusingboththefragmentoffsetandthemorefragmentsflag.Whenthereceiverreceivesthelastfragment,whichhasthemorefragmentsflagsetto0,itcancalculatethesizeoftheoriginaldatapayload,bymultiplyingthelastfragment'soffsetbyeightandaddingthelastfragment'sdatasize.Inthegivenexample,thiscalculationwas 495 × 8 + 540 = 4,500 {\displaystyle495\times8+540=4{,}500} bytes.Whenthereceiverhasallfragments,theycanbereassembledinthecorrectsequenceaccordingtotheoffsetstoformtheoriginaldatagram. Assistiveprotocols[edit] IPaddressesarenottiedinanypermanentmannertohardwareidentificationsand,indeed,anetworkinterfacecanhavemultipleIPaddressesinmodernoperatingsystems.HostsandroutersneedadditionalmechanismstoidentifytherelationshipbetweendeviceinterfacesandIPaddresses,inordertoproperlydeliveranIPpackettothedestinationhostonalink.TheAddressResolutionProtocol(ARP)performsthisIP-address-to-hardware-addresstranslationforIPv4.(AhardwareaddressisalsocalledaMACaddress.)Inaddition,thereversecorrelationisoftennecessary.Forexample,whenanIPhostisbootedorconnectedtoanetworkitneedstodetermineitsIPaddress,unlessanaddressispreconfiguredbyanadministrator.ProtocolsforsuchinversecorrelationsexistintheInternetProtocolSuite.CurrentlyusedmethodsareDynamicHostConfigurationProtocol(DHCP),BootstrapProtocol(BOOTP)and,infrequently,reverseARP. Seealso[edit] HistoryoftheInternet Listofassigned/8IPv4addressblocks ListofIPprotocolnumbers Notes[edit] ^UpdatedbyRFC 3168andRFC 3260 ^AsanAprilFools'joke,proposedforuseinRFC3514asthe"Evilbit" References[edit] ^"BGPAnalysisReports".Retrieved2013-01-09. ^"IPv6–Google".www.google.com.Retrieved2022-01-28. ^"IANAIPv4Special-PurposeAddressRegistry".www.iana.org.Retrieved2022-01-28. ^"RFC5735-SpecialUseIPv4Addresses".datatracker.ietf.org.Retrieved2022-01-28. ^"ABriefHistoryofIPv4".IPv4MarketGroup.Retrieved2020-08-19. ^"UnderstandingIPAddressing:EverythingYouEverWantedToKnow"(PDF).3Com.Archivedfromtheoriginal(PDF)onJune16,2001. ^Cotton,M.;Vegoda,L.(January2010).SpecialUseIPv4Addresses.doi:10.17487/RFC5735.RFC5735. ^abcdM.Cotton;L.Vegoda;R.Bonica;B.Haberman(April2013).Special-PurposeIPAddressRegistries.InternetEngineeringTaskForce.doi:10.17487/RFC6890.BCP153.RFC6890.UpdatedbyRFC 8190. ^abcdY.Rekhter;B.Moskowitz;D.Karrenberg;G.J.deGroot;E.Lear(February1996).AddressAllocationforPrivateInternets.NetworkWorkingGroup.doi:10.17487/RFC1918.BCP5.RFC1918.UpdatedbyRFC 6761. ^J.Weil;V.Kuarsingh;C.Donley;C.Liljenstolpe;M.Azinger(April2012).IANA-ReservedIPv4PrefixforSharedAddressSpace.InternetEngineeringTaskForce(IETF).doi:10.17487/RFC6598.ISSN 2070-1721.BCP153.RFC6598. ^S.Cheshire;B.Aboba;E.Guttman(May2005).DynamicConfigurationofIPv4Link-LocalAddresses.NetworkWorkingGroup.doi:10.17487/RFC3927.RFC3927. ^abcJ.Arkko;M.Cotton;L.Vegoda(January2010).IPv4AddressBlocksReservedforDocumentation.InternetEngineeringTaskForce.doi:10.17487/RFC5737.ISSN 2070-1721.RFC5737. ^O.Troan(May2015).B.Carpenter(ed.).DeprecatingtheAnycastPrefixfor6to4RelayRouters.InternetEngineeringTaskForce.doi:10.17487/RFC7526.BCP196.RFC7526. ^C.Huitema(June2001).AnAnycastPrefixfor6to4RelayRouters.NetworkWorkingGroup.doi:10.17487/RFC3068.RFC3068.ObsoletedbyRFC 7526. ^S.Bradner;J.McQuaid(March1999).BenchmarkingMethodologyforNetworkInterconnectDevices.NetworkWorkingGroup.doi:10.17487/RFC2544.RFC2544.Updatedby:RFC 6201andRFC 6815. ^abM.Cotton;L.Vegoda;D.Meyer(March2010).IANAGuidelinesforIPv4MulticastAddressAssignments.InternetEngineeringTaskForce.doi:10.17487/RFC5771.BCP51.RFC5771. ^S.Venaas;R.Parekh;G.VandeVelde;T.Chown;M.Eubanks(August2012).MulticastAddressesforDocumentation.InternetEngineeringTaskForce.doi:10.17487/RFC6676.RFC6676. ^J.Reynolds,ed.(January2002).AssignedNumbers:RFC1700isReplacedbyanOn-lineDatabase.NetworkWorkingGroup.doi:10.17487/RFC3232.RFC3232.ObsoletesRFC 1700. ^JeffreyMogul(October1984).BroadcastingInternetDatagrams.NetworkWorkingGroup.doi:10.17487/RFC0919.RFC919. ^"RFC923".IETF.June1984.Retrieved15November2019.SpecialAddresses:Incertaincontexts,itisusefultohavefixedaddresseswithfunctionalsignificanceratherthanasidentifiersofspecifichosts.Whensuchusageiscalledfor,theaddresszeroistobeinterpretedasmeaning"this",asin"thisnetwork". ^RobertBraden(October1989)."RequirementsforInternetHosts –CommunicationLayers".IETF.p. 31.RFC 1122. ^RobertBraden(October1989)."RequirementsforInternetHosts –CommunicationLayers".IETF.p. 66.RFC 1122. ^RFC 3021 ^Almquist,Philip;Kastenholz,Frank(November1994)."TowardsRequirementsforIPRouters".{{citejournal}}:Citejournalrequires|journal=(help) ^RFC 1916 ^RFC 1716 ^RFC 1812 ^"UnderstandingandConfiguringtheipunnumberedCommand".Cisco.Retrieved2021-11-25. ^"World'runningoutofInternetaddresses'".Archivedfromtheoriginalon2011-01-25.Retrieved2011-01-23. ^Smith,Lucie;Lipner,Ian(3February2011)."FreePoolofIPv4AddressSpaceDepleted".NumberResourceOrganization.Retrieved3February2011. ^ICANN,nanogmailinglist."Five/8sallocatedtoRIRs –nounallocatedIPv4unicast/8sremain". ^Asia-PacificNetworkInformationCentre(15April2011)."APNICIPv4AddressPoolReachesFinal/8".Archivedfromtheoriginalon7August2011.Retrieved15April2011. ^Hinden,Bob;Deering,SteveE.(December1998)."InternetProtocol,Version6(IPv6)Specification".tools.ietf.org.Retrieved2019-12-13. ^Fink,R.;HInden,R.(March2004).6bone(IPv6TestingAddressAllocation)Phaseout.doi:10.17487/RFC3701.RFC3701. ^2016IEEEInternationalConferenceonEmergingTechnologiesandInnovativeBusinessPracticesfortheTransformationofSocieties(EmergiTech) :date,3-6Aug.2016.UniversityofTechnology,Mauritius,InstituteofElectricalandElectronicsEngineers.Piscataway,NJ.2016.ISBN 9781509007066.OCLC 972636788.{{citebook}}:CS1maint:others(link) ^Partridge,C.;Kastenholz,F.(December1994)."6.2IPHeaderChecksum".TechnicalCriteriaforChoosingIPTheNextGeneration(IPng).p. 26. sec. 6.2.doi:10.17487/RFC1726.RFC1726. ^Postel,J.InternetProtocol.doi:10.17487/RFC0791.RFC791. ^Savage,Stefan(2000)."PracticalnetworksupportforIPtraceback".ACMSIGCOMMComputerCommunicationReview.30(4):295–306.doi:10.1145/347057.347560.Retrieved2010-09-06. ^"CiscounofficialFAQ".Retrieved2012-05-10. ^"InternetProtocolVersion4(IPv4)Parameters". Externallinks[edit] IPv4atWikipedia'ssisterprojectsDefinitionsfromWiktionaryMediafromCommonsResourcesfromWikiversity InternetAssignedNumbersAuthority(IANA) IP,InternetProtocol—IPHeaderBreakdown,includingspecificoptions RFC 3344—IPv4Mobility IPv6vs.carrier-gradeNAT/squeezingmoreoutofIPv4 RIPEreportonaddressconsumptionasofOctober2003 OfficialcurrentstateofIPv4/8allocations,asmaintainedbyIANA DynamicallygeneratedgraphsofIPv4addressconsumptionwithpredictionsofexhaustiondates—GeoffHuston IPaddressinginChinaandthemythofaddressshortage CountdownofremainingIPv4availableaddresses(estimated) Authoritycontrol:Nationallibraries Germany Retrievedfrom"https://en.wikipedia.org/w/index.php?title=IPv4&oldid=1077835101" Categories:IPv4InternetStandardsInternetlayerprotocolsNetworklayerprotocolsHiddencategories:CS1errors:missingperiodicalCS1maint:othersArticleswithshortdescriptionShortdescriptionmatchesWikidataPagesusingSisterprojectlinkswithdefaultsearchArticleswithGNDidentifiersArticlescontainingvideoclips Navigationmenu Personaltools NotloggedinTalkContributionsCreateaccountLogin Namespaces ArticleTalk English expanded collapsed Views ReadEditViewhistory More expanded collapsed Search Navigation MainpageContentsCurrenteventsRandomarticleAboutWikipediaContactusDonate Contribute HelpLearntoeditCommunityportalRecentchangesUploadfile Tools WhatlinkshereRelatedchangesUploadfileSpecialpagesPermanentlinkPageinformationCitethispageWikidataitem Print/export DownloadasPDFPrintableversion Inotherprojects WikimediaCommons Languages العربيةAzərbaycancaবাংলাБеларускаяБългарскиBosanskiČeštinaDanskDeutschEestiΕλληνικάEspañolEuskaraفارسیFrançaisGalegoગુજરાતી한국어हिन्दीHrvatskiBahasaIndonesiaItalianoעבריתLatviešuLingálaМакедонскиമലയാളംBahasaMelayuNederlands日本語NorskbokmålPolskiPortuguêsРусскийSlovenčinaСрпски/srpskiSrpskohrvatski/српскохрватскиSvenskaதமிழ்TürkçeУкраїнськаTiếngViệt吴语Yorùbá粵語中文 Editlinks
延伸文章資訊
- 1IPv4 - Packet Structure - Tutorialspoint
IPv4 - Packet Structure · Version − Version no. · IHL − Internet Header Length; Length of entire ...
- 2IPv4 Header Format | Gate Vidyalay
IPv4 | IPv4 Header | IPv4 Header Format · IPv4 short for Internet Protocol Version 4 is the fourt...
- 3Learn Components of IPv4 Header Format - eduCBA
IPv4 Header Format Component · Version: The first header field is a 4-bit version indicator. · In...
- 4IPv4 - Wikipedia
Header
- 5IPv4 Datagram | Baeldung on Computer Science