Java Network Problem

We have a router and 3 PCs.

  • PC1: 192.168.1.2 (wireless)
  • PC2: 192.168.1.3 (wireless)
  • PC3: 192.168.1.6

Default Gateway: 192.168.1.1

When PC3 tried to find connected PCs using the code of this forum post , it returns the IP address of the default gateway (this address is the only available address).

I tried to increase the timeout for the method isReachable(). But still, it only returns the default gateway address.

I tried to do this with separate IP addresses.

try {
            InetAddress temp2 = InetAddress.getByAddress(new byte[]{(byte) 192, (byte) 168, (byte) 1, (byte) 2});
            if (temp2.isReachable(1100)) {
                java.lang.System.out.println("IP Address: " + temp2.getHostAddress() + " has connection.");
            }else{
                java.lang.System.out.println("IP Address: " + temp2.getHostAddress() + " has no connection.");
            }
        } catch (Exception ex) {
            java.lang.System.out.println("Error: " + ex.getMessage());
        }  

However, on those IP addresses PC1 and PC2, I got the connection status. (This means that these IP addresses are not available.)

But when I ping them on my Windows console, these IP addresses are connected, and pinging is successful.

  • What is the problem with my setup.
  • How can i solve this.
+3
1

, . . . , Linux/UNIX, Windows 7 , TCP- echo (7), ICMP-. ( Java 1.6.0_21 Windows 7, ver Microsoft Windows [Version 6.1.7600])

Windows, , Windodws. :

  • Java- ( ICMP Windows) TCP- Windows, SYN (synchronize) 7
  • Windows , , RST-, RFC 793, . Windows RFC TCP:
    • RST:
    • SYN + ACK:
  • Java- , (2), ( Windows SYN , - TCP), Windows .

, " ". , . , . , . , ping 100% , . ARP ping-, .

:

  • Windows , .
  • , , , ping .
+2

Source: https://habr.com/ru/post/1794905/


All Articles