Class IPv6

    • Field Detail

      • version

        protected byte version
      • trafficClass

        protected byte trafficClass
      • flowLabel

        protected int flowLabel
      • payloadLength

        protected short payloadLength
      • nextHeader

        protected byte nextHeader
      • hopLimit

        protected byte hopLimit
      • sourceAddress

        protected byte[] sourceAddress
      • destinationAddress

        protected byte[] destinationAddress
    • Constructor Detail

      • IPv6

        public IPv6()
        Default constructor that sets the version to 6.
    • Method Detail

      • getVersion

        public byte getVersion()
        Description copied from class: IP
        Gets IP version number.
        Specified by:
        getVersion in class IP
        Returns:
        IP version number
      • setVersion

        public IPv6 setVersion​(byte version)
        Description copied from class: IP
        Sets IP version number.
        Specified by:
        setVersion in class IP
        Parameters:
        version - the version to set
        Returns:
        IP class
      • getTrafficClass

        public byte getTrafficClass()
        Gets traffic class.
        Returns:
        the traffic class
      • setTrafficClass

        public IPv6 setTrafficClass​(byte trafficClass)
        Sets traffic class.
        Parameters:
        trafficClass - the traffic class to set
        Returns:
        this
      • getFlowLabel

        public int getFlowLabel()
        Gets flow label.
        Returns:
        the flow label
      • setFlowLabel

        public IPv6 setFlowLabel​(int flowLabel)
        Sets flow label.
        Parameters:
        flowLabel - the flow label to set
        Returns:
        this
      • setNextHeader

        public IPv6 setNextHeader​(byte nextHeader)
        Description copied from interface: IExtensionHeader
        Sets the type of next header.
        Specified by:
        setNextHeader in interface IExtensionHeader
        Parameters:
        nextHeader - the next header to set
        Returns:
        this
      • getHopLimit

        public byte getHopLimit()
        Gets hop limit.
        Returns:
        the hop limit
      • setHopLimit

        public IPv6 setHopLimit​(byte hopLimit)
        Sets hop limit.
        Parameters:
        hopLimit - the hop limit to set
        Returns:
        this
      • getSourceAddress

        public byte[] getSourceAddress()
        Gets source address.
        Returns:
        the IPv6 source address
      • setSourceAddress

        public IPv6 setSourceAddress​(byte[] sourceAddress)
        Sets source address.
        Parameters:
        sourceAddress - the IPv6 source address to set
        Returns:
        this
      • getDestinationAddress

        public byte[] getDestinationAddress()
        Gets destination address.
        Returns:
        the IPv6 destination address
      • setDestinationAddress

        public IPv6 setDestinationAddress​(byte[] destinationAddress)
        Sets destination address.
        Parameters:
        destinationAddress - the IPv6 destination address to set
        Returns:
        this
      • serialize

        public byte[] serialize()
        Description copied from interface: IPacket
        Sets all payloads parent packet if applicable, then serializes this packet and all payloads.
        Specified by:
        serialize in interface IPacket
        Returns:
        a byte[] containing this packet and payloads
      • deserializer

        public static Deserializer<IPv6> deserializer()
        Deserializer function for IPv6 packets.
        Returns:
        deserializer function
      • getSolicitNodeAddress

        public static byte[] getSolicitNodeAddress​(byte[] targetIp)
        According to the RFC 4291, the solicitation node addresses are formed by taking the low-order 24 bits of an address (unicast or anycast) and appending those bits to the prefix FF02:0:0:0:0:1:FF00::/104. Solicited-Node Address: FF02:0:0:0:0:1:FFXX:XXXX
        Parameters:
        targetIp - the unicast or anycast address
        Returns:
        the computed solicitation node address
      • getMCastMacAddress

        public static byte[] getMCastMacAddress​(byte[] targetIp)
        According to the RFC 2464, an IPv6 packet with a multicast destination address DST, consisting of the sixteen octets DST[1] through DST[16], is transmitted to the Ethernet multicast address whose first two octets are the value 3333 hexadecimal and whose last four octets are the last four octets of DST. +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |0 0 1 1 0 0 1 1|0 0 1 1 0 0 1 1| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST[13] | DST[14] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | DST[15] | DST[16] | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
        Parameters:
        targetIp - the multicast address.
        Returns:
        the multicast mac address
      • isLinkLocalAddress

        public static boolean isLinkLocalAddress​(byte[] targetIp)
        According to the RFC 4291, an IPv6 link local address is an IPv6 unicast address that can be automatically configured on any interface using the link-local prefix FE80::/10 (1111 1110 10) and the interface identifier in the modified EUI-64 format. +----------------------------------------------------------------+ | 10 bits | 54 bits | 64 bits | +----------- +-------------------------+-------------------------+ | 1111111010 | 0 | interface ID | +----------- +-------------------------+-------------------------+
        Parameters:
        targetIp - the ip address to verify
        Returns:
        true if the ipv6 address is link local, false otherwise
      • getLinkLocalAddress

        public static byte[] getLinkLocalAddress​(byte[] macAddress)
        Returns the auto-generated link local address using the mac address as parameter.
        Parameters:
        macAddress - the mac address to use
        Returns:
        the ipv6 link local address
      • getMacAddress

        public static byte[] getMacAddress​(byte[] linkLocalAddress)
        Returns the mac address from the auto-generated link local address.
        Parameters:
        linkLocalAddress - the ipv6 to use
        Returns:
        the mac address