java.lang.Object
net.i2p.router.transport.udp.MTU

public class MTUextends Object
The MTU for the network interface of an address. Not available until Java 6 / Android API 9.

Public only for command line test. Not for external use, not a public API.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    private static class 
    Comparator for InetAddress by host address.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final boolean
    False on Java 5, which has no MTU discovery.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    MTU()
    Utility class, not intended for instantiation.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    static int
    getMTU(InetAddress ia, boolean isSSU2)
    The MTU for the socket interface, if available.
    static void
    main(String[] args)
    CLI test.
    static int
    rectify(boolean isIPv6, int mtu)
    Rectify the MTU value to valid range and alignment.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • HAS_MTU

      private static final boolean HAS_MTU
      False on Java 5, which has no MTU discovery.
  • Constructor Details

    • MTU

      private MTU()
      Utility class, not intended for instantiation.
  • Method Details

    • getMTU

      public static int getMTU(InetAddress ia, boolean isSSU2)
      The MTU for the socket interface, if available. Not available for Java 5.

      Note that we don't return the value for the default interface if we can't find the address. Finding the default interface is hard, although we could perhaps just look for the first non-loopback address. But the MTU of the default route probably isn't relevant.

      For SSU2 MTU, values lower than PeerState2.MIN_MTU may be returned, so the caller can determine if SSU2 should be supported.

      Parameters:
      ia - null ok
      isSSU2 - if true, calculate SSU2 MTU
      Returns:
      0 if Java 5, or if not bound to an address; limited to range MIN_MTU to LARGE_MTU for SSU 1.
    • rectify

      public static int rectify(boolean isIPv6, int mtu)
      Rectify the MTU value to valid range and alignment.
      Parameters:
      isIPv6 - true if IPv6
      mtu - the MTU value to rectify
      Returns:
      min of PeerState.MIN_MTU, max of PeerState.LARGE_MTU, rectified so rv % 16 == 12 (IPv4) or rv % 16 == 0 (IPv6)
    • main

      public static void main(String[] args)
      CLI test.
      Parameters:
      args - hostnames or IP addresses of interfaces to report MTU for; with no arguments, every local interface is reported