패킷 손실률을 확인하는 C#ping 정보
using?System;?
using?System.Collections;?
using?System.Data;?
using?System .Net;?
using?System.Net.Sockets;?
네임스페이스?PPing?
{?
/// ?
///?Summary?description?for?Class.?
///??
// /?Ping 클래스?
class?Ping?
{? //상수 선언? const?int?SOCKET_ERROR?=?-1;? const?int?ICMP_ECHO?=? 8;? ///?
serverHE?=?Dns.GetHostByName(host);? }? catch(Exception)? {?
return?"호스트를 찾을 수 없습니다";? ?IP_EndPoint에서 EndPoint로? IPEndPoint?ipepServer?=?new?IPEndPoint(serverHE.AddressList[0],?0);? EndPoint?epServer?=?(ipepServer); //?클라이언트의 수신 엔드포인트 설정?
fromHE?=?Dns.GetHostByName(Dns.GetHostName());? IPEndPoint?ipEndPointFrom?=?new?IPEndPoint(fromHE.AddressList[0],?0);? EndPoint?EndPointFrom?=?(ipEndPointFrom);? ?PacketSize?=?0;? IcmpPacket?packet?=?new?IcmpPacket();? //?전송할 패킷을 작성합니까? packet.Type?=?ICMP_ECHO;?//8? 0 ;? packet.CheckSum?=?UInt16.Parse("0");? packet.Identifier=?UInt16.Parse("45");? packet.SequenceNumber?=?UInt16.Parse("0");? int ?PingData?=?32;?//?sizeof(IcmpPacket)?-?8;? packet.Data?=?new?Byte[PingData];? //?Packet.Data 초기화?string?Tempstr=@" ?checksum?of?struct? public?UInt16?Identifier;?//?identifier? public?UInt16?SequenceNumber;?//?sequence?number? public?Byte?[]?Data;?
> }?//?class?IcmpPacket?}