Class MacNetworkIF
- java.lang.Object
-
- oshi.hardware.common.AbstractNetworkIF
-
- oshi.hardware.platform.mac.MacNetworkIF
-
- All Implemented Interfaces:
NetworkIF
@ThreadSafe public final class MacNetworkIF extends AbstractNetworkIF
MacNetworks class.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface oshi.hardware.NetworkIF
NetworkIF.IfOperStatus
-
-
Field Summary
Fields Modifier and Type Field Description private longbytesRecvprivate longbytesSentprivate longcollisionsprivate intifTypeprivate longinDropsprivate longinErrorsprivate static org.slf4j.LoggerLOGprivate longoutErrorsprivate longpacketsRecvprivate longpacketsSentprivate longspeedprivate longtimeStamp
-
Constructor Summary
Constructors Constructor Description MacNetworkIF(java.net.NetworkInterface netint, java.util.Map<java.lang.Integer,NetStat.IFdata> data)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description longgetBytesRecv()Getter for the fieldbytesRecv.longgetBytesSent()Getter for the fieldbytesSent.longgetCollisions()Getter for the fieldcollisions.intgetIfType()(Windows, macOS) The NDIS Interface Type.longgetInDrops()Getter for the fieldinDrops.longgetInErrors()Getter for the fieldinErrors.static java.util.List<NetworkIF>getNetworks(boolean includeLocalInterfaces)Gets all network interfaces on this machinelonggetOutErrors()Getter for the fieldoutErrors.longgetPacketsRecv()Getter for the fieldpacketsRecv.longgetPacketsSent()Getter for the fieldpacketsSent.longgetSpeed()Getter for the fieldspeed.longgetTimeStamp()Getter for the fieldtimeStamp.private static java.lang.StringqueryIfDisplayName(java.net.NetworkInterface netint)booleanupdateAttributes()Updates interface network statistics on this interface.private booleanupdateNetworkStats(java.util.Map<java.lang.Integer,NetStat.IFdata> data)Updates interface network statistics on the given interface.-
Methods inherited from class oshi.hardware.common.AbstractNetworkIF
getDisplayName, getIndex, getIPv4addr, getIPv6addr, getMacaddr, getMTU, getName, getNetworkInterfaces, getPrefixLengths, getSubnetMasks, isKnownVmMacAddr, queryNetworkInterface, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface oshi.hardware.NetworkIF
getIfAlias, getIfOperStatus, getNdisPhysicalMediumType, isConnectorPresent
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
ifType
private int ifType
-
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
-
-
Constructor Detail
-
MacNetworkIF
public MacNetworkIF(java.net.NetworkInterface netint, java.util.Map<java.lang.Integer,NetStat.IFdata> data) throws java.lang.InstantiationException- Throws:
java.lang.InstantiationException
-
-
Method Detail
-
queryIfDisplayName
private static java.lang.String queryIfDisplayName(java.net.NetworkInterface netint)
-
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
NetworkIFobjects 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
-
getBytesRecv
public long getBytesRecv()
Description copied from interface:NetworkIFGetter for the field
bytesRecv.- Returns:
- The Bytes Received.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getBytesSent
public long getBytesSent()
Description copied from interface:NetworkIFGetter for the field
bytesSent.- Returns:
- The Bytes Sent.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getPacketsRecv
public long getPacketsRecv()
Description copied from interface:NetworkIFGetter for the field
packetsRecv.- Returns:
- The Packets Received.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getPacketsSent
public long getPacketsSent()
Description copied from interface:NetworkIFGetter for the field
packetsSent.- Returns:
- The Packets Sent.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getInErrors
public long getInErrors()
Description copied from interface:NetworkIFGetter for the field
inErrors.- Returns:
- Input Errors.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getOutErrors
public long getOutErrors()
Description copied from interface:NetworkIFGetter for the field
outErrors.- Returns:
- The Output Errors.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getInDrops
public long getInDrops()
Description copied from interface:NetworkIFGetter for the field
inDrops.- Returns:
- Incoming/Received dropped packets. On Windows, returns discarded incoming packets.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getCollisions
public long getCollisions()
Description copied from interface:NetworkIFGetter for the field
collisions.- Returns:
- Packet collisions. On Windows, returns discarded outgoing packets.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getSpeed
public long getSpeed()
Description copied from interface:NetworkIFGetter for the field
speed.- Returns:
- The speed of the network interface in bits per second.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute theNetworkIF.updateAttributes()method
-
getTimeStamp
public long getTimeStamp()
Description copied from interface:NetworkIFGetter for the field
timeStamp.- Returns:
- Returns the timeStamp.
-
updateAttributes
public boolean updateAttributes()
Description copied from interface:NetworkIFUpdates interface network statistics on this interface. Statistics include packets and bytes sent and received, and interface speed.- Returns:
trueif the update was successful,falseotherwise.
-
updateNetworkStats
private boolean updateNetworkStats(java.util.Map<java.lang.Integer,NetStat.IFdata> data)
Updates interface network statistics on the given interface. Statistics include packets and bytes sent and received, and interface speed.- Parameters:
data- A map of network interface statistics with the index as the key- Returns:
trueif the update was successful,falseotherwise.
-
-