//ICMP 类定义
public class IcmPacket
{
private Byte my_type;
private Byte my_subCode;
private UInt16 my_checkSum;
private UInt16 my_identifier;
private UInt16 my_sequenceNumber;
private UInt16 my_data;
public IcmPacket(Byte type,Byte subCode,UInt16 checkSum,UInt16 identifier,
UInt16 sequenceNumber,int dataSize)
{
my_type=type;
my_subCode=subCode;
my_checkSum=checkSum;
my_identifier=identifier;
my_sequenceNumber=sequenceNumber;
my_data=new Byte[dataSize];
for (int i=0;i<dataSize; i++)
{
my_data[i]=(byte)'k';
}
}
public UInt16 checkSum
{
get
{
return my_checkSum;
}
set
{
my_checkSum=value;
}
}
public int CountByte(Byte[] buffer)
{
Byte[] b_type=new Byte[1] {my_type};
Byte[] b_code=new Byte[1] {my_subCode};
Byte[] b_cksum=BitConverter.GetBytes(my_checkSum);
Byte[] b_id=BitConverter.GetBytes(my_sequenceNumber);
Byte[] b_seq=BitConverter.GetBytes(my_sequenceNumber);
int i=0;
Array.Copy(b_type,0,buffer,i,b_type.length);
i+=b_type.Length;