Class WindowsNetworkIF
- java.lang.Object
-
- oshi.hardware.common.AbstractNetworkIF
-
- oshi.hardware.platform.windows.WindowsNetworkIF
-
- All Implemented Interfaces:
NetworkIF
@ThreadSafe public final class WindowsNetworkIF extends AbstractNetworkIF
WindowsNetworks class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface oshi.hardware.NetworkIF
NetworkIF.IfOperStatus
-
-
Field Summary
Fields Modifier and Type Field Description private long
bytesRecv
private long
bytesSent
private long
collisions
private static byte
CONNECTOR_PRESENT_BIT
private boolean
connectorPresent
private java.lang.String
ifAlias
private NetworkIF.IfOperStatus
ifOperStatus
private int
ifType
private long
inDrops
private long
inErrors
private static boolean
IS_VISTA_OR_GREATER
private static org.slf4j.Logger
LOG
private int
ndisPhysicalMediumType
private long
outErrors
private long
packetsRecv
private long
packetsSent
private long
speed
private long
timeStamp
-
Constructor Summary
Constructors Constructor Description WindowsNetworkIF(java.net.NetworkInterface netint)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getBytesRecv()
Getter for the fieldbytesRecv
.long
getBytesSent()
Getter for the fieldbytesSent
.long
getCollisions()
Getter for the fieldcollisions
.java.lang.String
getIfAlias()
TheifAlias
as described in RFC 2863.NetworkIF.IfOperStatus
getIfOperStatus()
TheifOperStatus
as described in RFC 2863.int
getIfType()
(Windows, macOS) The NDIS Interface Type.long
getInDrops()
Getter for the fieldinDrops
.long
getInErrors()
Getter for the fieldinErrors
.int
getNdisPhysicalMediumType()
(Windows Vista and higher only) The NDIS physical medium type.static java.util.List<NetworkIF>
getNetworks(boolean includeLocalInterfaces)
Gets all network interfaces on this machinelong
getOutErrors()
Getter for the fieldoutErrors
.long
getPacketsRecv()
Getter for the fieldpacketsRecv
.long
getPacketsSent()
Getter for the fieldpacketsSent
.long
getSpeed()
Getter for the fieldspeed
.long
getTimeStamp()
Getter for the fieldtimeStamp
.boolean
isConnectorPresent()
(Windows Vista and higher) Set if a connector is present on the network interface.boolean
updateAttributes()
Updates interface network statistics on this interface.-
Methods inherited from class oshi.hardware.common.AbstractNetworkIF
getDisplayName, getIndex, getIPv4addr, getIPv6addr, getMacaddr, getMTU, getName, getNetworkInterfaces, getPrefixLengths, getSubnetMasks, isKnownVmMacAddr, queryNetworkInterface, toString
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
IS_VISTA_OR_GREATER
private static final boolean IS_VISTA_OR_GREATER
-
CONNECTOR_PRESENT_BIT
private static final byte CONNECTOR_PRESENT_BIT
- See Also:
- Constant Field Values
-
ifType
private int ifType
-
ndisPhysicalMediumType
private int ndisPhysicalMediumType
-
connectorPresent
private boolean connectorPresent
-
bytesRecv
private long bytesRecv
-
bytesSent
private long bytesSent
-
packetsRecv
private long packetsRecv
-
packetsSent
private long packetsSent
-
inErrors
private long inErrors
-
outErrors
private long outErrors
-
inDrops
private long inDrops
-
collisions
private long collisions
-
speed
private long speed
-
timeStamp
private long timeStamp
-
ifAlias
private java.lang.String ifAlias
-
ifOperStatus
private NetworkIF.IfOperStatus ifOperStatus
-
-
Method Detail
-
getNetworks
public static java.util.List<NetworkIF> getNetworks(boolean includeLocalInterfaces)
Gets all network interfaces on this machine- Parameters:
includeLocalInterfaces
- include local interfaces in the result- Returns:
- A list of
NetworkIF
objects representing the interfaces
-
getIfType
public int getIfType()
Description copied from interface:NetworkIF
(Windows, macOS) The NDIS Interface Type. NDIS interface types are registered with the Internet Assigned Numbers Authority (IANA), which publishes a list of interface types periodically in the Assigned Numbers RFC, or in a derivative of it that is specific to Internet network management number assignments.(Linux) ARP Protocol hardware identifiers defined in
include/uapi/linux/if_arp.h
- Returns:
- the ifType
-
getNdisPhysicalMediumType
public int getNdisPhysicalMediumType()
Description copied from interface:NetworkIF
(Windows Vista and higher only) The NDIS physical medium type. This member can be one of the values from theNDIS_PHYSICAL_MEDIUM
enumeration type defined in theNtddndis.h
header file.- Returns:
- the ndisPhysicalMediumType
-
isConnectorPresent
public boolean isConnectorPresent()
Description copied from interface:NetworkIF
(Windows Vista and higher) Set if a connector is present on the network interface.(Linux) Indicates the current physical link state of the interface.
- Returns:
true
if there is a physical network adapter (Windows) or a connected cable (Linux), false otherwise
-
getBytesRecv
public long getBytesRecv()
Description copied from interface:NetworkIF
Getter for the field
bytesRecv
.- Returns:
- The Bytes Received.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getBytesSent
public long getBytesSent()
Description copied from interface:NetworkIF
Getter for the field
bytesSent
.- Returns:
- The Bytes Sent.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getPacketsRecv
public long getPacketsRecv()
Description copied from interface:NetworkIF
Getter for the field
packetsRecv
.- Returns:
- The Packets Received.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getPacketsSent
public long getPacketsSent()
Description copied from interface:NetworkIF
Getter for the field
packetsSent
.- Returns:
- The Packets Sent.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getInErrors
public long getInErrors()
Description copied from interface:NetworkIF
Getter for the field
inErrors
.- Returns:
- Input Errors.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getOutErrors
public long getOutErrors()
Description copied from interface:NetworkIF
Getter for the field
outErrors
.- Returns:
- The Output Errors.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getInDrops
public long getInDrops()
Description copied from interface:NetworkIF
Getter for the field
inDrops
.- Returns:
- Incoming/Received dropped packets. On Windows, returns discarded incoming packets.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getCollisions
public long getCollisions()
Description copied from interface:NetworkIF
Getter for the field
collisions
.- Returns:
- Packet collisions. On Windows, returns discarded outgoing packets.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getSpeed
public long getSpeed()
Description copied from interface:NetworkIF
Getter for the field
speed
.- Returns:
- The speed of the network interface in bits per second.
This value is set when the
NetworkIF
is instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()
method
-
getTimeStamp
public long getTimeStamp()
Description copied from interface:NetworkIF
Getter for the field
timeStamp
.- Returns:
- Returns the timeStamp.
-
getIfAlias
public java.lang.String getIfAlias()
Description copied from interface:NetworkIF
TheifAlias
as described in RFC 2863.The ifAlias object allows a network manager to give one or more interfaces their own unique names, irrespective of any interface-stack relationship. Further, the ifAlias name is non-volatile, and thus an interface must retain its assigned ifAlias value across reboots, even if an agent chooses a new ifIndex value for the interface.
Only implemented for Windows (Vista and newer) and Linux.
- Returns:
- The
ifAlias
of the interface if available, otherwise the empty string.
-
getIfOperStatus
public NetworkIF.IfOperStatus getIfOperStatus()
Description copied from interface:NetworkIF
TheifOperStatus
as described in RFC 2863.Only implemented for Windows (Vista and newer) and Linux.
- Returns:
- The current operational state of the interface.
-
updateAttributes
public boolean updateAttributes()
Description copied from interface:NetworkIF
Updates interface network statistics on this interface. Statistics include packets and bytes sent and received, and interface speed.- Returns:
true
if the update was successful,false
otherwise.
-
-