nbsp; {
if (m_Monitor!=null)
{
byte pkt = new byte[received];
Array.Copy(Buffer, 0, pkt, 0, received);
OnNewPacket(new Packet(pkt, DateTime.Now));
}
}
catch(Exception e)
{
throw;
}
m_Monitor.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, new AsyncCallback(OnReceive), null);
}
catch (Exception e)
{
}
}
protected void OnNewPacket(Packet p)
{
NewPacket(this, p);
}
}
}
using System;
using System.Text;
using System.Net;
using System.Net.Sockets;
namespace UpdateTester
{
public enum Precedence
{
Routine = 0,
Priority = 1,
Immediate = 2,
Flash = 3,
FlashOverride = 4,
CRITICECP = 5,
InternetworkControl = 6,
NetworkControl = 7
}
public enum Delay
{
NormalDelay = 0,
LowDelay = 1
}
public enum Throughput
{
NormalThroughput = 0,
HighThroughput = 1
}
public enum Reliability
{
NormalReliability = 0,
HighReliability = 1
}
public enum Protocol
{
Ggp = 3,
Icmp = 1,
Idp = 22,
Igmp = 2,
IP = 4,
ND = 77,
Pup = 12,
Tcp = 6,
Udp = 17,
Other = -1
}
/**//// <summary>
/// Packet 的摘要说明。
/// </summary>
public class Packet
{
private byte m_Raw;
private DateTime m_Time;
private int m_Version;
private int m_HeaderLength;
private Precedence m_Precedence;
private Delay m_Delay;
private Throughput m_Throughput;
private Reliability m_Reliability;
private int m_TotalLength;
private int m_Identification;
private int m_TimeToLive;
private Protocol m_Protocol;
private byte m_Checksum;
private string m_SourceAddress;
private string m_DestinationAddress;
private int m_SourcePort;
private int m_DestinationPort;
public Packet()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
//
// public Packet(byte raw):(byte raw, DateTime time
)
// {
// Packet(raw, DateTime.Now);
// }
public Packet(byte raw, DateTime time)
{
if (raw==null)
{
throw