##netsat
netstat -ant
得到
root@f6c0aba5201d:/# netstat -antActive Internet connections (servers and established)Proto Recv-Q Send-Q Local Address Foreign Address Statetcp6 0 0 :::8080 :::* LISTENtcp6 52 0 172.17.0.2:8080 192.168.99.1:56750 ESTABLISHEDtcp6 0 0 172.17.0.2:8080 192.168.99.1:56503 TIME_WAITtcp6 52 0 172.17.0.2:8080 192.168.99.1:56788 ESTABLISHEDtcp6 0 0 172.17.0.2:8080 192.168.99.1:56686 TIME_WAITtcp6 0 0 172.17.0.2:8080 192.168.99.1:56658 TIME_WAITtcp6 0 0 172.17.0.2:8080 192.168.99.1:56723 TIME_WAITtcp6 52 0 172.17.0.2:8080 192.168.99.1:56695 ESTABLISHEDtcp6 0 0 172.17.0.2:8080 192.168.99.1:56688 TIME_WAITtcp6 0 0 172.17.0.2:8080 192.168.99.1:56701 TIME_WAIT
##整体统计
netstat -an | awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}'
得到
root@f6c0aba5201d:/# netstat -an | awk '/^tcp/ {++S[$NF]} END {for (a in S) print a, S[a]}'LISTEN 1TIME_WAIT 22ESTABLISHED 96
##TCP的状态机
##建立连接时对应的状态
##doc