SharpPcap中文开发全攻略Word格式.docx

上传人:b****6 文档编号:16827775 上传时间:2022-11-26 格式:DOCX 页数:38 大小:50.64KB
下载 相关 举报
SharpPcap中文开发全攻略Word格式.docx_第1页
第1页 / 共38页
SharpPcap中文开发全攻略Word格式.docx_第2页
第2页 / 共38页
SharpPcap中文开发全攻略Word格式.docx_第3页
第3页 / 共38页
SharpPcap中文开发全攻略Word格式.docx_第4页
第4页 / 共38页
SharpPcap中文开发全攻略Word格式.docx_第5页
第5页 / 共38页
点击查看更多>>
下载资源
资源描述

SharpPcap中文开发全攻略Word格式.docx

《SharpPcap中文开发全攻略Word格式.docx》由会员分享,可在线阅读,更多相关《SharpPcap中文开发全攻略Word格式.docx(38页珍藏版)》请在冰豆网上搜索。

SharpPcap中文开发全攻略Word格式.docx

NET应用WinPcap而在他的大学最后项目的工作。

TheprojectinvolvedanalyzinganddecodingVoIPtrafficandhewantedtokeepcodingsimplewithC#whichhastimesavingfeatureslikegarbagecollection.该项目涉及VoIP流量分析和解码,他想继续用C#编码具有省时,如垃圾收集功能简单。

AccessingtheWinPcapAPIfrom.NETseemedtobequiteapopularrequirement,andhefoundsomeusefulprojectsonCodeProject'

swebsitethatletyoudojustthat:

WinPcap的API的访问似乎从净是相当流行的要求,他发现在CodeProject上的一些网站,让您做到这一点有益的项目。

∙PacketCaptureandAnalyzer数据包捕获和分析仪

∙RawSocketCapturingUsingC#原始套接字捕获使用C#

∙Packetsniffingwithwinpcapfunctionsportedtoa.NETlibrary与WinPcap的包嗅探功能移植到。

NET库

Thefirstprojectisagreatethereal.NETclonethatletsyoucaptureandanalyzenumeroustypesofprotocolpackets.第一个项目是一个伟大的空灵。

NET的克隆,让您获取和分析大量的数据包的协议类型。

However,afewissueswiththisprojectmakeitalmostimpossibletobesharedamongother.NETapplications.然而,随着这个项目的几个问题使它几乎不可能得到在其他。

NET应用程序共享。

Firstly,theauthordidnotprovideanygenericAPIforcapturingpacketsthatcanbeusedbyother.NETapplications.首先,作者没有提供用于捕获,可以通过其他。

NET应用程序中使用任何通用的API包。

Hedidn'

tseparatehisUIcodeandhisanalyzingandcapturingcode,makinghiscapturingcodedependontheGUIclassessuchasListViewtooperate.他没有单独的UI代码和他的分析和捕获的代码,使他的捕捉代码类依赖于图形用户界面,如ListView操作。

Secondly,forsomereasontheauthorchosetore-implementsomeofWinPcap'

sfunctionsinC#byhimselfratherthanjustwrappingthem.其次,由于某些原因,笔者选择了重新实现在C#由他本人,而不是仅仅WinPcap的包装他们的部分职能。

Thismeansthathisapplicationcan'

ttakeadvantageofthenewWinPcapversionssincehehardcodedacertainversionofWinPcapinhisapplication.这意味着他的应用程序无法利用新的WinPcap的版本的硬编码的优势,因为他在他的WinPcap的应用程序的某些版本。

ThesecondandthethirdarticlesarenicestartsforwrapperprojectsforWinPcap,howevertheydidn'

tprovidesomeimportantWinPcapfeaturessuchashandlingofflinepcapfilesandapplyingkernel-levelpacketfilters,andmostimportantlytheyprovidenoparserclassesforanalyzingprotocolpackets.第二个和第三个物品的包装项目为WinPcap的好开始,但他们没有提供一些重要的WinPcap的功能,如离线pcap的文件处理和应用内核级数据包过滤器,以及最重要的是他们提供了这样的分析没有协议分析器类包。

Bothprojectsdidn'

tposttheirlibrarysourcecodetogetherwiththearticleinordertoletotherpeopleextendtheirworkandaddnewfeaturesandnewpacketparserclasses.这两个项目没有张贴的文章,以自己的库的源代码,让其他人一起延长他们的工作和增加新功能和新的数据包分析器类。

Andso,Tamirdecidedtostarthisownlibraryforthetask.因此,塔米尔决定开始他对自己的图书馆工作。

Severalversionsinthe1.xserieswerereleased.在1.x系列的几个版本发布。

