资料
  • 资料
  • 专题
uC/IP源代码
推荐星级:
时间:2019-12-24
大小:548.32KB
阅读数:173
上传用户:rdg1993
查看他发布的资源
下载次数
0
所需E币
3
ebi
新用户注册即送 300 E币
更多E币赚取方法,请查看
close
资料介绍
一个用于uC/OS的TCP/IP/PPP协议栈Version1.0.0ThesereleasenotesforuC/IParedividedintothefollowingsections:Introduction-AnoverviewoftheuC/IPproject.DesignOverview-Commentsonthedesignofthestack.Features-DescriptionofthefeaturesprovidedornotbyuC/IP.Copyright-Descriptionofthecopyrightsonthesourcefiles.Files-Abriefdescriptionofeachofthesourcefiles.Build-Commentsonhowtobuildthestackforyourapplication.ToDo-Anon-triviallistofthingsonthewishlist.Support-Wheretofindsupportinusingthestack.IntroductionThisisthefirstreleaseofafreeTCP/IP/PPPprotocolstackfortheuC/OSReal-TimeOperatingSystem.Asafirstreleaseit'sstillratherroughandverymuchlargerthandesiredhoweveritisworkingwellinanembeddedproductandthereforemaybeusefultoothers.MuchofthecodeisportedfrompublicsourcesincludingBDSLiteandKA9Q(anditsderivatives)andcarriescopyrightnoticesfromthosesources.EssentiallyTCPisbasedonKA9QbutwithideasfromBSD,IPisasimpleimplementationsupportingBSDstructures,ICMPisportedfromBSD,andPPPisportedfromtheBSDversionofthedistributioncommontoBSD,Linux,andmanyothersystems.ABriefHistoryWeatGlobalElectionSystemsInc.havebeenconvertingourembeddedsystemsfrommonolithicdesignsandproprietaryprotocolstoreal-timemultitaskingdesignsandstandardprotocols.Forvariousreasons,wechoseuC/OSasthefoundationforourprojectsbutwhenevaluatingthecommercialTCPofferings,wefeltthatwewouldwanttotweakthemasmuchaswewouldthepublicsourcesandthereforewemightaswelljustworkwiththepublicsources.Westartedwithvolumes1and2ofStevens'TCP/IPIllustratedandaCDROMofBSD-Liteanddivedintoit.Asalways,itwasrathermoreinvolvedthanplannedbutalsomorerewardinginthatbythetimewegotthroughit,wereallyknewourstuff.LuckilyGlobalhasnocommercialinterestintheresultandwasquitewillingtoletmemakethecodepubliclyavailableprovidedthatIdiditonmyowntimeandthattherewasnoliabilitytothecompany.DesignOverviewThisstackisdesignedforasmallblackboxsystemwithaminimaluserinterfaceandaserialport.Nokeyboard,novideodisplay,nodiskdrive,andnonetworkadaptor.Invariousmodesourboxcanoperateindependantlywithoccasionalconnectionstoahostoritcanworkonlinewithcontinouscommunicationswiththehost.Ourseriallinkmaybedirectlyconnectedtothehostorviamodemandtelephonelines.Now,usingtheTCPprocotols,theconnectionmaygothroughanynetworkconfigurationincludingtheInternet.NetworkBuffersCentraltothesourcesweusedistheideaofanetworkormemorybuffer.InBSDandKA9Qit'sknownasanmbuf.Normallydataistransferredtoachainofbuffersatthepacketinterface(commonlyknownsimplyasaninterface)whicharethentransferredviaqueuesthroughtheprotocollayersuntilfinallybeingunloadedatthesocketlayer.WemodifiedthedesignofthembufandrenameditnbufforNetworkBuffer.SinceoursystemhaslimitedRAMspaceandwewanttoguaranteethatneededspaceisalwaysavailable,wecreateafixednumberofnbufsandmanagethemasaresourcepool.Thenetbufmoduleprovidesfunctionssupportingnbufallocationandqueueingandservicessuchasprepending,appending,andtruncatingnbufchains.Inourstack,weusenbufsrightfromtheserialinterrupthandleruptotheapplicationinterface.Foranyparticularapplication,it'simportanttoselectthenbufandpoolsizesforoptimumperformance.First,setthesizeofthenbufssothatonaverage,eachpacketfitsinasinglenbuf.Ifyourapplicationcommunicateswithalotofsmallpacketsandrarelymorethan100bytes,sayatelnetappthatreturnsasinglelineatatime,thensetthenbufsizetoabout50bytesandallocatemoreofthem.Ifyourapplicationdoesbulktransfers,setthenbufsizetohandleafullTCPsegmentandtherebyminimizethechainingoverhead.ThereiscurrentlyaminimumnbufsizesinceitneedstohandleanentireLCPpacketinPPP.WithalittleworkLCPwouldbeabletohandlepacketssplitacrossmultiplenbufs.InthenextpassthroughthecodeI'dliketoaddabuffertypefieldthattheprotocolscanusetoautomaticallyhandledatafromdifferentsources.Inparticular,I'dliketoknowwhetherornotaPPPpacketneedstohavespecialcharactersescapedornotsothatthiscouldbehandledintheserialdriver.WhenthePPPprotocolsbuildapacket,theyautomaticallyencodethespecialcharacters.Tohandlethis,PPPneedstoknowwhereapacketoriginatedandthenensurethatallpacketsareencodedbeforepassingthemtotheserialdriver.Thisrequiresacharacterbycharacterfilter(copy)operationwhichcouldtriviallybehandledatthedriverlevelifonlyitknew.PointtoPointProtocolThePPPcodewasthefirstcodeimplementedandisthegreatestresourcehog.PPPiscomposedofanumberofdifferentprotocolshandlingeverythingfromtestingthelinktocompressionanduserauthentication.EssentiallyPPPrecievesnbufpacketchainsfromtheserialport,filtersouttheescapesequences,passesitthroughdecompressorsandfinallypassesanIPpackettotheIPprotocol.InmostsystemsPPPisimplementedasapacketdriversothatit'scompatiblewiththeinterfaceforanethernetpacketdriverbutthatrequiresmanaginganothersetofbuffers.MostofthePPPprotocolsusethefinitestatemachineengineinthenetfsmmodule.NotethatalthoughcodeisincludedforCHAP,ithasneverbeenusedandwillnotlikelyworkout-of-the-box.TransactionControlProtocol/InternetProtocolAsmentioned,theTCPcodeisbasedontheKA9QsourcesalthoughtheTCPControlBlock(TCB)includesfieldsfromtheBSDcodes.Thebiggestchangesfromeitherofthesesourcesisinthetimersandtheuseofsemaphores.KA9QwaswrittenforthesingletaskingenvironmentofDOSandthereforeusescallbackfunctionstodriveapplicationsusingthestack.WewantedtomakeblockingcallsandthereforewebuiltsemaphoresintotheTCBtosychronizereads,writes,connections,andformutualexclusionofcriticalsections.Thisdesigndoesn'thandlewakingupmultipletaskswaitingonareadorwritewhichwouldbeusefuliftheconnectionhasclosed.Thisisn'taproblemforourapplicationbutI'dliketofindamoregeneralsolution.InUnix,thenormalmethodtohandleTCPtimersistohaveprocessespollingalloftheTCBat200msand500msintervals.Likeallpolling,thismeansthatCPUcyclesare"wasted"checkingTCB'sthatdon'tneedtobeservicedbutthemethodscaleswell(i.e.linearly)tolargenumbersofTCBs.InuC/IPweuseLinuxstyletimerswithpreallocatedtimerstructuresthatgetinsertedintoanorderedlinkedlistthatispolledbythesystemclockinterrupt.ThisworkswellforasmallnumberofTCBsbutformorethanafewdozen,theoverheadofinsertingandremovingtimersfromthelistwouldstarttoexceedinanon-linearfashionthecostofpollingalltheTCBs.TheIPmoduleisprettybasicsinceweonlydotrivialroutingandwedon'thandlefragmentation.OnethingthatIwouldliketochangeistheuseofthesocketstylenetworkaddresses.Thesockaddrstruct(NetAddrtype)iswonderfullygeneralwhenyouwantittohandleanytypeofnetworkaddressbutwon'tbeabletohandleIPv6addresseswithoutchange.So,IwouldliketogothroughandsimplyhandleIPaddresses.FeaturesFeaturesSupportedPPPwithPAPauthenticationandVJcompressiondynamicIPoptimizedforsinglerequest/responseexchangesTCPkeepalivepollingwithprogrammableintervalsTheoptimizationFeaturesNOTSupportedCHAPauthentication(thecodeistherebutnotused)delayedTCPacknowledgement……
版权说明:本资料由用户提供并上传,仅用于学习交流;若内容存在侵权,请进行举报,或 联系我们 删除。
PARTNER CONTENT
相关评论 (下载后评价送E币 我要评论)
没有更多评论了
  • 可能感兴趣
  • 关注本资料的网友还下载了
  • 技术白皮书