当前位置:网站首页>Technology sharing | packet capturing analysis TCP protocol
Technology sharing | packet capturing analysis TCP protocol
2022-07-07 11:24:00 【The elegance of testing】
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 network transmission of data packets “ head ” Completely intercepted to provide analysis tools . 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 .

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 .
Last : It can be in the official account : Sad spicy bar ! Get one by yourself 216 Page software testing engineer interview guide document information 【 Free of charge 】. And the corresponding video learning tutorial is free to share !, It includes basic knowledge 、Linux necessary 、Shell、 The principles of the Internet 、Mysql database 、 Special topic of bag capturing tools 、 Interface testing tool 、 Test advanced -Python Programming 、Web automated testing 、APP automated testing 、 Interface automation testing 、 Testing advanced continuous integration 、 Test architecture development test framework 、 Performance testing 、 Safety test, etc. .
I recommend one 【Python Automated test communication group :746506216】, We can discuss communication software testing together , Learn software testing together 、 Interview and other aspects of software testing , Help you advance quickly Python automated testing / Test Development , On the road to high pay .
Friends who like software testing , If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One Key triple connection !
边栏推荐
- RationalDMIS2022 高级编程宏程序
- 关于在云服务器上(这里用腾讯云)安装mysql8.0并使本地可以远程连接的方法
- The opacity value becomes 1%
- Shardingsphere sub database and table examples (logical table, real table, binding table, broadcast table, single table)
- MIF file format record
- 学习笔记|数据小白使用DataEase制作数据大屏
- 基于Retrofit框架的金山API翻译功能案例
- 软件设计之——“高内聚低耦合”
- 什么是高内聚、低耦合?
- 测试优惠券要怎么写测试用例?
猜你喜欢

Design intelligent weighing system based on Huawei cloud IOT (STM32)
![[untitled]](/img/a0/29975bc0f9832e1640cc39dfce4a71.jpg)
[untitled]

Static semantic check of clang tidy in cicd

About the application of writing shell script JSON in JMeter

對比學習之 Unsupervised Learning of Visual Features by Contrasting Cluster Assignments

uniCloud

From pornographic live broadcast to live broadcast E-commerce

学习笔记|数据小白使用DataEase制作数据大屏

The concept, implementation and analysis of binary search tree (BST)

electron添加SQLite数据库
随机推荐
深度学习秋招面试题集锦(一)
The seventh training assignment
[untitled]
Activity lifecycle
毕业季|与青春作伴,一起向未来!
Une fois que l'uniapp a sauté de la page dans onlaunch, cliquez sur Event Failure resolution
关于jmeter中编写shell脚本json的应用
QT | multiple windows share a prompt box class
技术分享 | 抓包分析 TCP 协议
解决VSCode只能开两个标签页的问题
Unsupervised learning of visual features by contracting cluster assignments
聊聊SOC启动(七) uboot启动流程三
Briefly introduce closures and some application scenarios
【时间格式工具函数的封装】
通过 Play Integrity API 的 nonce 字段提高应用安全性
Audit migration
CentOS系统下Redis安装和自启动配置的步骤
audit 移植
MIF file format record
[C #] the solution of WinForm operation zoom (blur)