[go: up one dir, main page]

CN115277058A - Communication method and device - Google Patents

Communication method and device Download PDF

Info

Publication number
CN115277058A
CN115277058A CN202210650766.9A CN202210650766A CN115277058A CN 115277058 A CN115277058 A CN 115277058A CN 202210650766 A CN202210650766 A CN 202210650766A CN 115277058 A CN115277058 A CN 115277058A
Authority
CN
China
Prior art keywords
file
content
node
sequence number
request
Prior art date
Legal status (The legal status 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 status listed.)
Pending
Application number
CN202210650766.9A
Other languages
Chinese (zh)
Inventor
郭玲玲
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
New H3C Security Technologies Co Ltd
Original Assignee
New H3C Security Technologies Co Ltd
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 New H3C Security Technologies Co Ltd filed Critical New H3C Security Technologies Co Ltd
Priority to CN202210650766.9A priority Critical patent/CN115277058A/en
Publication of CN115277058A publication Critical patent/CN115277058A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/14Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic
    • H04L63/1408Network architectures or network communication protocols for network security for detecting or protecting against malicious traffic by monitoring network traffic
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/20Network architectures or network communication protocols for network security for managing network security; network security policies in general

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a communication method and a communication device, wherein the method is applied to network equipment and comprises the following steps: acquiring a first read response data packet sent to a client by a server, wherein the first read response data packet comprises first file content and a first request sequence number; acquiring a second request sequence number from a first node included in a first queue, wherein the first node is a first node of the first queue; judging whether the first request sequence number is the same as the second request sequence number; if the first file content is the same as the second file content, performing DPI service processing on the first file content; if the first response data packet is different from the second response data packet, caching the first response data packet; the first queue comprises at least one node, and the request sequence number stored in the head node of the first queue is the minimum value.

Description

通信方法及装置Communication method and device

技术领域technical field

本申请涉及通信技术领域,尤其涉及一种通信方法及装置。The present application relates to the technical field of communication, and in particular to a communication method and device.

背景技术Background technique

深度报文检测(英文:Deep Packet Inspection,简称:DPI)是一种基于应用层信息对经过网络设备的业务流量进行检测和控制的安全机制。Deep Packet Inspection (English: Deep Packet Inspection, DPI for short) is a security mechanism for detecting and controlling service traffic passing through network devices based on application layer information.

在日益复杂的网络安全威胁中,很多恶意行为(比如,蠕虫病毒、垃圾邮件、漏洞等)均是隐藏在数据报文的应用层载荷中。传统安全防护技术仅依靠网络层、传输层的安全检测技术已无法满足网络安全要求。因此,网络设备须具备DPI功能,实现对网络应用层信息的检测和控制,以保证数据内容的安全,提高网络的安全性。In increasingly complex network security threats, many malicious behaviors (for example, worms, spam, loopholes, etc.) are hidden in the application layer payload of data packets. Traditional security protection technologies relying only on network layer and transport layer security detection technologies can no longer meet network security requirements. Therefore, network equipment must have DPI function to realize the detection and control of network application layer information, so as to ensure the security of data content and improve network security.

在一种场景下,客户端预从服务端(例如,服务器信息块(英文:Server MessageBlock,简称:SMB)服务器)内读取文件。具体过程为:In one scenario, the client pre-reads the file from the server (for example, a Server Message Block (English: Server Message Block, SMB for short) server). The specific process is:

客户端先向服务端发送NT_CREATE_ANDX Request数据包以请求服务端打开文件。服务端返回NT_CREATE_ANDX Response数据包以告知客户端已打开文件。客户端向服务端发送READ_ANDX Request数据包以请求读取文件。服务端返回的READ_ANDX Response数据包以向客户端传输文件内容。传输完成后,客户端向服务端发送CLOSE Request数据包以请求关闭文件。服务端返回CLOSE Response数据包以告知客户端已关闭文件。The client first sends an NT_CREATE_ANDX Request packet to the server to request the server to open the file. The server returns an NT_CREATE_ANDX Response packet to inform the client that the file has been opened. The client sends a READ_ANDX Request packet to the server to request to read the file. The READ_ANDX Response packet returned by the server to transfer the file content to the client. After the transfer is complete, the client sends a CLOSE Request packet to the server to request to close the file. The server returns a CLOSE Response packet to inform the client that the file has been closed.

在上述过程中,客户端发送READ_ANDX Request数据包时是按照读取文件内容的顺序依次发送多个数据包。但是,服务端在返回READ_ANDX Response数据包时,未按照读取文件内容给的顺序依次响应READ_ANDX Request数据包。如此,将导致文件内容出现乱序。In the above process, when the client sends the READ_ANDX Request data packet, it sends multiple data packets sequentially in the order in which the file content is read. However, when the server returns the READ_ANDX Response packet, it does not respond to the READ_ANDX Request packets in the order in which the file content was read. Doing so will result in out-of-order file contents.

上述出现的文件内容乱序具体是指应用层内容乱序,而非IP网络层乱序和TCP传输层乱序。由于深度检测管理(英文:Deepth Inspect Manager,简称:DIM)引擎的处理是基于流的,若文件传输过程中,文件内容出现乱序,则将导致在对报文解析时出现算法层面错误、协议识别、解析失败、文件识别、解析失败、攻击特征识别漏报等情况的发生。The disorder of file content mentioned above specifically refers to the disorder of the content of the application layer, not the disorder of the IP network layer and the disorder of the TCP transport layer. Since the processing of the Deep Inspection Management (English: Deep Inspect Manager, referred to as: DIM) engine is based on streams, if the file content is out of order during the file transmission process, it will cause algorithm level errors and protocol errors when parsing the message. Identification and analysis failures, file identification and analysis failures, and false negatives in attack signature identification.

发明内容Contents of the invention

有鉴于此,本申请提供了一种通信方法及装置,用以解决现有客户端与服务器之间传输文件过程中,文件内容易出现乱序的问题。In view of this, the present application provides a communication method and device, which are used to solve the problem that files are easily out of order in the process of transferring files between the existing client and server.

第一方面,本申请提供了一种通信方法,所述方法应用于网络设备,所述方法包括:In a first aspect, the present application provides a communication method, the method is applied to a network device, and the method includes:

获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;Obtaining the first read response data packet sent by the server to the client, the first read response data packet including the first file content and the first request sequence number;

从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;Obtaining a second request sequence number from a first node included in the first queue, where the first node is the head node of the first queue;

判断所述第一请求序号是否与所述第二请求序号相同;judging whether the first request sequence number is the same as the second request sequence number;

若相同,则对所述第一文件内容进行DPI业务处理;If they are the same, perform DPI service processing on the content of the first file;

若不同,则缓存所述第一响应数据包;If different, cache the first response data packet;

其中,所述第一队列包括至少一个节点,所述第一队列包括的首节点内存储的请求序号为最小值。Wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is a minimum value.

第二方面,本申请提供了一种通信装置,所述装置应用于网络设备,所述装置包括:In a second aspect, the present application provides a communication device, the device is applied to a network device, and the device includes:

第一获取单元,用于获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;The first obtaining unit is configured to obtain a first read response data packet sent by the server to the client, the first read response data packet including the first file content and the first request sequence number;

第二获取单元,用于从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;A second obtaining unit, configured to obtain a second request sequence number from a first node included in the first queue, where the first node is the head node of the first queue;

第一判断单元,用于判断所述第一请求序号是否与所述第二请求序号相同;a first judging unit, configured to judge whether the first request serial number is the same as the second request serial number;

业务处理单元,用于若相同,则对所述第一文件内容进行DPI业务处理;A service processing unit, configured to perform DPI service processing on the first file content if they are the same;

缓存单元,用于若不同,则缓存所述第一响应数据包;a cache unit, configured to cache the first response data packet if they are different;

其中,所述第一队列包括至少一个节点,所述第一队列包括的首节点内存储的请求序号为最小值。Wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is a minimum value.

第三方面,本申请提供了一种网络设备,包括处理器和机器可读存储介质,机器可读存储介质存储有能够被处理器执行的机器可执行指令,处理器被机器可执行指令促使执行本申请第一方面所提供的方法。In a third aspect, the present application provides a network device, including a processor and a machine-readable storage medium, where the machine-readable storage medium stores machine-executable instructions that can be executed by the processor, and the processor is prompted to execute by the machine-executable instructions The method provided in the first aspect of the present application.

因此,通过应用本申请提供的通信方法及装置,网络设备获取服务端向客户端发送的第一读响应数据包,该第一读响应数据包包括第一文件内容以及第一请求序号;网络设备从第一队列包括的第一节点中获取第二请求序号,该第一节点为第一队列的首节点;网络设备判断第一请求序号是否与第二请求序号相同;若相同,则网络设备对第一文件内容进行DPI业务处理;若不同,则网络设备缓存第一响应数据包;其中,第一队列包括至少一个节点,第一队列包括的首节点内存储的请求序号为最小值。Therefore, by applying the communication method and device provided in this application, the network device obtains the first read response data packet sent from the server to the client, the first read response data packet includes the first file content and the first request sequence number; the network device Obtain the second request sequence number from the first node included in the first queue, and the first node is the head node of the first queue; the network device judges whether the first request sequence number is the same as the second request sequence number; The first file content is subjected to DPI service processing; if different, the network device caches the first response data packet; wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is the minimum value.

如此,利用客户端、服务端相互发送的请求序号,使得网络设备按请求序号对匹配的文件内容进行业务处理。解决了现有客户端与服务器之间传输文件过程中,文件内容易出现乱序的问题。保证了文件内容顺序处理,从而提升对文件检测的能力。In this way, the request sequence numbers sent by the client and the server are used to enable the network device to perform business processing on the matched file content according to the request sequence numbers. It solves the problem that the file is prone to disorder in the file transfer process between the existing client and the server. It ensures the sequential processing of file content, thereby improving the ability to detect files.

附图说明Description of drawings

图1为本申请实施例提供的通信方法的流程图;FIG. 1 is a flowchart of a communication method provided in an embodiment of the present application;

图2为本申请实施例提供的通信装置结构图;FIG. 2 is a structural diagram of a communication device provided in an embodiment of the present application;

图3为本申请实施例提供的网络设备硬件结构体。FIG. 3 is a hardware structure of a network device provided by an embodiment of the present application.

具体实施方式Detailed ways

这里将详细地对示例性实施例进行说明,其示例表示在附图中。下面的描述涉及附图时,除非另有表示,不同附图中的相同数字表示相同或相似的要素。以下示例性实施例中所描述的实施例并不代表与本申请相一致的所有实施例。相反,它们仅是与如所附权利要求书中所详述的、本申请的一些方面相一致的装置和方法的例子。Reference will now be made in detail to the exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numerals in different drawings refer to the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Rather, they are merely examples of apparatuses and methods consistent with aspects of the present application as recited in the appended claims.

在本申请使用的术语是仅仅出于描述特定实施例的目的,而非旨在限制本申请。在本申请和所附权利要求书中所使用的单数形式的“一种”、“所述”和“该”也旨在包括多数形式,除非上下文清楚地表示其他含义。还应当理解,本文中使用的术语“和/或”是指并包含一个或多个相对应的列出项目的任何或所有可能组合。The terminology used in this application is for the purpose of describing particular embodiments only, and is not intended to limit the application. As used in this application and the appended claims, the singular forms "a", "the", and "the" are intended to include the plural forms as well, unless the context clearly dictates otherwise. It should also be understood that the term "and/or" as used herein refers to and includes any and all possible combinations of one or more corresponding listed items.

应当理解,尽管在本申请可能采用术语第一、第二、第三等来描述各种信息,但这些信息不应限于这些术语。这些术语仅用来将同一类型的信息彼此区分开。例如,在不脱离本申请范围的情况下,第一信息也可以被称为第二信息,类似地,第二信息也可以被称为第一信息。取决于语境,如在此所使用的词语“如果”可以被解释成为“在……时”或“当……时”或“响应于确定”。It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, the information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, without departing from the scope of the present application, first information may also be called second information, and similarly, second information may also be called first information. Depending on the context, the word "if" as used herein may be interpreted as "at" or "when" or "in response to a determination."

下面对本申请实施例提供的通信方法进行详细地说明。参见图1,图1为本申请实施例提供的通信方法的流程图。该方法应用于网络设备,该网络设备可具体为能够处理DPI业务的防火墙设备。本申请实施例提供的通信方法可包括如下所示步骤。The communication method provided by the embodiment of the present application will be described in detail below. Referring to FIG. 1 , FIG. 1 is a flowchart of a communication method provided by an embodiment of the present application. The method is applied to a network device, and the network device may specifically be a firewall device capable of processing DPI services. The communication method provided in the embodiment of the present application may include the following steps.

步骤110、获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;Step 110, obtain the first read response data packet sent by the server to the client, the first read response data packet includes the content of the first file and the first request sequence number;

具体地,客户端、网络设备、服务端处于同一局域网内。网络设备处于客户端与服务端之间,其可捕获客户端、服务端之间交互的各类数据包。例如,读请求数据包、读响应数据包、写请求数据包、写响应数据包等等。Specifically, the client, the network device, and the server are in the same local area network. The network device is between the client and the server, and it can capture various data packets exchanged between the client and the server. For example, a read request packet, a read response packet, a write request packet, a write response packet, and so on.

服务端接收到客户端发送的第一读请求数据包(例如,READ_ANDX Request)后,根据第一读请求数据包,在对应的文件中获取第一文件内容。服务端生成第一读响应数据包(例如,READ_ANDX Response),该第一读响应数据包包括第一文件内容以及第一请求序号。After receiving the first read request data packet (for example, READ_ANDX Request) sent by the client, the server acquires the content of the first file in the corresponding file according to the first read request data packet. The server generates a first read response data packet (for example, READ_ANDX Response), and the first read response data packet includes the content of the first file and the first request sequence number.

服务端向客户端发送第一读响应数据包。The server sends the first read response packet to the client.

网络设备获取到第一读响应数据包后,从中获取第一文件内容以及第一请求序号。After obtaining the first read response data packet, the network device obtains the content of the first file and the first request sequence number therefrom.

需要说明的是,第一读请求数据包包括第一文件内容长度、第一文件内容起始位置以及第二请求序列号。服务端可根据第一文件内容长度、第一文件内容起始位置从文件中获取第一文件内容。It should be noted that the first read request data packet includes the content length of the first file, the starting position of the content of the first file, and the second request sequence number. The server can obtain the first file content from the file according to the length of the first file content and the starting position of the first file content.

通常情况下,服务端接收到读请求数据包后,将该读请求数据包包括的请求序号作为与该读请求数据包对应的读响应数据包包括的请求序号。Usually, after receiving the read request data packet, the server uses the request serial number included in the read request data packet as the request serial number included in the read response data packet corresponding to the read request data packet.

可选地,在步骤110之前,还包括网络设备获取客户端向服务端发送第一读请求数据包、以及网络设备将读请求数据包包括的内容对应存储至第一队列,即Req_Queue1的节点处。Optionally, before step 110, it also includes that the network device acquires that the client sends the first read request packet to the server, and the network device correspondingly stores the content included in the read request packet into the first queue, that is, at the node of Req_Queue1 .

以客户端预从服务端(例如,SMB服务器)内读取文件为例进行说明。Take the client pre-reading the file from the server (for example, SMB server) as an example for illustration.

局域网内通过文件共享方式访问文件时,客户端与服务端之间先进行SMB会话认证。客户端先向服务端发送创建请求(例如,NT_CREATE_ANDX Request)数据包以请求服务端打开文件。服务端返回创建响应(例如,NT_CREATE_ANDX Response)数据包以告知客户端已打开文件。When accessing files through file sharing in the LAN, SMB session authentication is first performed between the client and the server. The client first sends a create request (for example, NT_CREATE_ANDX Request) packet to the server to request the server to open the file. The server returns a create response (eg, NT_CREATE_ANDX Response) packet to inform the client that the file has been opened.

客户端向服务端发送第一读请求数据包以请求读取文件。网络设备获取到该第一读请求数据包,该第一读请求数据包包括客户端待读取的第一文件内容长度(len)、第一文件内容起始位置(也可称之为偏移量offset)以及第二请求序号(messageID)。The client sends a first read request packet to the server to request to read the file. The network device obtains the first read request data packet, and the first read request data packet includes the content length (len) of the first file to be read by the client, the starting position of the first file content (also referred to as offset amount offset) and the second request sequence number (messageID).

其中,len为当前待读取的文件内容长度。offset为当前待读取的文件内容位于整个文件的偏移位置。messageID可具体为一数字,例如,1、2、3等。客户端每发送一个读请求数据包后,将messageID加1。在本申请实施例中,请求数据包与响应数据包的messageID应是对应匹配的。Among them, len is the length of the file content currently to be read. offset is the offset position of the current file content to be read in the entire file. The messageID can be specifically a number, for example, 1, 2, 3 and so on. After the client sends a read request packet, the messageID is incremented by 1. In the embodiment of this application, the messageIDs of the request data packet and the response data packet should match correspondingly.

若offset为0,messageID为1,网络设备确定该第一读请求数据包为读取文件的首个读请求数据包,网络设备可将该messageID作为lastReqID。若len与offset的和值为file_size,即和值为当前待读取的文件总长度,网络设备确定该第一读取请求数据包为读取文件的最后一个读请求数据包。网络设备可将messageID为endOfFileID。If offset is 0 and messageID is 1, the network device determines that the first read request packet is the first read request packet for reading the file, and the network device may use the messageID as lastReqID. If the sum of len and offset is file_size, that is, the sum is the total length of the file currently to be read, the network device determines that the first read request packet is the last read request packet for reading the file. The network device can set messageID to endOfFileID.

在本申请实施例中,网络设备在本地利用Req_Queue1记录请求序号、len以及offset。Req_Queue1包括至少一个节点,每个节点用于存储请求序号,节点之间按请求序号的大小顺序进行排序,Req_Queue1中首节点内存储的请求序号为全部请求序号的最小值。当然,len、offset等内容也可存储在对应的请求序号所在节点处。In the embodiment of the present application, the network device locally uses Req_Queue1 to record the request sequence number, len and offset. Req_Queue1 includes at least one node, each node is used to store the request serial number, and the nodes are sorted according to the order of the request serial number, and the request serial number stored in the first node in Req_Queue1 is the minimum value of all request serial numbers. Certainly, content such as len and offset may also be stored at the node where the corresponding request sequence number is located.

网络设备获取第一读请求数据包后,将第二请求序号缓存至Req_Queue1包括的第一节点处(网络设备根据第二请求序号的大小缓存至对应的节点处,此处以第一节点为例进行说明)。网络设备计算第一文件内容长度与第一文件内容起始位置的和值,得到第一值,即第一值=len+offset。网络设备从本地获取SMB协议解析插件内存储的第二值。网络设备判断第二值是否与第一文件内容起始位置相同。After the network device obtains the first read request data packet, it caches the second request serial number to the first node included in Req_Queue1 (the network device caches the second request serial number to the corresponding node according to the size of the second request serial number, and the first node is used as an example here. illustrate). The network device calculates the sum of the length of the content of the first file and the starting position of the content of the first file to obtain a first value, that is, first value=len+offset. The network device acquires the second value stored in the SMB protocol parsing plug-in locally. The network device judges whether the second value is the same as the starting position of the content of the first file.

若相同,则网络设备确定当前客户端读取文件内容为顺序读取,网络设备利用第一值更新第二值;若不同,则网络设备确定当前客户端读取文件内容为乱序读取,并维持第二值不变,网络设备还将第一文件内容长度、第一文件内容起始位置缓存至第一节点处缓存至第一节点处。If they are the same, the network device determines that the current client reads the file content as sequential reading, and the network device uses the first value to update the second value; if different, the network device determines that the current client reads the file content as out-of-order reading, Keeping the second value unchanged, the network device also caches the content length of the first file and the starting position of the content of the first file from the first node to the first node.

同理,当网络设备获取到客户端向服务端发送的第二读请求数据包时,网络设备将第二读请求数据包包括的第三请求序号缓存至Req_Queue1包括的第三节点(此处以第三节点为例进行说明,也可以为第二节点)处。网络设备比较第二值是否与第二读请求数据包包括的第二文件内容起始位置相同。Similarly, when the network device obtains the second read request packet sent by the client to the server, the network device caches the third request sequence number included in the second read request packet to the third node included in Req_Queue1 (herein referred to as the first The third node is taken as an example for illustration, and it may also be the second node). The network device compares whether the second value is the same as the start position of the second file content included in the second read request data packet.

若不相同,则网络设备确定当前客户端读取文件内容为乱序读取,并维持第二值不变,网络设备将第二读请求数据包包括的第二文件内容长度、第二文件内容起始位置缓存至第三节点处;若相同,则网络设备确定当前客户端读取文件内容为顺序读取,网络设备计算第二文件内容长度与第二文件内容起始位置的和值,得到第三值,并利用第三值更新第二值。If they are not the same, the network device determines that the current client reads the content of the file as out-of-order reading, and maintains the second value unchanged, and the network device sends the second file content length, second file content, and The starting position is cached to the third node; if they are the same, the network device determines that the current client reads the file content as sequential reading, and the network device calculates the sum of the length of the second file content and the starting position of the second file content to obtain third value, and update the second value with the third value.

在本申请实施例中,网络设备本地包括一SMB协议解析插件,该SMB协议解析插件内存储的第二值具体为NextReqOffset。也即是,下一个请求数据包应携带的offset值。NextReqOffset根据请求类型的不同,对应不同的值。例如,当为读请求数据时,NextReqOffset具体为第二值;当为写请求数据包时,NextReqOffset具体为第四值(此处以第四值为例进行说明,也可以为第三值)。在后续实施例中,将具体介绍第四值。In the embodiment of the present application, the network device locally includes an SMB protocol analysis plug-in, and the second value stored in the SMB protocol analysis plug-in is specifically NextReqOffset. That is, the offset value that the next request packet should carry. NextReqOffset corresponds to different values depending on the request type. For example, when it is read request data, NextReqOffset is specifically the second value; when it is a write request data packet, NextReqOffset is specifically the fourth value (here, the fourth value is used as an example for illustration, and may also be the third value). In subsequent embodiments, the fourth value will be introduced in detail.

在一个例子中,网络设备本地SMB协议解析插件内存储的第二值为0。网络设接收第一读请求数据包,第一文件内容长度(len)为40、第一文件内容起始位置(offset)为0以及第二请求序号(messageID)为1。In an example, the second value stored in the local SMB protocol parsing plug-in of the network device is 0. The network assumes that the first read request packet is received, the length (len) of the first file content is 40, the start position (offset) of the first file content is 0, and the second request sequence number (messageID) is 1.

网络设备将第二请求序号1缓存至第一节点处,并确定第一读请求数据包为首个读请求数据包。网络设备计算第一文件内容长度与第一文件内容起始位置的和值,得到第一值为40。网络设备从SMB协议解析插件内获取第二值,并比较第二值是否与第一文件内容起始位置相同。The network device caches the second request sequence number 1 at the first node, and determines that the first read request data packet is the first read request data packet. The network device calculates the sum of the content length of the first file and the starting position of the content of the first file, and obtains a first value of 40. The network device obtains the second value from the SMB protocol parsing plug-in, and compares whether the second value is the same as the starting position of the content of the first file.

在本示例中,第二值与第一文件内容起始位置相同。网络设备确定当前客户端读取文件内容为顺序读取,网络设备利用第一值40更新第二值0,此时,第二值为40。In this example, the second value is the same as the starting position of the content of the first file. The network device determines that the current file content read by the client is sequential reading, and the network device uses the first value 40 to update the second value 0. At this time, the second value is 40.

此时,网络设备获取到客户端向服务端发送的第二读请求数据包,第二文件内容长度(len)为40、第二文件内容起始位置(offset)为120以及第三请求序号(messageID)为2。At this time, the network device obtains the second read request packet sent by the client to the server, the second file content length (len) is 40, the second file content start position (offset) is 120, and the third request sequence number ( messageID) is 2.

网络设备将第三请求序号2缓存至第三节点处。可以理解的是,第三节点与第一节点相邻并处于第一节点后。网络设备从SMB协议解析插件内获取第二值40,并比较第二值是否与第二文件内容起始位置相同。The network device caches the third request sequence number 2 to the third node. It can be understood that the third node is adjacent to and behind the first node. The network device obtains the second value 40 from the SMB protocol parsing plug-in, and compares whether the second value is the same as the starting position of the second file content.

本示例中,第二值与第二文件内容起始位置不同。网络设备确定当前客户端读取文件内容为乱序读取,网络设备将第二文件内容长度、第二文件内容起始位置缓存至第三节点处。In this example, the second value is different from the starting position of the content of the second file. The network device determines that the file content read by the current client is out-of-order reading, and the network device caches the content length of the second file and the starting position of the second file content to the third node.

在另一个例子中,此时,网络设备获取到客户端向服务端发送的第二读请求数据包,第二文件内容长度(len)为40、第二文件内容起始位置(offset)为40以及第三请求序号(messageID)为2。In another example, at this time, the network device obtains the second read request packet sent by the client to the server, the second file content length (len) is 40, and the second file content start position (offset) is 40 And the third request sequence number (messageID) is 2.

网络设备将第三请求序号2缓存至第三节点处。可以理解的是,第三节点与第一节点相邻并处于第一节点后。网络设备从SMB协议解析插件内获取第二值40,并比较第二值是否与第二文件内容起始位置相同。The network device caches the third request sequence number 2 to the third node. It can be understood that the third node is adjacent to and behind the first node. The network device obtains the second value 40 from the SMB protocol parsing plug-in, and compares whether the second value is the same as the starting position of the second file content.

本示例中,第二值与第二文件内容起始位置相同。网络设备确定当前客户端读取文件内容为顺序读取,网络设备计算第二文件内容长度与第二文件内容起始位置的和值,得到第一值为80,并利用第一值80更新第二值40,此时,第二值为80。In this example, the second value is the same as the starting position of the content of the second file. The network device determines that the current client reads the content of the file as sequential reading, the network device calculates the sum of the length of the second file content and the starting position of the second file content, obtains the first value of 80, and uses the first value 80 to update the first value The second value is 40, at this time, the second value is 80.

可以理解的是,网络设备每获取到客户端向服务端发送的读请求数据包后,首先将请求序号按照大小顺序存储至Req_Queue1的节点处。然后,网络设备比较SMB协议解析插件内的值是否与文件内容起始位置相同。It can be understood that, each time the network device obtains the read request data packet sent by the client to the server, it first stores the request sequence numbers to the nodes of Req_Queue1 in order of size. Then, the network device compares whether the value in the SMB protocol parsing plug-in is the same as the starting position of the file content.

若相同,则网络设备确定客户端读取文件内容为顺序读取。网络设备计算文件内容长度与文件内容起始位置的和值,并利用和值更新SMB协议解析插件内的值。If they are the same, the network device determines that the client reads the file content as sequential reading. The network device calculates the sum of the length of the file content and the starting position of the file content, and uses the sum to update the value in the SMB protocol parsing plug-in.

若不同,则网络设备确定客户端读取文件内容为乱序读取。网络设备维持SMB协议解析插件内的值,并将文件内容长度、文件内容起始位置缓存至请求序号所在的节点处。If they are different, the network device determines that the client reads the file content out of order. The network device maintains the value in the SMB protocol analysis plug-in, and caches the length of the file content and the starting position of the file content to the node where the request sequence number is located.

网络设备重复执行上述过程。The network device repeatedly executes the above process.

步骤120、从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;Step 120, obtaining a second request sequence number from a first node included in the first queue, the first node being the head node of the first queue;

具体地,根据步骤110的描述,网络设备获取Req_Queue1包括的首节点中缓存的第二请求序号。Specifically, according to the description of step 110, the network device acquires the second request sequence number cached in the first node included in Req_Queue1.

步骤130、判断所述第一请求序号是否与所述第二请求序号相同;Step 130, judging whether the first request sequence number is the same as the second request sequence number;

具体地,根据步骤120的描述,网络设备获取到第二请求序号后,比较第一请求序号是否与第二请求序号相同。若相同,则网络设备执行步骤140;若不同,则网络设备执行步骤150。Specifically, according to the description of step 120, after obtaining the second request serial number, the network device compares whether the first request serial number is the same as the second request serial number. If they are the same, the network device executes step 140; if they are different, the network device executes step 150.

步骤140、若相同,则对所述第一文件内容进行DPI业务处理;Step 140, if they are the same, perform DPI service processing on the first file content;

具体地,根据步骤130的描述,若第一请求序号与第二请求序号相同,则网络设备确定第一读响应数据包为与第一读请求数据包对应的响应数据包。Specifically, according to the description of step 130, if the first request sequence number is the same as the second request sequence number, the network device determines that the first read response data packet is a response data packet corresponding to the first read request data packet.

网络设备对第一文件内容进行进行DPI业务处理。The network device performs DPI service processing on the content of the first file.

可选地,网络设备对第一文件内容进行DPI业务处理后,网络设备将第一节点从Req_Queue1中删除。此时,与第一节点相邻的下一节点升级为第一队列的首节点,该节点内缓存的请求序号为全部请求序号的最小值。Optionally, after the network device performs DPI service processing on the first file content, the network device deletes the first node from Req_Queue1. At this time, the next node adjacent to the first node is promoted to be the head node of the first queue, and the request sequence number cached in this node is the minimum value of all request sequence numbers.

步骤150、若不同,则缓存所述第一响应数据包。Step 150, if different, cache the first response data packet.

具体地,根据步骤130的描述,若第一请求序号与第二请求序号不同,则网络设备确定第一读响应数据包不为与第一读请求数据包对应的响应数据包,并确定服务端并未按序返回读响应数据包。网络设备先不对第一文件内容进行进行DPI业务处理。Specifically, according to the description of step 130, if the first request sequence number is different from the second request sequence number, the network device determines that the first read response data packet is not a response data packet corresponding to the first read request data packet, and determines that the server Read response packets are not returned in order. The network device does not perform DPI service processing on the content of the first file first.

网络设备缓存第一响应数据包。The network device caches the first response packet.

可选地,网络设备缓存第一响应数据包,具体过程:网络设备将第一请求序号缓存至Req_Queue1包括的第二节点处,并将第一文件内容缓存至第二节点处。Optionally, the network device caches the first response data packet. The specific process: the network device caches the first request sequence number to the second node included in Req_Queue1, and caches the first file content to the second node.

因此,通过应用本申请提供的通信方法,网络设备获取服务端向客户端发送的第一读响应数据包,该第一读响应数据包包括第一文件内容以及第一请求序号;网络设备从第一队列包括的第一节点中获取第二请求序号,该第一节点为第一队列的首节点;网络设备判断第一请求序号是否与第二请求序号相同;若相同,则网络设备对第一文件内容进行DPI业务处理;若不同,则网络设备缓存第一响应数据包;其中,第一队列包括至少一个节点,第一队列包括的首节点内存储的请求序号为最小值。Therefore, by applying the communication method provided by this application, the network device obtains the first read response data packet sent by the server to the client, the first read response data packet includes the first file content and the first request sequence number; Obtain the second request serial number from the first node included in a queue, and the first node is the head node of the first queue; the network device judges whether the first request serial number is the same as the second request serial number; DPI service processing is performed on the file content; if different, the network device caches the first response data packet; wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is the minimum value.

如此,利用客户端、服务端相互发送的请求序号,使得网络设备按请求序号对匹配的文件内容进行业务处理。解决了现有客户端与服务器之间传输文件过程中,文件内容易出现乱序的问题。保证了文件内容顺序处理,从而提升对文件检测的能力。In this way, the request sequence numbers sent by the client and the server are used to enable the network device to perform business processing on the matched file content according to the request sequence numbers. It solves the problem that the file is prone to disorder in the file transfer process between the existing client and the server. It ensures the sequential processing of file content, thereby improving the ability to detect files.

可选地,在本申请实施例中,还包括网络设备识别第一请求序号是否为最终序号,进而结束本次文件传输流程的过程。Optionally, in this embodiment of the present application, it also includes a process in which the network device identifies whether the first request sequence number is the final sequence number, and then ends the current file transfer process.

具体地,网络设备重复执行前述步骤110-步骤150,在每次获取到第一请求序号后,判断第一请求序号是否为最终序号,即第一请求序号是否为endOfFileID。Specifically, the network device repeatedly executes the aforementioned steps 110 to 150, and after obtaining the first request serial number each time, judges whether the first request serial number is the final serial number, that is, whether the first request serial number is endOfFileID.

若是,则确定服务端已将最后一部分文件内容传输,网络设备遍历文件内容。若遍历到文件结束标记,则网络设备结束本次文件传输流程。If yes, it is determined that the server has transmitted the last part of the file content, and the network device traverses the file content. If the file end mark is traversed, the network device ends the current file transfer process.

其中,endOfFileID的值为待获取文件的文件总长度,待获取文件的文件总长度为待获取文件的文件内容长度与待获取文件的文件内容起始位置之和。Wherein, the value of endOfFileID is the total length of the file to be obtained, and the total length of the file to be obtained is the sum of the length of the file content of the file to be obtained and the starting position of the file content of the file to be obtained.

可选地,若未遍历到文件技术标记,则网络设备确定本次文件传输流量中文件传输不全,网络设备无法结束本次文件传输流程。Optionally, if the file technical flag is not traversed, the network device determines that the file transfer in the current file transfer traffic is incomplete, and the network device cannot end the current file transfer process.

若未结束本次文件传输流程,则当网络设备获取到客户端向服务端发送的关闭请求数据包(例如,CLOSE Request数据包)时,结束本次文件传输流程。If the current file transfer process has not ended, when the network device obtains the close request data packet (for example, CLOSE Request data packet) sent by the client to the server, the current file transfer process ends.

可选地,在本申请实施例中,前述均以客户端、服务端之间交互读请求数据包、读响应数据包为例进行说明。在实际过程中,客户端、服务端之间也会交互写请求数据包、写响应数据包。Optionally, in the embodiment of the present application, the above descriptions are all described by taking the exchange of read request data packets and read response data packets between the client and the server as an example. In the actual process, the client and the server will also interact with each other to write request packets and write response packets.

下面以客户端、服务端之间交互写请求数据包、写响应数据包为例进行说明。The following takes the interaction between the client and the server to write request data packets and write response data packets as an example for illustration.

具体地,客户端与服务端之间先进行SMB会话认证。客户端先向服务端发送创建请求(例如,NT_CREATE_ANDX Request)数据包以请求服务端创建并打开新文件。服务端返回创建响应(例如,NT_CREATE_ANDX Response)数据包以告知客户端已创建并打开文件。Specifically, SMB session authentication is first performed between the client and the server. The client first sends a create request (for example, NT_CREATE_ANDX Request) packet to the server to request the server to create and open a new file. The server returns a create response (eg, NT_CREATE_ANDX Response) packet to inform the client that the file has been created and opened.

客户端向服务端发送第一写请求数据包(例如,WRITE_ANDX Request),该第一写请求数据包包括客户端待写入的第三文件内容、第三文件内容长度、第三文件内容起始位置以及第四请求序号。The client sends a first write request packet (for example, WRITE_ANDX Request) to the server, the first write request packet includes the content of the third file to be written by the client, the length of the content of the third file, the start of the content of the third file location and the fourth request sequence number.

网络设备获取第一写请求数据包,从第一写请求数据包中获取第三文件内容、第三文件内容长度、第三文件内容起始位置以及第四请求序号。The network device obtains the first write request data packet, and obtains the third file content, the length of the third file content, the starting position of the third file content, and the fourth request sequence number from the first write request data packet.

网络设备计算第三文件内容长度与第三文件内容起始位置的和值,得到第三值。网络设备获取本地SMB协议解析插件内存储的第四值。网络设备判断第四值是否与第三文件内容起始位置相同。The network device calculates the sum of the content length of the third file and the starting position of the content of the third file to obtain a third value. The network device acquires the fourth value stored in the local SMB protocol parsing plug-in. The network device judges whether the fourth value is the same as the starting position of the content of the third file.

若相同,则网络设备确定客户端写入文件内容为顺序写入,并利用第三值更新第四值;若不同,则网络设备确定客户端写入文件内容为乱序写入,并维持本地SMB协议解析插件内存储的第四值。If they are the same, the network device determines that the file content written by the client is written sequentially, and uses the third value to update the fourth value; if not, the network device determines that the file content written by the client is written out of order, and maintains the local The SMB protocol parses the fourth value stored in the plug-in.

进一步地,网络设备利用第三值更新第四值后,对第三文件内容进行DPI业务处理。Further, after the network device updates the fourth value with the third value, it performs DPI service processing on the content of the third file.

网络设备维持本地SMB协议解析插件内存储的第四值后,将第三文件内容、第三文件内容长度以及第三文件内容起始位置缓存至第二队列(例如,Req_Queue2)包括的第一节点处。After the network device maintains the fourth value stored in the local SMB protocol analysis plug-in, the content of the third file, the length of the content of the third file and the starting position of the content of the third file are cached to the first node included in the second queue (for example, Req_Queue2) place.

可以理解的是,Req_Queue2与Req_Queue1的结构、功能相同,每个节点可用于记录len、offset以及文件内容。Req_Queue1与获取的读请求数据包、读响应数据包对应;Req_Queue2与获取的写请求数据包对应。It can be understood that Req_Queue2 has the same structure and function as Req_Queue1, and each node can be used to record len, offset and file content. Req_Queue1 corresponds to the obtained read request data packet and read response data packet; Req_Queue2 corresponds to the obtained write request data packet.

在本申请实施例中,网络设备不再将第四请求序号缓存至节点内,原因在于,服务端接收到写请求数据包后,将文件内容写入对应的位置后,生成并向客户端发送写响应数据包(例如,WRITE_ANDX Response),以告知客户端写执行结果。在写响应数据包中不再包括对应的请求序号,而包括写入成功或写入失败。In this embodiment of the application, the network device no longer caches the fourth request sequence number in the node because, after the server receives the write request data packet, it writes the file content to the corresponding location, generates and sends it to the client Write a response packet (for example, WRITE_ANDX Response) to inform the client of the write execution result. The corresponding request sequence number is no longer included in the write response data packet, but includes write success or write failure.

需要说明的是,网络设备维持本地SMB协议解析插件内存储的第四值后,若后续再接收到写请求数据包,经过上述计算、判断后,第四值与文件内容起始位置不同,则网络设备可遍历Req_Queue2包括的每个节点内存储的offset,查找是否存在与第四值相同的offset。若存在,则网络设备计算该offset与该节点内len的和值,并利用该和值更新第四值。更新第四值后,网络设备对该节点内存储的文件内容进行DPI业务处理。进行DPI业务处理后,网络设备删除该节点内存储的offset、len以及文件内容。It should be noted that after the network device maintains the fourth value stored in the local SMB protocol analysis plug-in, if the write request packet is subsequently received, after the above calculation and judgment, the fourth value is different from the starting position of the file content, then The network device may traverse the offsets stored in each node included in the Req_Queue2 to find whether there is an offset that is the same as the fourth value. If it exists, the network device calculates the sum of the offset and len in the node, and uses the sum to update the fourth value. After updating the fourth value, the network device performs DPI service processing on the file content stored in the node. After processing the DPI service, the network device deletes the offset, len and file content stored in the node.

在一个例子中,网络设备本地SMB协议解析插件内存储的第四值为0。网络设接收第一写请求数据包,第三文件内容长度(len)为40、第三文件内容起始位置(offset)为0以及第四请求序号(messageID)为1。In an example, the fourth value stored in the local SMB protocol parsing plug-in of the network device is 0. The network assumes that the first write request packet is received, the third file content length (len) is 40, the third file content start position (offset) is 0, and the fourth request sequence number (messageID) is 1.

网络设备网络设备计算第三文件内容长度与第三文件内容起始位置的和值,得到第三值为40。网络设备从SMB协议解析插件内获取第四值,并比较第四值是否与第三文件内容起始位置相同。The network device calculates the sum of the content length of the third file and the starting position of the content of the third file, and obtains a third value of 40. The network device obtains the fourth value from the SMB protocol parsing plug-in, and compares whether the fourth value is the same as the starting position of the content of the third file.

在本示例中,第四值与第三文件内容起始位置相同。网络设备确定当前客户端写入文件内容为顺序写入,网络设备利用第三值40更新第四值0,此时,第四值为40。网络设备对第三文件内容进行DPI业务处理。In this example, the fourth value is the same as the starting position of the content of the third file. The network device determines that the current file content written by the client is sequential writing, and the network device uses the third value 40 to update the fourth value 0. At this time, the fourth value is 40. The network device performs DPI service processing on the content of the third file.

此时,网络设备获取到客户端向服务端发送的第二写请求数据包,第四文件内容长度(len)为40、第四文件内容起始位置(offset)为120以及第五请求序号(messageID)为2。At this time, the network device obtains the second write request packet sent by the client to the server, the fourth file content length (len) is 40, the fourth file content start position (offset) is 120, and the fifth request sequence number ( messageID) is 2.

网络设备再次从SMB协议解析插件内获取第四值40,并比较第四值是否与第四文件内容起始位置相同。The network device obtains the fourth value 40 from the SMB protocol parsing plug-in again, and compares whether the fourth value is the same as the starting position of the content of the fourth file.

本示例中,第四值与第四文件内容起始位置不同。网络设备确定当前客户端读取文件内容为乱序写入,网络设备将第四文件内容长度、第四文件内容起始位置以及第四文件内容缓存至Req_Queue2包括的第一节点处。In this example, the fourth value is different from the starting position of the content of the fourth file. The network device determines that the file content read by the current client is out-of-order writing, and the network device caches the length of the fourth file content, the starting position of the fourth file content, and the fourth file content to the first node included in Req_Queue2.

在另一个例子中,网络设备本地SMB协议解析插件内存储的第四值为40。Req_Queue2包括的节点1、节点2、节点3均存储了对应的offset、len以及文件内容。In another example, the fourth value stored in the local SMB protocol parsing plug-in of the network device is 40. Node 1, Node 2, and Node 3 included in Req_Queue2 all store the corresponding offset, len, and file content.

节点1内存储offset1为40、len1为40以及文件内容1;节点2内存储offset2为120、len2为40以及文件内容2;节点3内存储offset3为200、len3为40以及文件内容3。Node 1 stores offset1 as 40, len1 as 40 and file content 1; node 2 stores offset2 as 120, len2 as 40 and file content 2; node 3 stores offset3 as 200, len3 as 40 and file content 3.

此时,网络设备获取到客户端向服务端发送的第二读请求数据包,第三文件内容长度(len)为40、第三文件内容起始位置(offset)为160以及第四请求序号(messageID)为2。At this time, the network device obtains the second read request packet sent by the client to the server, the content length (len) of the third file is 40, the starting position (offset) of the content of the third file is 160, and the fourth request sequence number ( messageID) is 2.

网络设备从SMB协议解析插件内获取第四值40,并比较第四值是否与第三文件内容起始位置相同。The network device obtains the fourth value 40 from the SMB protocol parsing plug-in, and compares whether the fourth value is the same as the starting position of the content of the third file.

本示例中,第四值与第三文件内容起始位置不同。网络设备确定当前客户端读取文件内容为乱序写入,网络设备遍历节点1、节点2、节点3内存储的offset,查找到节点1内存储的offset1与第四值相同。网络设备计算offset1与len1的和值为80,利用该和值80更新第四值。更新第四值为80后,网络设备对文件内容1进行DPI业务处理。进行DPI业务处理后,网络设备删除节点1内存储的offset1、len1以及文件内容1。In this example, the fourth value is different from the content starting position of the third file. The network device determines that the file content read by the current client is out-of-order writing, the network device traverses the offsets stored in node 1, node 2, and node 3, and finds that offset1 stored in node 1 is the same as the fourth value. The network device calculates the sum of offset1 and len1 to be 80, and uses the sum of 80 to update the fourth value. After updating the fourth value to 80, the network device performs DPI service processing on file content 1. After processing the DPI service, the network device deletes offset1, len1 and file content 1 stored in node 1.

基于同一发明构思,本申请实施例还提供了与通信装置。参见图2,图2为本申请实施例提供的通信装置,所述装置应用于网络设备,所述装置包括:Based on the same inventive concept, an embodiment of the present application also provides a communication device. Referring to Fig. 2, Fig. 2 is a communication device provided by an embodiment of the present application, the device is applied to a network device, and the device includes:

第一获取单元210,用于获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;The first obtaining unit 210 is configured to obtain a first read response data packet sent by the server to the client, the first read response data packet includes the first file content and the first request sequence number;

第二获取单元220,用于从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;The second obtaining unit 220 is configured to obtain a second request sequence number from a first node included in the first queue, the first node being the head node of the first queue;

第一判断单元230,用于判断所述第一请求序号是否与所述第二请求序号相同;The first judging unit 230 is configured to judge whether the first request serial number is the same as the second request serial number;

业务处理单元240,用于若相同,则对所述第一文件内容进行DPI业务处理;The service processing unit 240 is configured to perform DPI service processing on the first file content if they are the same;

缓存单元250,用于若不同,则缓存所述第一响应数据包;The cache unit 250 is configured to cache the first response data packet if they are different;

其中,所述第一队列包括至少一个节点,所述第一队列包括的首节点内存储的请求序号为最小值。Wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is a minimum value.

可选地,所述第一获取单元210还用于,获取所述客户端向所述服务端发送的第一读请求数据包,所述第一读请求数据包包括所述客户端待读取的第一文件内容长度、第一文件内容起始位置以及第二请求序号;Optionally, the first obtaining unit 210 is further configured to obtain a first read request packet sent by the client to the server, the first read request packet includes The content length of the first file, the starting position of the first file content and the second request sequence number;

所述缓存单元250还用于,将所述第二请求序号缓存至所述第一节点处;The caching unit 250 is further configured to cache the second request sequence number at the first node;

所述装置还包括:计算单元(图中未示出),用于计算所述第一文件内容长度与第一文件内容起始位置的和值,得到第一值;The device further includes: a calculation unit (not shown in the figure), configured to calculate the sum of the length of the content of the first file and the starting position of the content of the first file to obtain the first value;

第三获取单元(图中未示出),用于获取本地SMB协议解析插件内存储的第二值;A third acquisition unit (not shown in the figure), configured to acquire the second value stored in the local SMB protocol analysis plug-in;

第二判断单元(图中未示出),用于判断所述第二值是否与所述第一文件内容起始位置相同;The second judging unit (not shown in the figure) is used to judge whether the second value is the same as the starting position of the content of the first file;

更新单元(图中未示出),用于若相同,则利用所述第一值更新所述第二值;An updating unit (not shown in the figure), configured to use the first value to update the second value if they are the same;

所述缓存单元250还用于,若不同,则维持所述本地SMB协议解析插件内存储的第二值,并将所述第一文件内容长度、所述第一文件内容起始位置缓存至所述第一节点处缓存至所述第一节点处;The cache unit 250 is also used to, if different, maintain the second value stored in the local SMB protocol analysis plug-in, and cache the first file content length and the first file content start position to the Cache at the first node to the first node;

其中,所述第一文件内容由所述服务器根据所述第一文件内容长度以及所述第一文件内容起始位置确定。Wherein, the first file content is determined by the server according to the length of the first file content and the starting position of the first file content.

可选地,所述装置还包括:删除单元(图中未示出),用于将所述第一节点从所述第一队列中删除。Optionally, the apparatus further includes: a deleting unit (not shown in the figure), configured to delete the first node from the first queue.

可选地,所述缓存单元250具体用于,将所述第一请求序号缓存至所述第一队列包括的第二节点处,并将所述第一文件内容缓存至所述第二节点处。Optionally, the cache unit 250 is specifically configured to cache the first request sequence number to a second node included in the first queue, and cache the first file content to the second node .

可选地,所述装置还包括:第三判断单元(图中未示出),用于判断所述第一请求序号是否为最终序号;Optionally, the device further includes: a third judging unit (not shown in the figure), configured to judge whether the first request sequence number is a final sequence number;

结束单元(图中未示出),用于若是,则结束本次文件传输流程;An end unit (not shown in the figure) is used to end the file transfer process if so;

其中,所述最终序号的值为待获取文件的文件总长度,所述待获取文件的文件总长度为所述待获取文件的文件内容长度与所述待获取文件的文件内容起始位置之和。Wherein, the value of the final sequence number is the total file length of the file to be obtained, and the total file length of the file to be obtained is the sum of the file content length of the file to be obtained and the starting position of the file content of the file to be obtained .

可选地,所述结束单元(图中未示出)还用于,若未结束本次文件传输流程,则当获取到所述客户端向所述服务端发送的关闭请求数据包时,结束本次文件传输流程。Optionally, the end unit (not shown in the figure) is also configured to, if the current file transfer process is not ended, when the close request packet sent by the client to the server is obtained, end This file transfer process.

可选地,所述第一获取单元210还用于,获取所述客户端向所述服务端发送的第一写请求数据包,所述第一写请求数据包包括所述客户端待写入的第三文件内容、第三文件内容长度以及第三文件内容起始位置;Optionally, the first obtaining unit 210 is further configured to obtain a first write request packet sent by the client to the server, the first write request packet includes The content of the third file, the length of the content of the third file, and the starting position of the content of the third file;

所述计算单元(图中未示出)还用于,计算所述第三文件内容长度与所述第三文件内容起始位置的和值,得到第三值;The calculation unit (not shown in the figure) is also used to calculate the sum of the content length of the third file and the starting position of the content of the third file to obtain a third value;

所述第三获取单元(图中未示出)还用于,获取本地SMB协议解析插件内存储的第四值;The third obtaining unit (not shown in the figure) is also used to obtain the fourth value stored in the local SMB protocol analysis plug-in;

所述第二判断单元(图中未示出)还用于,判断所述第四值是否与所述第三文件内容起始位置相同;The second judging unit (not shown in the figure) is also used to judge whether the fourth value is the same as the starting position of the content of the third file;

所述更新单元(图中未示出)还用于,若相同,则利用所述第三只更新所述第四值;The updating unit (not shown in the figure) is also used to, if they are the same, update the fourth value only by using the third one;

所述缓存单元250还用于,若不同,则维持所述本地SMB协议解析插件内存储的第四值。The cache unit 250 is further configured to, if different, maintain the fourth value stored in the local SMB protocol parsing plug-in.

可选地,所述业务处理单元240还用于,对所述第三文件内容进行DPI业务处理。Optionally, the service processing unit 240 is further configured to perform DPI service processing on the third file content.

可选地,所述缓存单元250还用于,将所述第三文件内容、第三文件内容长度以及第三文件内容起始位置缓存至第二队列包括的第一节点处;Optionally, the caching unit 250 is further configured to cache the third file content, the length of the third file content, and the starting position of the third file content at the first node included in the second queue;

其中,所述第二队列包括至少一个节点,每个节点用于存储文件内容、文件内容长度以及文件内容起始位置。Wherein, the second queue includes at least one node, and each node is used to store the file content, the length of the file content, and the starting position of the file content.

因此,通过应用本申请提供的通信装置,网络设备获取服务端向客户端发送的第一读响应数据包,该第一读响应数据包包括第一文件内容以及第一请求序号;网络设备从第一队列包括的第一节点中获取第二请求序号,该第一节点为第一队列的首节点;网络设备判断第一请求序号是否与第二请求序号相同;若相同,则网络设备对第一文件内容进行DPI业务处理;若不同,则网络设备缓存第一响应数据包;其中,第一队列包括至少一个节点,第一队列包括的首节点内存储的请求序号为最小值。Therefore, by using the communication device provided by this application, the network device obtains the first read response data packet sent from the server to the client, the first read response data packet includes the first file content and the first request sequence number; Obtain the second request serial number from the first node included in a queue, and the first node is the head node of the first queue; the network device judges whether the first request serial number is the same as the second request serial number; DPI service processing is performed on the file content; if different, the network device caches the first response data packet; wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is the minimum value.

如此,利用客户端、服务端相互发送的请求序号,使得网络设备按请求序号对匹配的文件内容进行业务处理。解决了现有客户端与服务器之间传输文件过程中,文件内容易出现乱序的问题。保证了文件内容顺序处理,从而提升对文件检测的能力。In this way, the request sequence numbers sent by the client and the server are used to enable the network device to perform business processing on the matched file content according to the request sequence numbers. It solves the problem that the file is prone to disorder in the file transfer process between the existing client and the server. It ensures the sequential processing of file content, thereby improving the ability to detect files.

基于同一发明构思,本申请实施例还提供了一种网络设备,如图3所示,包括处理器310、收发器320和机器可读存储介质330,机器可读存储介质330存储有能够被处理器310执行的机器可执行指令,处理器310被机器可执行指令促使执行本申请实施例所提供的通信方法。前述图2所示的通信装置,可采用如图3所示的网络设备硬件结构实现。Based on the same inventive concept, the embodiment of the present application also provides a network device, as shown in FIG. 3 , including a processor 310, a transceiver 320 and a machine-readable storage medium 330. The machine-readable storage medium 330 stores The processor 310 executes the machine-executable instructions, and the processor 310 is prompted by the machine-executable instructions to execute the communication method provided by the embodiment of the present application. The aforementioned communication device shown in FIG. 2 can be realized by using the hardware structure of the network equipment shown in FIG. 3 .

上述计算机可读存储介质330可以包括随机存取存储器(英文:Random AccessMemory,简称:RAM),也可以包括非易失性存储器(英文:Non-volatile Memory,简称:NVM),例如至少一个磁盘存储器。可选的,计算机可读存储介质330还可以是至少一个位于远离前述处理器310的存储装置。The above-mentioned computer-readable storage medium 330 may include a random access memory (English: Random Access Memory, abbreviated as RAM), and may also include a non-volatile memory (English: Non-volatile Memory, abbreviated: NVM), such as at least one disk memory . Optionally, the computer-readable storage medium 330 may also be at least one storage device located away from the aforementioned processor 310 .

