-
Bug
-
Resolution: Fixed
-
P4
-
7
-
b38
-
x86
-
windows_7
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8072267 | 7u85 | Robert Mckenna | P4 | Resolved | Fixed | b01 |
JDK-8056059 | 7u80 | Robert Mckenna | P4 | Resolved | Fixed | b03 |
JDK-8061076 | 7u79 | Robert Mckenna | P4 | Resolved | Fixed | b01 |
JDK-8057971 | 7u76 | Robert Mckenna | P4 | Resolved | Fixed | b01 |
FULL PRODUCT VERSION :
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versie 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
For an UDP application I want to send a packet to the network broadcast address.
java.net.InterfaceAddress has the method getBroadcast() to retrieve this information. However, on a wireless connection this functionality is broken.
getBroadcast() always returns 0.0.0.0 on the wireless interface, although it works correctly for the wired interface.
I can reproduce this problem on multiple laptops.
Trying to work around this by applying the subnetmask to the ip myself is impossible, because getNetworkPrefixLength() returns -1 on a WLAN connection.
If I connect to laptop to the same network using a cable instead of using WiFi, Java returns the correct information about the broadcast address on the wired interface.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute source code attached as "Source code for an executable test case" on a laptop connected to WiFi / WLAN.
2. Output shows that the broadcast address is wrong
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The names of the network interfaces and the ip can be different:
{{net3}}
145.89.X.X: 145.89.131.255 | 22
{{eth3}}
145.89.X.X: 145.89.131.255 | 22
ACTUAL -
Instead of the expected result java.net.InterfaceAddress.getBroadcast() returns 0.0.0.0 and getNetworkPrefixLength() returns -1 for the WiFi adapter only. As seen here, the wired interface returns the correct information.
{{net3}}
145.89.X.X: 0.0.0.0 | -1
{{eth3}}
145.89.X.X: 145.89.131.255 | 22
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.Inet6Address;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class BugDemonstrator
{
public static void main(String[] args) throws Exception
{
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while(interfaces.hasMoreElements())
{
NetworkInterface networkInterface = interfaces.nextElement();
if (networkInterface.isLoopback() || (!networkInterface.isUp()))
continue; // Ignore loopback and interfaces that are down
System.out.println("== "+networkInterface.getName()+" ==");
for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
if(interfaceAddress.getAddress() instanceof Inet6Address)
continue; //IPv6 doesn't have broadcast adresses
String ipAddress = interfaceAddress.getAddress().getHostAddress();
String broadcastAddress = interfaceAddress.getBroadcast().getHostAddress();
short networkPrefixLength = interfaceAddress.getNetworkPrefixLength();
System.out.println(ipAddress+": "+broadcastAddress+" | "+networkPrefixLength);
}
System.out.println();
}
}
}
---------- END SOURCE ----------
java version "1.7.0_02"
Java(TM) SE Runtime Environment (build 1.7.0_02-b13)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [versie 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
For an UDP application I want to send a packet to the network broadcast address.
java.net.InterfaceAddress has the method getBroadcast() to retrieve this information. However, on a wireless connection this functionality is broken.
getBroadcast() always returns 0.0.0.0 on the wireless interface, although it works correctly for the wired interface.
I can reproduce this problem on multiple laptops.
Trying to work around this by applying the subnetmask to the ip myself is impossible, because getNetworkPrefixLength() returns -1 on a WLAN connection.
If I connect to laptop to the same network using a cable instead of using WiFi, Java returns the correct information about the broadcast address on the wired interface.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Execute source code attached as "Source code for an executable test case" on a laptop connected to WiFi / WLAN.
2. Output shows that the broadcast address is wrong
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The names of the network interfaces and the ip can be different:
{{net3}}
145.89.X.X: 145.89.131.255 | 22
{{eth3}}
145.89.X.X: 145.89.131.255 | 22
ACTUAL -
Instead of the expected result java.net.InterfaceAddress.getBroadcast() returns 0.0.0.0 and getNetworkPrefixLength() returns -1 for the WiFi adapter only. As seen here, the wired interface returns the correct information.
{{net3}}
145.89.X.X: 0.0.0.0 | -1
{{eth3}}
145.89.X.X: 145.89.131.255 | 22
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.net.Inet6Address;
import java.net.InterfaceAddress;
import java.net.NetworkInterface;
import java.util.Enumeration;
public class BugDemonstrator
{
public static void main(String[] args) throws Exception
{
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
while(interfaces.hasMoreElements())
{
NetworkInterface networkInterface = interfaces.nextElement();
if (networkInterface.isLoopback() || (!networkInterface.isUp()))
continue; // Ignore loopback and interfaces that are down
System.out.println("== "+networkInterface.getName()+" ==");
for (InterfaceAddress interfaceAddress : networkInterface.getInterfaceAddresses())
{
if(interfaceAddress.getAddress() instanceof Inet6Address)
continue; //IPv6 doesn't have broadcast adresses
String ipAddress = interfaceAddress.getAddress().getHostAddress();
String broadcastAddress = interfaceAddress.getBroadcast().getHostAddress();
short networkPrefixLength = interfaceAddress.getNetworkPrefixLength();
System.out.println(ipAddress+": "+broadcastAddress+" | "+networkPrefixLength);
}
System.out.println();
}
}
}
---------- END SOURCE ----------
- backported by
-
JDK-8056059 InterfaceAddress.getBroadcast() returns invalid broadcast address on WLAN
-
- Resolved
-
-
JDK-8057971 InterfaceAddress.getBroadcast() returns invalid broadcast address on WLAN
-
- Resolved
-
-
JDK-8061076 InterfaceAddress.getBroadcast() returns invalid broadcast address on WLAN
-
- Resolved
-
-
JDK-8072267 InterfaceAddress.getBroadcast() returns invalid broadcast address on WLAN
-
- Resolved
-