public bool Ping(IpV4Address IP, MacAddress Mac, int Count = 10) { this._target_ip = IP; this._target_mac = Mac; bool Result = false; for (ushort SequenceNumber = 1; SequenceNumber < Count; SequenceNumber++) { _ping_echo_wait_handle.Reset(); _current_icmp_sequence_num = SequenceNumber; SendIcmpEcho(_target_ip, _target_mac, SequenceNumber); VirtualNetwork.Instance.PostTraceMessage(string.Format("PING {0} ({1})", _target_ip.ToString(), SequenceNumber), false); _current_state = ICMP_STATE.WAIT_ECHO; if (_ping_echo_wait_handle.WaitOne(PING_ECHO_TIMEOUT)) { VirtualNetwork.Instance.PostTraceMessage(" - OK"); Result = true; } else { VirtualNetwork.Instance.PostTraceMessage(" - TIMEOUT"); } _current_state = ICMP_STATE.IDLE; Thread.Sleep(1000); } return(Result); }
public IcmpService(VirtualAdapter Adapter) { _adapter = Adapter; _current_state = ICMP_STATE.IDLE; }