⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 packetform.cs

📁 是用C#编写的一个获取网络数据包输出交换机个个IP的实时流量
💻 CS
字号:
/*
 * Original Code by KPD-Team (http://www.mentalis.org), 2003
 * Modified: Philip Pierce July 2004
*/

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace Org.Mentalis.Network.PacketMonitor {
	public class PacketForm : System.Windows.Forms.Form {
		private System.Windows.Forms.Panel panel1;
		private System.Windows.Forms.Splitter splitter1;
		private System.Windows.Forms.TextBox RawText;
		private System.Windows.Forms.ColumnHeader InfoHeader;
		private System.Windows.Forms.ColumnHeader ValueHeader;
		private System.Windows.Forms.ListView InfoList;
		private System.ComponentModel.Container components = null;
		public PacketForm(Packet p) {
			if (p == null)
				throw new ArgumentNullException();
			// Required for Windows Form Designer support
			InitializeComponent();
			m_Packet = p;
		}
		protected override void Dispose( bool disposing ) {
			if(disposing) {
				if(components != null) {
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent() {
			this.panel1 = new System.Windows.Forms.Panel();
			this.InfoList = new System.Windows.Forms.ListView();
			this.InfoHeader = new System.Windows.Forms.ColumnHeader();
			this.ValueHeader = new System.Windows.Forms.ColumnHeader();
			this.splitter1 = new System.Windows.Forms.Splitter();
			this.RawText = new System.Windows.Forms.TextBox();
			this.panel1.SuspendLayout();
			this.SuspendLayout();
			// 
			// panel1
			// 
			this.panel1.Controls.AddRange(new System.Windows.Forms.Control[] {
																				 this.InfoList});
			this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
			this.panel1.Name = "panel1";
			this.panel1.Size = new System.Drawing.Size(480, 208);
			this.panel1.TabIndex = 2;
			// 
			// InfoList
			// 
			this.InfoList.Columns.AddRange(new System.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.Name = "InfoList";
			this.InfoList.Size = new System.Drawing.Size(480, 208);
			this.InfoList.TabIndex = 0;
			this.InfoList.View = System.Windows.Forms.View.Details;
			// 
			// InfoHeader
			// 
			this.InfoHeader.Text = "Information Type";
			this.InfoHeader.Width = 237;
			// 
			// ValueHeader
			// 
			this.ValueHeader.Text = "Value";
			this.ValueHeader.Width = 210;
			// 
			// splitter1
			// 
			this.splitter1.Cursor = System.Windows.Forms.Cursors.NoMoveVert;
			this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
			this.splitter1.Location = new System.Drawing.Point(0, 208);
			this.splitter1.Name = "splitter1";
			this.splitter1.Size = new System.Drawing.Size(480, 8);
			this.splitter1.TabIndex = 3;
			this.splitter1.TabStop = false;
			// 
			// RawText
			// 
			this.RawText.Dock = System.Windows.Forms.DockStyle.Fill;
			this.RawText.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.RawText.Location = new System.Drawing.Point(0, 216);
			this.RawText.Multiline = true;
			this.RawText.Name = "RawText";
			this.RawText.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
			this.RawText.Size = new System.Drawing.Size(480, 232);
			this.RawText.TabIndex = 4;
			this.RawText.Text = "";
			// 
			// PacketForm
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(480, 448);
			this.Controls.AddRange(new System.Windows.Forms.Control[] {
																		  this.RawText,
																		  this.splitter1,
																		  this.panel1});
			this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
			this.MaximizeBox = false;
			this.MinimizeBox = false;
			this.Name = "PacketForm";
			this.Text = "Detailed Packet Information";
			this.Load += new System.EventHandler(this.PacketForm_Load);
			this.panel1.ResumeLayout(false);
			this.ResumeLayout(false);

		}
		#endregion
		private void PacketForm_Load(object sender, System.EventArgs e) {
			RawText.Text = m_Packet.ToString();
			InfoList.Items.Add(new ListViewItem(new string[] {"Time", m_Packet.Time.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Source", m_Packet.Source}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Destination", m_Packet.Destination}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Protocol", m_Packet.Protocol.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Time To Live", m_Packet.TimeToLive.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Version", m_Packet.Version.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Header Length", m_Packet.HeaderLength.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Precedence", m_Packet.Precedence.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Delay", m_Packet.Delay.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Throughput", m_Packet.Throughput.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Reliability", m_Packet.Reliability.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Total Length", m_Packet.TotalLength.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Identification", m_Packet.Identification.ToString()}));
			InfoList.Items.Add(new ListViewItem(new string[] {"Checksum", m_Packet.Checksum[0].ToString("X2") + m_Packet.Checksum[1].ToString("X2")}));
		}
		private Packet m_Packet;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -