当前位置:网站首页>Technology sharing | packet capturing analysis TCP protocol
Technology sharing | packet capturing analysis TCP protocol
2022-07-06 19:59:00 【Hua Weiyun】
This article is excerpted from the internal textbook of Hogwarts testing and development society
TCP The protocol is in the transport layer , A connection oriented 、 reliable 、 Transport layer communication protocol based on byte stream .
Environmental preparation
Classify interface testing tools , It can be classified as follows :
- Network sniffer tool :tcpdump,wireshark
- Agent tools :fiddler,charles,anyproxyburpsuite,mitmproxy
- Analysis tools :curl,postman,chrome Devtool
Caught analysis TCP agreement
tcpdump
tcpdump Is a The of packets transmitted over a network “ head ” Completely intercepted to provide analysis Tools for . It supports for network layer 、 agreement 、 host 、 Network or port filtering , And provide and、or、not And other logical statements to remove useless information .
Give Way tcpdump Always monitor 443 port , If there is any difference, enter it into log In file
sudo tcpdump port 443 -v -w /tmp/tcp.log Use this command , Will put the report in the directory /tmp/tcp.log in .
| Common parameters | meaning |
|---|---|
| port 443 | monitor 443 port |
| -v | Output more detailed information |
| -w | Write data to log in |
wireshark
wireshark It is also a network sniffing tool , In addition to having tcpdump function , There are more extensions , For example, analysis tools , But in interface testing , The process of capturing packets is often carried out on the server , Servers generally do not provide UI Interface , therefore wireshark Unable to work on server , Can only use tcpdump Grab bag generation log, And then log Import wireshark Use , There is UI Analysis on the client of the interface .
Caught analysis TCP agreement
Grab one http Of get request :
- Search on Baidu mp3
http://www.baidu.com/s?wd=mp3 - use tcpdump Intercept this get request , And generate log
- use wireshark open tcpdump Generated log
Use wireshark see log:

log The first few messages are three handshakes . Because the channel is unreliable , Before sending the data , It is necessary to ensure channel stability , And three handshakes are like the following operations :
- The first handshake : When establishing a connection , The client sends syn package (syn=j) To the server , And enter SYN_SENT state , Wait for server to confirm .
- The second handshake : Server received syn package , Must confirm customer's SYN(ack=j+1), At the same time, I also send a SYN package (seq=k), namely SYN+ACK package , At this time, the server enters SYN_RECV state ;
- The third handshake : Client receives server's SYN+ACK package , Send confirmation package to server ACK(ack=k+1), This package has been sent , Client and server access ESTABLISHED(TCP Successful connection ) state , Complete three handshakes .
After three handshakes , Can further communicate , It looks like this :

At the end of the communication , Four waves are also required :

- First wave : The client sends a... To the server FIN, Request to turn off data transfer .
- Second wave : The server received... From the client FIN, Send a ACK, among ack The value is equal to the FIN+SEQ.
- Third wave : The server sends a... To the client FIN, Tell client application to close .
- Fourth wave : The client receives... From the server FIN, Reply to one ACK To the server . among ack The value is equal to the FIN+SEQ.
Be careful : A request may be divided into multiple packets , So is a data , So in wireshark You'll see a lot of bags .
边栏推荐
- 【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
- Appx代码签名指南
- [translation] Digital insider. Selection process of kubecon + cloudnativecon in Europe in 2022
- JVM_常见【面试题】
- Cf960g - bandit Blues (type I Stirling number +ogf)
- LeetCode_ Double pointer_ Medium_ 61. rotating linked list
- 爬虫(14) - Scrapy-Redis分布式爬虫(1) | 详解
- POJ3617 Best Cow Line 馋
- POJ 3207 Ikki's Story IV – Panda's Trick (2-SAT)
- 广州首个数据安全峰会将在白云区开幕
猜你喜欢

语音识别(ASR)论文优选:全球最大的中英混合开源数据TALCS: An Open-Source Mandarin-English Code-Switching Corpus and a Speech

Introduction to enterprise lean management system
![[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.](/img/09/106adc222c06cbd2f4f66cf475cce2.jpg)
[translation] linkerd's adoption rate in Europe and North America exceeded istio, with an increase of 118% in 2021.

腾讯字节阿里小米京东大厂Offer拿到手软,老师讲的真棒

腾讯Android面试必问,10年Android开发经验

枚举根据参数获取值

(3) Web security | penetration testing | basic knowledge of network security construction, IIS website construction, EXE backdoor generation tool quasar, basic use of

Analysis of rainwater connection

Vscode debug run fluent message: there is no extension for debugging yaml. Should we find yaml extensions in the market?

BUUCTF---Reverse---easyre
随机推荐
Test Li hi
350. 两个数组的交集 II
【计网】第三章 数据链路层(4)局域网、以太网、无线局域网、VLAN
Learning and Exploration - function anti shake
腾讯架构师首发,2022Android面试笔试总结
Vmware虚拟机无法打开内核设备“\\.\Global\vmx86“的解决方法
PHP and excel phpexcel
mod_ WSGI + pymssql path SQL server seat
深入浅出,面试突击版
手把手教你学会js的原型与原型链,猴子都能看懂的教程
JVM_常见【面试题】
Tencent T2 Daniel explained in person and doubled his job hopping salary
Standardized QCI characteristics
Tencent Android development interview, basic knowledge of Android Development
VMware virtual machine cannot open the kernel device "\.\global\vmx86"
【云小课】EI第47课 MRS离线数据分析-通过Flink作业处理OBS数据
数据的同步为每个站点创建触发器同步表
[infrastructure] deployment and configuration of Flink / Flink CDC (MySQL / es)
Alibaba数据源Druid可视化监控配置
Tencent cloud database public cloud market ranks top 2!