Internet Control Message Packets (Ping)
Inheritance: DataPacket
Ejemplo n.º 1
0
    ///<summary>This sends an Icmp Request to the specified address, we want
    ///him to respond to us, so we can guarantee that by pretending to be the
    ///Server (i.e. x.y.z.1).  We'll get a response in our main thread.</summary>
    ///<param name="dest_ip">Destination IP of our request.</summary>
    protected virtual void SendIcmpRequest(MemBlock dest_ip) {
      if(_dhcp_server == null) {
        return;
      }
      MemBlock ether_addr = null;
      if(!_ip_to_ether.TryGetValue(dest_ip, out ether_addr)) {
        ether_addr = EthernetPacket.BroadcastAddress;
      }

      IcmpPacket icmp = new IcmpPacket(IcmpPacket.Types.EchoRequest);
      IPPacket ip = new IPPacket(IPPacket.Protocols.Icmp, _dhcp_server.ServerIP,
          dest_ip, icmp.Packet);
      EthernetPacket ether = new EthernetPacket(ether_addr,
          EthernetPacket.UnicastAddress, EthernetPacket.Types.IP, ip.ICPacket);
      Ethernet.Send(ether.ICPacket);
    }