WO2012163262A1 - 一种转发数据的方法及网关 - Google Patents

一种转发数据的方法及网关 Download PDF

Info

Publication number
WO2012163262A1
WO2012163262A1 PCT/CN2012/076155 CN2012076155W WO2012163262A1 WO 2012163262 A1 WO2012163262 A1 WO 2012163262A1 CN 2012076155 W CN2012076155 W CN 2012076155W WO 2012163262 A1 WO2012163262 A1 WO 2012163262A1
Authority
WO
WIPO (PCT)
Prior art keywords
tcp
data packet
forwarding
application layer
protocol
Prior art date
Application number
PCT/CN2012/076155
Other languages
English (en)
French (fr)
Inventor
周波
甘化新
胡军伟
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2012163262A1 publication Critical patent/WO2012163262A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W88/00Devices specially adapted for wireless communication networks, e.g. terminals, base stations or access point devices
    • H04W88/16Gateway arrangements

Definitions

  • the present invention relates to the field of communications technologies, and in particular, to a method and a gateway for forwarding data.
  • the gateway device when the client connects to the Internet, in order to control or charge the access of the client, or even perform page adaptation or advertisement insertion, the gateway device can usually be used.
  • a gateway used to provide network-compatible functions such as protocol conversion, routing, and data exchange when interworking between networks using different architectures or protocols.
  • the gateway can be divided into an explicit gateway or a transparent proxy gateway.
  • the gateway has its own listening address.
  • the client needs to configure the gateway address to access the Internet normally.
  • the process of forwarding data by the gateway may be as follows: The terminal directly accesses the gateway and sends the request to the gateway. After the gateway parses the processing, the request is forwarded to the real server, and the server first returns the response to the client to the gateway. After the gateway processes the response, it forwards it to the terminal.
  • the embodiment of the invention provides a method and a gateway for forwarding data, so as to solve the problem that the data forwarding process in the prior art is cumbersome and the efficiency of forwarding data by the gateway is low.
  • an embodiment of the present invention provides a method for forwarding data, where the method includes: Receiving a data packet on the TCP connection between the client and the server, and determining, according to the protocol of the data packet, whether the data packet needs to be forwarded at the application layer, and if yes, forwarding the datagram at the application layer If no, the data packet is forwarded at the network layer.
  • the embodiment of the invention provides a gateway, and the gateway includes:
  • a receiving module configured to receive a data packet on a TCP connection between the client and the server; and a determining module, configured to determine, according to the protocol of the data packet, whether the data packet needs to be forwarded at an application layer;
  • the forwarding module is configured to forward the data packet at the application layer when the result of the determining module is YES, or forward the data packet at the network layer when the result of the determining module is no.
  • the gateway can determine whether the data packet needs to be forwarded by the application layer, and directly forwards the network layer when not needed, and then performs the application layer forwarding when needed. Therefore, the request for forwarding the data packet is determined.
  • the gateway can identify the subsequent processing of the data packets of different protocols, and because the gateway of the embodiment of the present invention has the function of identifying the data packets, the gateway address is not required to be configured on the terminal side.
  • the process of data forwarding is relatively simple, so the forwarding efficiency of network data can also be improved.
  • FIG. 1 is a flowchart of Embodiment 1 of a method for forwarding data according to the present invention
  • step 102 is a flow chart of step 102 in the first embodiment of the method
  • Embodiment 3 is a flowchart of Embodiment 2 of a method for forwarding data according to the present invention
  • Embodiment 4 is a flowchart of Embodiment 3 of a method for forwarding data according to the present invention.
  • FIG. 5 is a schematic structural diagram of a gateway embodiment of the present invention.
  • FIG. 6 is a schematic structural diagram of a judging module in a gateway embodiment of the present invention.
  • Figure ⁇ is a schematic structural diagram of a forwarding module in the gateway embodiment of the present invention.
  • Open System Interconnec is a seven-layer abstract reference model for communication protocols in which each layer performs a specific task. The purpose of this model is to allow various hardware to communicate with each other at the same level.
  • the seven layers are: physical layer, data link layer, network layer, transport layer, session layer, presentation layer, and application layer.
  • the application layer involved in the embodiment of the present invention has 7 layers at the highest layer, 3 layers at the network layer, and 4 layers at the transport layer.
  • Step 101 The gateway receives the data packet on the TCP connection between the client and the server, and determines whether the data packet needs to be forwarded at the application layer according to the protocol of the data packet. If yes, the process proceeds to step 103. If no, go to step 104.
  • the Transmission Control Protocol (TCP) between the client and the server can be pre-established.
  • the client sends a SYN message to the server through the gateway, and the server returns a SYN ACK message to the client through the gateway to establish a TCP connection.
  • the gateway is equivalent to establishing a TCP connection between the client and the server by parsing and forwarding the connection establishment request between the client and the server.
  • the gateway In the process of establishing a TCP connection, the gateway only saves the TCP options in the SYN. These options determine the characteristics of the established TCP connection.
  • the gateway receives the data packet on the established TCP connection, and determines whether the data packet needs to be forwarded at the application layer according to the protocol of the data packet.
  • the step of determining in step 102 may include the process shown in FIG. 2 in an actual application:
  • Step 201 Perform protocol identification on the data packet to obtain an application protocol of the data packet.
  • the gateway first performs protocol identification on the data packet. If the data packet applies the application layer protocol, the process proceeds to step 103 to perform application layer forwarding. For example, the gateway parses the destination address of the data packet as a specific URL, and the specific URL is set to insert an advertisement. In this case, step 202: determining whether the application protocol is an application layer protocol, and the current Whether the TCP connection content/protocol content can be implemented at the application layer.
  • the gateway When the gateway obtains the application protocol of the data packet, it determines whether the application protocol is an application layer protocol, and whether the current TCP connection content and the protocol content can be implemented at the application layer.
  • Step 102 The gateway forwards the data packet at the application layer.
  • the application layer forwards the data packet, which is the 7-layer forwarding.
  • the gateway uses the traditional OSI model to forward data on the highest-layer application layer.
  • the TCP protocol stack built in the gateway is implemented, and the next embodiment will focus on the data packet. This section describes how to implement the TCP protocol stack to forward data packets at the application layer.
  • Step 103 The gateway forwards the data packet at the network layer.
  • Network layer forwarding is also known as Layer 3 forwarding, which is to forward data on the network layer. If the data packet does not need to be forwarded by the application layer, the data packet can be directly forwarded at the network layer in this embodiment.
  • the gateway mentioned in the embodiment of the present invention can be deployed on the path of the terminal to the server, that is, the gateway is deployed as a routing device, and the data packet from the terminal to the server must pass through the gateway first.
  • the gateway can perform IP layer forwarding directly when the data packet does not need to be forwarded by the application layer, and the application layer forwarding is performed when the data packet needs to be forwarded by the application layer, because The performance of the application layer forwarding data packet is higher than that of the data packet when the data packet is forwarded at the IP layer or the application layer is forwarded. Therefore, the switching between the application layer forwarding and the IP layer forwarding disclosed in this embodiment may be performed.
  • the balance between the performance and the function of the gateway is implemented, and the gateway address is not required to be configured on the client. Therefore, the embodiment of the present invention can improve the forwarding efficiency of the network data.
  • the gateway can improve the performance and flexibility of the gateway by forwarding the data packets between the IP layer and the application layer while the service is being processed normally.
  • the method provided in Embodiment 2 of the present invention may include the following steps:
  • Step 301 The gateway receives the data packet on the TCP connection between the client and the server, and determines that the data packet needs to be forwarded at the application layer according to the protocol of the data packet.
  • Step 302 Start a TCP protocol stack and two TCP state machines corresponding to the TCP connection.
  • the TCP protocol stack is first started.
  • the TCP protocol stack is built in the gateway, and can take over the connection when the application layer needs to be forwarded, that is, the interaction process between the server and the client data packet is simulated.
  • application layer forwarding all data packets are received by the application layer for processing.
  • the gateway behind the built-in TCP protocol stack works in proxy mode and can process data packets sent by the client to the server.
  • the TCP protocol stack in this embodiment can be understood as an enhanced TCP protocol stack.
  • the normal TCP protocol stack has only one TCP state machine for one TCP connection
  • the enhanced TCP protocol stack has two TCP state machines for each TCP connection.
  • the two TCP state machines correspond to the client and the server respectively.
  • each pair of client and server has a pair of TCP state machines corresponding to it, if the client and server are larger than one pair, the number of corresponding TCP state machines should also be adjusted accordingly.
  • any switching between Layer 7 forwarding and Layer 3 or Layer 4 forwarding can be implemented by setting two TCP state machines corresponding to the client and the server. In the specific implementation, only the client and the server are separately converted. Two TCP state machines are fine.
  • the TCP state machine can be used to indicate the status of the current TCP connection, for example, when the status is
  • the "CLOSED" indicates that the current TCP connection is in the "off state, no connection is active or in progress"
  • the TCP state machine in the embodiment of the present invention can be represented by a finite state machine having 11 states. For details, refer to Table 1 for the description of the above 11 states. status description
  • TIMED WAIT completes two-way shutdown, waiting for all packets to die
  • Step 303 The data packet is forwarded by the TCP protocol stack at the application layer.
  • the TCP protocol stack forwards the data packets at the application layer.
  • the specific processing may include TCP reassembly, packetization, and retransmission.
  • Step 304 When the data packet forwarding of the TCP connection is completed, when the TCP protocol stack is completed for the task that should be corresponding to the application layer forwarding, the application layer notifies the TCP protocol stack that the service access ends, and the TCP protocol stack will be On the TCP state machine that abandons the connected transmission after the data remaining in the buffer is sent, the switching of the application layer forwarding to the IP layer forwarding can be realized by the switching of the TCP state machine.
  • the built-in TCP protocol stack of the gateway can take over and abandon the TCP connection at any time, and can support switching between Layer 3 forwarding and Layer 7 forwarding through the setting of the TCP state machine.
  • the method provided in Embodiment 3 of the present invention may include the following steps:
  • Step 401 Receive a data packet on the TCP connection between the client and the server, and determine, according to the protocol of the data packet, that the data packet does not need to be forwarded at the application layer.
  • Step 402 Forward the data packet at the network IP layer.
  • Step 403 If the TCP sequence number in the data packet is modified, the TCP will be modified.
  • the serial number data packet is forwarded at the transport layer.
  • the transport layer forwarding is layer 4 forwarding.
  • the data part of the data packet is not modified when the layer 4 is forwarded.
  • the gateway will modify the TCP sequence number part of the data packet. Forward it out.
  • the gateway in the embodiment of the present invention has a built-in TCP protocol stack, and correspondingly one TCP connection correspondingly sets two TCP state machines respectively corresponding to the client and the server, so that the gateway in the embodiment of the present invention
  • the switch between Layer 3 forwarding, Layer 4 forwarding, and Layer 7 forwarding can be implemented, that is, corresponding to the network layer, the transport layer, and the application layer in the OSI, respectively, further improving the performance and flexibility of the gateway.
  • the embodiment of the present invention further provides a schematic structural diagram of a gateway embodiment, where the gateway may specifically include:
  • the receiving module 501 is configured to receive a data message on a TCP connection between the client and the server;
  • the determining module 502 is configured to determine, according to the protocol of the data packet, whether the data packet needs to be forwarded at an application layer;
  • the determining module 503 includes:
  • the identification sub-module 601 is configured to perform protocol identification on the data packet to obtain an application protocol of the data.
  • the determining sub-module 602 is configured to determine whether the application protocol is an application layer protocol, and whether the current TCP connection content/protocol content can be implemented at the application layer.
  • the forwarding module 503 is configured to forward the data packet at the application layer when the result of the determining module 503 is YES, or forward the data packet at the network layer when the result of the determining module 503 is NO Text.
  • the gateway disclosed in this embodiment can perform the IP layer forwarding directly when the data packet does not need to be forwarded by the application layer, and the high-performance application layer forwarding is performed when the data packet needs to be forwarded by the application layer.
  • the switching between the IP layer forwarding and the application layer forwarding is implemented to implement the balance between the performance and the function of the gateway.
  • the embodiment of the present invention can also improve the forwarding efficiency of the network data because the gateway address is not required to be configured on the client.
  • the gateway can improve the performance and flexibility of the gateway by switching between data packets forwarding between the IP layer and the application layer while processing the service normally.
  • the forwarding module 504 may specifically include:
  • the triggering sub-module 701 is configured to start a TCP protocol stack and two TCP state machines corresponding to the TCP connection, where one TCP connection corresponds to two TCP state machines;
  • the TCP protocol stack 702 is configured to forward the data packet at the application layer.
  • the TCP state machine is forwarded by the IP layer.
  • the forwarding module 504 may be further configured to: if the TCP sequence number in the data packet is modified, forward the data packet with the modified TCP sequence number in the transport layer. .
  • the program can be stored in a computer readable storage medium.
  • the storage medium can include: ROM, RAM, disk or CD, etc.

Abstract

一种转发数据的方法及网关,所述方法包括:建立客户端与服务器之间的传输控制协议TCP连接;在建立的TCP连接上接收数据报文,并依据所述数据报文的协议判断所述数据报文是否需要在应用层转发,如果是,则在应用层转发所述数据报文,如果否,则在网络层转发所述数据报文。应用本发明实施例的方法及网关,可以提升网关的性能和灵活性,且提升网关转发数据的效率。

Description

一种转发数据的方法及网关
本申请要求于 2011 年 06 月 03 日提交中国专利局、 申请号为 201110149527.7、 发明名称为"一种转发数据的方法及网关 "的中国专利申请 的优先权, 其全部内容通过引用结合在本申请中。
技术领域
本发明涉及通信技术领域, 尤其涉及一种转发数据的方法及网关,
背景技术
在通信系统中, 客户端连接互联网时, 为了实现对客户端的访问进行 控制或计费, 甚至于进行页面适配或者广告插入等动作, 通常可以使用网关 设备来完成。 网关在采用不同体系结构或协议的网络之间进行互通时, 用于 提供协议转换、 路由选择、 数据交换等网络兼容功能的设施。
网关可以分为显式网关或者透明代理网关方式。 以显式网关为例, 网 关拥有自己的监听地址, 客户端需要配置网关地址才能正常访问互联网。 在 现有技术中, 网关转发数据的流程可以如下所示: 终端直接访问网关并将请 求发送给网关, 网关解析处理后将请求转发给真正的服务器, 服务器将对客 户端的响应首先返回给网关, 网关处理完响应后再转发给终端。
可以看出在现有技术中, 终端与服务器之间的数据交互是由网关进行 转发的, 因此需要在终端上配置网关地址, 甚至还需要根据不同的协议配置 不同的网关地址, 这就使现有技术中的数据转发过程较为繁瑣, 网关转发数 据的效率较低。
发明内容
本发明实施例提供一种转发数据的方法及网关, 以解决现有技术中数据 转发过程较为繁瑣使网关转发数据的效率较低的问题。
为解决上述技术问题, 本发明实施例提供了一种转发数据的方法, 该方 法包括: 在客户端与服务器之间的 TCP连接上接收数据报文, 并依据所述数据 报文的协议判断所述数据报文是否需要在应用层转发, 如果是, 则在应用层 转发所述数据报文, 如果否, 则在网络层转发所述数据报文。
本发明实施例提供了一种网关, 该网关包括:
接收模块, 用于在客户端与服务器之间的 TCP连接上接收数据报文; 判断模块, 用于依据所述数据报文的协议判断所述数据报文是否需要在 应用层转发;
转发模块, 用于当所述判断模块的结果为是时, 在应用层转发所述数据 报文, 或者, 当所述判断模块的结果为否时, 在网络层转发所述数据报文。
本发明实施例具有以下优点:
在本发明实施例中, 网关可以判断数据报文是否需要进行应用层转发, 在不需要时直接进行网络层转发, 在需要时才进行应用层转发, 因此通过对 数据报文的转发需求的判断, 可以由网关来识别出不同协议的数据报文应该 做什么样的后续处理, 并且因为本发明实施例的网关具有了识别数据报文的 功能, 所以就不需要在终端侧来配置网关地址, 使得数据转发的过程相对筒 单, 因此也可以提高网络数据的转发效率。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案, 下面将对实 施例或现有技术描述中所需要使用的附图作筒单地介绍, 显而易见地, 下面 描述中的附图仅仅是本发明的一些实施例, 对于本领域普通技术人员来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的附图。 图 1是本发明的转发数据的方法实施例一的流程图;
图 2是方法实施例一中步骤 102的流程图;
图 3是本发明的转发数据的方法实施例二的流程图;
图 4是本发明的转发数据的方法实施例三的流程图;
图 5是本发明的网关实施例的结构示意图;
图 6是本发明的网关实施例中判断模块的结构示意图; 图 Ί是本发明的网关实施例中转发模块的结构示意图。
具体实施方式
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行 清楚、 完整地描述, 显然, 所描述的实施例仅仅是本发明一部分实施例, 而 不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有做 出创造性劳动前提下所获得的所有其他实施例, 都属于本发明保护的范围。
开放式系统互连( OSI, Open System Interconnec ), 是一种通信协议的 7 层抽象的参考模型, 其中每一层执行某一特定任务。 该模型的目的是使各种 硬件在相同的层次上相互通信。 这 7层分别是: 物理层、 数据链路层、 网络 层、 传输层、 会话层、 表示层和应用层。 其中, 本发明实施例中涉及的应用 层为最高层 7层, 网络层为 3层, 传输层为 4层。 为使本发明实施例的上述目的、 特征和优点能够更加明显易懂, 下面结 合附图和具体实施方式对本发明实施例作进一步详细的说明。 参考图 1 , 在本发明实施例一中, 实现本发明实施例一所提供的方法可 以包括以下步骤:
步骤 101 : 网关在客户端与服务器之间的 TCP连接上接收数据报文, 并 依据所述数据报文的协议判断所述数据报文是否需要在应用层转发, 如果 是, 则进入步骤 103, 如果否, 则进入步骤 104。
在实际应用中,客户端与服务器之间的传输控制协议( TCP, Transmission Control Protocol )可以预先建立。 客户端通过网关向服务器发送 SYN信息, 服务器再通过网关向客户端返回 SYN ACK信息以建立 TCP连接。而网关相当 于通过解析并转发客户端和服务器之间的连接建立请求,使客户端和服务器 正常建立了 TCP连接。 在建立 TCP连接的过程中, 网关仅保存 SYN中的 TCP 选项, 这些选项决定了建立的 TCP连接的特性。 网关再在建立的 TCP连接上 接收数据报文, 并依据数据报文的协议判断该数据报文是否需要在应用层转 发。 请参考图 2所示, 在步骤 102中进行判断的步骤, 在实际应用中, 可以包 括图 2所示的流程:
步骤 201: 对所述数据报文进行协议识别, 以得到所述数据报文的应用 协议;
网关首先对数据报文进行协议识别, 如果数据报文应用了应用层协议, 则将进入步骤 103执行应用层转发。 例如, 网关解析出数据报文的目标地址 为一个特定的网址, 而这个特定的网址又设置了需要插入广告, 这种情况就 步骤 202: 判断所述应用协议是否为应用层协议, 以及当前的 TCP连接 内容 /协议内容是否能够在应用层实现。
网关得到数据报文的应用协议时, 就判断这个应用协议是否为应用层协 议, 并且当前的 TCP连接内容以及协议内容是否能够在应用层实现。
步骤 102: 网关在应用层转发所述数据报文。
应用层转发数据报文即是 7层转发,就是网关使用传统的 OSI模型在最高 层应用层上转发数据, 在本发明实施例中由网关内置的 TCP协议栈实现, 在 下一个实施例中将重点介绍 TCP协议栈实现在应用层转发数据报文的过程。
步骤 103: 网关在网络层转发所述数据报文。
网络层转发也被称为 3层转发, 即是在网络层上转发数据。 如果数据报 文不需要进行应用层转发, 本实施例中可以在网络层直接转发所述数据报 文。
本发明实施例中提及的网关可以部署在终端到服务器的路径上, 即是将 网关作为一个路由设备部署, 从终端到服务器的数据报文就必定先通过网 关。
在本实施例中, 网关可以在数据报文不需要进行应用层转发的时候, 直 接进行 IP层转发, 且在数据报文需要进行应用层转发的时候才进行高性能消 耗的应用层转发, 因为在应用层转发数据报文时消耗的性能要高于数据报文 在 IP层转发或在应用层转发时消耗的性能, 所以本实施例公开的在应用层转 发和 IP层转发之间的切换可以实现网关性能和功能的平衡, 并且因为不需在 客户端配置网关地址, 因此本发明实施例还可以提高网络数据的转发效率。 同时, 网关在正常处理业务的同时, 通过 IP层和应用层之间数据报文的转发 切换, 能够提高网关性能和灵活性。 参考图 3 , 在本发明实施例二中, 实现本发明实施例二所提供的方法可 以包括以下步骤:
步骤 301 : 网关在客户端与服务器之间的 TCP连接上接收数据报文, 并 依据所述数据报文的协议判断得到所述数据报文需要在应用层转发。
步骤 302: 启动 TCP协议栈以及对应所述 TCP连接的两个 TCP状态机。 在本实施例中, 网关判断得到数据报文需要执行应用层转发时, 首先会 启动 TCP协议栈。 所述 TCP协议栈内置在所述网关中, 可以在需要进行应用 层转发时接管连接, 即是模拟服务器端和客户端数据报文的交互过程。 在执 行应用层转发时, 所有的数据报文都会被接收到应用层进行处理。 内置 TCP 协议栈之后的网关工作在代理模式下, 可以处理由客户端发往服务器的数据 报文。
本实施例中的 TCP协议栈可以理解为增强 TCP协议栈, 普通的 TCP协议 栈针对一条 TCP连接只有一个 TCP状态机, 而增强的 TCP协议栈针对每个 TCP连接却有两个 TCP状态机, 该两个 TCP状态机分别对应客户端和服务器。 当然, 因为每一对客户端和服务器都有一对 TCP状态机与之对应, 所以如果 客户端和服务器大于一对, 那么相应的 TCP状态机的个数也应该相应调整。 因为在应用层转发时, 分别对应于客户端和服务器的两个 TCP状态机是不同 步的, 而在 3层或者 4层转发时却需要客户端和服务器的 TCP状态机是同步 的, 所以本发明实施例通过对应于客户端和服务器设置两个 TCP状态机就能 够实现在 7层转发和 3层或者 4层转发之间的任意切换, 具体实施时只需要分 别转换对应于客户端和服务器的两个 TCP状态机即可。
所述 TCP状态机可以用来表示当前 TCP连接的状态, 例如, 当状态为
"CLOSED" 时表示当前的 TCP连接处于 "关闭状态, 没有连接活动或正在 进行",本发明实施例中的 TCP状态机可以使用一个具有 11 种状态的有限状 态机(Finite State Machine )来表示, 具体可以参考表 1 , 为上述 11种状态的 说明。 状 态 描 述
CLOSED 关闭状态, 没有连接活动或正在进行
LISTEN 监听状态, 服务器正在等待连接进入
SYN RCVD 收到一个连接请求, 尚未确认
SYN SENT 已经发出连接请求, 等待确认
ESTABLISHED 连接建立, 正常数据传输状态
FIN WAIT 1 (主动关闭) 已经发送关闭请求, 等待确认
FIN WAIT 2 (主动关闭) 收到对方关闭确认, 等待对方关闭请求
TIMED WAIT 完成双向关闭, 等待所有分组死掉
CLOSING 双方同时尝试关闭, 等待对方确认
CLOSE WAIT (被动关闭) 收到对方关闭请求, 已经确认
LAST ACK (被动关闭) 等待最后一个关闭确认,
并等待所有分组死掉
步骤 303: 由 TCP协议栈将所述数据报文在应用层进行转发。
网关启动 TCP协议栈之后, 就由 TCP协议栈对数据报文在应用层进行转 发, 具体处理可以包括 TCP重组、 分包以及重传等。
步骤 304: 当所述 TCP连接的数据报文转发完成时, TCP协议栈从用于应 当对应于应用层转发的任务完成时, 由应用层通知 TCP协议栈本次业务 访问结束, TCP协议栈将残留在緩存中的数据发送完成之后就放弃连接的接 发的 TCP状态机上, 通过 TCP状态机的切换可以实现应用层转发到 IP层转发 的切换。
在本实施例中, 网关内置的 TCP协议栈能够实现随时接管和放弃 TCP连 接, 并且通过 TCP状态机的设置能够支持在 3层转发和 7层转发之间的切换。 参考图 4, 在本发明实施例三中, 实现本发明实施例三所提供的方法可 以包括以下步骤:
步骤 401: 在客户端与服务器之间的 TCP连接上接收数据报文, 并依据 所述数据报文的协议判断得到所述数据报文不需要在应用层转发。
步骤 402: 在网络 IP层转发所述数据报文。
步骤 403: 如果所述数据报文中的 TCP序号进行了修改, 则将修改了 TCP 序号的数据报文在传输层进行转发。
在本实施例中,当所述数据报文在 IP层转发之后,如果数据报文中的 TCP 序号发生了变化, 则需要将修改了 TCP序号的数据报文在传输层进行转发。 传输层转发即是 4层转发, 在 4层转发时不修改数据报文中的数据部分, 但是 为了使客户端和服务端的 TCP序号对应上, 网关会修改数据报文中的 TCP序 号部分之后再转发出去。
通过本发明实施例中的描述可知, 本发明实施例中的网关内置了 TCP协 议栈, 且对应一个 TCP连接对应设置两个 TCP状态机分别对应客户端和服务 器, 从而本发明实施例中的网关能够实现在 3层转发、 4层转发以及 7层转发 之间的切换, 即是分别对应 OSI中的网络层、 传输层和应用层, 进一步提升 了网关的性能和灵活性。
需要说明的是, 对于前述的各方法实施例, 为了筒单描述, 故将其都表 述为一系列的动作组合, 但是本领域技术人员应该知悉, 本发明并不受所描 述的动作顺序的限制, 因为依据本发明, 某些步骤可以采用其他顺序或者同 时进行。 其次, 本领域技术人员也应该知悉, 说明书中所描述的实施例均属 于优选实施例, 所涉及的动作和模块并不一定是本发明所必须的。 与上述本发明实施例所提供的方法相对应, 参见图 5 , 本发明实施例还 提供了一种网关实施例的结构示意图, 所述网关具体可以包括:
接收模块 501 , 用于在立客户端与服务器之间的 TCP连接上接收数据报 文;
判断模块 502, 用于依据所述数据报文的协议判断所述数据报文是否需 要在应用层转发;
参考图 6所示, 示出了判断模块 503的结构示意图, 如图所示, 所述判断 模块 503包括:
识别子模块 601 , 用于对所述数据报文进行协议识别, 以得到所述数据 4艮文的应用协议;
判断子模块 602, 用于判断所述应用协议是否为应用层协议, 以及当前 的 TCP连接内容 /协议内容是否能够在应用层实现。 转发模块 503, 用于当所述判断模块 503的结果为是时, 在应用层转发所 述数据报文, 或者, 当所述判断模块 503的结果为否时, 在网络层转发所述 数据报文。
本实施例公开的网关可以在数据报文不需要进行应用层转发的时候, 直 接进行 IP层转发, 且在数据报文需要进行应用层转发的时候才进行较高性能 的应用层转发, 通过数据报文在 IP层转发和应用层转发之间的切换, 以实现 网关性能和功能的平衡, 并且因为不需在客户端配置网关地址, 因此本发明 实施例还可以提高网络数据的转发效率。同时,网关在正常处理业务的同时, 通过 IP层和应用层的数据报文转发之间的切换, 能够提高网关性能和灵活 性。
在实际应用中的不同实施例中, 参考图 7所示, 所述转发模块 504具体可 以包括:
触发子模块 701 , 用于启动 TCP协议栈以及对应所述 TCP连接的两个 TCP 状态机, 所述 TCP协议栈中一个 TCP连接对应两个 TCP状态机;
TCP协议栈 702, 用于将所述数据报文在应用层进行转发。
在实际应用中的不同实施例中, 当所述 TCP连接的数据报文转发完成 于 IP层转发的 TCP状态机上。
在实际应用中的不同实施例中, 所述转发模块 504具体还可以用于: 如果所述数据报文中的 TCP序号进行了修改, 则将修改了 TCP序号的数 据报文在传输层进行转发。
需要说明的是, 本说明书中的各个实施例均采用递进的方式描述, 每个 实施例重点说明的都是与其他实施例的不同之处, 各个实施例之间相同相似 的部分互相参见即可。 对于网关类实施例而言, 由于其与方法实施例基本相 似, 所以描述的比较筒单, 相关之处参见方法实施例的部分说明即可。
还需要说明的是, 在本文中, 术语 "包括"、 "包含" 或者其任何其他变 体意在涵盖非排他性的包含, 从而使得包括一系列要素的过程、 方法、 物品 或者设备不仅包括那些要素, 而且还包括没有明确列出的其他要素, 或者是 还包括为这种过程、 方法、 物品或者设备所固有的要素。 在没有更多限制的 情况下, 由语句 "包括一个 ... ... " 限定的要素, 并不排除在包括所述要素的 过程、 方法、 物品或者设备中还存在另外的相同要素。
本领域普通技术人员可以理解上述实施例的各种方法中的全部或部分 步骤是可以通过程序来指令相关的硬件来完成, 该程序可以存储于一计算机 可读存储介质中, 存储介质可以包括: ROM、 RAM, 磁盘或光盘等。
以上对本发明实施例所提供的一种转发数据的方法及网关进行了详细 实施例的说明只是用于帮助理解本发明实施例的方法及其思想; 同时, 对于 本领域的一般技术人员, 依据本发明实施例的思想, 在具体实施方式及应用 范围上均会有改变之处, 综上所述, 本说明书内容不应理解为对本发明的限 制。