Developmentslowedtowardsmid-2007whenthelastversioninthe1.xserieswasreleased,SharpPcap1.6.2.发展放缓对2007年年中时,在1.x系列的最后一个版本发布时,SharpPcap1.6.2。

ChrisMorgantookoverdevelopmentofSharpPcapinNovemberof2008.克里斯摩根发生在2008年11月超过SharpPcap发展。

SincethenSharpPcaphashadmajorinternalrewritesandAPIimprovements.从那时起SharpPcap主要内部已重写和API改进。

InlateFebruary2010,SharpPcapv3.0wasreleased.2010年2月下旬,SharpPcap3.0被释放。

ThisreleaserepresentsarewriteofSharpPcap'

spacketparsers.此版本是一个重写SharpPcap的数据包分析器。

Packetparsingfunctionalitywasbrokenoutintoanewlibrary,Packet.Net.分组分析功能被打破,进入一个新的图书馆,Packet.Net。

SharpPcaptakescareofinterfacingwithlibpcap/winpcapandPacket.Nettakescareofpacketdissectionandcreation.SharpPcap注意到与libpcap的/WinPcap的包和Packet.Net注意到接口解剖和创造护理照顾。

ThedetailsofPacket.Net'

sarchitecturewillbediscussedlaterinthetutorial.对Packet.Net的建筑的细节将在本教程的后面讨论。

SharpPcapv3.5wasreleasedFebruary1st,2011.SharpPcapv3.5版本发布了2月1日,2011年。

The3.5releasecontainssignificantAPIchangesaswellasWinPcapremotecaptureandAirPcapsupport.3.5版本包含重大的空气污染指数的变化以及WinPcap的远程采集和支持AirPcap。

AboutSharpPcap关于SharpPcap

ThepurposeofSharpPcapistoprovideaframeworkforcapturing,injectingandanalyzingnetworkpacketsfor.NETapplications.的目的SharpPcap是提供一个框架NET应用程序捕获,注资。

和分析网络数据包。

SharpPcapisopenlyandactivelydevelopedwithitssourcecodeandfilereleaseshostedonSourceForge.SharpPcap是公开和积极发展同它的源代码和文件发布在SourceForge托管。

Sourcecodepatchestoimproveorfixissuesarewelcomeviathesharppcapdevelopersmailinglist.源代码补丁,以改善或解决问题欢迎通过sharppcap开发者邮件列表。

Bugreports,featurerequestsandotherqueriesareactivelyansweredonthesupportforumsandissuetrackerstheresoifyouhaveanytroublewiththelibrarypleasefeelfreetoask.错误报告,功能要求和其他查询正在积极回答问题的论坛和跟踪支持,所以如果你有任何问题请与库随时问。

SharpPcapisafullymanagedcrossplatformlibrary.SharpPcap是一个完全跨平台的库管理。

ThesameassemblyrunsunderMicrosoft.NETaswellasMonoonboth32and64bitplatforms.同一程序集运行在微软的。

NET以及单在32位和64位平台。

ThefollowinglistillustratesthefeaturescurrentlysupportedbySharpPcap:

下面的列表说明了目前SharpPcap功能支持:

∙SingleassemblyforMicrosoft.NETandMonoplatformsonWindows(32or64bit),Linux(32or64bit)andMac.单一组件的Microsoft。

NET和Mono平台上的Windows(32位或64位)和Linux(32或64位)和Mac。

∙Highperformance-SharpPcapcancapturefastenoughtokeepupwith>

3MB/sscptransferrates高性能-SharpPcap可以捕捉足够快跟上>

的3MB/s的传输速率高达SCP的

∙WinPcapextensionsarepartiallysupported:

WinPcap的扩展部分支持:

oSettingthekernelbuffersize设置内核缓冲区大小

oInjectingpacketsusingsendqueues.注射用的数据包发送队列。

oCollectingnetworkstatisticsonagivennetworkinterface收集在一个特定的网络接口的网络统计

∙AirPcapsupportAirPcap支持

∙EnumeratingandshowingdetailsaboutthephysicalnetworkinterfaceonaWindowsmachine.枚举和显示有关Windows机器上的物理网络接口的细节。

∙Capturinglow-levelnetworkpacketsgoingthroughagiveninterface.捕获低级别的网络数据包将通过给定的接口。

∙Analyzingandparsingthefollowingprotocols:

分析和解析以下协议:

oEthernet以太网

oSLL(LinuxCooked-ModeCapture)血清瘦素(Linux的熟食方式采集)

oARP(AddressResolutionProtocol)ARP(地址解析协议)