上述处理器310可以是通用处理器,包括中央处理器(英文:Central ProcessingUnit,简称:CPU)、网络处理器(英文:Network Processor,简称:NP)等;还可以是数字信号处理器(英文:Digital Signal Processor,简称:DSP)、专用集成电路(英文:ApplicationSpecific Integrated Circuit,简称:ASIC)、现场可编程门阵列(英文:Field-Programmable Gate Array,简称:FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。The above-mentioned processor 310 can be a general-purpose processor, including a central processing unit (English: Central Processing Unit, referred to as: CPU), a network processor (English: Network Processor, referred to as: NP), etc.; it can also be a digital signal processor (English: Digital Signal Processor (abbreviation: DSP), application specific integrated circuit (English: Application Specific Integrated Circuit, abbreviation: ASIC), field programmable gate array (English: Field-Programmable Gate Array, abbreviation: FPGA) or other programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components.

本申请实施例中,处理器310通过读取机器可读存储介质330中存储的机器可执行指令,被机器可执行指令促使能够实现处理器310自身以及调用收发器320执行前述本申请实施例描述的通信方法。In the embodiment of the present application, the processor 310 reads the machine-executable instructions stored in the machine-readable storage medium 330, and is prompted by the machine-executable instructions to implement the processor 310 itself and call the transceiver 320 to execute the foregoing description of the embodiment of the present application. communication method.

另外,本申请实施例提供了一种机器可读存储介质330,机器可读存储介质330存储有机器可执行指令,在被处理器310调用和执行时,机器可执行指令促使处理器310自身以及调用收发器320执行前述本申请实施例描述的通信方法。In addition, the embodiment of the present application provides a machine-readable storage medium 330. The machine-readable storage medium 330 stores machine-executable instructions. When called and executed by the processor 310, the machine-executable instructions prompt the processor 310 itself and The transceiver 320 is invoked to execute the communication method described in the foregoing embodiments of the present application.

上述装置中各个单元的功能和作用的实现过程具体详见上述方法中对应步骤的实现过程,在此不再赘述。For the implementation process of the functions and effects of each unit in the above device, please refer to the implementation process of the corresponding steps in the above method for details, and will not be repeated here.

对于装置实施例而言,由于其基本对应于方法实施例,所以相关之处参见方法实施例的部分说明即可。以上所描述的装置实施例仅仅是示意性的,其中所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部模块来实现本申请方案的目的。本领域普通技术人员在不付出创造性劳动的情况下,即可以理解并实施。As for the device embodiment, since it basically corresponds to the method embodiment, for related parts, please refer to the part description of the method embodiment. The device embodiments described above are only illustrative, and the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in One place, or it can be distributed to multiple network elements. Part or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this application. It can be understood and implemented by those skilled in the art without creative effort.

对于通信装置以及机器可读存储介质实施例而言,由于其涉及的方法内容基本相似于前述的方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。As for the embodiments of the communication device and the machine-readable storage medium, since the content of the methods involved is basically similar to the foregoing method embodiments, the description is relatively simple, and for relevant details, please refer to the descriptions of the method embodiments.

以上所述仅为本申请的较佳实施例而已,并不用以限制本申请,凡在本申请的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本申请保护的范围之内。The above is only a preferred embodiment of the application, and is not intended to limit the application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the application should be included in the application. within the scope of protection.

Claims (10)

1.一种通信方法,其特征在于,所述方法应用于网络设备,所述方法包括:1. A communication method, characterized in that, the method is applied to a network device, and the method comprises: 获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;Obtaining the first read response data packet sent by the server to the client, the first read response data packet including the first file content and the first request sequence number; 从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;Obtaining a second request sequence number from a first node included in the first queue, where the first node is the head node of the first queue; 判断所述第一请求序号是否与所述第二请求序号相同;judging whether the first request sequence number is the same as the second request sequence number; 若相同,则对所述第一文件内容进行DPI业务处理;If they are the same, perform DPI service processing on the content of the first file; 若不同,则缓存所述第一响应数据包;If different, cache the first response data packet; 其中,所述第一队列包括至少一个节点,所述第一队列包括的首节点内存储的请求序号为最小值。Wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is a minimum value. 2.根据权利要求1所述的方法,其特征在于,所述获取服务端向客户端发送的第一读响应数据包之前,所述方法还包括:2. The method according to claim 1, wherein before obtaining the first read response packet sent by the server to the client, the method further comprises: 获取所述客户端向所述服务端发送的第一读请求数据包,所述第一读请求数据包包括所述客户端待读取的第一文件内容长度、第一文件内容起始位置以及第二请求序号;Obtaining the first read request data packet sent by the client to the server, the first read request data packet includes the content length of the first file to be read by the client, the starting position of the first file content, and the second request sequence number; 将所述第二请求序号缓存至所述第一节点处;cache the second request sequence number at the first node; 计算所述第一文件内容长度与第一文件内容起始位置的和值,得到第一值;calculating the sum of the content length of the first file and the starting position of the content of the first file to obtain a first value; 获取本地SMB协议解析插件内存储的第二值;Obtain the second value stored in the local SMB protocol parsing plug-in; 判断所述第二值是否与所述第一文件内容起始位置相同;judging whether the second value is the same as the starting position of the content of the first file; 若相同,则利用所述第一值更新所述第二值;If they are the same, updating the second value with the first value; 若不同,则维持所述本地SMB协议解析插件内存储的第二值,并将所述第一文件内容长度、所述第一文件内容起始位置缓存至所述第一节点处缓存至所述第一节点处;If different, then maintain the second value stored in the local SMB protocol analysis plug-in, and cache the content length of the first file and the starting position of the content of the first file to the first node and cache to the at the first node; 其中,所述第一文件内容由所述服务器根据所述第一文件内容长度以及所述第一文件内容起始位置确定。Wherein, the first file content is determined by the server according to the length of the first file content and the starting position of the first file content. 3.根据权利要求1所述的方法,其特征在于,所述对所述第一文件内容进行DPI业务处理后,所述方法还包括:3. The method according to claim 1, characterized in that, after performing DPI service processing on the first file content, the method further comprises: 将所述第一节点从所述第一队列中删除。deleting the first node from the first queue. 4.根据权利要求1所述的方法,其特征在于,所述缓存所述第一响应数据包,具体包括:4. The method according to claim 1, wherein the caching the first response data packet specifically comprises: 将所述第一请求序号缓存至所述第一队列包括的第二节点处,并将所述第一文件内容缓存至所述第二节点处。Cache the first request sequence number to the second node included in the first queue, and cache the first file content to the second node. 5.根据权利要求1所述的方法,其特征在于,所述方法还包括:5. The method according to claim 1, wherein the method further comprises: 判断所述第一请求序号是否为最终序号;judging whether the first request sequence number is the final sequence number; 若是,则结束本次文件传输流程;If so, end the file transfer process; 其中,所述最终序号的值为待获取文件的文件总长度,所述待获取文件的文件总长度为所述待获取文件的文件内容长度与所述待获取文件的文件内容起始位置之和。Wherein, the value of the final sequence number is the total file length of the file to be obtained, and the total file length of the file to be obtained is the sum of the file content length of the file to be obtained and the starting position of the file content of the file to be obtained . 6.根据权利要求5所述的方法,其特征在于,所述方法还包括:6. The method according to claim 5, further comprising: 若未结束本次文件传输流程,则当获取到所述客户端向所述服务端发送的关闭请求数据包时,结束本次文件传输流程。If the current file transfer process has not ended, when the close request data packet sent by the client to the server is obtained, the current file transfer process is ended. 7.根据权利要求1所述的方法,其特征在于,所述方法还包括:7. The method according to claim 1, further comprising: 获取所述客户端向所述服务端发送的第一写请求数据包,所述第一写请求数据包包括所述客户端待写入的第三文件内容、第三文件内容长度以及第三文件内容起始位置;Obtain the first write request data packet sent by the client to the server, the first write request data packet includes the content of the third file to be written by the client, the length of the content of the third file, and the content of the third file Content start position; 计算所述第三文件内容长度与所述第三文件内容起始位置的和值,得到第三值;calculating the sum of the content length of the third file and the starting position of the content of the third file to obtain a third value; 获取本地SMB协议解析插件内存储的第四值;Obtain the fourth value stored in the local SMB protocol parsing plug-in; 判断所述第四值是否与所述第三文件内容起始位置相同;judging whether the fourth value is the same as the starting position of the content of the third file; 若相同,则利用所述第三只更新所述第四值;If they are the same, then using the third one to update the fourth value; 若不同,则维持所述本地SMB协议解析插件内存储的第四值。If not, maintain the fourth value stored in the local SMB protocol parsing plug-in. 8.根据权利要求7所述的方法,其特征在于,所述利用所述第三值更新所述第四值之后,所述方法还包括:8. The method according to claim 7, wherein after updating the fourth value using the third value, the method further comprises: 对所述第三文件内容进行DPI业务处理。Perform DPI service processing on the content of the third file. 9.根据权利要求7所述的方法,其特征在于,所述维持所述本地SMB协议解析插件内存储的第四值之后,所述方法还包括:9. The method according to claim 7, wherein after maintaining the fourth value stored in the local SMB protocol analysis plug-in, the method further comprises: 将所述第三文件内容、第三文件内容长度以及第三文件内容起始位置缓存至第二队列包括的第一节点处;Cache the content of the third file, the length of the content of the third file, and the starting position of the content of the third file to the first node included in the second queue; 其中,所述第二队列包括至少一个节点,每个节点用于存储文件内容、文件内容长度以及文件内容起始位置。Wherein, the second queue includes at least one node, and each node is used to store the file content, the length of the file content, and the starting position of the file content. 10.一种通信装置,其特征在于,所述装置应用于网络设备,所述装置包括:10. A communication device, characterized in that the device is applied to network equipment, and the device comprises: 第一获取单元,用于获取服务端向客户端发送的第一读响应数据包,所述第一读响应数据包包括第一文件内容以及第一请求序号;The first obtaining unit is configured to obtain a first read response data packet sent by the server to the client, the first read response data packet including the first file content and the first request sequence number; 第二获取单元,用于从第一队列包括的第一节点中获取第二请求序号,所述第一节点为所述第一队列的首节点;A second obtaining unit, configured to obtain a second request sequence number from a first node included in the first queue, where the first node is the head node of the first queue; 第一判断单元,用于判断所述第一请求序号是否与所述第二请求序号相同;a first judging unit, configured to judge whether the first request serial number is the same as the second request serial number; 业务处理单元,用于若相同,则对所述第一文件内容进行DPI业务处理;A service processing unit, configured to perform DPI service processing on the first file content if they are the same; 缓存单元,用于若不同,则缓存所述第一响应数据包;a cache unit, configured to cache the first response data packet if they are different; 其中,所述第一队列包括至少一个节点,所述第一队列包括的首节点内存储的请求序号为最小值。Wherein, the first queue includes at least one node, and the request sequence number stored in the first node included in the first queue is a minimum value.
CN202210650766.9A 2022-06-10 2022-06-10 Communication method and device Pending CN115277058A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210650766.9A CN115277058A (en) 2022-06-10 2022-06-10 Communication method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210650766.9A CN115277058A (en) 2022-06-10 2022-06-10 Communication method and device

Publications (1)

Publication Number Publication Date
CN115277058A true CN115277058A (en) 2022-11-01

Family

ID=83758745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210650766.9A Pending CN115277058A (en) 2022-06-10 2022-06-10 Communication method and device

Country Status (1)

Country Link
CN (1) CN115277058A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117812068A (en) * 2024-01-05 2024-04-02 湖北安博通科技有限公司 SMB protocol file restoration method and system

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101388039A (en) * 2008-11-11 2009-03-18 深圳市金蝶中间件有限公司 Response message executing method and device
WO2015151612A1 (en) * 2014-04-02 2015-10-08 株式会社日立製作所 Network system, distribution management device, and distribution management method
CN106330833A (en) * 2015-06-29 2017-01-11 中兴通讯股份有限公司 Communication method, client and server based on Internet content adaptation protocol
CN109150726A (en) * 2018-08-10 2019-01-04 新华三信息安全技术有限公司 A kind of message processing method and device
CN110839060A (en) * 2019-10-16 2020-02-25 武汉绿色网络信息服务有限责任公司 A kind of file restoration method and device for HTTP multi-session in DPI scene
CN113055535A (en) * 2019-12-26 2021-06-29 中国电信股份有限公司 Method and system for generating 5G end-to-end call ticket

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101388039A (en) * 2008-11-11 2009-03-18 深圳市金蝶中间件有限公司 Response message executing method and device
WO2015151612A1 (en) * 2014-04-02 2015-10-08 株式会社日立製作所 Network system, distribution management device, and distribution management method
CN106330833A (en) * 2015-06-29 2017-01-11 中兴通讯股份有限公司 Communication method, client and server based on Internet content adaptation protocol
CN109150726A (en) * 2018-08-10 2019-01-04 新华三信息安全技术有限公司 A kind of message processing method and device
CN110839060A (en) * 2019-10-16 2020-02-25 武汉绿色网络信息服务有限责任公司 A kind of file restoration method and device for HTTP multi-session in DPI scene
CN113055535A (en) * 2019-12-26 2021-06-29 中国电信股份有限公司 Method and system for generating 5G end-to-end call ticket

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117812068A (en) * 2024-01-05 2024-04-02 湖北安博通科技有限公司 SMB protocol file restoration method and system

Similar Documents

Publication Publication Date Title
US9729655B2 (en) Managing transfer of data in a data network
Caviglione et al. Covert channels in personal cloud storage services: The case of Dropbox
WO2022193447A1 (en) Data packet deduplication and transmission method, electronic device, and storage medium
WO2018107784A1 (en) Method and device for detecting webshell
JP2004538678A (en) Dynamic packet filter using session tracking
CN106161617A (en) Reverse proxy method based on NODEJS, Reverse Proxy and system
US20110038378A1 (en) Techniques for using the network as a memory device
CN112272164B (en) Message processing method and device
US9674283B2 (en) Method for solving coherency lock issues in proxy services
CN115277058A (en) Communication method and device
US7774847B2 (en) Tracking computer infections
CN104780178B (en) A kind of connection management method for being used to prevent that TCP from attacking
CN109905352B (en) Method, device and storage medium for auditing data based on encryption protocol
JP2004535096A (en) Method and system for regulating external access
CN116708041B (en) Camouflage proxy method, device, equipment and medium
CN115051851B (en) User access behavior management and control system and method in scene of internet of things
CN115580584A (en) A message processing method and device
US11546235B2 (en) Action based on advertisement indicator in network packet
CN116567082A (en) Method and apparatus for container network communication
Torres-Jr et al. Packet reordering metrics to enable performance comparison in IP‐networks
CN110392129B (en) IPv6 client and method for IPv6 client to communicate with server
US11483394B2 (en) Delayed proxy-less network address translation decision based on application payload
CN118713936B (en) Data monitoring method, system, device and medium based on API traffic data
CN114826975B (en) Data transmission optimization method, control device and storage medium
CN117812068B (en) SMB protocol file restoration method and system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination