public virtual void Input(IPFrame frame) { if (frame.ProtocolType == ProtocolType.Tcp) { var f = Tcp.Parse(frame); if (f != null) { Tcp.Input(f); } } else if (frame.ProtocolType == ProtocolType.Udp) { var f = Udp.Parse(frame); if (f != null) { Udp.Input(f); } } else if (frame.ProtocolType == ProtocolType.Icmp) { var f = Icmp.Parse(frame); if (f != null) { Icmp.Input(f); } } }
private double PacketLossTestSignleRun(IPAddress destinationIpAddress) { var options = new PingOptions { DontFragment = true }; var data = new char[_bufferSizeInBytes]; for (var i = 0; i < _bufferSizeInBytes; i++) { data[i] = 'a'; } var buffer = Encoding.ASCII.GetBytes(data); int failed = 0; for (int i = 0; i < _pingCount; i++) { var reply = Icmp.Send(this._networkInterface.IpAddress, destinationIpAddress, _timeoutInMsec, buffer, options); if (reply.Status != IPStatus.Success) { failed += 1; Logger.Logger.AddMessage($"Ping status for {i} - {reply.Status.ToString()} ", MessageThreshold.WARNING); } } return(((double)failed / _pingCount) * 100); }
public void PacketDispatcher(PcapDotNet.Packets.Packet packet) { Common.PacketData pdata = new Common.PacketData(packet); if (!NetworkFirewall.TestIncoming(pdata)) { return; } Task.Run(() => { switch (pdata.Type) { case PacketType.Arp: Arp.OnReceivePacket(pdata); break; case PacketType.Icmp: Icmp.OnReceivePacket(pdata); break; case PacketType.Dns: Dns.OnReceivePacket(pdata); break; case PacketType.Tcp: Tcp.OnReceivePacket(pdata); break; case PacketType.Http: Tcp.OnReceivePacket(pdata); break; } }); }
private double ResponseTimeSingleTest(IPAddress destinationAddress) { double meanLatency = 0; var pingReply = Icmp.Send(this._networkInterface.IpAddress, destinationAddress, _timeoutInMsec); for (int i = 0; i < _pingCount; i++) { if (pingReply == null) { continue; } pingReply = Icmp.Send(this._networkInterface.IpAddress, destinationAddress); if (pingReply != null) { meanLatency += pingReply.RoundTripTime.TotalMilliseconds; } } return(meanLatency / _pingCount); }