Class NetworkIF
public class NetworkIF
extends java.lang.Object
-
Constructor Summary
Constructors Constructor Description NetworkIF() -
Method Summary
Modifier and Type Method Description longgetBytesRecv()Getter for the fieldbytesRecv.longgetBytesSent()Getter for the fieldbytesSent.longgetCollisions()Getter for the fieldcollisions.java.lang.StringgetDisplayName()Interface description.longgetInDrops()Getter for the fieldinDrops.longgetInErrors()Getter for the fieldinErrors.java.lang.String[]getIPv4addr()The Internet Protocol (IP) v4 address.java.lang.String[]getIPv6addr()The Internet Protocol (IP) v6 address.java.lang.StringgetMacaddr()The Media Access Control (MAC) address.intgetMTU()The interface Maximum Transmission Unit (MTU).java.lang.StringgetName()Interface name.longgetOutErrors()Getter for the fieldoutErrors.longgetPacketsRecv()Getter for the fieldpacketsRecv.longgetPacketsSent()Getter for the fieldpacketsSent.java.lang.Short[]getPrefixLengths()The Internet Protocol (IP) v6 address.longgetSpeed()Getter for the fieldspeed.java.lang.Short[]getSubnetMasks()The Internet Protocol (IP) v4 subnet masks.longgetTimeStamp()Getter for the fieldtimeStamp.java.net.NetworkInterfacequeryNetworkInterface()The NetworkInterface object.voidsetBytesRecv(long bytesRecv)Setter for the fieldbytesRecv.voidsetBytesSent(long bytesSent)Setter for the fieldbytesSent.voidsetCollisions(long collisions)Setter for the fieldcollisions.voidsetInDrops(long inDrops)Setter for the fieldinDrops.voidsetInErrors(long inErrors)Setter for the fieldinErrors.voidsetNetworkInterface(java.net.NetworkInterface networkInterface)Sets the network interface and calculates other information derived from itvoidsetOutErrors(long outErrors)Setter for the fieldoutErrors.voidsetPacketsRecv(long packetsRecv)Setter for the fieldpacketsRecv.voidsetPacketsSent(long packetsSent)Setter for the fieldpacketsSent.voidsetSpeed(long speed)Setter for the fieldspeed.voidsetTimeStamp(long timeStamp)Setter for the fieldtimeStamp.java.lang.StringtoString()booleanupdateAttributes()Updates interface network statistics on this interface.
-
Constructor Details
-
NetworkIF
public NetworkIF()
-
-
Method Details
-
queryNetworkInterface
public java.net.NetworkInterface queryNetworkInterface()The NetworkInterface object.
- Returns:
- the network interface, an instance of
NetworkInterface.
-
setNetworkInterface
public void setNetworkInterface(java.net.NetworkInterface networkInterface)Sets the network interface and calculates other information derived from it- Parameters:
networkInterface- The network interface to set
-
getName
public java.lang.String getName()Interface name.
- Returns:
- The interface name.
-
getDisplayName
public java.lang.String getDisplayName()Interface description.
- Returns:
- The description of the network interface. On some platforms, this is identical to the name.
-
getMTU
public int getMTU()The interface Maximum Transmission Unit (MTU).
- Returns:
- The MTU of the network interface.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method
-
getMacaddr
public java.lang.String getMacaddr()The Media Access Control (MAC) address.
- Returns:
- The MAC Address.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method
-
getIPv4addr
public java.lang.String[] getIPv4addr()The Internet Protocol (IP) v4 address.
- Returns:
- The IPv4 Addresses.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method
-
getSubnetMasks
public java.lang.Short[] getSubnetMasks()The Internet Protocol (IP) v4 subnet masks.
- Returns:
- The IPv4 subnet mask length. Ranges between 0-32.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method.
-
getIPv6addr
public java.lang.String[] getIPv6addr()The Internet Protocol (IP) v6 address.
- Returns:
- The IPv6 Addresses.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method
-
getPrefixLengths
public java.lang.Short[] getPrefixLengths()The Internet Protocol (IP) v6 address.
- Returns:
- The IPv6 address prefix lengths. Ranges between 0-128.
This value is set when the
NetworkIFis instantiated and may not be up to date. To update this value, execute thesetNetworkInterface(NetworkInterface)method
-
getBytesRecv
public long getBytesRecv()Getter 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 theupdateAttributes()method
-
setBytesRecv
public void setBytesRecv(long bytesRecv)Setter for the field
bytesRecv.- Parameters:
bytesRecv- Set Bytes Received
-
getBytesSent
public long getBytesSent()Getter 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 theupdateAttributes()method
-
setBytesSent
public void setBytesSent(long bytesSent)Setter for the field
bytesSent.- Parameters:
bytesSent- Set the Bytes Sent
-
getPacketsRecv
public long getPacketsRecv()Getter 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 theupdateAttributes()method
-
setPacketsRecv
public void setPacketsRecv(long packetsRecv)Setter for the field
packetsRecv.- Parameters:
packetsRecv- Set The Packets Received
-
getPacketsSent
public long getPacketsSent()Getter 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 theupdateAttributes()method
-
setPacketsSent
public void setPacketsSent(long packetsSent)Setter for the field
packetsSent.- Parameters:
packetsSent- Set The Packets Sent
-
getInErrors
public long getInErrors()Getter 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 theupdateAttributes()method
-
setInErrors
public void setInErrors(long inErrors)Setter for the field
inErrors.- Parameters:
inErrors- The Input Errors to set.
-
getOutErrors
public long getOutErrors()Getter 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 theupdateAttributes()method
-
setOutErrors
public void setOutErrors(long outErrors)Setter for the field
outErrors.- Parameters:
outErrors- The Output Errors to set.
-
getInDrops
public long getInDrops()Getter 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 theupdateAttributes()method
-
setInDrops
public void setInDrops(long inDrops)Setter for the field
inDrops.- Parameters:
inDrops- The incoming (receive) dropped packets to set.
-
getCollisions
public long getCollisions()Getter 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 theupdateAttributes()method
-
setCollisions
public void setCollisions(long collisions)Setter for the field
collisions.- Parameters:
collisions- The collisions to set.
-
getSpeed
public long getSpeed()Getter 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 theupdateAttributes()method
-
setSpeed
public void setSpeed(long speed)Setter for the field
speed.- Parameters:
speed- Set the speed of the network interface
-
getTimeStamp
public long getTimeStamp()Getter for the field
timeStamp.- Returns:
- Returns the timeStamp.
-
setTimeStamp
public void setTimeStamp(long timeStamp)Setter for the field
timeStamp.- Parameters:
timeStamp- The timeStamp to set.
-
updateAttributes
public boolean updateAttributes()Updates interface network statistics on this interface. Statistics include packets and bytes sent and received, and interface speed.- Returns:
trueif the update was successful,falseotherwise.
-
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-