STACKOVER ADDRESS:https://stackoverflow.com/questions/21390479/fin-omitted-fin-ack-sent

question:

As it's written on Wikipedia closing TCP connection should be using packets FIN->(FIN,ACK)->ACK. However when I use close() function to close socket I don't see FIN packet, there is instantly sent (FIN,ACK) packet from server to client, then client closes also connection by sending (FIN,ACK) and server responds with ACK packet. So where is the missing FIN packet (maybe it's merged to FIN,ACK)?

answer:

The closing sequence can also be different and don't need to have FIN+ACK inside the same packet:

  • ACK just acknowledges the receipt of data (e.g. received everything up to given sequence number)
  • packets will be re-send until one receives an ACK for them
  • FIN just says that the side sending the FIN will not send any more data. It gives no information if it will still receive data.
  • like every other packet FIN will be re-send until the receipt is acknowledged

Protocols like HTTP support a one-sided shutdown, e.g. the client sends the request data followed by a FIN to notify the server, that it will not send anymore data. But it will still receive the data send by the server. The server will acknowledge the FIN like it did with all the data before. Once the server is done it will send its own FIN which the client ACKs. In this case you have

. client: FIN  (will not send more)
. server: ACK (received the FIN)
.. server: sends more data..., client ACKs these data
. server: FIN (will not send more)
. client: ACK (received the FIN)

Note that the packet you see in step#1 might have an ACK inside too. But this ACK just acknowledges data send before by the server. If the server has no more data to send it might close the connection also. In this case steps 2+3 can be merged, e.g. the server sends a FIN+ACK, where the ACK acknowledges the FIN received by the client.

If one side sends its FIN the connection is called half-closed. It is fully closed once both sides send their FIN and received the ACK for the FIN, no matter if they do this in 3 or 4 packets.

FIN omitted, FIN-ACK sent的更多相关文章

  1. TCP状态机:当服务端主动发FIN进TIME_WAIT,客户端源端口复用会发生什么

    0X01 正常情况下TCP连接会通过4次挥手进行拆链(也有通过RST拆除连接的可能,见为什么服务器突然回复RST--小心网络中的安全设备),下图TCP状态机展示了TCP连接的状态变化过程: 我们重点看 ...

  2. tcp 接收被动关闭 fin

    void tcp_rcv_established(struct sock *sk, struct sk_buff *skb, const struct tcphdr *th, unsigned int ...

  3. 浅谈iptables 入站 出站以及NAT实例

    --------------本文是自己工作上的笔记总结,适合的可以直接拿去用,不适合的,适当修改即可!--------------- iptbales默认ACCEPT策略,也称通策略,这种情况下可以做 ...

  4. TCP三次握手/四次挥手详解

    一. TCP/IP协议族 TCP/IP是一个协议族,通常分不同层次进行开发,每个层次负责不同的通信功能.包含以下四个层次: 1. 链路层,也称作数据链路层或者网络接口层,通常包括操作系统中的设备驱动程 ...

  5. TCP十一种状态

    2.全部11种状态 2.1.客户端独有的:(1)SYN_SENT (2)FIN_WAIT1 (3)FIN_WAIT2 (4)CLOSING (5)TIME_WAIT . 2.2.服务器独有的:(1)L ...

  6. TCP/IP是一种十一状态

    1.建立连接协议(三次握手) 三次握手过程说明: 1.  在最开始,客户端和服务器都是处于CLOSED状态 2.服务器会创建sockert开始监听,服务器状态LISTEN 3.客户端向服务器端发送SY ...

  7. 简析TCP的三次握手与四次分手

    TCP是什么? 具体的关于TCP是什么,我不打算详细的说了:当你看到这篇文章时,我想你也知道TCP的概念了,想要更深入的了解TCP的工作,我们就继续.它只是一个超级麻烦的协议,而它又是互联网的基础,也 ...

  8. TCP的三次握手(建立连接)和四次挥手(关闭连接)

    参照: http://course.ccniit.com/CSTD/Linux/reference/files/018.PDF http://hi.baidu.com/raycomer/item/94 ...

  9. 转载请注明出处: https://github.com/qiu-deqing/FE-interview

    转载请注明出处: https://github.com/qiu-deqing/FE-interview Table of Contents generated with DocToc FE-inter ...

随机推荐

  1. sqler sql 转rest api 2.0 试用

    sqler 的迭代还是很快的,已经2.0 了,2.0 有好多新功能的添加,同时也有好多不兼容的修改 说明: 测试使用docker-compose,同时我已经push 了docker 镜像 dalong ...

  2. tile38 一款开源的geo 数据库

    tile38 是基于golang 编写的geo 数据库,支持地理空间索引.实时地理围栏,同时也支持leader-flower 的部署模型 备注: 下边测试一个简单的地理围栏功能 环境准备 docker ...

  3. 01python简介

    目录 1.  Python起源 2.  解释器 3.  Python 的设计目标 4.  Python 的设计哲学 5.  为什么选择  Python ? 6.  Python 特点 7.  Pyth ...

  4. 访问平安银行网站时出现证书问题 NET::ERR_CERT_SYMANTEC_LEGACY

    访问平安银行网站时出现证书问题 NET::ERR_CERT_SYMANTEC_LEGACY 查了资料说是 Google 取消了对 Symantec SSL 的信任,因为 Symantec 干了坏事1. ...

  5. Jmeter关于断言

    本文摘自:一颗糖果   https://www.cnblogs.com/linglingyuese/p/linglingyuese-five.html 1.断言持续时间(Duration to Ass ...

  6. [转] Centos7 yum lock,无法上网问题,以及安装python3.5

    centos 7 无法上网问题 转自 http://www.cnblogs.com/katios/p/5660336.html 博主本着学无止境的精神在虚拟机上安装了一个centos7 来敲敲命令行. ...

  7. Qt中的主窗口之菜单栏

    1.Qt中的主窗口 主窗口为建立应用程序用户界面提供了一个框架 Qt开发平台中直接支持主窗口的概念 QMainWindow是Qt中主窗口的基类 QMainWindow继承于QWidget是一种容器类型 ...

  8. VMware Ubuntu配置虚拟机和主机互相ping通

    安装VMware后,主机会有两个虚拟网卡:  vmnet1和vmnet8是两个虚拟网卡,主要作用是让虚拟机可以通过你的宿主机的网线上网.注意:如果有“!”,说明不能用. vmnet1是为host-on ...

  9. PHP中的插件机制原理和实例

    PHP项目中很多用到插件的地方,更尤其是基础程序写成之后很多功能由第三方完善开发的时候,更能用到插件机制,现在说一下插件的实现.特点是无论你是否激活,都不影响主程序的运行,即使是删除也不会影响. 从一 ...

  10. Django 模板语法

    模板语法之变量 变量在HTML中的表示:{{var_name}} 变量取值:句点符 "." views: def index(request): import datetime s ...