UDP.docx
- 文档编号:10021155
- 上传时间:2023-02-08
- 格式:DOCX
- 页数:12
- 大小:674.16KB
UDP.docx
《UDP.docx》由会员分享,可在线阅读,更多相关《UDP.docx(12页珍藏版)》请在冰豆网上搜索。
UDP
实验三WiresharkLab:
UDP
一.实验目的
通过此次试验,应该对UGP的报文段的头部以及其中的字段有更好地掌握.
二、实验器材
1.PC机电脑一台。
2.WireShark软件,并安装。
三、实验内容
用WireShark抓取让自己主机发出和接受UDP协议的包。
然后观察这些包中的其中一个,回答问题,从而更好地掌握UDP协议.
四、实验操作实践与步骤
IchoosethefirstoneUDP.
1.Selectonepacket.Fromthispacket,determinehowmanyfieldsthereareintheUDPheader.(Donotlookinthetextbook!
Answerthesequestionsdirectlyfromwhatyouobserveinthepackettrace.)Namethesefields.
Thereare4fieldsintheUDPheader.
Theirnamesare:
Sourceport;Destinationport;Length;Checksum.
2.Fromthepacketcontentfield,determinethelength(inbytes)ofeachoftheUDPheaderfields.
ThelengthofUDPdatagramis159bytes,thelengthofdatais151bytes.So,thelengthofUDPheaderis(159-151=)8bytes.
3.ThevalueintheLengthfieldisthelengthofwhat?
VerifyyourclaimwithyourcapturedUDPpacket.
ThevalueintheLengthfieldisthelengthofUDPdatagram.
4.WhatisthemaximumnumberofbytesthatcanbeincludedinaUDPpayload?
Thetotallengthis1500bytes.ThelengthofIPheaderis20bytes.ThelengthofUDPheaderis8bytes.So,Themaximumnumberofbytesis(1500-20-8=)1472bytes.
5.Whatisthelargestpossiblesourceportnumber?
ThelengthofUDPheaderis8bytes.Thereare4fields.Everyoneofthemarethesamelength.So,thesourceportis2bytes.
Thetotalnumberis(2^16=)65536.
Andtheboundaryofsourceportnumberis(0~65535).
Thelargestpossiblesourceportnumberis65535.
6.WhatistheprotocolnumberforUDP?
Giveyouranswerinbothhexadecimalanddecimalnotation.(Toanswerthisquestion,you’llneedtolookintotheIPheader.)
TheprotocolnumberforUDPis17.
7.
Search“UDP”inGoogleanddeterminethefieldsoverwhichtheUDPchecksumiscalculated.
ThewaytocalculateUDPchecksum.
Thisprotocolprovidesaprocedureforapplicationprogramstosend
messagestootherprogramswithaminimumofprotocolmechanism.The
protocolistransactionoriented,anddeliveryandduplicateprotection
arenotguaranteed.Applicationsrequiringorderedreliabledeliveryof
streamsofdatashouldusetheTransmissionControlProtocol(TCP)[2].
Format
------
0781516232431
+--------+--------+--------+--------+
|Source|Destination|
|Port|Port|
+--------+--------+--------+--------+
|||
|Length|Checksum|
+--------+--------+--------+--------+
|
|dataoctets...
+----------------...
UserDatagramHeaderFormat
Fields
------
SourcePortisanoptionalfield,whenmeaningful,itindicatestheport
ofthesendingprocess,andmaybeassumedtobetheporttowhicha
replyshouldbeaddressedintheabsenceofanyotherinformation.If
notused,avalueofzeroisinserted.
Postel[page1]
28Aug1980
UserDatagramProtocolRFC768
Fields
DestinationPorthasameaningwithinthecontextofaparticular
internetdestinationaddress.
Lengthisthelengthinoctetsofthisuserdatagramincludingthis
headerandthedata.(Thismeanstheminimumvalueofthelengthis
eight.)
Checksumisthe16-bitone'scomplementoftheone'scomplementsumofa
pseudoheaderofinformationfromtheIPheader,theUDPheader,andthe
data,paddedwithzerooctetsattheend(ifnecessary)tomakea
multipleoftwooctets.
ThepseudoheaderconceptuallyprefixedtotheUDPheadercontainsthe
sourceaddress,thedestinationaddress,theprotocol,andtheUDP
length.Thisinformationgivesprotectionagainstmisrouteddatagrams.
ThischecksumprocedureisthesameasisusedinTCP.
0781516232431
+--------+--------+--------+--------+
|sourceaddress|
+--------+--------+--------+--------+
|destinationaddress|
+--------+--------+--------+--------+
|zero|protocol|UDPlength|
+--------+--------+--------+--------+
Ifthecomputedchecksumiszero,itistransmittedasallones(the
equivalentinone'scomplementarithmetic).Anallzerotransmitted
checksumvaluemeansthatthetransmittergeneratednochecksum(for
debuggingorforhigherlevelprotocolsthatdon'tcare).
8.ExamineapairofUDPpacketsinwhichthefirstpacketissentbyyourhostandthesecondpacketisareplytothefirstpacket.Describetherelationshipbetweentheportnumbersinthetwopackets.
TotheUDPpacketwhichmyhostsentandmyhostreceived,theirsourceportnumberanddestinationportnumberareeachother.Wecanseeitfromtheabove2images.
ExtraCredit
1.CaptureasmallUDPpacket.Manuallyverifythechecksuminthispacket.Showallworkandexplainallsteps.
以太网帧首部(14字节):
01005e2217ea00247e0518370800
IP首部(20字节):
4500003041f800000111e3a80a028829ea2217ea
UDP首部(8字节):
fb43838a001cbab4
源端口号:
fb43目的端口号:
838a
UDP长度:
001c
伪首部字段:
32位源IP地址、32位目的IP地址、8位协议、16位UDP长度.
udp数据报和tcp报文段在为了计算检验和而设置了一个12字节长的伪首部。
由于udp数据报的长度可以为奇数字节,但是检验和算法是把若干个16bit字相加,因此可在填充字节字段填入0,可能增加的填充字节不被传送。
因此必须构造12字节的伪首部:
0a028829
ea2217ea
0011
001c
构造完毕之后,把udp检验和部分置0,然后对udp每个16bit进行二进制反码求和,
0a02+8829+ea22+17ea+0011+001c+fb43+838a+001c+0000+
1000+0000+…+4fbb+5ef3=454b
计算过程如下:
0a02+8829+ea22+17ea=9438
0011+001c+fb43+838a=7efb
001c+0000+1000+aed3+fa1e=b90e
Efff+fa4e+37fd+a80d=ca59
4fbb+5ef3=aeae
再把以上算的结果相加:
9438+7efb+b90e=cc42
ca59+aeae=7908
最后的结果为:
cc42+7908=454b
对454b求反即得:
CheckSum:
bab4
五、实验结论
1.UDP报文段头部8个字节,分为四个字段,分别为:
源端口号,目的端口号,长度和检验和。
2.UDP报文段的最大长度为1472个字节。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- UDP
![提示](https://static.bdocx.com/images/bang_tan.gif)