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. 海量路由表能够使用HASH表存储吗-HASH查找和TRIE树查找

    千万别! 非常多人这样说,也包括我. Linux内核早就把HASH路由表去掉了.如今就仅仅剩下TRIE了,只是我还是希望就这两种数据结构展开一些形而上的讨论. 1.hash和trie/radix ha ...

  2. CSS彻底研究(3) - 浮动,定位

    Github pages 博文 CSS彻底研究(3)-浮动,定位 一 . 浮动float I . 定义及规则 float默认为none,对应标准流的情况.当float : left;时,元素就会向其父 ...

  3. C# 文件操作(一)

    1.说明: 写入文件内容,如果文件中有内容,则进行追加,目录是程序集下的目录 public static void WriteLog(string value) { try { //目录是程序集下的D ...

  4. javascript正则简单入门

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. Android的ADB工具使用

    在SDK的Tools文件夹下包含着Android模拟器操作的重要命令ADB,ADB的全称为Android Debug Bridge,就是调试桥的作用,借助这个工具,我们可以管理设备或手机模拟器的状态  ...

  6. Vim知识点收集

    (注意: 只记录工作中实际使用的命令) 删除带有pattern的所有行    :g/pattern/d 删除不带pattern的所有行   :g!/pattern/d 匹配red和blue,无次序   ...

  7. DOM元素尺寸和位置(clientwidth ,scrollwidth , offsetwidth.......)

    [1] slientWidth 和 sclientHeight slientWidth:获取的是可视宽度 slientHeight:获取的是可视高度 <html> <head> ...

  8. Mybatis Generator最完整配置详解

    <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE generatorConfiguration ...

  9. _ConnectionPtr.CreateInstance(__uuidof(Connection))“不支持此接口”错误解决

    最近在换了win7 64位的系统,今天突然发现以前写的ADO连接数据库的代码编译后在windows2003下会执行到: _ConnectionPtr.CreateInstance(__uuidof(C ...

  10. js入门基础7-2 (求模-隔行变色)

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...