connect函数与karn算法
来源:互联网 发布:店铺数据查看 编辑:程序博客网 时间:2024/05/21 09:11
先看connect函数:
#include <unistd.h>#include <sys/types.h>#include <sys/socket.h>#include <netdb.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <ctype.h>#include <errno.h>#include <malloc.h>#include <netinet/in.h>#include <arpa/inet.h>#include <sys/ioctl.h>#include <stdarg.h>#include <fcntl.h>int main(){ int sockClient = socket(AF_INET, SOCK_STREAM, 0); struct sockaddr_in addrSrv; addrSrv.sin_addr.s_addr = inet_addr("1.2.3.4"); addrSrv.sin_family = AF_INET; addrSrv.sin_port = htons(8765); connect(sockClient, ( const struct sockaddr *)&addrSrv, sizeof(struct sockaddr_in));char szSendBuf[1024 * 64 * 10] = {0};int iRet = send(sockClient, szSendBuf, sizeof(szSendBuf) , 0); printf("send size is %d, iRet is %d\n", sizeof(szSendBuf), iRet); getchar(); close(sockClient); return 0;}运行并抓包:
xxxxxx$ sudo tcpdump -iany port 8765 -nlps0tcpdump: verbose output suppressed, use -v or -vv for full protocol decodelistening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes23:58:48.918381 IP 10.100.70.139.48767 > 1.2.3.4.ultraseek-http: Flags [S], seq 1851659651, win 14280, options [mss 1428,sackOK,TS val 1238166474 ecr 0,nop,wscale 8], length 023:58:49.916564 IP 10.100.70.139.48767 > 1.2.3.4.ultraseek-http: Flags [S], seq 1851659651, win 14280, options [mss 1428,sackOK,TS val 1238166724 ecr 0,nop,wscale 8], length 023:58:51.920561 IP 10.100.70.139.48767 > 1.2.3.4.ultraseek-http: Flags [S], seq 1851659651, win 14280, options [mss 1428,sackOK,TS val 1238167225 ecr 0,nop,wscale 8], length 023:58:55.932564 IP 10.100.70.139.48767 > 1.2.3.4.ultraseek-http: Flags [S], seq 1851659651, win 14280, options [mss 1428,sackOK,TS val 1238168228 ecr 0,nop,wscale 8], length 0过一会儿, connect函数超时, 从抓包看, 连接的时候, 重传时间间隔分别为1, 2, 4秒, 这就是之前介绍过的karn算法。
阅读全文
1 0
- connect函数与karn算法
- Karn算法
- connect与select函数用法
- tcp超时重传(RTO)之karn算法及其简要实验
- QT 信号与槽 connect函数
- 信号与槽的connect连接函数
- connect函数
- connect函数
- connect函数
- connect函数
- connect函数
- connect函数
- connect函数
- Connect函数
- connect函数
- connect函数
- socket编程里connect函数与qt冲突
- Qt_log2000_信号与槽中的connect函数之深入part1
- 占位
- Xshell连接不上虚拟机的问题和解决办法
- java类名文件名规范
- C语言入门基础知识(一)
- NYOJ:79-拦截导弹
- connect函数与karn算法
- asp.net 操作带输入输出参数的分页存储过程(三)
- 统计学原理
- Composer的两种安装方式和依赖安装方式
- vps租用适合那些平台呢?
- TX2440开发板Uboot移植教程
- Windows编程_Lesson007_内核对象
- 函数原型!!
- 630总结