Class ICMP

  • All Implemented Interfaces:
    IPacket

    public class ICMP
    extends BasePacket
    Implements ICMP packet format.
    • Field Detail

      • icmpType

        protected byte icmpType
      • icmpCode

        protected byte icmpCode
      • checksum

        protected short checksum
    • Constructor Detail

      • ICMP

        public ICMP()
    • Method Detail

      • getIcmpType

        public byte getIcmpType()
        Returns:
        the icmpType
      • setIcmpType

        public ICMP setIcmpType​(byte icmpType)
        Parameters:
        icmpType - to set
        Returns:
        this
      • getIcmpCode

        public byte getIcmpCode()
        Returns:
        the icmp code
      • setIcmpCode

        public ICMP setIcmpCode​(byte icmpCode)
        Parameters:
        icmpCode - code to set
        Returns:
        this
      • getChecksum

        public short getChecksum()
        Returns:
        the checksum
      • setChecksum

        public ICMP setChecksum​(short checksum)
        Parameters:
        checksum - the checksum to set
        Returns:
        this
      • serialize

        public byte[] serialize()
        Serializes the packet. Will compute and set the following fields if they are set to specific values at the time serialize is called: -checksum : 0 -length : 0
        Returns:
        a byte[] containing this packet and payloads
      • deserializer

        public static Deserializer<ICMP> deserializer()
        Deserializer function for ICMP packets.
        Returns:
        deserializer function
      • buildIcmpReply

        public static Ethernet buildIcmpReply​(Ethernet ethRequest)
        Builds an ICMP reply using the supplied ICMP request.
        Parameters:
        ethRequest - the Ethernet packet containing the ICMP ECHO request
        Returns:
        the Ethernet packet containing the ICMP ECHO reply