netstat포트 상태를 확인 하는 데 사용 합니다.
나는 포트 상태 사이의 차이가 무엇 궁금 해서요 LISTENING, TIME_WAIT, CLOSE_WAIT, FIN_WAIT1그리고 ESTABLISHED?
답변
맨 의는 netstat각각의 상태에 대한 간단한 설명이있다 :
ESTABLISHED
The socket has an established connection.
SYN_SENT
The socket is actively attempting to establish a connection.
SYN_RECV
A connection request has been received from the network.
FIN_WAIT1
The socket is closed, and the connection is shutting down.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown
from the remote end.
TIME_WAIT
The socket is waiting after close to handle packets still in the
network.
CLOSE The socket is not being used.
CLOSE_WAIT
The remote end has shut down, waiting for the socket to close.
LAST_ACK
The remote end has shut down, and the socket is closed. Waiting
for acknowledgement.
LISTEN The socket is listening for incoming connections. Such sockets
are not included in the output unless you specify the
--listening (-l) or --all (-a) option.
CLOSING
Both sockets are shut down but we still don't have all our data
sent.
UNKNOWN
The state of the socket is unknown.
상태 전환 다이어그램 (예 : 여기 , 여기 및 여기 )을 사용하여 상태를 더 잘 이해할 수 있습니다.
소켓 연결을 시도하는 두 개의 프로그램을 고려하십시오 ( a및 호출 b). 둘 다 소켓을 설정하고 LISTEN상태로 전환합니다 . 그런 다음 한 프로그램 (예 :)이 다른 프로그램 ( a)에 연결을 시도합니다 b. a요청을 보내고 SYN_SENT상태를 입력 한 b후 요청을 수신하고 SYN_RECV상태를 입력합니다 . 때 b수신 확인을 요청, 그들은 입력 ESTABLISHED상태를 자신의 사업을 할. 이제 몇 가지 일이 발생할 수 있습니다.
a연결을 닫고을 입력FIN_WAIT1합니다.b수신하고FIN, 요청을 전송ACK(다음a입사FIN_WAIT2), 진입CLOSE_WAIT, 지시a가 폐쇄되고,이 들어간다LAST_ACK. 이를a확인하고 (를 입력 한 후TIME_WAIT)를b입력하십시오CLOSE.a남아있는 것이 있는지 조금 기다렸다가을 입력CLOSE합니다.a그리고b그들의 사업을 완료하고 연결 (동시 폐쇄를) 종료하기로 결정했다. 경우a에FIN_WAIT, 그리고 대신 수신ACK에서b, 그것은 수신FIN(ASb소원뿐만 아니라 그것을 폐쇄)a들어간다CLOSING. 그러나이 전송에 여전히 일부 메시지는합니다 (있는ACK그a원래 얻을 것으로 예상되는FIN)이 일단ACK도착,a들어가TIME_WAIT평소처럼.