Title of Invention: Method for encapsulating data streams
Abstract: 
A method for encapsulating data streams is disclosed in the present invention. In this method, a buffer is preset and a low threshold value is set in the buffer in advance. When the data stream encapsulation is required, firstly it is judged whether the stored data in the buffer reaches the low threshold value, if so, the data in the buffer is segmented according to a predefined length which is less than or equal to the low threshold value, and frame header is added for the segmented data; otherwise no segmenting process for the data in the buffer is implemented. With the present invention, the data stream encapsulation is implemented by performing counter slicing for the received data stream and adding frame header as well as frame trailer. As there is no need to perform any recognition process to the received service when applying the method according to the present invention, the implementation of encapsulation process for discretional service of data stream can be accomplished. Meanwhile, in the present invention there is no need to distinguish data character from control character, resulting in more simple and effective processing procedure. 

Detailed Description: 

CROSS-REFERENCE TO RELATED APPLICATIONS 
 This application claims the benefit of Chinese Patent Application No. 03149588.5 filed on Jul. 17, 2003. The disclosure of the above application is incorporated herein by reference. 
FIELD OF THE INVENTION 
 The present invention relates to data communication technology, especially to a method for encapsulating data streams. 
BACKGROUND OF THE INVENTION 
 With the abroad application of Multi Service Transfer Platform (MSTP), manifold encapsulating modes are emerging, such as Link Access Procedure-SDH (LAPS) protocol, High-level Data Link Control (HLDC), Point-to-Point Protocol (PPP), etc. Manifold services can be encapsulated by utilizing these encapsulating modes, and accordingly the encapsulated services can be transferred. The current standards suggest that one encapsulating mode is used for a certain protocol such as Gigabit Ethernet (GE) and Internet Protocol (IP), or a certain kind of protocols such as coding service protocol at 8B/10B. 
 At present Generic Framing Procedure (GFP) is one of the most popular encapsulating modes, in which a general mechanism is provided to process the client signals of high hierarchy and access the signals to a byte synchronization transfer network. Transparent Generic Framing Procedure (GFP-T) is a standard special for encapsulating data streams, in which it is regulated that the client signal of 8B/10B be encoded at 64B/65B and then be mapped to a GFP format with a fixed length before being sent out. So, unlike packet encapsulation, by utilizing data-stream encapsulation the encapsulated data can be transferred immediately before finishing receiving one frame signal. Accordingly, low delay transfers can be realized. Some protocols, such as fibre channel protocol, Enterprise Systems Connection (ESCON) Protocol, Fibre Connection (FICON), Gigabit Ethernet (GE), etc, can be used for transparent encapsulation. 
 FIG. 1 is a schematic diagram showing an encapsulation structure of GFP-T. Generally speaking, a GFP-T frame is comprised of two parts, namely frame header and payload field. Specially, as for a GFP-T frame, the frame header is also called core header. Core header is comprised of length indicator and Core Header Error Check (cHEC), in which cHEC is a 16-bit Cyclic Redundancy Code (CRC). Payload field is comprised of payload headers having 4˜64 bytes, payload information field and payload FCS, in which payload FCS is a 32-bit CRC and optional in GFP-T frame structure. Payload headers are comprised of 16-bit payload type field and Type Header Error Check (tHEC), in which tHEC is a 16-bit CRC. An idle GFP frame only includes core header. 
 When the GFP-T encapsulation mode is applied to encapsulate 8B/10B service, block decoding is required. If 8B/10B code is a data character, the received 10-bit character is decoded to 8-bit original data. If 8B/10B code is a control character, the received 10-bit character is decoded to control code. Then 64B/65B encoding is implemented for the decoded signal, specifically speaking, in terms of the data character, the 8-bit original data is directly encapsulated to the 65B encoding block, and then the 65B encoding block is placed into payload field of GFP; in terms of the control character, firstly the control code is encoded to a 4-bit control code, then this 4-bit control code is encapsulated to the 65B encoding block, and then the 65B encoding block is placed into payload field of GFP. After every character of the client signal has been decoded, the decoded codes are encapsulated to the GFP with a fixed length in terms of data character or control character. Compared with packet encapsulation mode, by applying GFP-T encapsulation mode there is no need to buffer the whole frame, so the real-time ability of transfers is improved. 
 Generally speaking, bandwidth convergence is not provided in data stream encapsulation service, so it is required that the mapping bandwidth be larger than the basic data rate of client data before being encoded, namely the mapping bandwidth be larger than the original bandwidth. In this way, since the rate of storing the data stream in the First In First Out (FIFO) buffer is less than that of reading out the data stream, there may be vacancy in the data stream. Under such a condition, to guarantee the transferring continuity, when there is no data for mapping transfer in FIFO, if the frame trailer of GFP is being transferred, idle frames are inserted between frames; if the GFP frame is being transferred, fill characters are inserted in the encapsulated GFP frames. The mapping mode of fill characters is the same as that of the control characters. The decapsulation module of GFP realizes the recognition and discard of fill characters. 
 According to the description above, one advantage of GFP-T is that the control character of 8B/10B service is reserved; but the encapsulating object of GFP-T must be 8B/10B service accordingly, and encapsulation for discretional service can not be implemented, which limits the application of GFP-T. At the same time, since the characters must be distinguished as data character or control character, this encapsulate process is pretty complicated. 
 With the development of technology, more and more types of services need to be supported on multi-service transfer platform. The problem of how to realize data stream encapsulation for discretional service and guarantee the complete transparency of data content being transferred is to be resolved. 
