Enum NetStat.BusyPort.TcpState
java.lang.Object
java.lang.Enum<NetStat.BusyPort.TcpState>
org.terracotta.utilities.test.net.NetStat.BusyPort.TcpState
- All Implemented Interfaces:
Serializable,Comparable<NetStat.BusyPort.TcpState>,java.lang.constant.Constable
- Enclosing class:
- NetStat.BusyPort
TCP Connection states.
This class maps the states observed by the utilities used to examine the TCP connections on the platform to a common form. Where the state maps to a state described in RFC-793 Transmission Control Protocol, that state name is used for the enumeration constant.
The following diagram shows the usual TCP state transitions. For a discussion of this diagram, see RFC-793 Transmission Control Protocol and TCP/IP Illustrated, Volume 1, 1ed: The Protocols by W. Richard Stevens.
![]() |
![]() |
- The CLOSE_WAIT and FIN_WAIT_2 states are paired -- one side of the connection will be in CLOSE_WAIT and the other in FIN_WAIT_2. Until the application in CLOSE_WAIT actually closes the connection, the connection remains with neither socket endpoint being available for re-use. (According to (Stevens 1994), some TCP implementations will move a socket in FIN_WAIT_2 to CLOSED after 10+ minutes of idle time.)
- The TIME_WAIT state is applied to a newly closed connection and is used to prevent immediate re-use of the socket to allow delivery of potentially delayed packets. The amount of time the socket remains in TIME_WAIT varies by implementation (and potentially configuration) but is commonly 2 minutes.
Implementation Notes
Mac OS X
Thenettop utility used for Mac OS X is closed source but source for a variant
(netbottom.c) is available. The TCP state constants returned by nettop
are neither documented nor listed in an available source file. The values used in this
enum are presumed from the known values and the names of external references,
in the form of kNStatSrcTcpStateXxxxxxxxxx, made by netbottom.c.- See Also:
-
- Get-NetTCPConnection
- MSFT_NetTCPConnection class
- lsof/dialects/linux/dsock.c
- apple/darwin-xnu/bsd/netinet/tcp_fsm.h
netbottom.cSources- "Stevens, W. Richard (1994) <i>TCP/IP Illustrated, Volume 1, 1ed: The Protocols</i>, Addison-Wesley"
- RFC-793 Transmission Control Protocol
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAwaiting applicationlisten,connect,accept, orclosecall followingbind(lsof).Awaiting applicationclosefollowing a socket/connection error (lsof/Linux).Awaiting application-level connection termination (socket close) (RFC-793).Not connected (RFC-793).Awaiting connection termination request acknowledgement from remote (RFC-793).Indicates the control block representing the TCP connection is being deleted (MSFT_NetTCPConnection).An "open" TCP connection over which data may be transferred (RFC-793).Awaiting connection termination request or acknowledgement of sent connection termination request from remote (RFC-793).Awaiting connection termination request from remote (RFC-793).Awaiting applicationbind,connect, orcloseon socket (lsof).Awaiting acknowledgement of connection termination request sent to remote (RFC-793).Awaiting a connection request (RFC-793).Awaiting connection request acknowledgement after having sent and received a connection request (RFC-793).Awaiting a matching connection request after having sent a connection request (RFC-793).Awaiting expiration of TCP implementation-defined timeout before socket of closed connection can be re-used (RFC-793).Connection state is unknown (MSFT_NetTCPConnection). -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic NetStat.BusyPort.TcpStatefromLsofString(String lsofStateString) Determine theTcpCodefrom the state string from thelsofcommand.static NetStat.BusyPort.TcpStatefromMicrosoftNumber(int msStateNumber) Determine theTcpStatefrom the state number corresponding to a MicrosoftSystem.Net.NetworkInformation.TcpStateenum value.static NetStat.BusyPort.TcpStatefromMicrosoftString(String msStateString) Determine theTcpStatefrom the state string from the MicrosoftGet-NetTCPConnectioncmdlet.static NetStat.BusyPort.TcpStatefromNettopString(String nettopStateString) Determine theTcpCodefrom the state string from thenettopcommand.static NetStat.BusyPort.TcpStateReturns the enum constant of this type with the specified name.static NetStat.BusyPort.TcpState[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
UNKNOWN
Connection state is unknown (MSFT_NetTCPConnection). -
CLOSED
Not connected (RFC-793). -
LISTEN
Awaiting a connection request (RFC-793). -
SYN_SENT
Awaiting a matching connection request after having sent a connection request (RFC-793). -
SYN_RECEIVED
Awaiting connection request acknowledgement after having sent and received a connection request (RFC-793). -
ESTABLISHED
An "open" TCP connection over which data may be transferred (RFC-793). -
FIN_WAIT_1
Awaiting connection termination request or acknowledgement of sent connection termination request from remote (RFC-793). -
FIN_WAIT_2
Awaiting connection termination request from remote (RFC-793). -
CLOSE_WAIT
Awaiting application-level connection termination (socket close) (RFC-793). -
CLOSING
Awaiting connection termination request acknowledgement from remote (RFC-793). -
LAST_ACK
Awaiting acknowledgement of connection termination request sent to remote (RFC-793). -
TIME_WAIT
Awaiting expiration of TCP implementation-defined timeout before socket of closed connection can be re-used (RFC-793). -
DELETE_TCB
Indicates the control block representing the TCP connection is being deleted (MSFT_NetTCPConnection). -
BOUND
Awaiting applicationlisten,connect,accept, orclosecall followingbind(lsof). -
CLOSE
Awaiting applicationclosefollowing a socket/connection error (lsof/Linux). -
IDLE
Awaiting applicationbind,connect, orcloseon socket (lsof).
-
-
Field Details
-
msStateString
String representation used by Microsoft. -
msStateNumber
private final int msStateNumberNumber associated with Microsoft's .Net TcpState enum. -
nettopStateString
State value reported by Mac OS Xnettopcommand. -
lsofStateStrings
State values reported bylsof. Multiple values are permitted because of differences in representation by platform.
-
-
Constructor Details
-
TcpState
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
fromNettopString
Determine theTcpCodefrom the state string from thenettopcommand.- Parameters:
nettopStateString- the state string fromnettop- Returns:
- the
TcpStatecorresponding tonettopStateString - Throws:
EnumConstantNotPresentException- ifnettopStateStringis not a recognizedTcpState
-
fromLsofString
Determine theTcpCodefrom the state string from thelsofcommand.- Parameters:
lsofStateString- the state string fromlsof- Returns:
- the
TcpStatecorresponding tolsofStateString - Throws:
EnumConstantNotPresentException- iflsofStateStringis not a recognizedTcpState- See Also:
-
fromMicrosoftString
Determine theTcpStatefrom the state string from the MicrosoftGet-NetTCPConnectioncmdlet.- Parameters:
msStateString- the state string from theGet-NetTCPConnectioncmdlet- Returns:
- the
TcpStatecorresponding tomsStateString - Throws:
EnumConstantNotPresentException- ifmsStateStringis not a recognizedTcpState- See Also:
-
fromMicrosoftNumber
Determine theTcpStatefrom the state number corresponding to a MicrosoftSystem.Net.NetworkInformation.TcpStateenum value.- Parameters:
msStateNumber- theTcpStateenum number- Returns:
- the
TcpStatecorresponding tomsStateNumber - Throws:
EnumConstantNotPresentException- ifmsStateNumberis not a recognizedTcpState- See Also:
-

