IP地址快速变化下的TCPIP通信中间件客户端开发

 2021-12-28 08:12

论文总字数:25284字

摘 要

本文通过设计一套与原生SOCKET极为类似的中间件接口,在SOCKET原有基础上,实现移动环境下无需应用干预的连接自动恢复及数据续传功能

在中间件中,通过为每一个连接建立起一个连接结构体的方式保存连接信息。在通信正常的情况下,以尽量接近原生SOCKET的方式进行通信。一旦通信发生中断,中间件开始接管SOCKET的错误信息。同时,通过中间件内实现的心跳包机制检查通信的连接状况。当发现客户端到服务器的连接重新可用时,中间件开始重建连接,并将重建好的连接交给应用使用。

中间件处理中断连接的整个过程对于应用而言是透明的,应用不需要考虑通信可靠性的问题。同时中间件的实现非常轻量级,对应用正常通信的性能影响很小。

关键词:SOCKET,中间件,TCP,断点续传, 网络

Development of TCP/IP Communication Middleware’s Client Side in Changing IP Address

04011226 Mengyuan Yang

Advisor Guohua Chen

Abstract

The study designes a set of interface which is very similar to the native SOCKET interface, and it add a resuming broken transfer function in the original basis.

In the middleware, a connection structure is built for each connection, for that we can save the connection’s information. In the case of normal communication, we try to communicate just like the native SOCKET. Once the communication is interrupted, the middleware begins to take over SOCKET's error message. At the same time, it will check the connection status of communication through the middleware’s heartbeat packet mechanism. When a client find itself is able to connect to the server, the middleware starts rebuilding the connection and will give the reconstructed connection to the application.

The whole process of middleware processing interrupt connection is transparent for application, so the application is not required to consider the reliability of communication.. At the same time, the implementation of the middleware is very lightweight, and it has little effect on the performance of normal communication.

Keyword:SOCKET, Middleware,TCP,Resuming Boken Tansfer, Network

目 录

摘要 ……………………………………………………………………………………1

Abstract …………………………………………………………………………… 3

  1. 绪论 ………………………………………………………………………1

1.1 引言 …………………………………………………………………1

1.2现有的变化IP场景下通信方案 ……………………………………………1

1.3 本文的研究目的和主要研究内容 ………………………………………3

  1. TCP与SOCKET简述…………………………………………………………5

2.1 TCP简述 …………………………………………………………………5

2.1.1 TCP定义 ………………………………………………………………5

2.1.2 TCP重传 ………………………………………………………………7

2.1.3 异常关闭 ……………………………………………………………7

2.2 SOCKET简述 ………………………………………………………………8

2.2.1 SOCKET主要接口 ……………………………………………………8

2.2.2 SOCKET接口作用 ……………………………………………………9

2.2.3 SOCKET接口与TCP协议 ……………………………………………9

  1. 方案设计与实现 ……………………………………………………………13

3.1 内置数据结构设计 …………………………………………………………13

3.2 通信协议设计 …………………………………………………………15

3.2.1 连接建立过程 ………………………………………………………16

3.2.2 数据传输阶段 ………………………………………………………16

3.2.3 重建连接阶段 ………………………………………………………16

3.2.4 连接关闭阶段 ………………………………………………………16

3.2.5 心跳包协议 …………………………………………………………17

3.3 方案设计 ……………………………………………………………………17

3.3.1 心跳机制 ………………………………………………………………17

3.3.2 初始化过程 ……………………………………………………………19

3.3.3 连接建立过程 …………………………………………………………21

3.3.4 重连过程 ………………………………………………………………21

3.3.5 发送数据过程 …………………………………………………………23

3.3.6 接收数据过程 …………………………………………………………24

3.3.7 关闭过程 ………………………………………………………………25

3.3.8 计数机制 ………………………………………………………………26

  1. 测试 …………………………………………………………………………27

4.1 测试场景介绍 ……………………………………………………………27

4.2 测试内容 …………………………………………………………………27

4.2.1 功能测试 ……………………………………………………………27

4.2.2 性能测试 ……………………………………………………………30

结论 …………………………………………………………………………………31

致谢 …………………………………………………………………………………31

参考文献(References) ……………………………………………………………33

绪 论

    1. 引言

TCP/IP 自设计完成以来,已经成为互联网的根基,在几乎所有系统内都得到了广泛且完善的支持。在大多数情况下,IP地址作为主机的标识,已经能够很好的完成大多数工作。

剩余内容已隐藏,请支付后下载全文,论文总字数:25284字

您需要先支付 80元 才能查看全部内容!立即支付

该课题毕业论文、开题报告、外文翻译、程序设计、图纸设计等资料可联系客服协助查找;