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. 01串(dp)

    01串 时间限制:1000 ms  |  内存限制:65535 KB 难度:2   描述 ACM的zyc在研究01串,他知道某一01串的长度,但他想知道不含有“11”子串的这种长度的01串共有多少个, ...

  2. Working with Numbers in PL/SQL(在PL/SQL中使用数字)

    This article gives you all the information you need in order to begin working with numbers in your P ...

  3. Remastersys备份linux系统ISO镜像

    1. 安装Remastersys 利用Ubuntu Software Center安装,修改sources.list文件,在文件末尾加入下面三行,添加软件源, #Rsudo remastersys d ...

  4. gradient杂谈

    工作中难免遇到某些小项目中没有设计的情况,这对于PS基础薄弱的我来说非常恐怖.无奈之下,只好自己自学UI方面的知识,但对于某些能用CSS实现的背景样式等,还是尽可能地用已经掌握的知识去实现.本文主要分 ...

  5. html进阶css(2)

    选择器的类型 <!doctype html> <html> <head> <meta charset="utf-8"> <ti ...

  6. NFinal ajax

    AJAX返回 我们经常会用到ajax,当我们想返回json时,需要这样写. context.Response.ContentType="application/json"; con ...

  7. Android的Fragment中onActivityResult不被调用的解决方案

    常见的,我们会在FragmentActivity中嵌套一层Fragment使用,甚至两次或多层Fragment嵌套使用.这个时候,在第二级或者更深级别的Fragment调用startActivityF ...

  8. java基础学习笔记

    Q:    What if the main method is declared as private?  如果将主函数声明为私有类型的会怎样? A:     The program compile ...

  9. Java的Date类与Calendar类

    一:Date类 在JDK1.0中,Date类是唯一的一个代表时间的类,但是由于Date类不便于实现国际化,所以从JDK1.1版本开始,推荐使用Calendar类进行时间和日期处理.这里简单介绍一下Da ...

  10. Oracle中MERGE语句的使用

    Oracle在9i引入了merge命令, 通过这个merge你能够在一个SQL语句中对一个表同时执行inserts和updates操作. 当然是update还是insert是依据于你的指定的条件判断的 ...