Recently, the server was operated and maintained, and a large number of connections in the LAST_ACK state were monitored. I learned about the status of the TCP connection and checked the connection status, and the network card data packet statistics were checked.
A network client-server interaction process
Two state transitions when a TCP client server establishes a connection
Three state transitions when the TCP client server closes the connection
Four netstat to view the connection status
1) View the TCP connection status
Command: netstat -ant
[test@localhost ~]$ # netstat -ant
Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN tcp 0 0 192.168.1.102:6379 192.168.1.101:64476 ESTABLISHED
tcp 0 0 192.168.1.102:32981 125.56.219.11:80 ESTABLISHED
tcp 0 0 192.168.1.102:6379 192.168.1.103:51081 ESTABLISHED
tcp 0 0 192.168.1.102:6379 192.168.1.101:65132 ESTABLISHED
tcp 0 0 192.168.1.102:6379 192.168.1.101:65133 ESTABLISHED
tcp 0 0 192.168.1.102:6379 192.168.1.101:65131 ESTABLISHED
|
The last column is the TCP connection status
Check the status of a network segment in a certain state:
netstat -ant | grep 'LAST_ACK' | awk '{print $5}' | awk -F '.' '{print $1"."$2"."$3}' | sort | uniq -c
2) View network interface statistics
Command: netstat -i
[test@localhost ~]$ netstat -i
Kernel Interface table
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 7136404312 0 0 0 6882295066 0 0 0 BMRU
eth1 1500 0 2908664373 0 0 0 1821339838 0 0 0 BMRU
lo 16436 0 18037157 0 0 0 18037157 0 0 0 LRU
|
explain:
Iface: network interface name
MTU: Maximum Transmission Unit
Met:
RX-OK: Correct number of packets when received
RX-ERR: Number of packets received with errors
RX-DRP: Number of packets dropped on receive
RX-OVR: When receiving, the number of packets dropped due to overrun
In data transmission, data is lost because the receiving device cannot receive the data transmitted at the transmission rate
TX-OK: Correct number of packets when sending
TX-ERR: Number of packets with errors while sending
TX-DRP: Number of packets dropped while sending
TX-OVR: Number of packets discarded due to overrun while sending
Flg: Flag
B has already set a broadcast address.
L This interface is a loopback device.
M Receive all packets (chaotic mode).
N Avoid tracking.
O On this interface, disable ARP.
P This is a point-to-point link.
R interface is working
The U interface is in the "active" state.