資源描述:
《tcp及udp區(qū)別》由會員上傳分享,免費在線閱讀,更多相關內容在行業(yè)資料-天天文庫。
1、TCP與UDP區(qū)別TCP---傳輸控制協(xié)議,提供的是面向連接、可靠的字節(jié)流服務。當客戶和服務器彼此交換數(shù)據(jù)前,必須先在雙方之間建立一個TCP連接,之后才能傳輸數(shù)據(jù)。TCP提供超時重發(fā),丟棄重復數(shù)據(jù),檢驗數(shù)據(jù),流量控制等功能,保證數(shù)據(jù)能從一端傳到另一端。UDP---用戶數(shù)據(jù)報協(xié)議,是一個簡單的面向數(shù)據(jù)報的運輸層協(xié)議。UDP不提供可靠性,它只是把應用程序傳給IP層的數(shù)據(jù)報發(fā)送出去,但是并不能保證它們能到達目的地。由于UDP在傳輸數(shù)據(jù)報前不用在客戶和服務器之間建立一個連接,且沒有超時重發(fā)等機制,故而傳輸速度很快
2、OverviewTCP(TransmissionControlProtocol)isthemostcommonlyusedprotocolontheInternet.ThereasonforthisisbecauseTCPofferserrorcorrection.WhentheTCPprotocolisusedthereisa"guaranteeddelivery."Thisisduelargelyinparttoamethodcalled"flowcontrol."Flowcontroldetermi
3、neswhendataneedstobere-sent,andstopstheflowofdatauntilpreviouspacketsaresuccessfullytransferred.Thisworksbecauseifapacketofdataissent,acollisionmayoccur.Whenthishappens,theclientre-requeststhepacketfromtheserveruntilthewholepacketiscompleteandisidenticalt
4、oitsoriginal.UDP(UserDatagramProtocol)isanthercommonlyusedprotocolontheInternet.However,UDPisneverusedtosendimportantdatasuchaswebpages,databaseinformation,etc;UDPiscommonlyusedforstreamingaudioandvideo.StreamingmediasuchasWindowsMediaaudiofiles(.WMA),Rea
5、lPlayer(.RM),andothersuseUDPbecauseitoffersspeed!ThereasonUDPisfasterthanTCPisbecausethereisnoformofflowcontrolorerrorcorrection.ThedatasentovertheInternetisaffectedbycollisions,anderrorswillbepresent.RememberthatUDPisonlyconcernedwithspeed.Thisisthemainr
6、easonwhystreamingmediaisnothighquality.Onthecontrary,UDPhasbeenimplementedamongsometrojanhorseviruses.HackersdevelopscriptsandtrojanstorunoverUDPinordertomasktheiractivities.UDPpacketsarealsousedinDoS(DenialofService)attacks.Itisimportanttoknowthedifferen
7、cebetweenTCPport80andUDPport80.Ifyoudon'tknowwhatportsaregohere.FrameStructureAsdatamovesalonganetwork,variousattributesareaddedtothefiletocreateaframe.Thisprocessiscalledencapsulation.Therearedifferentmethodsofencapsulationdependingonwhichprotocolandtopo
8、logyarebeingused.Asaresult,theframestructureofthesepacketsdifferaswell.TheimagesbelowshowboththeTCPandUDPframestructures.TCPFRAMESTRUCTUREUDPFRAMESTRUCTUREThepayloadfieldcontainstheactuallydata.NoticethatTCPhasamore