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. 证明与计算(7): 有限状态机(Finite State Machine)

    什么是有限状态机(Finite State Machine)? 什么是确定性有限状态机(deterministic finite automaton, DFA )? 什么是非确定性有限状态机(nond ...

  3. Finite State Machine 是什么?

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

  4. State Machine.(状态机)

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

  5. Finite State Machine

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

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

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

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

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

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

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

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

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

随机推荐

  1. Arithmetic Sequence(dp)

    Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 51  Solved: 19[Submit][Status][We ...

  2. JAVA wait(), notify(),sleep具体解释

    在CSDN开了博客后,一直也没在上面公布过文章,直到前一段时间与一位前辈的对话,才发现技术博客的重要,立志要把CSDN的博客建好.但一直没有找到好的开篇的主题,今天再看JAVA线程相互排斥.同步的时候 ...

  3. [HeadFirst-JSPServlet学习笔记][第一章:前言与概述]

    第一章 前言与概述 web服务器做什么? 答:接收客户请求,然后向客户返回结果 web客户做什么? 答:此处客户指浏览器,web客户允许用户请求服务器上的某个资源,并向用户展现请求的结果. html ...

  4. Audio笔记之MediaPlayerService:setDataSource

    //下面是一个典型的播放序列: MediaPlayer player=new MediaPlayer() player->setDataSource(url,header); player-&g ...

  5. java String常见的处理

    import java.util.Arrays; class Demo5 { public static void main(String [] args) { String name1=" ...

  6. .NET winform 的keypress事件中判断当用户按下的是哪个键

    keys是按键的枚举类型 private void txtPropertyValue_KeyPress(object sender, KeyPressEventArgs e) { if ((Keys) ...

  7. iPhone6设计自适应布局

    http://www.devtalking.com/articles/adaptive-layout-for-iphone6-1/ http://www.devtalking.com/articles ...

  8. wxPython缩放图片控件的一个小例子

    前几天写程序的时候,想有个自适应的图片控件,但是一直没有找到合适的解决方案.今天终于解决了这个问题,发在这里,以供参考. 程序截图: 文件下载地址: http://files.cnblogs.com/ ...

  9. c++中的名字查找

    参看下面链接:<C++中的名字查找>

  10. EcStore中的App是什么东西?

    Ecstore中的App不是手机上的App,它是一个Web应用包,集合了Web应用的后端PHP程序.Mysql数据表定义,以及前端HTML+CSS+JS展现,通常是实现某个业务功能,如购物车.促销.支 ...