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

public static enum NetStat.BusyPort.TcpState extends Enum<NetStat.BusyPort.TcpState>
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.

TCP State Diagram Legend for TCP State Diagram
  • 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

The nettop 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:
  • Nested Class Summary

    Nested classes/interfaces inherited from class java.lang.Enum

    Enum.EnumDesc<E extends Enum<E>>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Awaiting application listen, connect, accept, or close call following bind (lsof).
    Awaiting application close following 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 application bind, connect, or close on 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
    Modifier and Type
    Field
    Description
    private final List<String>
    State values reported by lsof.
    private final int
    Number associated with Microsoft's .Net TcpState enum.
    private final String
    String representation used by Microsoft.
    private final String
    State value reported by Mac OS X nettop command.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    TcpState(String msStateString, int msStateNumber, String nettopStateString, String... lsofStateStrings)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    fromLsofString(String lsofStateString)
    Determine the TcpCode from the state string from the lsof command.
    fromMicrosoftNumber(int msStateNumber)
    Determine the TcpState from the state number corresponding to a Microsoft System.Net.NetworkInformation.TcpState enum value.
    fromMicrosoftString(String msStateString)
    Determine the TcpState from the state string from the Microsoft Get-NetTCPConnection cmdlet.
    fromNettopString(String nettopStateString)
    Determine the TcpCode from the state string from the nettop command.
    Returns the enum constant of this type with the specified name.
    Returns an array containing the constants of this enum type, in the order they are declared.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • UNKNOWN

      public static final NetStat.BusyPort.TcpState UNKNOWN
      Connection state is unknown (MSFT_NetTCPConnection).
    • CLOSED

      public static final NetStat.BusyPort.TcpState CLOSED
      Not connected (RFC-793).
    • LISTEN

      public static final NetStat.BusyPort.TcpState LISTEN
      Awaiting a connection request (RFC-793).
    • SYN_SENT

      public static final NetStat.BusyPort.TcpState SYN_SENT
      Awaiting a matching connection request after having sent a connection request (RFC-793).
    • SYN_RECEIVED

      public static final NetStat.BusyPort.TcpState SYN_RECEIVED
      Awaiting connection request acknowledgement after having sent and received a connection request (RFC-793).
    • ESTABLISHED

      public static final NetStat.BusyPort.TcpState ESTABLISHED
      An "open" TCP connection over which data may be transferred (RFC-793).
    • FIN_WAIT_1

      public static final NetStat.BusyPort.TcpState FIN_WAIT_1
      Awaiting connection termination request or acknowledgement of sent connection termination request from remote (RFC-793).
    • FIN_WAIT_2

      public static final NetStat.BusyPort.TcpState FIN_WAIT_2
      Awaiting connection termination request from remote (RFC-793).
    • CLOSE_WAIT

      public static final NetStat.BusyPort.TcpState CLOSE_WAIT
      Awaiting application-level connection termination (socket close) (RFC-793).
    • CLOSING

      public static final NetStat.BusyPort.TcpState CLOSING
      Awaiting connection termination request acknowledgement from remote (RFC-793).
    • LAST_ACK

      public static final NetStat.BusyPort.TcpState LAST_ACK
      Awaiting acknowledgement of connection termination request sent to remote (RFC-793).
    • TIME_WAIT

      public static final NetStat.BusyPort.TcpState TIME_WAIT
      Awaiting expiration of TCP implementation-defined timeout before socket of closed connection can be re-used (RFC-793).
    • DELETE_TCB

      public static final NetStat.BusyPort.TcpState DELETE_TCB
      Indicates the control block representing the TCP connection is being deleted (MSFT_NetTCPConnection).
    • BOUND

      public static final NetStat.BusyPort.TcpState BOUND
      Awaiting application listen, connect, accept, or close call following bind (lsof).
    • CLOSE

      public static final NetStat.BusyPort.TcpState CLOSE
      Awaiting application close following a socket/connection error (lsof/Linux).
    • IDLE

      public static final NetStat.BusyPort.TcpState IDLE
      Awaiting application bind, connect, or close on socket (lsof).
  • Field Details

    • msStateString

      private final String msStateString
      String representation used by Microsoft.
    • msStateNumber

      private final int msStateNumber
      Number associated with Microsoft's .Net TcpState enum.
    • nettopStateString

      private final String nettopStateString
      State value reported by Mac OS X nettop command.
    • lsofStateStrings

      private final List<String> lsofStateStrings
      State values reported by lsof. Multiple values are permitted because of differences in representation by platform.
  • Constructor Details

    • TcpState

      private TcpState(String msStateString, int msStateNumber, String nettopStateString, String... lsofStateStrings)
  • Method Details

    • values

      public static NetStat.BusyPort.TcpState[] 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

      public static NetStat.BusyPort.TcpState valueOf(String name)
      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 name
      NullPointerException - if the argument is null
    • fromNettopString

      public static NetStat.BusyPort.TcpState fromNettopString(String nettopStateString)
      Determine the TcpCode from the state string from the nettop command.
      Parameters:
      nettopStateString - the state string from nettop
      Returns:
      the TcpState corresponding to nettopStateString
      Throws:
      EnumConstantNotPresentException - if nettopStateString is not a recognized TcpState
    • fromLsofString

      public static NetStat.BusyPort.TcpState fromLsofString(String lsofStateString)
      Determine the TcpCode from the state string from the lsof command.
      Parameters:
      lsofStateString - the state string from lsof
      Returns:
      the TcpState corresponding to lsofStateString
      Throws:
      EnumConstantNotPresentException - if lsofStateString is not a recognized TcpState
      See Also:
    • fromMicrosoftString

      public static NetStat.BusyPort.TcpState fromMicrosoftString(String msStateString)
      Determine the TcpState from the state string from the Microsoft Get-NetTCPConnection cmdlet.
      Parameters:
      msStateString - the state string from the Get-NetTCPConnection cmdlet
      Returns:
      the TcpState corresponding to msStateString
      Throws:
      EnumConstantNotPresentException - if msStateString is not a recognized TcpState
      See Also:
    • fromMicrosoftNumber

      public static NetStat.BusyPort.TcpState fromMicrosoftNumber(int msStateNumber)
      Determine the TcpState from the state number corresponding to a Microsoft System.Net.NetworkInformation.TcpState enum value.
      Parameters:
      msStateNumber - the TcpState enum number
      Returns:
      the TcpState corresponding to msStateNumber
      Throws:
      EnumConstantNotPresentException - if msStateNumber is not a recognized TcpState
      See Also: