States

TCP includes 11 states, they are:

LISTEN

SYN_SENT

SYN_RECV

ESTABLISHED

FIN_WAIT1

CLOSE_WAIT

FIN_WAIT2

LAST_ACK

TIME_WAIT

CLOSED

CLOSING

@include/net/tcp_states.h:

/* Definitions for the TCP protocol sk_state field. */

#ifndef _LINUX_TCP_STATES_H
#define _LINUX_TCP_STATES_H

enum {
    TCP_ESTABLISHED = 1,
    TCP_SYN_SENT,
    TCP_SYN_RECV,
    TCP_FIN_WAIT1,
    TCP_FIN_WAIT2,
    TCP_TIME_WAIT,
    TCP_CLOSE,
    TCP_CLOSE_WAIT,
    TCP_LAST_ACK,
    TCP_LISTEN,
    TCP_CLOSING,    /* Now a valid state */

    TCP_MAX_STATES    /* leave at the end! */
};

#define TCP_STATE_MASK 0xF
#define TCP_ACTION_FIN (1 << 7)

enum {
    TCPF_ESTABLISHED = (1 << 1),
    TCPF_SYN_SENT = (1 << 2),
    TCPF_SYN_RECV = (1 << 3),
    TCPF_FIN_WAIT1 = (1 << 4),
    TCPF_FIN_WAIT2 = (1 << 5),
    TCPF_TIME_WAIT = (1 << 6),
    TCPF_CLOSE = (1 << 7),
    TCP_CLOSE_WAIT = (1 << 8),
    TCP_LAST_ACK = (1 << 9),
    TCP_LISTEN = (1 << 10),
    TCP_CLOSING = (1 << 11)
};

#endif /* _LINUX_TCP_STATES_H */

View of Server

Passive open and passive close often performed by Server, the normal routine is illustrated as follow.

I denote the passive open/close transitions with a blue line (normal transitions are in bold).

View of Client

Ative open and Active close often performed by Client, the normal routine is illustrated as follow.

I denote the active open/close transitions with a green line (normal transitions are in bold).

As a whole

We know while most TCP state transitions are normal, it also has some unnormal transitions, including:

simultaneous open

simultaneous close

RST and etc.

I use dashed line to denote this kind of transitions.

Sequence chart

(1)Normal sequence chart (including active open/close, passive open/close)

(2)simultaneous open

 (3)simultaneous close

Author

zhangskd @ csdn blog

Exploring TCP state machine by graphs的更多相关文章

  1. Qt: The State Machine Framework 学习

    State Machine,即为状态机,是Qt中一项非常好的框架.State Machine包括State以及State间的Transition,构成状态和状态转移.通过状态机,我们可以很方便地实现很 ...

  2. Finite State Machine 是什么?

    状态机(Finite State Machine):状态机由状态寄存器和组合逻辑电路构成,能够根据控制信号按照预先设定的状态进行状态转移,是协调相关信号动       作.完成特定操作的控制中心. 类 ...

  3. State Machine.(状态机)

    What is a State Machine? Any device that changes its state from one to another due to some actions a ...

  4. Finite State Machine

    Contents [hide]  1 Description 2 Components 3 C# - FSMSystem.cs 4 Example Description This is a Dete ...

  5. Android4.0中蓝牙适配器state machine(状态机)的分析

    今天晓东和大家来一起看一下Android4.0中蓝牙适配器(Bluetooth Adapter)的状态机变化的过程.首先,我们需要了解一下,蓝牙适配器究竟有哪些状态,从代码可以清晰地看到(framew ...

  6. 控制结构(3) 状态机(state machine)

    // 上一篇:卫语句(guard clause) // 下一篇:局部化(localization) 基于语言提供的基本控制结构,更好地组织和表达程序,需要良好的控制结构. 前情回顾 上次分析了guar ...

  7. UNIX网络编程——SOCKET API和TCP STATE的对应关系_三次握手_四次挥手及TCP延迟确认

    在socket系统调用中,如何完成三次握手和四次挥手: SOCK_DGRAM即UDP中的connect操作知识在内核中注册对方机器的IP和PORT信息,并没有建立连接的过程,即没有发包,close也不 ...

  8. 控制结构(3): 状态机(state machine)

    // 上一篇:卫语句(guard clause) // 下一篇:局部化(localization) 基于语言提供的基本控制结构,更好地组织和表达程序,需要良好的控制结构. 前情回顾 上次分析了guar ...

  9. 【UML】-NO.43.EBook.5.UML.1.003-【UML 大战需求分析】- 状态机图(State Machine Diagram)

    1.0.0 Summary Tittle:[UML]-NO.43.EBook.1.UML.1.003-[UML 大战需求分析]- 状态机图(State Machine Diagram) Style:D ...

随机推荐

  1. BZOJ 2286: [Sdoi2011]消耗战

    2286: [Sdoi2011消耗战 Time Limit: 20 Sec  Memory Limit: 512 MBSubmit: 2082  Solved: 736[Submit][Status] ...

  2. 标准库类型vector

    标准库类型vector表示对象的集合,其中所有对象的类型都相同.集合中的每个对象都有一个与之对应的索引,索引用于访问对象.因为vector“容纳着”其他对象,所以它被称为容器. 要想使用vector, ...

  3. json.net xml转换为json格式时,如何将指定节点转换成数组

    using System.Xml.Linq; using Newtonsoft.Json; Response.ContentType = "application/json"; X ...

  4. CSS3 box-shadow(阴影使用)

    from: http://jingyan.baidu.com/article/03b2f78c4d9fae5ea237aea6.html css3 box-shadow 内阴影与外阴影 1- box- ...

  5. App设计相关网站

    http://sketch.im/ 设计素材 principle  动效软件 http://principleformac.com/ 官网 http://principlecn.com/ 中文网

  6. 【转】Jmeter(二)-使用代理录制脚本

    Jmeter脚本是以JMX格式为主 Jmeter也是支持录制的,支持第三方录制方式和代理录制方式. 1.第三方录制主要是通过badboy来录制,录制后另存为jmx格式即可. 2.Jmeter也有自己的 ...

  7. console.log

    其实,console.log 不仅仅有一下应用 console.log() 这个应该是最常用的 console.error() 输出错误信息 会以红色显示 console.assert(bool,”i ...

  8. 03-python3.5-模拟购物车流程--更新追加细节注释功能

    03-python3.5-模拟购物车流程--更新追加细节注释功能: 模拟购物车更新脚本: #!/usr/bin/env python #-*- coding: utf-8 -*- #__author_ ...

  9. sse矩阵乘法 应该是1毫秒纯运算1000次

    #include <intrin.h> #include <math.h> struct Vector4 { float x, y, z, w; }; struct Matri ...

  10. EBS查询在线用户

    转自:https://www.cnblogs.com/benio/archive/2011/03/10/1979417.html SELECT u.user_name, app.application ...