WO2010063198A1 - 一种发送复杂消息的方法 - Google Patents

一种发送复杂消息的方法 Download PDF

Info

Publication number
WO2010063198A1
WO2010063198A1 PCT/CN2009/074390 CN2009074390W WO2010063198A1 WO 2010063198 A1 WO2010063198 A1 WO 2010063198A1 CN 2009074390 W CN2009074390 W CN 2009074390W WO 2010063198 A1 WO2010063198 A1 WO 2010063198A1
Authority
WO
WIPO (PCT)
Prior art keywords
message
stereo
memory
data
buffer
Prior art date
Application number
PCT/CN2009/074390
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 WO2010063198A1 publication Critical patent/WO2010063198A1/zh

Links

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/50Network services
    • H04L67/56Provisioning of proxy services
    • H04L67/568Storing data temporarily at an intermediate stage, e.g. caching

Definitions

  • the present invention relates to techniques for transmitting complex messages, and more particularly to a method for transmitting complex messages between processes.
  • inter-process communication actually sends messages between processes
  • the specific implementation of sending a message is usually: After the message is encapsulated in the form of a message packet, the message is sent between processes. Due to the independence of the process, the process of sending a message packet can be abstracted as a process of copying the message packet from the source buffer to the destination buffer. As shown in Figure 1, the process of sending the message packet can be intuitively obtained. abstract. However, for a complex message containing a data pointer, since the complex message includes both the data pointer itself and the data referenced by the data pointer, the message message is still copied from the source buffer to the destination cache. The simple copy operation of the area will only copy the data pointer itself, but the data referenced by the pointer is not copied, resulting in the failure of the complex message transmission.
  • stereo messages are characterized by one or more data pointers. As shown in Figure 2, this core feature of stereoscopic messages can be viewed directly. A data pointer can also be included in a data block referenced by other data pointers.
  • the stereo message For stereoscopic messages, the stereo message must first be encapsulated into a message message that can be sent before it can be sent. The message message that can be sent by applying the processing to the stereo message is simply referred to as a stereo message message.
  • the stereoscopic message is obtained by using a static planarization technique: converting the data pointer body in the stereo message into a fixed-length byte sequence, that is, converting the data pointer body described by the pointer data structure into The array described by the array data structure, so that the data pointer body and the data pointer body reference all reside in the stereo message.
  • the shortcomings of the prior art are: Since two sets of data structures, that is, a pointer data structure and an array data structure, need to be set in the system, the problem of heterogeneous message expression may be caused. And the message is heterogeneous, This will lead to a series of problems, such as increased memory copy times; memory allocation redundancy; memory copying due to memory allocation redundancy; low system efficiency and increased system design complexity. Summary of the invention
  • the main purpose of the present invention is to provide a method for transmitting a complex message, which not only can realize the transmission of a stereo message, but also has a simple expression and avoids a series of problems caused by heterogeneous message expression.
  • a method of transmitting a complex message comprising:
  • the stereo message packet is sent.
  • the method further includes: converting the offset in the stereo message packet buffer into a local data pointer.
  • the dynamically allocating memory allocates memory dynamically and continuously, and implements memory allocation redundancy to zero;
  • the dynamically allocating memory for the stereo message to be sent on the buffer further includes:
  • Dynamically and continuously allocating memory for the data pointers in the stereoscopic message and dynamically and continuously allocating memory for data referenced by the data pointers in the stereoscopic message.
  • [P n :: P ] [P] + L ; in the formula, P Volume:: P denotes the nth data pointer in the P; [P Volume:: P ] denotes access to P n :: The value of P is the content of the memory unit of the address; [P] indicates the content of the memory unit that accesses the address with the value of P;
  • A3 cache the J value; and update the J value according to the value of ⁇ :
  • indicates the length of the data pointer reference data.
  • the shifting the data pointer in the stereo message into the buffer in the stereo message packet is specifically:
  • [ ⁇ + / ⁇ sweater] indicates the access to the contents of the memory location with the value of P + / p réelle.
  • the present invention dynamically allocates data blocks continuously at the transmitting end.
  • the present invention is different from the prior art in that a stereoscopic message is dynamically planarized to obtain a stereo message, that is, the data pointer in the stereo message is converted into a stereo message packet.
  • the offset in the buffer is used to convert the stereo message defined by the service application layer and meet the needs of the service application layer into a stereo message that meets the requirements for stereoscopic message transmission. Since the data pointer and the offset generated by converting the data pointer are described by the pointer data structure, in order to satisfy the needs of the business application layer and the stereo message transmission, the conversion does not have message heterogeneity, thereby avoiding A series of problems caused by heterogeneous message expression.
  • the present invention is different from the prior art in that it does not need to specifically design a conversion module in the system, but stereoscopically obtains a stereoscopic message after the stereoscopic message is obtained, that is, the receiving end receives the stereoscopic message sent by the transmitting end.
  • the offset in the buffer of the stereo message packet is converted into a local data pointer to quickly obtain the stereoscopic message required by the service application layer.
  • the dynamic planarization is actually a transformation between the data pointer in the stereo message and the offset in the stereo message, and the stereoscopically actual data pointer between the stereo message and the offset in the stereo message The inverse of the transformation.
  • the present invention implements a transform and inverse transform technique between a data pointer in a stereo message and an offset in a stereo message, and a new technique for obtaining an offset in a stereo message to implement a stereo message and a stereo message.
  • the dynamic conversion of the message completes the sending and receiving of the stereo message.
  • the message of the invention is simple to express, and a set of data structure, that is, the pointer data structure description, can be used, and the two sets of data structures are not required to be maintained as in the prior art, and the message heterogeneity is eliminated.
  • This avoids a series of problems caused by heterogeneous message expression, such as memory copy count / memory copy amount increase and system design complexity increase.
  • the present invention uses a technique in which data blocks are dynamically allocated continuously, which can better eliminate memory redundancy allocation, reduce system memory requirements, and significantly reduce inter-process message traffic.
  • FIG. 2 is a schematic diagram of a stereo message with one or more data pointers
  • FIG. 3 is a schematic diagram of a stereoscopic message obtained by applying the existing static planarization technology
  • FIG. 4 is a schematic diagram of memory redundancy generated after static planarization
  • FIG. 5 is a schematic diagram of a whole process of applying the dynamic planarization and stereoscopic technology of the present invention
  • FIG. 7 is a schematic diagram of an implementation process of the method of the present invention.
  • the basic idea of the present invention is: implementing a stereoscopic message and a stereoscopic message by using a transform and inverse transform technique between a data pointer in a stereoscopic message and an offset in a stereoscopic message, and a new technique for obtaining an offset in a stereo message packet.
  • the dynamic conversion of the message completes the sending and receiving of the stereo message.
  • a method of obtaining a stereo message message uses a static flattening technique. Specifically, the data pointer body in the stereo message is converted into a fixed-length byte sequence, that is, the data pointer body described by the pointer data structure is converted into an array described by the array data structure, and then the data pointer body is referenced. The data is placed in an array generated by the transformation. Thus, the data referenced by the data pointer body and the data pointer body all reside in the stereo message. Then, by applying the above-described static planarization processing to the stereoscopic message, a stereoscopic message that can be transmitted is formed.
  • the stereo message received by the static planarization technique is shown in Figure 3.
  • Figure 4 is a schematic diagram of memory redundancy generated after static planarization. In Figure 4, the shaded portion represents the currently used memory, and the blank portion represents the redundant allocated memory.
  • the stereo message expression used in the business application layer that is, the actual operation is: Data pointer body plus data refers to The data referenced by the pin body; and the stereo message is required to be sent in the inter-process communication, that is, the stereo message including the data pointer body cannot be directly sent, and the data needs to be sent in order to transmit the stereo message.
  • the pointer body is converted into an array, and the stereo message used in the process of communicating the stereo message between processes is expressed as follows: the array generated by converting the data pointer ontology and the data referenced by the original data pointer body.
  • the data pointer body is described by a data structure such as a pointer
  • the array is described by another data structure, that is, an array data structure. Therefore, in order to adapt to the different needs of the same stereoscopic message in the business application layer operation and the stereoscopic message transmission, two types of data structures will be defined in the system, so that the system selects one of the current needs according to the current needs during the read/write operation.
  • the stereoscopic message expressed by the data structure brings operational confusion.
  • the normal copy operation refers to: the data copy operation during the message message sending process. In other words, you can copy the message directly into the system.
  • the copy operation of the stereo message is: first copy the data referenced by the original data pointer onto the array. , then copy the array to the system. That is to say, the copy operation of the stereoscopic message additionally increases the copying process of the stereoscopic message obtained by the stereoscopic message to the static planarization technique, and then performs the above-mentioned normal copying operation.
  • the use of the prior art leads to problems of memory allocation redundancy and memory copying.
  • the reason is:
  • the array generated by the data pointer ontology conversion is usually not defined according to actual needs, that is, the actual data length is not known in advance, and the array is uniformly defined according to the maximum data length. of.
  • the data represented by the data pointer and the actual data length in order to meet the needs of the stereo message transmission, after the data pointer is converted into an array, are all allocated after the static flattening.
  • the body of the stereo message is in the body.
  • the structure of the stereoscopic message after static flattening is very large, and uniformly defining the array and allocating the memory according to the maximum data length necessarily leads to redundancy of memory allocation.
  • the memory is redundant. Therefore, the copy is executed according to the maximum data length every time the copy operation is performed, instead of performing the copy according to the actual data length. . That is, memory redundancy causes the maximum amount of data to be copied each time, increasing the amount of memory copy.
  • the use of existing technology can lead to inefficiencies. The reasons are as follows: Memory redundancy causes an increase in memory copy size, and an increase in the number of memory copies due to heterogeneous message expressions causes a large system overhead, resulting in low system efficiency.
  • the use of the prior art leads to a complicated operation of accessing the message, which brings about an increase in the complexity of the system design.
  • the reason is: Since the stereo message received by the static planarization technology has the problem of heterogeneous message representation, the receiver of the stereoscopic message cannot directly use the received stereoscopic message, but must pass the conversion module to The array in the message message is converted into a data pointer to meet the needs of the business application layer, which will inevitably increase the complexity of the system design.
  • the present invention has emerged as a result, and solves the above four problems existing in the prior art.
  • the layout of the stereo message packet obtained by applying the dynamic planarization technique of the present invention is as shown in FIG. 5.
  • the process of transmitting and receiving a stereo message by using the dynamic planarization and stereoscopic technology of the present invention is as shown in FIG. 6.
  • the service data representation of the stereo message at the transmitting end is: satisfying the requirements of the service application layer, including the data.
  • the stereoscopic message of the data referenced by the pointer and the data pointer, the stereoscopic message after the dynamic planarization is: the stereoscopic message obtained after the stereoscopic message is processed by the dynamic planarization technology at the transmitting end.
  • the message of the invention is simple to express, and can be described by using a set of data structures, that is, a pointer data structure. It is not necessary to define an additional data structure, that is, an array data structure, for the transmission of a stereo message, as in the prior art, and maintain two sets of data structures. It can be seen that the present invention eliminates message heterogeneity, thereby avoiding message expression differences. A series of problems caused by structure.
  • the present invention makes the message expression mode simple and eliminates message heterogeneity by transforming and inverse transforming between the data pointer in the stereo message and the offset in the stereo message. And the method of encapsulating the transformation operation between all the local data pointers and the buffer offset is adopted, so that the system receiving end obtains the local data pointer directly by the inverse transform according to the buffer offset, without the need of the prior art,
  • the conversion module is designed specifically at the receiving end. It can be seen that the invention is used to eliminate the heterogeneity of message expression, and the complexity of system design is greatly reduced.
  • the present invention is based on a reliable data block dynamic continuous allocation technique to separately allocate the memory occupied by the data pointer body in the stereo message message and the memory occupied by the data block referenced by the data pointer body.
  • This secondary dynamic continuous allocation technique for memory is dynamically allocated according to the actual data length, which is different from the prior art in that the data is uniformly pre-allocated according to the maximum data length. It can be seen that the use of the invention reduces the memory allocation redundancy to zero, which greatly improves the memory usage. When the memory allocation redundancy drops to 0, The length of the memory copy during the transmission of the stereo message is minimized, and the number of memory copies and the amount of memory copy are greatly reduced, thereby greatly improving the system operation efficiency.
  • a method for sending a complex message includes the following steps: Step 101: Dynamically allocate memory on a buffer for a stereo message to be sent.
  • Step 102 After converting the data pointer in the stereo message into an offset in the stereo message packet buffer, send the stereo message.
  • the process of converting the data pointer in the stereoscopic message to the offset in the stereo message packet buffer at the transmitting end may be referred to as a dynamic planarization process.
  • the stereo message that meets the needs of the service application layer is converted into a stereo message that meets the requirements for stereoscopic message transmission.
  • the stereoscopic message is sent, and after the receiving end receives the stereoscopic message, the step 102 further includes:
  • Step 201 Convert an offset in the stereo message packet buffer into a local data pointer.
  • the process of converting the offset in the stereo message message buffer to the local data pointer at the receiving end may be referred to as a stereoscopic process.
  • the stereo message that meets the requirements for the transmission of the stereo message is converted into a stereo message required by the service application layer.
  • step 101 the calculation formula of the length of the buffer is: + /; where ⁇ is the length of the buffer; ⁇ is the length of the body of the stereo message; N is the total number of data pointers contained in the stereo message; L n is the nth data pointer The length of the data referenced.
  • step 101 the dynamically allocated memory is dynamically and continuously allocated memory, and the memory allocation redundancy is zero. Then, step 101 further includes:
  • Step 1011 Dynamically and continuously allocate memory for the data pointer in the stereo message, and dynamically and continuously allocate memory for the data referenced by the data pointer in the stereo message.
  • the values of the memory are dynamically allocated in turn, and the values will be cached and updated in time. Also, the value of the cache is to obtain the / described in the subsequent step 102a.
  • Step 1011b Starting from the P + position of the memory of the buffer, the following formula (1) is taken as ⁇ .P to divide the memory of the length to realize dynamic continuous allocation of the memory.
  • the ⁇ here indicates the length of the data pointer reference data.
  • the L n in the formula represents the length of the data pointer.
  • step 102 further comprises the step of calculating the offset of the buffer, specifically: step 102a, the recording ::; 5 offset within the buffer / p ", and the" :: The offset of the referenced data in the buffer / discourse; wherein, the /iller is the value corresponding to the cache operation in step 1011c above, rather than the value corresponding to the update operation, and the cache operation on the value corresponding to the cache operation In the middle, complete the record of / cauliflower; the following formula (2) is obtained:
  • step 102 The specific processing procedure of step 102 is:
  • step 201 converting the offset in the stereo message packet buffer into a local data pointer, specifically obtained by the following formula (4):
  • Step 301 Obtain a send buffer.
  • Step 302 Allocate a memory for the body of the stereo message to be sent in the buffer, and record the pointer of the stereo message as P.
  • Step 303 Construct a body of the stereo message to be sent on the sending buffer.
  • Step 304 Dynamically allocate continuous memory for the data pointer in the body of the stereo message in the sending buffer.
  • Step 305 Construct data pointed by the data pointer in the body of the stereo message.
  • Step 306, step 304 and step 305 are repeated until the data pointers in the body of the stereo message are all processed.
  • Step 307 Convert the data pointer value in the body of the stereo message packet into an offset value in the buffer.
  • Step 308 Calculate the total length of the stereo message obtained after dynamic planarization, and record it as .
  • Step 309 Encapsulate the pointer sent by the stereo message packet and the total length of the stereoscopic message obtained by the dynamic planarization, and send the stereo message packet.
  • Step 401 Obtain a buffer of the received stereo message, and extract the sum.
  • Step 402 The buffer offset in the converted stereo message packet is a local data pointer.
  • the system receiver directly obtains the local data pointer according to the buffer offset according to the inverse transform.
  • Step 403 Repeat step 402 until the data pointer in the body of the stereo message packet is completely processed, and the execution ends.
  • the method of the present invention is illustrated by the following examples.
  • the method embodiment of the present invention includes: a dynamic planarization process at the transmitting end, and a stereoscopic processing process at the receiving end.
  • the dynamic planarization process at the sender includes the following steps:
  • Step 501 Obtain a send buffer.
  • L b , L m , N and ⁇ are integers.
  • L m and N can be directly obtained from the data structure expressing the stereo message, and the service of the runtime is assigned.
  • L n should be obtained by the formula (5), that is, the alignment value Ln' is substituted for L n .
  • Ln (Ln + S - ⁇ ) / S ( 5 )
  • S is the alignment value, and any one of 1, 2, 4, 8, 16 can be used.
  • Step 503 Assign a value to the pointer P of the stereo message.
  • Step 504 Starting from the P+ position of the memory of the buffer, the above formula (1) is taken as ⁇ : and the memory of the length is divided to realize dynamic continuous allocation of the memory.
  • step 504 since the dynamic continuous allocation of the memory is realized by the above formula (1) in step 504, the memory redundancy allocation is eliminated, and the memory redundancy allocation can be reduced to zero. This reduces the system's memory requirements and significantly reduces inter-process message traffic.
  • step 505 the algorithm used in step 505, that is, the above formula (2), can ensure reliable acquisition of the offset of the data pointer itself, thereby converting the data pointer in the body of the stereo message into a buffer for the subsequent step 508.
  • the offset conversion provides a reliable guarantee.
  • Step 506 Assign a value to the referenced data.
  • Step 507, step 504, step 505, and step 506 are repeated until the data pointers in the stereo message body are all processed.
  • step 507 defines a loop process. If the processed stereoscopic message contains a data pointer of type 7 ⁇ as shown in FIG. 2, that is, a data pointer contained in data referenced by the data pointer, which may be referred to as a secondary data pointer, the secondary is guaranteed.
  • the data pointer When the data pointer is processed, the data pointer of the data block in which the secondary data pointer is located may be referred to as the primary data pointer has been processed.
  • Processing completion means that step 504, step 505, and step 506 have been performed.
  • step 507 when step 507 is completed, a sequence of U pn , / perhaps , , ne [l, N] 0 is obtained, and step 508 is performed, and the value of _ in the sequence (I p réelle, I n ) is written.
  • the referenced memory that implements this conversion is obtained by taking the above formula (3).
  • Step 508 the data pointer in the body of the stereo message is converted into a buffer offset.
  • Step 509 Calculate a total length of the stereo message that is obtained after the stereoscopic message is dynamically planarized.
  • Step 510 Send a stereo message packet by using a pointer P of the stereo message and a total length of the stereo message obtained after the dynamic planarization.
  • the stereo processing process of the receiving end includes the following steps:
  • Step 601 Obtain a pointer of the received stereo message packet as P.
  • P is the data pointer of the received stereo message.
  • Step 602 Convert the buffer offset in the stereo message packet to the local data pointer by using the above formula (4).
  • Step 603, step 602 is repeated, until all the data pointers in the body of the stereo message body are processed, and the execution ends.
  • the flattening process of the transmitting end and the stereoscopic process of the receiving end are encapsulated into two sets of routines for use by the business application layer.
  • the PopFrame ( ) routine converts the offset in the dynamic flattened stereo message packet buffer to a pointer, and stereoscopically receives the received dynamic planarized stereo message.
  • the GetFrame ( ) routine on the sender side replaces the malloc ( ) or new ( ) routines provided by the language library to ensure that the service application layer will correctly allocate memory for sending stereoscopic messages. All conversion preparation information is processed internally.
  • YieldMessage the business application layer can operate freely and access the stereoscopic message as defined by the stereo message.
  • YieldMessage the business application layer can send the message directly.
  • the present invention is implemented by using the above routine, so that the service application layer does not have to care about the conversion process of the stereo message and its specific details while obtaining the benefits obtained by using the invention, which greatly simplifies the process of the service application layer transmitting the stereo message.
  • the package can be obtained due to the specific operation of the routine. The security guarantee brought by it.
  • the present invention realizes a stereo message and a stereo message by a transform and inverse transform technique between a data pointer in a stereo message and an offset in a stereo message, and a new technique for obtaining an offset in a stereo message packet.
  • the dynamic conversion completes the sending and receiving of the stereo message.
  • the message of the present invention is simple to express, and a set of data structure, that is, the pointer data structure description, can be used, and it is not necessary to maintain two sets of data structures as in the prior art, thereby eliminating message heterogeneity.
  • This avoids a series of problems caused by heterogeneous message expression, such as memory copy count / memory copy size increase and system design complexity increase.
  • the technique of dynamically and continuously allocating data blocks of the present invention can better eliminate memory redundancy allocation, reduce system memory requirements, and significantly reduce inter-process data traffic.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Data Exchanges In Wide-Area Networks (AREA)

Abstract

本发明公开了一种发送复杂消息的方法,在发送端将立体消息里的数据指针转化为立体消息报文缓冲区内的偏移,从而将立体消息转化为满足立体消息发送需要的立体消息报文。由于数据指针和将数据指针转化后生成的偏移都是以指针数据结构描述的,转化不存在消息表达异构。在接收端接收到 发送端发送的立体消息报文后,将立体消息报文缓冲区内的偏移转化为本地数据指针,便快速获得立体消息。本发明避免了消息表达异构导致的问题,而且能更好地消除内存冗余分配,降低系统对内存的需求,使进程间消息流量显著降低。

Description

一种发送复杂消息的方法 技术领域
本发明涉及发送复杂消息的技术, 尤其涉及一种在进程间发送复杂消息 的方法。
背景技术
在通信领域的系统实现中, 进程间通信实际上就是在进程间发送消息, 而发送消息的具体实现通常是: 将消息以消息报文的形式封装后, 在进程间 发送该消息报文。 由于进程之间的独立性, 发送消息报文的过程都可抽象为 将消息报文从源緩存区拷贝到目的緩存区的过程, 如图 1所示, 可直观得出 发送消息报文过程的抽象。 然而, 对于含有数据指针的复杂消息, 由于该复 杂消息中既包括了数据指针本身, 又包括了数据指针所引用的数据, 因此, 仍然釆用上述将消息报文从源緩存区拷贝到目的緩存区的简单拷贝操作, 将 只拷贝了数据指针本身, 而未拷贝指针所引用的数据, 从而导致该复杂消息 发送失败。
为了便于描述, 以下将含有一个或多个数据指针的复杂消息简称为立体 消息。 立体消息以含有一个或多个数据指针为核心特征, 如图 2所示, 可直 观看出立体消息的这一核心特征。 一个数据指针还可以被包含在被其他数据 指针所引用的一数据块里。 针对立体消息而言, 必须首先将立体消息封装为 可发送的消息报文后, 才能进行发送。 将通过对立体消息施加处理而得到的 可以发送的消息报文简称为立体消息报文。
现有技术中, 釆用静态平面化技术获得立体消息报文是: 将立体消息中 的数据指针本体转化为固定长度的字节序列, 也就是将以指针数据结构描述 的数据指针本体转化为以数组数据结构描述的数组, 使数据指针本体和数据 指针本体所引用的数据全部驻留在立体消息里。 现有技术存在的缺陷是: 由于系统中需设置两套数据结构, 即指针数据 结构和数组数据结构, 因此会导致消息表达异构的问题。 而消息表达异构, 随之会带来一系列问题, 比如内存拷贝次数增加; 内存分配冗余; 内存分配 冗余导致的内存拷贝量增加; 系统效率运行低下以及系统设计复杂度增加等。 发明内容
有鉴于此, 本发明的主要目的在于提供一种发送复杂消息的方法, 不仅 能实现立体消息报文的发送, 而且消息表达简单, 避免了消息表达异构导致 的一系列问题。
为达到上述目的, 本发明的技术方案是这样实现的:
一种发送复杂消息的方法, 该方法包括:
在緩冲区上为待发送的立体消息动态分配内存;
将所述立体消息里的数据指针转化为立体消息报文緩冲区内的偏移后, 发送所述立体消息报文。
其中, 所述发送立体消息报文后还包括: 将立体消息报文緩冲区内的偏 移转化为本地数据指针。
其中, 所述动态分配内存为动态连续地分配内存, 并实现内存分配冗余 为零;
在发送端, 所述在緩冲区上为待发送的立体消息动态分配内存进一步包 括:
为所述立体消息中的数据指针动态连续地分配内存, 以及为立体消息中 数据指针所引用的数据动态连续地分配内存。
其中, 所述緩冲区的长度的计算公式为:
Figure imgf000004_0001
其中, ^为緩冲区的长度; 为所述立体消息报文的主体的长度; N为 所述立体消息中含有的数据指针的总个数; Ln 为第 n个数据指针所引用的 数据的长度。
其中, 所述为立体消息中的数据指针动态连续地分配内存, 以及为立体 消息中数据指针所引用的数据动态连续地分配内存具体包括: Al、通过划分所述 长度的内存, 在所述緩冲区上为所述立体消息报文 的主体分配内存,记录所述立体消息报文的指针为 P ;根据 = 计算出当前 立体消息报文的总长度值; 其中, 为所述立体消息报文的当前的总长度;
A2、 从所述緩冲区的内存的 P + 位置开始, 釆取以下公式为 P„:: P划分 ^长度的内存, 实现内存的动态连续分配;
[Pn :: P ]=[P] + L ; 所述公式中, P„:: P表示所述 P中的第 n个数据指针; [P„:: P ]表示访问以 Pn:: P的值为地址的内存单元的内容; [P ]表示访问以 P的值为地址的内存单 元的内容;
A3、 緩存 J值; 同时根据^的值更新 J值:
L = L + Ln ;
公式中, ^表示该数据指针引用数据的长度。 其中, 所述将立体消息里的数据指针转化为立体消息报文緩冲区内的偏 移之前还包括:
记录所述 :: P在所述緩冲区内的偏移 Ιρ„ , 以及所述 :: Ρ引用的数据在 緩冲区内的偏移 /„; 其中, 所述 /„为所述步骤 A3中緩存操作对应的 值, 并 在对所述 值的緩存操作中, 完成对 /„的记录; 所述 釆取以下公式获得:
公式中, φρη '.'. ρ )表示取存放 „:: ρ的内存地址。
其中, 所述将立体消息里的数据指针转化为立体消息报文緩冲区内的偏 移具体为:
根据所述 /„和所述 获得序列 ( ιρ„, Ιη ) ; 将所述序列 Up„, /„ ) 中 的 /„值写入相对应的 所引用的内存, 实现所述转换, 釆取以下公式获得:
公式中, [Ρ + /ρ„]表示访问以 P + /p„的值为地址的内存单元的内容。 其中, 所述将立体消息报文緩冲区内的偏移转化为本地数据指针具体釆 取以下公式获得: [# P„:: P ] = P + Pn . P ;
其中, [# P„:: P ]表示访问以 # P„ .... P的值为地址的内存单元的内容; # P„ P表示取存放 P„:: P的内存地址。
在发送端本发明动态连续分配数据块; 本发明区别于现有技术, 是对立 体消息进行动态平面化后获得立体消息报文, 即为: 将立体消息里的数据指 针转化为立体消息报文緩冲区内的偏移, 从而将业务应用层定义的、 满足业 务应用层需要的立体消息转化为满足立体消息发送需要的立体消息报文。 由 于数据指针和将数据指针转化后生成的偏移都是以指针数据结构描述的, 因 此, 为了同时满足业务应用层需要和立体消息发送需要, 这种转化不存在消 息表达异构, 从而避免了消息表达异构所导致的一系列问题。 在接收端, 本 发明区别于现有技术, 无需专门在系统中设计转换模块, 而是对立体消息报 文进行立体化后获得立体消息, 即为: 接收端接收到发送端发送的立体消息 报文, 将立体消息报文緩冲区内的偏移转化为本地数据指针, 来快速获得业 务应用层需要的立体消息。 其中, 动态平面化实际上是立体消息里的数据指 针与立体消息报文里的偏移之间的变换, 而立体化实际上立体消息里的数据 指针与立体消息报文里的偏移之间的逆变换。
综上所述, 本发明通过立体消息里的数据指针与立体消息报文里偏移之 间的变换与逆变换技术, 以及获得立体消息报文里偏移的新技术, 实现立体 消息与立体消息报文的动态转换, 完成立体消息报文的发送与接收。 不仅能 实现立体消息报文的发送, 而且本发明消息表达简单, 使用一套数据结构即 指针数据结构描述即可, 无需像现有技术那样维护两套数据结构, 消除了消 息表达异构。 从而避免了消息表达异构导致的一系列问题, 比如内存拷贝次 数 /内存拷贝量的增加和系统设计复杂度增加等。 而且, 本发明釆用数据块动 态连续分配的技术, 能更好地消除内存冗余分配, 降低系统对内存的需求, 使进程间消息流量显著降低。
附图概述 图 1为消息报文发送的通用示意图;
图 2为具有一个或多个数据指针的立体消息的示意图;
图 3为应用现有静态平面化技术得到的立体消息报文的示意图; 图 4 为静态平面化后产生的内存冗余的示意图;
图 5 为应用本发明动态平面化技术得到立体消息报文的示意图; 图 6 是应用本发明动态平面化和立体化技术的整个过程的示意图; 图 7为本发明方法的实现流程示意图。
本发明的较佳实施方式
本发明的基本思想是: 通过立体消息里的数据指针与立体消息报文里偏 移之间的变换与逆变换技术, 以及获得立体消息报文里偏移的新技术, 实现 立体消息与立体消息报文的动态转换, 完成立体消息报文的发送与接收。
下面结合附图对技术方案的实施作进一步的详细描述。
以下将现有技术和本发明进行对比阐述, 以更好地体现本发明相对于现 有技术的优点。
就现有技术而言, 在现有技术中, 获得立体消息报文的方法釆用静态平 面化技术。 具体来说, 将立体消息中的数据指针本体转化为固定长度的字节 序列, 也就是将以指针数据结构描述的数据指针本体转化为以数组数据结构 描述的数组, 然后将数据指针本体所引用的数据放入转化生成的数组中。 从 而, 让数据指针本体和数据指针本体所引用的数据全部驻留在立体消息里。 那么通过对立体消息施加上述静态平面化的处理, 就形成了可发送的立体消 息报文。 釆用静态平面化技术得到的立体消息报文如图 3所示。 图 4为静态 平面化后产生的内存冗余的示意图, 图 4中, 阴影填充的部分代表当前使用 的内存, 空白的部分代表冗余分配的内存。
现有技术存在的缺点包括以下几个方面。
第一方面、 釆用现有技术会导致消息表达异构。 原因在于: 在业务应用 层, 也就是实际操作时使用的立体消息表达方式是: 数据指针本体加数据指 针本体所引用的数据; 而在进程间通信发送立体消息时需要釆用立体消息报 文, 也就是说包含数据指针本体的立体消息是不可以直接发送的, 为了实现 立体消息的发送需要将数据指针本体转化为数组, 那么在进程间通信发送立 体消息时使用的立体消息表达方式是: 由对数据指针本体转化生成的数组加 原数据指针本体所引用的数据。 由于数据指针本体是以指针这种数据结构描 述的, 而数组是釆用另一种数据结构, 即以数组数据结构描述的。 因此, 为 了适应同一条立体消息在业务应用层操作和立体消息发送的不同需要, 系统 内将定义两种类型的数据结构, 从而系统在读 /写等操作过程中, 要根据当前 需要选择使用其中一个数据结构表达的立体消息, 带来操作混乱。
而且, 消息表达异构会进一步产生额外的内存拷贝次数的开销。 原因在 于: 通常的拷贝操作指: 消息报文发送过程中的数据拷贝操作。 也就是说, 将消息报文直接拷贝到系统中即可。 而针对消息表达异构的立体消息而言, 由于为了立体消息的发送定义了数组这种额外的数据结构, 因此立体消息的 拷贝操作为: 先将原数据指针本体所引用的数据拷贝到数组中, 再将数组拷 贝到系统中。 也就是说, 立体消息的拷贝操作额外增加了由立体消息到釆用 静态平面化技术所获得的立体消息报文的拷贝过程, 然后才执行上述通常的 拷贝操作。
第二方面、釆用现有技术会导致内存分配冗余和内存拷贝量增加的问题。 原因在于: 针对内存分配冗余而言, 对数据指针本体转化生成的数组通常不 是按照实际需要定义的, 也就是说, 预先定义时并不知道实际数据长度, 数 组是按照最大数据长度来统一定义的。 那么, 在业务应用层面的立体消息里, 以数据指针和实际数据长度来表示的数据, 为了满足立体消息发送的需要, 将数据指针转化成数组后, 都被最大化的分配在静态平面化后的立体消息报 文主体里。 从而, 导致经静态平面化后的立体消息报文的结构会非常大, 按 照最大数据长度来统一定义数组并分配内存, 必然导致内存分配冗余。 针对 内存拷贝量增加而言, 由于按照最大数据长度来统一定义数组并分配内存, 内存冗余, 因此, 在每一次执行拷贝操作时也是按照最大数据长度执行拷贝, 而不是按照实际数据长度执行拷贝。 也就是说, 内存冗余导致每次都要拷贝 最大化的数据, 使内存拷贝量增加。 第三方面、 釆用现有技术会导致效率低下的问题。 原因在于: 内存冗余 造成内存拷贝量的增加, 以及由于消息表达异构而造成的内存拷贝次数的增 加均造成系统开销很大, 从而导致系统效率运行低下。
第四方面、 釆用现有技术会导致对报文访问的操作复杂, 从而带来系统 设计复杂度增加的问题。 原因在于: 由于釆用静态平面化技术获得的立体消 息报文存在消息表达异构的问题, 因此, 立体消息的接收方不能直接使用接 收到的立体消息报文, 而必须通过转换模块, 将立体消息报文中的数组转换 成数据指针, 以满足业务应用层的需要, 这样势必增加系统设计的复杂度。 本发明应运而生, 解决了现有技术存在的上述四方面问题。 应用本发明 动态平面化技术得到立体消息报文的布局如图 5所示。 应用本发明动态平面 化和立体化技术, 来发送与接收立体消息报文的过程如图 6所示, 图 6中, 发送端的立体消息的业务数据表示即为: 满足业务应用层需求、 包含数据指 针和数据指针所引用的数据的立体消息, 动态平面化后的立体消息即为: 在 发送端对该立体消息经过动态平面化技术处理后获得的立体消息报文。
本发明消息表达简单, 使用一套数据结构即指针数据结构描述即可。 无 需像现有技术那样, 专门为了实现立体消息报文的发送定义额外的数据结构 即数组数据结构, 维护两套数据结构, 可见釆用本发明消除了消息表达异构, 从而避免了消息表达异构导致的一系列问题。
具体来说, 本发明通过立体消息里的数据指针与立体消息报文里偏移之 间的变换与逆变换技术, 使消息的表达方式简便, 消除了消息表达异构。 并 釆用封装全部本地数据指针与緩冲区偏移之间的变换操作的手段, 使系统接 收端直接根据緩冲区偏移, 经逆变换获得本地数据指针, 而无需像现有技术 那样, 专门在接收端设计转换模块。 可见, 釆用本发明, 消除消息表达异构 的同时, 极大地降低了系统设计的复杂度。 消除消息表达异构的同时, 本发 明基于可靠的数据块动态连续分配技术来分别分配立体消息报文中数据指针 本体所占的内存, 以及数据指针本体所引用数据块所占的内存。 这种对内存 的二次动态连续分配技术, 是按照实际数据长度进行的动态分配, 区别于现 有技术是按照最大数据长度统一预先分配的方式。 可见, 釆用本发明使得内 存分配冗余降为 0, 大大提高了内存的使用率。 当内存分配冗余降为 0时, 立体消息报文发送过程中的内存拷贝的长度降至最短, 内存拷贝次数和内存 拷贝量都大幅度减少, 从而大大提高了系统运行效率。
以下对本发明所釆用的发送复杂消息的方法进行具体阐述。
如图 7所示, 一种发送复杂消息的方法, 该方法包括以下步骤: 步骤 101、 在緩冲区上为待发送的立体消息动态分配内存。
步骤 102、 将该立体消息里的数据指针转化为立体消息报文緩冲区内的 偏移后, 发送该立体消息 4艮文。
这里, 在发送端将该立体消息里的数据指针转化为立体消息报文緩冲区 内的偏移的处理可称为动态平面化处理过程。 通过对立体消息的动态平面化 处理, 实现了将符合业务应用层需要的立体消息转化为符合立体消息发送需 要的立体消息报文。 当在发送端对立体消息釆取动态平面化处理获得立体消 息报文后,发送该立体消息报文; 当接收端收到该立体消息报文后, 步骤 102 后还包括:
步骤 201、 将立体消息报文緩冲区内的偏移转化为本地数据指针。
这里, 在接收端将立体消息报文緩冲区内的偏移转化为本地数据指针的 处理可称为立体化处理过程。 通过对立体消息报文的立体化处理, 实现了将 符合立体消息发送需要的立体消息报文转化为业务应用层需要的立体消息。
以下对上述步骤的技术实现进行细化并具体阐述上述步骤实现的技术细 节。 其中, 步骤 101中, 该緩冲区的长度的计算公式为:
Figure imgf000010_0001
+ /; 其中, ^为緩冲区的长度; 为所述立体消息报文的主体的长度; N为所 述立体消息中含有的数据指针的总个数; Ln 为第 n个数据指针所引用的数 据的长度。 而且, 步骤 101 中, 动态分配内存为动态连续地分配内存, 并实 现内存分配冗余为零。 那么, 步骤 101进一步包括:
步骤 1011、 为立体消息中的数据指针动态连续地分配内存, 以及为立体 消息中数据指针所引用的数据动态连续地分配内存。
这里, 步骤 1011的具体处理过程包括: 步骤 1011a、 通过划分所述 A„长度的内存, 在所述緩冲区上为所述立体 消息报文的主体分配内存, 记录所述立体消息报文的指针为 P; W =Lm 计算出当前立体消息报文的总长度值; 其中, 为所述立体消息报文的当前 的总长度。
这里, 针对 而言, 随着为立体消息里的多个指针, 依次动态分配内存 的进行, 的值将被及时的緩存和更新。 并且, 緩存 的值是为了获得后续 步骤 102a中描述的 /„。
步骤 1011b、从緩冲区的内存的 P + 位置开始,釆取以下公式( 1 )为^ .P 划分^长度的内存, 实现内存的动态连续分配。 这里的 ^表示该数据指针引 用数据的长度。
[Pn :.P]=[P] + L (1 ) 公式(1 ) 中, P„::P表示所述 P中的第 n个数据指针; [P„::P]表示访问 以^:: P的值为地址的内存单元的内容; [P ]表示访问以 P的值为地址的内存 单元的内容。
步骤 1011c、 緩存 J值; 同时根据^的值釆用公式 = + „来更新 J值。 公式中的 Ln表示该数据指针弓 )用数据的长度。
其中, 步骤 102之前还包括计算緩冲区的偏移的步骤, 具体为: 步骤 102a、记录所述 ::;5在所述緩冲区内的偏移 /p„, 以及所述 „ :: 引 用的数据在緩冲区内的偏移 /„; 其中, 所述 /„为上述步骤 1011c中緩存操作 对应的 值, 而非更新操作对应的 值, 并在对緩存操作对应的 值的緩存操 作中, 完成对 /„的记录; 所述 釆取以下公式(2)获得:
Figure imgf000011_0001
公式(2) 中, (#P„::P)表示取存放 ::P的内存地址。
其中, 步骤 102的具体处理过程为:
根据所述 /„和所述 获得序列 ( Ιρ„, Ιη ) ; 将所述序列 Ιρ„, /„ ) 中 的 /„值写入相对应的 所引用的内存, 实现所述转换, 釆取以下公式(3) 获得:
Figure imgf000011_0002
公式(3) 中, [Ρ + /ρ„]表示访问以 P + /p„的值为地址的内存单元的内容。 其中, 步骤 201的具体处理过程为: 将立体消息报文緩冲区内的偏移转 化为本地数据指针具体釆取以下公式(4)获得:
[#P„ P]= P + Pn .P (4) 公式(4)中, [#P„ ::P]表示访问以 #P„ ::P的值为地址的内存单元的内容;
# P„ P表示取存放 P„:: P的内存地址。
结合实际应用, 对实现发送端的动态平面化处理过程的原理, 以及接收 端的立体化过程的原理进行阐述。
针对发送端的动态平面化处理过程而言, 包括以下步骤:
步骤 301、 获得发送緩冲区。
步骤 302、 在该緩冲区上为待发送的立体消息报文的主体分配内存, 记 录该立体消息报文的指针为 P。
这里需要指出的是, 由于需要将立体消息处理成立体消息报文后才可以 发送, 因此需要预先对立体消息报文进行内存分配和构造。
步骤 303、 在发送緩冲区上构建要发送的立体消息报文主体。
步骤 304、 在发送緩冲区上, 为立体消息报文主体里的数据指针动态分 配连续的内存。
步骤 305、 构建立体消息报文主体里的数据指针所指向的数据。
步骤 306、 重复步骤 304 和步骤 305 , 直到立体消息报文主体里的数据 指针全部处理完成。
步骤 307、 将立体消息报文主体里的数据指针值转化为緩冲区内的偏移 值。
步骤 308、计算经动态平面化后获得的立体消息报文的总长度,记录为 。 步骤 309、将立体消息报文的指针 P, 和经动态平面化后获得的立体消息 报文的总长度 这两个立体消息报文发送的参数进行封装, 发送立体消息报 文。
针对接收端的立体化处理过程而言, 包括以下步骤: 步骤 401、 获得接收到的立体消息报文的緩冲区, 并提取出卩和 。 步骤 402、 转化立体消息报文里的緩冲区偏移为本地数据指针。
这里, 由于在立体消息发送时, 釆用了封装全部本地数据指针与緩冲区 偏移之间变换与逆变换的操作这一技术手段, 因此, 根据 P以及提取出该变 换操作的具体实现, 使系统接收端直接根据緩冲区偏移, 经逆变换获得本地 数据指针。
步骤 403、 重复执行步骤 402, 直到立体消息报文主体里的数据指针全部 处理完成, 结束执行。
以下举例对本发明的方法进行阐述。 本发明的方法实施例包括: 发送端 的动态平面化处理过程, 以及接收端的立体化处理过程两方面的内容。
针对发送端的动态平面化处理过程而言, 发送端的动态平面化处理过程 包括以下步骤:
步骤 501、 获得发送緩冲区。 该緩冲区的长度可以由业务数据的需求获 得, 具体来说, 釆用计算公式为: = 获得。
Figure imgf000013_0001
公式中, ^为緩冲区的长度; 为所述立体消息报文的主体的长度; N 为立体消息中含有的数据指针的总个数; Ln 为第 n的数据指针所引用的数 据的长度。 Lb、 Lm、 N和 ^均为整数。 这里, Lm 和 N可以直接由表达立 体消息报文的数据结构获得, 为运行期的业务赋值。
这里需要指出的是,由于处理器的对齐原因,如果需要 S字节对齐,则 Ln 应该以通过公式( 5 )获得, 即取对齐值 Ln'代替 Ln
Ln = (Ln + S - \) / S ( 5 ) 公式(5 ) 中, S 为对齐值, 取 1 , 2, 4, 8, 16中任一个即可。
步骤 502、 通过划分 ^长度的内存, 在所述緩冲区上为立体消息报文的 主体分配内存, 记录立体消息报文的指针为 P , 则相当于得到緩冲区上的立 体消息。 根据 = 计算出当前立体消息报文的总长度值; 其中, 为立 体消息报文的总长度。 这里需要指出的是, 由于需要将立体消息处理成立体消息报文后才可以 发送, 因此需要预先对立体消息报文进行内存分配和构造。
步骤 503、 为立体消息报文的指针 P赋值。
步骤 504、从緩冲区的内存的 P + 位置开始,釆取上述公式( 1 )为^ :: 划分^长度的内存, 实现内存的动态连续分配。
这里, 由于步骤 504里釆用上述公式(1 ) 实现了内存的动态连续分配, 因此, 消除了内存冗余分配, 可使内存冗余分配降低到零。 从而降低了系统 对内存的需求, 使进程间消息流量显著降低。
步骤 505、 记录 :: P在緩冲区内的偏移 以及 :: P引用的数据在緩 冲区内的偏移 /„; 其中, /„即为 ; 釆取上述公式(2 )获得; 釆用公式 L = L + Ln , 计算出当前立体消息报文的总长度值, 更新立体消息报文的总长 度 。
这里, 步骤 505所釆用的算法, 即上述公式(2 ) , 能保证可靠的获得数 据指针自身的偏移, 从而为后续步骤 508 , 对立体消息报文主体里的数据指 针转化为緩冲区偏移的转换提供了可靠保证。
步骤 506、 为 所引用的数据赋值。
步骤 507、 重复步骤 504、 步骤 505和步骤 506 , 直到立体消息 文主 体里的数据指针全部处理完成。
这里, 步骤 507定义了一个循环处理过程。 如果被处理的立体消息里包 含如图 2所示的 7^类型的数据指针,即在一个被数据指针所引用的数据里包 含的数据指针, 可简称次级数据指针, 则要保证该次级数据指针被处理时, 引用此次级数据指针所在的数据块的数据指针, 可简称初级数据指针已经被 处理完毕。 处理完毕意味着已经执行完步骤 504、 步骤 505和步骤 506。
这里, 步骤 507完成时, 得到一个 和 /„的序列 Upn , /„ ) , n e [l, N] 0 步骤 508、 将序列 ( Ip„, In ) 中的 /„值写入相对应的 所引用的内存, 实现这种转换, 釆取上述公式(3 )获得。
这里, 通过步骤 508的转换, 就完成了立体消息报文主体里的数据指 针转化为緩冲区偏移。 步骤 509、 计算立体消息经动态平面化后获得的立体消息报文的总长度 为 。
步骤 510、以立体消息报文的指针 P和经动态平面化后获得的立体消息报 文的总长度 发送立体消息报文。
针对接收端的立体化处理过程而言, 接收端的立体化处理过程包括以下 步骤:
步骤 601、 获得接收到的立体消息报文的指针为 P。 通常, P是收到的立 体消息报文的数据指针。
步骤 602、 以上述公式(4 )转化立体消息报文里的緩冲区偏移为本地数 据指针。
步骤 603、 重复步骤 602, 直到立体消息报文主体里的数据指针全部处理 完成, 结束执行。
在具体实施过程中, 将发送端的平面化过程和接收端的立体化过程封装 为两组例程供业务应用层使用。
在发送端,以 GetFrame( )例程实现内存的动态连续分配,以 YieldMessage
( ) 最终完成动态平面化转换并返回动态平面化后立体消息报文的长度, 以 提供发送时必须的消息长度参数。
在接收端, 以 PopFrame ( )例程转换动态平面化后立体消息报文緩冲区 内的偏移为指针, 实现对接收到的动态平面化后的立体消息报文进行的立体 化。
发送端的 GetFrame ( )例程替代语言库提供的 malloc ( )或 new ( )等 例程, 保证业务应用层对待发送立体立体消息进行正确的内存分配。 并内部 处理所有转换准备信息。 在使用 YieldMessage ( )之前, 业务应用层可以按 照立体消息的定义自由操作、 访问该立体消息。 在使用 YieldMessage ( )之 后, 业务应用层可直接发送该消息。
使用以上例程实现本发明, 使业务应用层在获得使用本发明所获得的收 益的同时, 又不必关心立体消息的转换过程及其具体细节, 极大的简化了业 务应用层发送立体消息的过程, 同时, 可以获得由于例程对具体操作的封装 所带来的安全性保证。
以上所述, 仅为本发明的较佳实施例而已, 并非用于限定本发明的保护 范围。
工业实用性 本发明通过立体消息里的数据指针与立体消息报文里偏移之间的变换与 逆变换技术, 以及获得立体消息报文里偏移的新技术, 实现立体消息与立体 消息报文的动态转换, 完成立体消息报文的发送与接收。 不仅能实现立体消 息报文的发送, 而且本发明消息表达简单, 使用一套数据结构即指针数据结 构描述即可, 无需像现有技术那样维护两套数据结构, 消除了消息表达异构。 从而避免了消息表达异构导致的一系列问题, 比如内存拷贝次数 /内存拷贝量 的增加和系统设计复杂度增加等。 而且, 本发明釆用数据块动态连续分配的 技术, 能更好地消除内存冗余分配, 降低系统对内存的需求, 使进程间数据 流量显著降低。

Claims

权 利 要 求 书
1、 一种发送复杂消息的方法, 包括:
在緩冲区上为待发送的立体消息动态分配内存; 以及
将所述立体消息里的数据指针转化为立体消息报文緩冲区内的偏移后, 发送所述立体消息报文。
2、 根据权利要求 1所述的方法, 在发送所述立体消息报文的步骤之后, 还包括: 将所述立体消息报文緩冲区内的偏移转化为本地数据指针。
3、 根据权利要求 1或 2所述的方法, 其中,
所述动态分配内存的步骤为动态连续地分配内存, 并实现内存分配冗余 为零;
所述在緩冲区上为待发送的立体消息动态分配内存的步骤包括: 在緩冲区上为所述立体消息中的数据指针动态连续地分配内存, 以及为 所述立体消息中的数据指针所引用的数据动态连续地分配内存, 并实现内存 分配冗余为零。
4、根据权利要求 3所述的方法,其中,所述緩冲区的长度的计算公式为:
N
Z b, = / z n + L m - ,
n=l
其中, ^为緩冲区的长度; Α„为所述立体消息报文的主体的长度; Ν为 所述立体消息中含有的数据指针的总个数; Ln 为第 n个数据指针所引用的数 据的长度。
5、 根据权利要求 4所述的方法, 其中, 为所述立体消息中的数据指针动 态连续地分配内存, 以及为所述立体消息中数据指针所引用的数据动态连续 地分配内存的步骤包括:
Al、通过划分所述 Α„长度的内存, 在所述緩冲区上为所述立体消息报文 的主体分配内存, 记录所述立体消息报文的指针为 Ρ ; 根据 = 计算出当 前立体消息报文的总长度值; 其中, 为所述立体消息报文的当前的总长度; A2、 从所述緩冲区的内存的 P + 位置开始, 釆取以下公式为 P„::P划分 „长度的内存, 实现内存的动态连续分配;
[Pn::P]=[P] + L;
所述公式中, P„::P表示所述 P中的第 n个数据指针; [P„::P]表示访问以 P„ ::P的值为地址的内存单元的内容; [P]表示访问以 P的值为地址的内存单 元的内容; 以及
A3、 緩存 J值; 同时根据^的值更新 J值:
L = L + Ln;
公式中, Ln表示所述第 n个数据指针弓 I用数据的长度。
6、根据权利要求 5所述的方法, 在将所述立体消息里的数据指针转化为 立体消息报文緩冲区内的偏移的步骤之前, 还包括:
记录所述 :: P在所述緩冲区内的偏移 Ιρ„ , 以及所述 :: Ρ引用的数据在 緩冲区内的偏移 /„; 其中, 所述 /„为所述步骤 A3中緩存操作对应的 值, 并 在对所述 值的緩存操作中, 完成对 /„的记录; 所述 釆取以下公式获得:
Figure imgf000018_0001
公式中, φρη'.'.ρ )表示取存放 „:: ρ的内存地址。
7、 根据权利要求 6所述的方法, 其中, 将所述立体消息里的数据指针转 化为立体消息报文緩冲区内的偏移的步骤包括:
根据所述 /„和所述 获得序列 ( ιρ„, Ιη ) ; 将所述序列 Up„, /„ ) 中 的 /„值写入相对应的 所引用的内存, 实现所述转换, 釆取以下公式获得:
公式中, [ P + ]表示访问以 P + ιρη的值为地址的内存单元的内容。
8、 根据权利要求 7所述的方法, 其中, 将所述立体消息报文緩冲区内的 偏移转化为本地数据指针的步骤釆取以下公式完成:
[#P„ P]= P + Pn:. P;
其中, [# P„:: P ]表示访问以 # P„ .... P的值为地址的内存单元的内容; #P„'.'.P表示取存放 P„:: P的内存地址。
PCT/CN2009/074390 2008-12-02 2009-10-10 一种发送复杂消息的方法 WO2010063198A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN200810227934.3 2008-12-02
CN200810227934A CN101753540A (zh) 2008-12-02 2008-12-02 一种发送复杂消息的方法

Publications (1)

Publication Number Publication Date
WO2010063198A1 true WO2010063198A1 (zh) 2010-06-10

Family

ID=42232884

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2009/074390 WO2010063198A1 (zh) 2008-12-02 2009-10-10 一种发送复杂消息的方法

Country Status (2)

Country Link
CN (1) CN101753540A (zh)
WO (1) WO2010063198A1 (zh)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105068878A (zh) * 2015-07-30 2015-11-18 汉柏科技有限公司 进程间的通信方法及系统

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020087909A1 (en) * 2001-01-03 2002-07-04 Hummel Mark D. Low latency synchronization of asynchronous data
WO2003007558A1 (en) * 2001-07-09 2003-01-23 Overture Networks, Inc. Use of a circular buffer to re-order packets
CN1644386A (zh) * 2005-01-31 2005-07-27 北京北大方正电子有限公司 一种能够提高内存利用率的打印内存管理方法
US20070300267A1 (en) * 2006-06-23 2007-12-27 Sony Ericsson Mobile Communications Ab Method and apparatus to facilitate multimedia transfer

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100426243C (zh) * 2006-09-15 2008-10-15 华为技术有限公司 一种数据结构传输方法

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20020087909A1 (en) * 2001-01-03 2002-07-04 Hummel Mark D. Low latency synchronization of asynchronous data
WO2003007558A1 (en) * 2001-07-09 2003-01-23 Overture Networks, Inc. Use of a circular buffer to re-order packets
CN1644386A (zh) * 2005-01-31 2005-07-27 北京北大方正电子有限公司 一种能够提高内存利用率的打印内存管理方法
US20070300267A1 (en) * 2006-06-23 2007-12-27 Sony Ericsson Mobile Communications Ab Method and apparatus to facilitate multimedia transfer

Also Published As

Publication number Publication date
CN101753540A (zh) 2010-06-23

Similar Documents

Publication Publication Date Title
WO2022105884A1 (zh) 数据传输方法、装置、网络设备、存储介质
JP4477613B2 (ja) AXIプロトコルを適用したNoCシステム
US8352628B2 (en) Method for transferring data from a source target to a destination target, and corresponding network interface
WO2018040629A1 (zh) 键值存储方法、装置及系统
US10496595B2 (en) Method for zero-copy object serialization and deserialization
EP3694274A1 (en) Service data transmission method and apparatus
US7996548B2 (en) Message communication techniques
CN105556930A (zh) 针对远程存储器访问的nvm express控制器
CN106598752B (zh) 远程零拷贝方法
RU2011107517A (ru) Способ и система для передачи потоковых мультимедийных данных с нулевым копированием
WO2018034875A1 (en) Method and apparatus for compressing addresses
EP3077914B1 (en) System and method for managing and supporting virtual host bus adaptor (vhba) over infiniband (ib) and for supporting efficient buffer usage with a single external memory interface
CN102566958B (zh) 一种基于sgdma的图像分割处理装置
WO2019134403A1 (zh) 发送数据包的方法、装置及计算机可读存储介质
US9274586B2 (en) Intelligent memory interface
US11347567B2 (en) Methods and apparatus for multiplexing data flows via a single data structure
US20090086729A1 (en) User datagram protocol (UDP) transmit acceleration and pacing
WO2010063198A1 (zh) 一种发送复杂消息的方法
TW200302413A (en) Netbufs: communication protocol packet buffering using paged memory management
US8898353B1 (en) System and method for supporting virtual host bus adaptor (VHBA) over infiniband (IB) using a single external memory interface
US20160085683A1 (en) Data receiving device and data receiving method
CN116248758A (zh) 一种高效的内核-片上网络的桥式连接结构
CN115167776A (zh) 一种分布式存储数据迁移的方法和系统
CN103747253B (zh) 一种基于fifo的视频编码数据传输方法
Kuang et al. A Modbus Protocol Stack Compatible with RTU/TCP Frames and Embedded Application

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: 09829982

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: 09829982

Country of ref document: EP

Kind code of ref document: A1