网络嗅探器的实际与实现的源代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

PacketMonitorForm.csusingSystem;usingSystem.Drawing;usingSystem.Collections;usingSystem.ComponentModel;usingSystem.Windows.Forms;namespaceOrg.Mentalis.Network.PacketMonitor{publicclassPacketForm:System.Windows.Forms.Form{privateSystem.Windows.Forms.Panelpanel1;privateSystem.Windows.Forms.Splittersplitter1;privateSystem.Windows.Forms.TextBoxRawText;privateSystem.Windows.Forms.ColumnHeaderInfoHeader;privateSystem.Windows.Forms.ColumnHeaderValueHeader;privateSystem.Windows.Forms.ListViewInfoList;privateSystem.ComponentModel.Containercomponents=null;publicPacketForm(Packetp){if(p==null)thrownewArgumentNullException();InitializeComponent();m_Packet=p;}protectedoverridevoidDispose(booldisposing){if(disposing){if(components!=null){components.Dispose();}}base.Dispose(disposing);}#regionWindowsFormDesignergeneratedcode///summary///设计所需的方法////summaryprivatevoidInitializeComponent(){this.panel1=newSystem.Windows.Forms.Panel();this.InfoList=newSystem.Windows.Forms.ListView();this.InfoHeader=newSystem.Windows.Forms.ColumnHeader();this.ValueHeader=newSystem.Windows.Forms.ColumnHeader();this.splitter1=newSystem.Windows.Forms.Splitter();this.RawText=newSystem.Windows.Forms.TextBox();this.panel1.SuspendLayout();this.SuspendLayout();////panel1//this.panel1.Controls.Add(this.InfoList);this.panel1.Dock=System.Windows.Forms.DockStyle.Top;this.panel1.Location=newSystem.Drawing.Point(0,0);this.panel1.Name=panel1;this.panel1.Size=newSystem.Drawing.Size(480,224);this.panel1.TabIndex=2;////InfoList//this.InfoList.Columns.AddRange(newSystem.Windows.Forms.ColumnHeader[]{this.InfoHeader,this.ValueHeader});this.InfoList.Dock=System.Windows.Forms.DockStyle.Fill;this.InfoList.FullRowSelect=true;this.InfoList.GridLines=true;this.InfoList.HeaderStyle=System.Windows.Forms.ColumnHeaderStyle.Nonclickable;this.InfoList.Location=newSystem.Drawing.Point(0,0);this.InfoList.Name=InfoList;this.InfoList.Size=newSystem.Drawing.Size(480,224);this.InfoList.TabIndex=0;this.InfoList.UseCompatibleStateImageBehavior=false;this.InfoList.View=System.Windows.Forms.View.Details;////InfoHeader//this.InfoHeader.Text=信息类型;this.InfoHeader.Width=237;////ValueHeader//this.ValueHeader.Text=值;this.ValueHeader.Width=210;////splitter1//this.splitter1.Cursor=System.Windows.Forms.Cursors.NoMoveVert;this.splitter1.Dock=System.Windows.Forms.DockStyle.Top;this.splitter1.Location=newSystem.Drawing.Point(0,224);this.splitter1.Name=splitter1;this.splitter1.Size=newSystem.Drawing.Size(480,9);this.splitter1.TabIndex=3;this.splitter1.TabStop=false;////RawText//this.RawText.Dock=System.Windows.Forms.DockStyle.Fill;this.RawText.Font=newSystem.Drawing.Font(宋体,8.25F,System.Drawing.FontStyle.Regular,System.Drawing.GraphicsUnit.Point,((byte)(0)));this.RawText.Location=newSystem.Drawing.Point(0,233);this.RawText.Multiline=true;this.RawText.Name=RawText;this.RawText.ScrollBars=System.Windows.Forms.ScrollBars.Vertical;this.RawText.Size=newSystem.Drawing.Size(480,215);this.RawText.TabIndex=4;////PacketForm//this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);this.ClientSize=newSystem.Drawing.Size(480,448);this.Controls.Add(this.RawText);this.Controls.Add(this.splitter1);this.Controls.Add(this.panel1);this.FormBorderStyle=System.Windows.Forms.FormBorderStyle.FixedSingle;this.MaximizeBox=false;this.MinimizeBox=false;this.Name=PacketForm;this.Text=详细的报文信息;this.Load+=newSystem.EventHandler(this.PacketForm_Load);this.panel1.ResumeLayout(false);this.ResumeLayout(false);this.PerformLayout();}#endregionprivatevoidPacketForm_Load(objectsender,System.EventArgse){RawText.Text=m_Packet.ToString();InfoList.Items.Add(newListViewItem(newstring[]{开始时间,m_Packet.Time.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{源端口,m_Packet.Source}));InfoList.Items.Add(newListViewItem(newstring[]{目的端口,m_Packet.Destination}));InfoList.Items.Add(newListViewItem(newstring[]{协议类型,m_Packet.Protocol.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{生存时间,m_Packet.TimeToLive.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{版本信息,m_Packet.Version.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{报头大小,m_Packet.HeaderLength.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{报文总长,m_Packet.TotalLength.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{优先级别,m_Packet.Precedence.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{延迟,m_Packet.Delay.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{吞吐量,m_Packet.Throughput.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{可靠性,m_Packet.Reliability.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{鉴定,m_Packet.Identification.ToString()}));InfoList.Items.Add(newListViewItem(newstring[]{校验和,m_Packet.Checksum[0].ToString(X2)+m_Packet.Checksum[1].ToString(X2)}));}privatePacketm_Packet;}}PacketMonitor.csusingSystem;usingSystem.Text;usingSystem.Net;usingSystem.Net.Sockets;usingSystem.Runtime.InteropServices;namespaceOrg.Mentalis.Network.PacketMonitor{///summary///一个类拦截IP数据包,Aclassthatinte

1 / 23
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功