Class AbstractNetworkIF
- All Implemented Interfaces:
NetworkIF
- Direct Known Subclasses:
AixNetworkIF, BsdNetworkIF, LinuxNetworkIF, MacNetworkIF, NetBsdNetworkIF, SolarisNetworkIF, WindowsNetworkIfJNA
-
Nested Class Summary
Nested classes/interfaces inherited from interface NetworkIF
NetworkIF.IfOperStatusModifier and TypeInterfaceDescriptionstatic enumThe current operational state of a network interface. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractNetworkIF(NetworkInterface netint) Construct aNetworkIFobject backed by the specifiedNetworkInterface.protectedAbstractNetworkIF(NetworkInterface netint, String displayName) Construct aNetworkIFobject backed by the specifiedNetworkInterface. -
Method Summary
Modifier and TypeMethodDescriptionlongGetter for the fieldbytesRecv.longGetter for the fieldbytesSent.longGetter for the fieldcollisions.Interface description.intgetIndex()Interface index.longGetter for the fieldinDrops.longGetter for the fieldinErrors.String[]The Internet Protocol (IP) v4 address.String[]The Internet Protocol (IP) v6 address.The Media Access Control (MAC) address.longgetMTU()The interface Maximum Transmission Unit (MTU).getName()Interface name.protected static List<NetworkInterface> getNetworkInterfaces(boolean includeLocalInterfaces) Returns network interfaces on this machine.longGetter for the fieldoutErrors.longGetter for the fieldpacketsRecv.longGetter for the fieldpacketsSent.Short[]The Internet Protocol (IP) v6 address.longgetSpeed()Getter for the fieldspeed.Short[]The Internet Protocol (IP) v4 subnet masks.longGetter for the fieldtimeStamp.booleanDetermines if the MAC address on this interface corresponds to a known Virtual Machine.Gets theNetworkInterfaceobject.protected voidsetBytesRecv(long bytesRecv) Sets the bytes received.protected voidsetBytesSent(long bytesSent) Sets the bytes sent.protected voidsetCollisions(long collisions) Sets the collisions.protected voidsetInDrops(long inDrops) Sets the input drops.protected voidsetInErrors(long inErrors) Sets the input errors.protected voidsetOutErrors(long outErrors) Sets the output errors.protected voidsetPacketsRecv(long packetsRecv) Sets the packets received.protected voidsetPacketsSent(long packetsSent) Sets the packets sent.protected voidsetSpeed(long speed) Sets the speed.protected voidsetTimeStamp(long timeStamp) Sets the timestamp.toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface NetworkIF
getIfAlias, getIfOperStatus, getIfType, getNdisPhysicalMediumType, isConnectorPresent, updateAttributesModifier and TypeMethodDescriptiondefault StringTheifAliasas described in RFC 2863.default NetworkIF.IfOperStatusTheifOperStatusas described in RFC 2863.default int(Windows, macOS) The NDIS Interface Type.default int(Windows Vista and higher only) The NDIS physical medium type.default boolean(Windows Vista and higher) Set if a connector is present on the network interface.booleanUpdates interface network statistics on this interface.
-
Constructor Details
-
AbstractNetworkIF
Construct aNetworkIFobject backed by the specifiedNetworkInterface.- Parameters:
netint- The core javaNetworkInterfacebacking this object.- Throws:
InstantiationException- If a socket exception prevents access to the backing interface.
-
AbstractNetworkIF
protected AbstractNetworkIF(NetworkInterface netint, String displayName) throws InstantiationException Construct aNetworkIFobject backed by the specifiedNetworkInterface.- Parameters:
netint- The core javaNetworkInterfacebacking this object.displayName- A string to use for the display name in preference to theNetworkInterfacevalue.- Throws:
InstantiationException- If a socket exception prevents access to the backing interface.
-
-
Method Details
-
getNetworkInterfaces
Returns network interfaces on this machine.- Parameters:
includeLocalInterfaces- include local interfaces in the result- Returns:
- A list of network interfaces
-
queryNetworkInterface
Description copied from interface:NetworkIFGets theNetworkInterfaceobject.- Specified by:
queryNetworkInterfacein interfaceNetworkIF- Returns:
- the network interface, an instance of
NetworkInterface.
-
getName
-
getIndex
-
getDisplayName
Description copied from interface:NetworkIFInterface description.- Specified by:
getDisplayNamein interfaceNetworkIF- Returns:
- The description of the network interface. On some platforms, this is identical to the name.
-
getMTU
public long getMTU()Description copied from interface:NetworkIFThe interface Maximum Transmission Unit (MTU).- Specified by:
getMTUin interfaceNetworkIF- Returns:
- The MTU of the network interface.
The value is a 32-bit integer which may be unsigned on some operating systems. On Windows, some non-physical interfaces (e.g., loopback) may return a value of -1 which is equivalent to the maximum unsigned integer value.
This value is set when the
NetworkIFis instantiated and may not be up to date.
-
getMacaddr
Description copied from interface:NetworkIFThe Media Access Control (MAC) address.- Specified by:
getMacaddrin interfaceNetworkIF- Returns:
- The MAC Address.
This value is set when the
NetworkIFis instantiated and may not be up to date.
-
getIPv4addr
Description copied from interface:NetworkIFThe Internet Protocol (IP) v4 address.- Specified by:
getIPv4addrin interfaceNetworkIF- Returns:
- An array of IPv4 Addresses.
This value is set when the
NetworkIFis instantiated and may not be up to date.
-
getSubnetMasks
Description copied from interface:NetworkIFThe Internet Protocol (IP) v4 subnet masks.- Specified by:
getSubnetMasksin interfaceNetworkIF- Returns:
- An array of IPv4 subnet mask lengths, corresponding to the IPv4 addresses from
NetworkIF.getIPv4addr(). Ranges between 0-32.This value is set when the
NetworkIFis instantiated and may not be up to date.
-
getIPv6addr
Description copied from interface:NetworkIFThe Internet Protocol (IP) v6 address.- Specified by:
getIPv6addrin interfaceNetworkIF- Returns:
- An array of IPv6 Addresses.
This value is set when the
NetworkIFis instantiated and may not be up to date.
-
getPrefixLengths
Description copied from interface:NetworkIFThe Internet Protocol (IP) v6 address.- Specified by:
getPrefixLengthsin interfaceNetworkIF- Returns:
- The IPv6 address prefix lengths, corresponding to the IPv6 addresses from
NetworkIF.getIPv6addr(). Ranges between 0-128.This value is set when the
NetworkIFis instantiated and may not be up to date.
-
isKnownVmMacAddr
public boolean isKnownVmMacAddr()Description copied from interface:NetworkIFDetermines if the MAC address on this interface corresponds to a known Virtual Machine.- Specified by:
isKnownVmMacAddrin interfaceNetworkIF- Returns:
trueif the MAC address corresponds to a known virtual machine.
-
getBytesRecv
public long getBytesRecv()Description copied from interface:NetworkIFGetter for the field
bytesRecv.- Specified by:
getBytesRecvin interfaceNetworkIF- 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.- Specified by:
getBytesSentin interfaceNetworkIF- 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.- Specified by:
getPacketsRecvin interfaceNetworkIF- 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.- Specified by:
getPacketsSentin interfaceNetworkIF- 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.- Specified by:
getInErrorsin interfaceNetworkIF- 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.- Specified by:
getOutErrorsin interfaceNetworkIF- 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.- Specified by:
getInDropsin interfaceNetworkIF- 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.- Specified by:
getCollisionsin interfaceNetworkIF- 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.- Specified by:
getSpeedin interfaceNetworkIF- 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.- Specified by:
getTimeStampin interfaceNetworkIF- Returns:
- Returns the timeStamp.
-
setBytesRecv
protected void setBytesRecv(long bytesRecv) Sets the bytes received.- Parameters:
bytesRecv- the bytes received
-
setBytesSent
protected void setBytesSent(long bytesSent) Sets the bytes sent.- Parameters:
bytesSent- the bytes sent
-
setPacketsRecv
protected void setPacketsRecv(long packetsRecv) Sets the packets received.- Parameters:
packetsRecv- the packets received
-
setPacketsSent
protected void setPacketsSent(long packetsSent) Sets the packets sent.- Parameters:
packetsSent- the packets sent
-
setInErrors
protected void setInErrors(long inErrors) Sets the input errors.- Parameters:
inErrors- the input errors
-
setOutErrors
protected void setOutErrors(long outErrors) Sets the output errors.- Parameters:
outErrors- the output errors
-
setInDrops
protected void setInDrops(long inDrops) Sets the input drops.- Parameters:
inDrops- the input drops
-
setCollisions
protected void setCollisions(long collisions) Sets the collisions.- Parameters:
collisions- the collisions
-
setSpeed
protected void setSpeed(long speed) Sets the speed.- Parameters:
speed- the speed in bits per second
-
setTimeStamp
protected void setTimeStamp(long timeStamp) Sets the timestamp.- Parameters:
timeStamp- the timestamp
-
toString
-