Claims

权 利 要 求
1、 一种转发数据的方法, 其特征在于, 该方法包括:
在客户端与服务器之间的 TCP连接上接收数据报文, 并依据所述数据 报文的协议判断所述数据报文是否需要在应用层转发, 如果是, 则在应用层 转发所述数据报文, 如果否, 则在网络层转发所述数据报文。
2、 根据权利要求 1所述的方法, 其特征在于, 所述依据所述数据报文 的协议判断是否数据报文是否需要在应用层转发, 包括:
对所述数据报文进行协议识别, 以得到所述数据报文的应用协议; 判断所述应用协议是否为应用层协议, 以及当前的 TCP连接内容和 /或 协议内容是否能够在应用层实现。
3、 根据权利要求 1所述的方法, 其特征在于, 一个 TCP连接对应两个 TCP状态机, 则所述在应用层转发数据报文, 包括:
启动 TCP协议栈以及对应所述 TCP连接的两个 TCP状态机,所述 TCP 协议栈中一个 TCP连接对应两个 TCP状态机;
由所述 TCP协议栈将所述数据报文在应用层进行转发。
4、 根据权利要求 3所述的方法, 其特征在于, 所述由 TCP协议栈将所 述数据报文在应用层进行转发之后, 还包括:
当所述 TCP连接的数据报文转发完成时, TCP协议栈从用于应用层转 发的两个 TCP状态机切换至用于网络层转发的 TCP状态机上。
5、 根据权利要求 1所述的方法, 其特征在于, 所述在网络层转发所述 数据报文之后, 还包括:
如果所述数据报文中的 TCP序号进行了修改, 则将修改了 TCP序号的 数据报文在传输层进行转发。
6、 一种网关, 其特征在于, 包括:
接收模块, 用于在客户端与服务器之间的 TCP连接上接收数据报文; 判断模块, 用于依据所述数据报文的协议判断所述数据报文是否需要在 应用层转发;
转发模块, 用于当所述判断模块的结果为是时, 在应用层转发所述数据 报文, 或者, 当所述判断模块的结果为否时, 在网络层转发所述数据报文。
7、 根据权利要求 6所述的网关, 其特征在于, 所述判断模块包括: 识别子模块, 用于对所述数据报文进行协议识别, 以得到所述数据报文 的应用切、议;
判断子模块, 用于判断所述应用协议是否为应用层协议, 以及当前的 TCP连接内容 /协议内容是否能够在应用层实现。
8、 根据权利要求 7所述的网关, 其特征在于, 所述转发模块包括: 触发子模块, 用于启动 TCP协议栈以及对应所述 TCP连接的两个 TCP 状态机, 所述 TCP协议栈中一个 TCP连接对应两个 TCP状态机;
TCP协议栈, 用于将所述数据报文在应用层进行转发。
9、 根据权利要求 8所述的网关, 其特征在于, 当所述 TCP连接的数据 报文转发完成时, 所述 TCP协议栈还用于从用于应用层转发的两个 TCP状 态机切换至用于网络层转发的 TCP状态机上。
10、 根据权利要求 6所述的网关, 其特征在于, 所述转发模块还用于: 如果所述数据报文中的 TCP序号进行了修改, 则将修改了 TCP序号的 数据报文在传输层进行转发。
PCT/CN2012/076155 2011-06-03 2012-05-28 一种转发数据的方法及网关 WO2012163262A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201110149527.7 2011-06-03
CN2011101495277A CN102215231A (zh) 2011-06-03 2011-06-03 一种转发数据的方法及网关

