tcp实验

tcp实验记录

抓包: 两台服务器,一台启动python http服务,上面有一个2G的文件。另一台下载。 怎么抓包,在那台机器上抓包,是不是指定来源ip就可以了? 是指定抓n个包,还是说指定ip,从开始下载到结束? 抓完包后怎么分析,需要分析哪些内容?arp协议?地址询问?http三次握手?三次挥手? 怎么调整内核,又要重新抓包?内核调整时,服务器有什么变化,用top命令能看出来么? rt,丢包率,curl速度怎么查看?使用–help,需要谷歌协助么? 执行curl就出问题了

服务端

1
2
3
4
5
server:172.19.5.43
python -m SimpleHTTPServer 8089

ll -h
-rw-r--r--. 1 root root 1.9G Mar 25 11:37 zookeeper.out

客户端

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
client:172.19.9.147
tcpdump -i eth0 tcp port 8089 and host 172.19.5.43 -w tcpdump-$(date +%Y-%m-%d-%H-%M-%S).cap
[root@172.19.9.147 ~]# wget http://172.19.5.43:8089/zookeeper.out
--2023-03-26 00:49:47--  http://172.19.5.43:8089/zookeeper.out
Connecting to 172.19.5.43:8089... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1972256747 (1.8G) [application/octet-stream]
Saving to: ‘zookeeper.out’

100%[==========================================================================================================================================>] 1,972,256,747 53.2MB/s   in 25s    

2023-03-26 00:50:11 (76.3 MB/s) - ‘zookeeper.out’ saved [1972256747/1972256747]

[root@172.19.9.147 ~]# curl http://172.19.5.43:8089/zookeeper.out --output zookeeper.out.file
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1880M  100 1880M    0     0  77.0M      0  0:00:24  0:00:24 --:--:-- 54.3M

curl 控制速度

1
2
3
4
[root@172.19.9.147 ~]# curl http://172.19.5.43:8089/zookeeper.out --output zookeeper.out.file --limit-rate 1M
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
 33 1880M   33  625M    0     0  1023k      0  0:31:21  0:10:25  0:20:56  996k

tc命令介绍

BDP和buffer、RT的关系 搜这个问题发现别人早就看过任总的文章了,还写了笔记。https://blog.csdn.net/fdsafwagdagadg6576/article/details/121011575

相关概念

  1. BDP: (Bandwidth-Delay Product) 带宽时延积
  2. Buffer: 指的是sysctl中的 rmem或者wmem
  3. rt: tcp的timestamps->time since previous frame in this tcp stream(我猜就是响应时间的一种)
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
[root@172.19.5.43 ~]# sysctl -a | grep 'net.ipv4.tcp_wmem'
sysctl: reading key "net.ipv6.conf.all.stable_secret"
net.ipv4.tcp_wmem = 4096        16384   4194304
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.veth59705c1.stable_secret"
sysctl: reading key "net.ipv6.conf.veth6cbfe80.stable_secret"
[root@172.19.5.43 ~]# sysctl -a | grep 'net.ipv4.tcp_wmem'
sysctl: reading key "net.ipv6.conf.all.stable_secret"
net.ipv4.tcp_wmem = 4096        4096    4096
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.veth59705c1.stable_secret"
sysctl: reading key "net.ipv6.conf.veth6cbfe80.stable_secret"

参数相关

更新了配置后,直接服务也启动失败,wget也异常了。

Licensed under CC BY-NC-SA 4.0
最后更新于 Jul 03, 2023 13:05 +0800
comments powered by Disqus
记录自己
Built with Hugo
主题 StackJimmy 设计