oIP(InternetProtocol):

IP(因特网协议):

▪IPv4IPv4的

▪IPv6IPv6的

oTCP(TransmissionControlProtocol)TCP(传输控制协议)

oUDP(UserDatagramProtocol)UDP(用户数据报协议)

oICMP(InternetControlMessageProtocol):

ICMP协议(Internet控制消息协议):

▪ICMPv4ICMPv4

▪ICMPv6ICMPv6报

oIGMPv2IGMPv2的

oPPPoEPPPoE协议

oPTP和平之路

oLLDPLLDP功能

oWake-on-LAN(WOL)唤醒局域网(网络唤醒)

∙Injectinglow-levelnetworkpacketsonagiveninterface.在给定接口注入的低级别的网络数据包。

∙Handling(readingandwriting)offlinepacketcapturefiles.处理(阅读和写作)离线数据包捕获文件。

∙Retrievingadapterstatisticsonpacketsreceivedvs.dropped检索的数据包接收适配器统计对比下降

Pleasechecktheprojecthomepagehomepageforthelatestupdatesandbugfixes.请检查项目主页主页最新的更新和bug修复。

SharpPcaparchitectureSharpPcap架构

SharpPcaphasalayeredarchitecture,atthetoplevelareclassesthatworkacrossalldevices:

SharpPcap具有层状结构,在顶层的类,所有设备的工作:

∙CaptureDeviceList-RetrievesalistofalldevicesonthesystemCaptureDeviceList-检索系统名单上的所有设备

∙OfflineCaptureDevice-DevicethatreadsfromapcapcapturefileOfflineCaptureDevice-文件读取装置从一个pcap的捕捉

∙ICaptureDevice-AllcapturedeviceshaveICaptureDeviceinterfacesICaptureDevice-所有的捕捉设备有ICaptureDevice接口

Thenamespacesarelayedouthierarchically:

该命名空间的布局层次:

∙LibPcaplibpcap的

oLibPcapLiveDevice-AnICaptureDeviceLibPcapLiveDevice-一个ICaptureDevice

oLibPcapLiveDeviceList-RetrievesalistofLibPcapLiveDevicedevices(theseincludepcap/winpcapandairpcapdevices)LibPcapLiveDeviceList-检索一个名单LibPcapLiveDevice设备(其中包括pcap的/WinPcap的和airpcap设备)

∙WinPcapWinPcap的

oWinPcapDeviceList-RetrievesalistofWinPcapDevices(theseincludewinpcapandairpcapdevices)WinPcapDeviceList-检索一个名单WinPcapDevices(其中包括WinPcap的和airpcap设备)

oWinPcapDevice-ALibPcapLiveDevicewithadditionalWinPcapfeaturesandinterfacesWinPcapDevice-阿LibPcapLiveDevice额外WinPcap的功能和接口

∙AirPcapAirPcap

oAirPcapDeviceList-RetrievesalistofAirPcapDevicesAirPcapDeviceList-检索一个名单AirPcapDevices

oAirPcapDevice-AWinPcapDevicewithadditionalAirPcapfeaturesandinterfacesAirPcapDevice-阿WinPcapDevice额外AirPcap功能和接口

CaptureDeviceListreturnsalistoffullydifferentiateddevices.CaptureDeviceList返回一个设备清单完全分化。

ThismeansthateachICaptureDevicereturnedbyCaptureDeviceListiseitheraLibPcapLiveDevice,aWinPcapDeviceoraAirPcapDevice.这意味着每个ICaptureDevice由归国CaptureDeviceList要么是LibPcapLiveDevice,一WinPcapDevice或AirPcapDevice。

Thisallowsyoutoretrievetheentirelistofdevicesanddifferentiatebylookingatthetypeofeachdevice.这使您可以检索整个列表的设备和差异化在每个设备类型看。

Ifyouwouldliketogetaspecifictypeofdeviceonly,youcanuseoneoftheparticular*DeviceListclasses.如果你想获得一个特定的特定类型的设备只,你可以使用一个*DeviceList类。

Collapse|CopyCode

//Retrieveallcapturedevices//检索所有捕获设备

vardevices=CaptureDeviceList;

=CaptureDeviceListVaR的装置;

//differentiatebasedupontypes//类型的区分依据

foreach(ICaptureDevicedevindevices)的foreach(ICaptureDevicedev的设备中)

{{

if(devisAirPcapDevice)如果(dev是AirPcapDevice)

//processasanAirPcapDevice//过程作为AirPcapDevice

}elseif(devisWinPcapDevice)}否则如果(dev是

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > IT计算机 > 计算机硬件及网络

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1