Publications (1)

Publication Number Publication Date
WO2012163262A1 true WO2012163262A1 (zh) 2012-12-06

Family

ID=44746361

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2012/076155 WO2012163262A1 (zh) 2011-06-03 2012-05-28 一种转发数据的方法及网关

Country Status (2)

Country Link
CN (1) CN102215231A (zh)
WO (1) WO2012163262A1 (zh)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102215231A (zh) * 2011-06-03 2011-10-12 华为软件技术有限公司 一种转发数据的方法及网关
CN103561007B (zh) * 2013-10-25 2016-10-05 华为技术有限公司 一种报文转发的方法及装置
CN106936707A (zh) * 2015-12-29 2017-07-07 北界创想(北京)软件有限公司 路由方法及装置
CN109547519B (zh) * 2017-09-22 2022-11-01 中兴通讯股份有限公司 反向代理方法、装置及计算机可读存储介质
CN108924200B (zh) * 2018-06-21 2021-11-23 国家电网有限公司 一种报文处理方法及装置
CN109714135B (zh) * 2018-12-24 2021-10-15 北京威努特技术有限公司 一种数据包传输方法及装置

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5941988A (en) * 1997-01-27 1999-08-24 International Business Machines Corporation Session and transport layer proxies via TCP glue
CN1400535A (zh) * 2001-07-26 2003-03-05 华为技术有限公司 一种在应用层交换中提高服务器响应速度的系统及方法
CN1512377A (zh) * 2002-12-31 2004-07-14 联想(北京)有限公司 基于内核中套接字对接的第七层负载均衡的方法
CN1538677A (zh) * 2003-04-14 2004-10-20 华为技术有限公司 实现快速五七层交换的方法
CN1649326A (zh) * 2004-12-09 2005-08-03 武汉大学 一种集群服务器的多分配器前端系统构成方法
US7325070B1 (en) * 2002-08-26 2008-01-29 Network Appliance, Inc. Sub-application layer data transfer in a network comprising a layered architecture
US7743160B2 (en) * 2007-03-29 2010-06-22 Blue Coat Systems, Inc. System and method of delaying connection acceptance to support connection request processing at layer-7
CN102215231A (zh) * 2011-06-03 2011-10-12 华为软件技术有限公司 一种转发数据的方法及网关

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US5941988A (en) * 1997-01-27 1999-08-24 International Business Machines Corporation Session and transport layer proxies via TCP glue
CN1400535A (zh) * 2001-07-26 2003-03-05 华为技术有限公司 一种在应用层交换中提高服务器响应速度的系统及方法
US7325070B1 (en) * 2002-08-26 2008-01-29 Network Appliance, Inc. Sub-application layer data transfer in a network comprising a layered architecture
CN1512377A (zh) * 2002-12-31 2004-07-14 联想(北京)有限公司 基于内核中套接字对接的第七层负载均衡的方法
CN1538677A (zh) * 2003-04-14 2004-10-20 华为技术有限公司 实现快速五七层交换的方法
CN1649326A (zh) * 2004-12-09 2005-08-03 武汉大学 一种集群服务器的多分配器前端系统构成方法
US7743160B2 (en) * 2007-03-29 2010-06-22 Blue Coat Systems, Inc. System and method of delaying connection acceptance to support connection request processing at layer-7
CN102215231A (zh) * 2011-06-03 2011-10-12 华为软件技术有限公司 一种转发数据的方法及网关

