六,iperf3做为TCP客户端运行时函数调用过程


本文描述从main函数入口开始,到一轮TCP测试包收发结束时,做为 TCP服务端函数调用顺序

加入调试代码

同前文,我们在我们可以在iperf_api.h及其它一些头文件中中增加编译宏,然后在每个函数的入口处增加这个宏的调用,可以打印出函数调用关系。

#ifndef PRINTFILEFUNCLINE
       #define PRINTFILEFUNCLINE printf("debug out: func = %-25s,line = %4d, file = %s\r\n",__FUNCTION__,__LINE__,__FILE__);
#endif

测试用命令

打流命令为

服务端

iperf3 -s

客户端
总共发送8K数据,每次发送1K

iperf3 -c 127.0.0.1 -n 8K -l 1K

要注意,在测试过程中,TCP客户端除了往TCP服务端发送测试数据流外,还会在测试开始时测试过程中每固定间隔测试完成时这三个时间分别向TCP服务端发送测试结果报告。

伪代码流程

TCP客户端发送TCP数据的代码调用逻辑如下面伪代码:
进入主函数main
{
调用iperf_new_test创建测试对象test
调用iperf_default和iperf_parse_arguments初始化测试对象test
调用run,测试对象test开始运行
调用iperf_run_client运行TCP客户端程序
调用iperf_connect–>netdial连接服务端

连接成功并且创建本次测试后进入while(IPERF_NOT_DONE)循环
{
调用iperf_create_streams–>iperf_new_stream创建本次测试
状态转为TEST_RUNNING
调用iperf_send通过sp->snd函数指针调用iperf_tcp_send开始向服务端发送数据包
检测到TCP数据全部发送完成后或者其它原因导致的连接断开后,跳出循环
}
}

测试代码调用关系输出

xxx@xxx-pc:~/iperf3/iperf$ iperf3 -c 127.0.0.1 -n 8K -l 1K
debug out: func = main                     ,line =   62, file = main.c
debug out: func = iperf_new_test           ,line = 2732, file = iperf_api.c
debug out: func = iperf_defaults           ,line = 2796, file = iperf_api.c
debug out: func = iperf_parse_arguments    ,line = 1125, file = iperf_api.c
debug out: func = run                      ,line =  145, file = main.c
debug out: func = iperf_run_client         ,line =  529, file = iperf_client_api.c
debug out: func = iperf_connect            ,line =  377, file = iperf_client_api.c
debug out: func = netdial                  ,line =  238, file = net.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
Connecting to host 127.0.0.1, port 5201
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_create_streams     ,line =   62, file = iperf_client_api.c
debug out: func = iperf_new_stream         ,line = 4223, file = iperf_api.c
[  5] local 127.0.0.1 port 39254 connected to 127.0.0.1 port 5201
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  648, file = iperf_client_api.c
debug out: func = iperf_send               ,line = 1877, file = iperf_api.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_send               ,line = 1900, file = iperf_api.c
debug out: func = iperf_tcp_send           ,line =   94, file = iperf_tcp.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  577, file = iperf_client_api.c
while(TEST_NO_DONE)
debug out: func = iperf_run_client         ,line =  593, file = iperf_client_api.c
debug out: func = iperf_run_client         ,line =  595, file = iperf_client_api.c
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-0.00   sec  8.00 KBytes   446 Mbits/sec    0    320 KBytes       
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-0.00   sec  8.00 KBytes   446 Mbits/sec    0             sender
[  5]   0.00-0.00   sec  4.00 KBytes   166 Mbits/sec                  receiver

iperf Done.


  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值