一、作用

  1. 用来获取套接字统计信息

二、选项

  • -a 显示所有套接字文件
  • -t 仅显示tcp套接字
  • -u 仅显示udp套接字
  • -l 显示监听状态的套接字
  • -n 不解析服务名
  • -p 显示套接字进程
  • -4 仅显示ipv4套接字

    三、实例

    [root@xxxx:~ ]# ss -altup
    Netid  State      Recv-Q Send-Q                   Local Address:Port                                    Peer Address:Port                
    udp    UNCONN     0      0                            127.0.0.1:323                                                *:*                     users:(("chronyd",pid=744,fd=5))
    udp    UNCONN     0      0                                [::1]:323                                             [::]:*                     users:(("chronyd",pid=744,fd=6))
    tcp    LISTEN     0      100                          127.0.0.1:smtp                                               *:*                     users:(("master",pid=1231,fd=13))
    tcp    LISTEN     0      128                                  *:ssh                                                *:*                     users:(("sshd",pid=1043,fd=3))
    tcp    LISTEN     0      100                              [::1]:smtp                                            [::]:*                     users:(("master",pid=1231,fd=14))
    tcp    LISTEN     0      128                               [::]:ssh                                             [::]:*                     users:(("sshd",pid=1043,fd=4))
    
    ``` [root@mysql mysql-8.0.26]# ss -antlp State Recv-Q Send-Q LocalAddress:Port Peer Address:Port
    LISTEN 0 100 127.0.0.1:25 : users:((“master”,pid=1412,fd=13)) LISTEN 0 128 :22 : users:((“sshd”,pid=14256,fd=3)) LISTEN 0 100 [::1]:25 [::]: users:((“master”,pid=1412,fd=14)) LISTEN 0 128 [::]:22 [::]:* users:((“sshd”,pid=14256,fd=4))
<a name="EDbQG"></a>
## 四、字段意思
```shell
LISTEN 状态: Recv-Q 表示的当前等待服务端调用


recv-Q 表示网络接收队列
表示收到的数据已经在本地接收缓冲,但是还有多少没有被进程取走,recv()
如果接收队列Recv-Q一直处于阻塞状态,可能是遭受了拒绝服务 denial-of-service 攻击。

send-Q 表示网路发送队列
对方没有收到的数据或者说没有Ack的,还是本地缓冲区.
如果发送队列Send-Q不能很快的清零,可能是有应用向外发送数据包过快,或者是对方接收数据包不够快。