Also Published As

Publication number Publication date
CN102215231A (zh) 2011-10-12

Similar Documents

Publication Publication Date Title
EP3459217B1 (en) Transporting udp packets over an mptcp connection
WO2012163262A1 (zh) 一种转发数据的方法及网关
TW201014272A (en) A method for optimizing the data transmission path between the client terminals and the device thereof
US20180034691A1 (en) Techniques for establishing a communication connection between two network entities via different network flows
US9172554B2 (en) Method and network access device for enabling data forwarding between different physical mediums
WO2015106453A1 (zh) 处理业务的方法和网络设备
JP2010504688A (ja) ネットワーク・プロトコルスタックのハンドオフおよび最適化を実装するための方法およびモジュール
WO2021169291A1 (zh) 发布路由的方法、网元、系统及设备
WO2007019809A1 (fr) Procede et systeme d'etablissement d'un canal direct point par point
WO2014067486A1 (zh) 一种报文转发的方法及相应设备
US9819730B2 (en) System and method for network access based on application layer data
WO2013086858A1 (zh) 一种恢复用户业务的方法和装置
WO2009026824A1 (fr) Procédé, dispositif et système pour transférer des messages multiplex
WO2013185696A2 (zh) 一种数据处理的方法与设备
WO2009053878A1 (en) Methods and systems for offload processing
WO2012167659A1 (zh) 受限应用协议中数据通信的方法和装置
WO2019196853A1 (zh) Tcp加速方法及装置
WO2012062156A1 (zh) Vplsmac表项空间的配置方法和装置
JP5840211B2 (ja) オフセットを用いてインバンド制御チャネルを提供する疑似ワイヤ
CN115514828A (zh) 数据传输方法及电子设备
WO2014107905A1 (zh) 集群以及转发方法
WO2022147792A1 (zh) 一种交换系统、交换网络和交换节点
CN104980456B (zh) 传输业务的方法、中间节点、终端和服务器
WO2012088828A1 (zh) 表维护方法、系统和接入网关路由器
WO2017067267A1 (zh) 数据包重定向的方法、系统及ap

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 12792343

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 12792343

Country of ref document: EP

Kind code of ref document: A1