前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >网络编程之TCP/IP

网络编程之TCP/IP

原创
作者头像
CoffeeLand
修改2020-04-07 11:24:53
3830
修改2020-04-07 11:24:53
举报
文章被收录于专栏:CoffeeLandCoffeeLand

Table of Content

  • Prerequisites
  • TCP intro
  • TCP的三次握手
  • Reference

Prerequisites

tcp flags

Value

Flag Type

Description

S

SYN

Connection Start

F

FIN

Connection Finish

P

PUSH

Data push

R

RST

Connection reset

.

ACK

Acknowledgment

TCP intro

tcp是传输层的协议

TCP的三次握手

tcp三次握手的过程

tcp的三次握手是指client与server端通过发送http请求,建立tcp连接, 分为三个步骤

代码语言:javascript
复制
第一步,  client向server端发送建立连接的请求, 用SYN来标志, SYN用[S]来表示
第二步, server端收到clent端发来的SYN请求, 然后发送确认ACK并建立连接SYN, 用SYN+ACK标志, 用[S.]
第三步, client端发送给客户端确认的相应ACK, 用[.]来表示

tcp的连接示意图

tcpdump分析tcp建立连接的过程

下面是从浏览器(客户端) 发送HTTP GET 请求给server端, 利用tcpdump抓包工具打印出详细过程

代码语言:javascript
复制
[root@mybuildvm bandao]# tcpdump -i any -c5 -nn port 8080
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes
(第一步) 01:20:59.617829 IP6 ::1.52734 > ::1.8080: Flags [S], seq 2772511575, win 43690, options [mss 65476,sackOK,TS val 51495764 ecr 0,nop,wscale 7], length 0
(第二步)15:50:22.569058 IP6 ::1.8080 > ::1.52734: Flags [S.], seq 3471702762, ack 2772511576, win 43690, options [mss 65476,sackOK,TS val 51495764 ecr 51495764,nop,wscale 7], length 0
(第三步)01:20:59.617871 IP6 ::1.52734 > ::1.8080: Flags [.], ack 1, win 342, options [nop,nop,TS val 51495764 ecr 51495764], length 0
(传输数据)01:20:59.618000 IP6 ::1.52734 > ::1.8080: Flags [P.], seq 1:405, ack 1, win 342, options [nop,nop,TS val 51495764 ecr 51495764], length 404
(响应完毕)01:20:59.618013 IP6 ::1.8080 > ::1.52734: Flags [.], ack 405, win 350, options [nop,nop,TS val 51495764 ecr 51495764], length 0
5 packets captured
10 packets received by filter
0 packets dropped by kernel

References

https://opensource.com/article/18/10/introduction-tcpdump

http://www.tcpipguide.com/free/t_TCPConnectionEstablishmentProcessTheThreeWayHandsh-3.htm

<未完待续~~~~~~~~~~~~~>

请点赞支持, 谢谢:)

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Table of Content
  • Prerequisites
    • tcp flags
    • TCP intro
    • TCP的三次握手
      • tcp三次握手的过程
        • tcp的连接示意图
          • tcpdump分析tcp建立连接的过程
          • References
          领券
          问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档