Ejemplo n.º 1
0
        public Task SendAsync(byte[] Data)
        {
            UDPPacket Packet = new UDPPacket(Data);

            Packet.DestIP     = LocalIP;
            Packet.DestPort   = LocalPort;
            Packet.SourceIP   = FakeRemoteIP;
            Packet.SourcePort = FakeRemotePort;
            return(net.SendIPPacketAsync(Packet));
        }
Ejemplo n.º 2
0
 public void TestICMPPacket()
 {
     SharpNet.OnReceiveICMPPacketHandler Handler = async(ICMPPacket Packet) =>
     {
         ICMPPacket echo = new ICMPPacket(Packet.Data);
         echo.Type     = 0;
         echo.PingId   = Packet.PingId;
         echo.PingSeq  = Packet.PingSeq;
         echo.DestIP   = Packet.SourceIP;
         echo.SourceIP = Packet.DestIP;
         await net.SendIPPacketAsync(echo);
     };
     net.OnReceiveICMPPacket += Handler;
     //Task.Delay(30000).Wait();
     for (int i = 0; i < 10; i++)
     {
         var result = ping.Send(RemoteIP, 100);
         Assert.AreEqual(IPStatus.Success, result.Status, "Timeout occured");
         Trace.WriteLine(string.Format("{0} ms delay", result.RoundtripTime));
     }
     net.OnReceiveICMPPacket -= Handler;
 }