SUMMARY OF THE INVENTION 
 Therefore, a main object of the present invention is to provide a method for encapsulating data stream so as to implement transparent transfer for various kinds of services. 
 To achieve the above-mentioned object, the specific technical scheme of this invention is as follows. 
 A method for encapsulating data streams, comprising: 



 A. presetting a buffer and presetting a low threshold value in the buffer; 
 B. judging whether the stored data in the buffer reaches the low threshold value, if so, segmenting the data in the buffer according to a predefined length which is less than or equal to the low threshold value and adding frame header for the segmented data; else not segmenting the data in the buffer. 



 The method may further comprise the step of presetting a byte counter in which the counting value equals to the predefined length. In this way, the step of segmenting the data in the buffer according to the predefined length which is less than or equal to the low threshold value is performed according to the counting value of the byte counter. 
 Before encapsulating data, the method may further comprise the step of performing series-parallel conversion for the data before the data is stored in the buffer. Under this condition, parallel-series conversion will be implemented for the decapsulated data. 
 The method may further comprise the step of decapsulating the data streams which comprises: bounding the start of data area according to the frame header, bounding the end of frame according to the predefined length, and then removing the frame header. 
 Besides frame header, the method may further comprise: adding payload field header for the segmented data. In this way, not only frame header but also payload field header needs to be removed. 
 Besides frame header and payload field header, the method may further comprise: adding frame trailer for the segmented data. In this way, not only frame header and payload field header but also frame trailer needs to be removed. Here, the start of data area is bounded according to the frame header, the end of frame is bounded according to the predefined length, and then the frame header, the payload field header and the frame trailer are removed. Alternatively, the start of data area is bounded according to the frame header, the end of frame is bounded according to the frame trailer, then the frame header, the payload field header and the frame trailer are removed. 
 The above-mentioned buffer may be a first-in-first-out (FIFO) buffer. 
 When applying the present invention, the data stream encapsulation is implemented by performing counter slicing for the received data stream and adding frame header as well as frame trailer. Because there is no need to perform any recognition process for the received service when applying the method according to this present invention, the present method has nothing to do with the specific service, encapsulation process for discretional service of data stream and transparent transfer afterwards can be implemented. Furthermore, in the present invention there is no need to distinguish data character from control character, resulting in more simple and effective processing procedure. Meanwhile, since the present invention is just a method for encapsulation, the encapsulated data can be transferred with any transfer method regulated in the present standard protocols, the present invention is provided with very good compatibility with the present standard protocols. 
 Further areas of applicability of the present invention will become apparent from the detailed description provided hereinafter. It should be understood that the detailed description and specific examples, while indicating the preferred embodiment of the invention, are intended for purposes of illustration only and are not intended to limit the scope of the invention. 


BRIEF DESCRIPTION OF THE DRAWINGS 
 The present invention will become more fully understood from the detailed description and the accompanying drawings, wherein: 
 FIG. 1 is a schematic diagram showing the encapsulation structure of GFP-T. 
 FIG. 2 is a schematic diagram of data stream encapsulation at the service-receiving terminal according to the invention. 
 FIG. 3 is a schematic diagram of data stream decapsulation at the service-sending terminal according to the invention.


DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS 
 The following description of the preferred embodiment(s) is merely exemplary in nature and is in no way intended to limit the invention, its application, or uses. 
 Now, the present invention will be described in detail hereinafter with reference to the accompanying drawings and a specific embodiment. 
 The idea of the present invention is that no recognition processing is implemented for the received service and only correctness of the transferred data stream needs to be guaranteed. 
 The encapsulation method according to the present invention will be described in detail taking the GFP-T encapsulation mode as an example. 
 FIG. 2 is a schematic diagram of data stream encapsulation at the service-receiving terminal according to the invention. After the serial electric signal at the service-receiving terminal is converted from serial signal to parallel signal through a series-parallel conversion module 201, the signal is sent into a FIFO buffer 202 for the process of encapsulation module. A byte counter 203 is preset, and the counting value N is the length of data area of the encapsulated frame. The value of counting value N is set according to the relation between effectiveness and cost in practical transfers, thus the counting value N is different for different services, but it keeps constant in the same service-transferring course. 
 Because rate adaptation between packets is not supported by GFP-T encapsulation mode, to guarantee the continuity of the transferred data between packets, control through buffer is necessary, and it is required that the mapping bandwidth be larger than the basic data rate of client data before being encoded. A low threshold value is set in the FIFO buffer 202, after the stored data in FIFO reaches the low threshold value, in terms of the first-in-first-out principle, the data in FIFO buffer is sliced according to the current counting value N in order to guarantee the continuity of data between frames. The sliced data is added with a core header and a payload field header, thereby encapsulation for the data can be implemented. The data without being sliced in the buffer will be combined and processed in the next slicing course. 
 When setting the counting value N, if N is excessively large, meaning that the slice length is too long and the depth of FIFO buffer is too large, the low-delay advantage of data stream encapsulation may be lost; if counting value N is excessively small, meaning that slice length is too short, the effective bandwidth may be decreased due to the existence of frame header and frame trailer. Therefore, in practical application, N is set according to the best transfer efficiency. 
 FIG. 3 is a schematic diagram of data stream decapsulation at the service-sending terminal according to the invention. As for GFP protocol, after the sending terminal receives the data frames from the outlying terminal, the start of data area is bounded through core header, the end of the frame is bounded according to the data length N, then core header and payload header is removed, the received data is sent to the FIFO buffer 302. Since the idle frame data has already been recognized and discarded before being stored in buffer 302, the data stored in buffer 302 is pure payload data. The data stream, in terms of FIFO principle, is converted from parallel data to series data through parallel-series conversion module 301 and then sent out. 
 The above description illustrates the encapsulation and decapsulation process in terms of GFP protocol. Since there is no frame trailer in the encapsulated frame in terms of GFP protocol, the process just needs to add core header and payload field header during encapsulation process and to remove core header and payload field header during decapsulation process. As for other protocols, such as LAPS protocol, the encapsulated frame must have frame trailer, so the process of encapsulation not only needs to add frame header and payload field header but also to add frame trailer; meanwhile the process of decapsulation not only needs to remove frame header and payload field header but also frame trailer. Usually the frame trailer is a Frame Checking Sequence (FCS) field. On the condition that the frame trailer exists, after the sending terminal receives the data frames from the outlying terminal, the start of data area can be bounded according to frame header, the end of data area can be bounded according to frame trailer, then frame header, payload field header and frame trailer will be removed, the data after this processing will be sent to the FIFO buffer 302. 
 An encapsulation scheme is provided in the present invention, so the method regulated in the prior standard encapsulation protocols, such as GFP, LAPS Protocol, may be used to perform data transmission. For instance, through defining speed adaptation during mapping process for idle packets, utilizing the reserved bit of frame header information to transfer the self-defined far terminal performance and alarm messages, such as fibre state at the service access terminal, some relevant protection operations can be realized. 
 While the invention has been shown and described with reference to a preferred embodiment thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention as defined by the appended claims. 
 The description of the invention is merely exemplary in nature and, thus, variations that do not depart from the gist of the invention are intended to be within the scope of the invention. Such variations are not to be regarded as a departure from the spirit and scope of the invention. 



{'application_number': '<application-reference appl-type="utility">\n<document-id>\n<country>US</country>\n<doc-number>10894415</doc-number>\n<date>20040716</date>\n</document-id>\n</application-reference>', 'publication_number': '<publication-reference>\n<document-id>\n<country>US</country>\n<doc-number>20050013313</doc-number>\n<kind>A1</kind>\n<date>20050120</date>\n</document-id>\n</publication-reference>', 'source_file': './application/2005/ipa050120.xml', 'source_data': 'USPTO-Application'}