netstat输出中Established时Recv-Q的含义

netstat输出中Recv-Q的含义,当然就和man中说的一样,我们做实验只看Established状态下Recv-Q的数据。

https://man7.org/linux/man-pages/man8/netstat.8.html

OUTPUT         top
   Active Internet connections (TCP, UDP, UDPLite, raw)
   Proto
       The protocol (tcp, udp, udpl, raw) used by the socket.

   Recv-Q
       Established: The count of bytes not copied by the user program
       connected to this socket.  Listening: Since Kernel 2.6.18 this column
       contains the current syn backlog.

   Send-Q
       Established: The count of bytes not acknowledged by the remote host.
       Listening: Since Kernel 2.6.18 this column contains the maximum size
       of the syn backlog.

 

tomcat只开启一个http线程,且,处理时为sleep 3600s。也就是说,tomcat只在处理一个请求

    @RequestMapping("/greeting")
    public @ResponseBody
    String greeting(HttpServletResponse rsp, @RequestParam(name = "cost") long cost) {
        try {
                Thread.sleep(cost * 1000L);
        } catch (Exception e) {
            e.printStackTrace();
        }
        String format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS").format(new Date());
        LOG.info(format);
        return format;
    }

使用Jmeter同时发送200个请求。由于我们设置为只能接受10个连接:

maxConnections + ( min(acceptCount, somaxconn) + 1 ) == 6 + ( min(3, 4096) + 1 ) == 6+ ( 3+1 ) == 10

所以,tomcat只能接受10个连接

上图中"192.168.86.204:8080     192.168.86.1:xxx   ESTABLISHED"的确实只有10个,其中

  1. "ESTABLISHED -"意思是该tcp连接由OS代为持有,放到了OS的 全连接队列中
  2. "ESTABLISHED 7977/java"意思是该tcp连接已经交由pid为7977的java应用

 

只在 "192.168.86.204:8080     192.168.86.1:45523"时Recv-Q显示为0,其余都是187。那么,这里的187是什么意思呢?

当然就是man netstat中说的含义了:The count of bytes not copied by the user program connected to this socket,也就是“OS已接收到,但,OS尚未交付给应用程序的数据”的大小"

Recv-Q
       Established: The count of bytes not copied by the user program
       connected to this socket.

       Listening: Since Kernel 2.6.18 this column contains the current syn backlog

 

我们是http请求,这就是我们http请求的数据,包括http头和http body数据(如果有)。把这个数据抓包到187.pcap文件中,我们用wireshark看下

marvin@vm204:~$ sudo tcpdump -v -nn -i ens33 port 8080 -w 187.pcap
[sudo] password for marvin: 
tcpdump: listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
^C2548 packets captured
2548 packets received by filter
0 packets dropped by kernel
marvin@vm204:~$ 

整个http的大小,正好是187

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值