Class EnumNet.IpRoute

java.lang.Object
com.frostwire.jlibtorrent.EnumNet.IpRoute
Enclosing class:
EnumNet

public static final class EnumNet.IpRoute extends Object
Network routing table entry describing a route to a destination network.

IpRoute represents a single entry in the system routing table. It specifies a destination network, the gateway to reach it, and the network interface to use. This is useful for understanding network topology and MTU (Maximum Transmission Unit) constraints for different routes.

Route Properties:

  • Destination: Target network address (e.g., 192.168.1.0)
  • Netmask: Network mask determining destination network size
  • Gateway: IP address of gateway/router to reach destination
  • Interface Name: Physical/logical interface used for this route
  • MTU: Maximum packet size for this route

Reading Route Information:

 EnumNet.IpRoute route = ...;

 // Get route destination
 Address dest = route.destination();
 System.out.println(\"Route to: \" + dest);

 // Get netmask (network size)
 Address netmask = route.netmask();
 System.out.println(\"Netmask: \" + netmask);

 // Get gateway
 Address gateway = route.gateway();
 System.out.println(\"Via gateway: \" + gateway);

 // Get interface
 String iface = route.name();
 System.out.println(\"Interface: \" + iface);

 // Get MTU (maximum packet size)
 int mtu = route.mtu();
 System.out.println(\"MTU: \" + mtu + \" bytes\");
 

Route Analysis:

 // Identify default route
 for (EnumNet.IpRoute route : EnumNet.enumRoutes(sm)) {
     Address dest = route.destination();
     Address mask = route.netmask();

     // Default route: 0.0.0.0/0
     if (dest.toString().equals(\"0.0.0.0\") &&
         mask.toString().equals(\"0.0.0.0\")) {
         System.out.println(\"Default gateway: \" + route.gateway());
         System.out.println(\"Via interface: \" + route.name());
     }
 }
 

Understanding MTU:

 // Check MTU for each route
 for (EnumNet.IpRoute route : EnumNet.enumRoutes(sm)) {
     int mtu = route.mtu();
     System.out.println(\"Route to \" + route.destination());
     System.out.println(\"  MTU: \" + mtu + \" bytes\");

     // Typical MTU values:
     // 1500 - Standard Ethernet
     // 1492 - PPPoE (Point-to-Point over Ethernet)
     // 9000 - Jumbo frames (high-speed networks)
     // 576  - Minimum (required by standards)
 }
 

IPv4 vs IPv6 Routes:

 // Check route address family
 for (EnumNet.IpRoute route : EnumNet.enumRoutes(sm)) {
     Address dest = route.destination();

     if (dest.isV4()) {
         System.out.println(\"IPv4 route: \" + dest);
     } else if (dest.isV6()) {
         System.out.println(\"IPv6 route: \" + dest);
     }
 }
 

Finding Route to Host:

 // Find which route would be used for a specific destination
 Address targetHost = new Address(\"8.8.8.8\");
 for (EnumNet.IpRoute route : EnumNet.enumRoutes(sm)) {
     Address dest = route.destination();
     Address mask = route.netmask();

     // Check if target is in this route's network
     // (simplified - actual implementation more complex)
     if (isInSubnet(targetHost, dest, mask)) {
         System.out.println(\"Route for \" + targetHost + \": \" + route.name());
         System.out.println(\"Via: \" + route.gateway());
     }
 }
 

Performance Notes:

  • Routing table is typically small (10-100 entries on most systems)
  • Routes are ordered by specificity (more specific routes first)
  • Default route (0.0.0.0/0) is the catch-all for unmatched destinations
  • MTU affects BitTorrent bandwidth efficiency
  • Method Details

    • swig

      public com.frostwire.jlibtorrent.swig.ip_route swig()
    • destination

      public Address destination()
    • netmask

      public Address netmask()
    • gateway

      public Address gateway()
    • name

      public String name()
    • mtu

      public int mtu()
    • toString

      public String toString()
      Overrides:
      toString in class Object