This application relates to the field of optical communication, and in particular, to a data scrambling method, a data descrambling method, and a related device.
A passive optical network (PON) access technology is widely deployed worldwide due to low network costs, low maintenance costs, and a high-quality service. The PON includes an optical line terminal (OLT) at a central office, an optical network unit (ONU) on a user side, and an optical distribution network (ODN) that is used to connect the OLT and the ONU.
In the PON network, sending data from the OLT to the ONU is referred to as downstream data transmission, and sending data from the ONU to the OLT is referred to as upstream data transmission. During downstream data transmission, the OLT sends downstream data to all ONUs in a broadcast mode, and each ONU can parse only data in a timeslot corresponding to the ONU. During upstream data transmission, each ONU sends upstream data to the OLT in a specific timeslot according to a sending rule of time division multiplexing. However, for both the upstream data and the downstream data, bits 0 and bits 1 in the data may be unevenly distributed. For example, many consecutive bits 0 or bits 1 may appear in the data, which causes a high bit error rate at a data receiving end.
Embodiments provide a data scrambling method, a data descrambling method, and a related device. Raw data is scrambled, so that bits 0 and bits 1 in scrambled target data are more evenly distributed. This reduces a possibility that consecutive bits 0 or bits 1 appear in the target data, thereby reducing a bit error rate at a data receiving end.
It should be noted that the “bit 0” in this application represents a bit whose value is 0, and the “bit 1” represents a bit whose value is 1.
According to a first embodiment, this application provides a data scrambling method. The method may be specifically performed by an OLT or an ONU, and includes: first, generating a raw data frame, where the raw data frame includes raw data and a physical synchronization block (PSB); next, generating a preload pattern based on a target bit, where the target bit is a part of bits in a superframe counter (SFC) bit sequence corresponding to the raw data frame; and further, scrambling the raw data based on the preload pattern to obtain target data.
It should be noted that both the OLT and the ONU are locally equipped with SFCs. The local SFC counts each raw data frame. Therefore, each raw data frame has an output value of an SFC corresponding to the raw data frame, that is, an SFC value. Specifically, the SFC value may be represented in a form of a bit sequence.
In this implementation, the raw data is scrambled, so that bits 0 and bits 1 in the scrambled target data are more evenly distributed. This reduces a possibility that consecutive bits 0 or bits 1 appear in the target data, thereby reducing a bit error rate at a data receiving end.
Optionally, in some possible implementations, a difference between a number of bits 0 and a number of bits 1 in the preload pattern is less than a preset value. Preferably, the number of bits 0 and the number of bits 1 in the preload pattern are the same. The bits 0 and the bits 1 in the preload pattern are more evenly distributed, thereby further ensuring even distribution of bits 0 and bits 1 in the scrambled target data.
Optionally, in some possible implementations, if the raw data frame is a data frame generated by the OLT, the PSB is specifically a downstream physical synchronization block (PSBd). The PSBd includes an SFC field, and the SFC field includes the SFC value corresponding to the raw data frame. Specifically, a value of the SFC field is the same as an output value of the local SFC of the OLT. The OLT can extract the target bit from the SFC field, or can extract the target bit from the output value of the local SFC. If the raw data frame is a data frame generated by the ONU, the PSB is specifically an upstream physical synchronization block (PSBu). The PSBu includes no SFC field. The ONU can extract the target bit only from an output value of the local SFC. In this implementation, several specific implementations of determining the target bit are provided, which improves expansibility of this solution.
Optionally, in some possible implementations, the scrambling the raw data based on the preload pattern to obtain target data includes: first, inputting the preload pattern to a scrambler; then, performing an operation on the preload pattern according to a polynomial operation rule preset in the scrambler to generate a target pattern; and further, performing an exclusive OR operation on each bit of the raw data based on the target pattern to obtain the target data. In this implementation, an implementation of scrambling the raw data by using the scrambler is provided, which improves practicality of this solution.
Optionally, in some possible implementations, a length of the preload pattern is M bits, M is an integer greater than 1, the target bit includes N least significant bits in the SFC value, and M is greater than or equal to 2 times of N. Alternatively, a length of the SFC value is K bits, K is an integer greater than 1, and K is greater than or equal to 2 times of N. In this implementation, the target bit is a part of least significant bits in the SFC value. Because in a counting process of the SFC, a least significant bit in the SFC value changes faster than a most significant bit, that is, the least significant bit in the SFC value continuously changes with a number of frames, the preload pattern constructed based on the least significant bit in the SFC value also continuously changes with the number of frames, so that a scrambling manner of each frame continuously changes. Therefore, an effect of data encryption is better, and data transmission security is improved.
Optionally, in some possible implementations, the generating a preload pattern based on a target bit includes: first, determining an opposite value of a value of each bit in the target bit; and further, arranging the value of each bit in the target bit and the opposite value of the value of each bit in the target bit to obtain the preload pattern. In this implementation, an inversion operation is performed on the value of each bit in the target bit, and then arranging is performed. This is operated to enable the bits 0 and the bits 1 in the preload pattern to be more evenly distributed.
Optionally, in some possible implementations, values of two adjacent bits in the preload pattern are a value of any bit in the target bit and an opposite value of the value of the bit.
Optionally, in some possible implementations, the generating a preload pattern based on a target bit includes: generating the preload pattern based on the target bit and a preset data pattern. In this implementation, another implementation of constructing the preload pattern by using the target bit is provided, which improves flexibility of this solution.
Optionally, in some possible implementations, after the raw data is scrambled to obtain the target data, a target data frame including the target data and the PSB is sent. A difference between the target data frame and the raw data frame lies only in that the scrambled target data replaces the raw data.
According to a second embodiment, this application provides a data descrambling method. The method may be specifically performed by an OLT or an ONU, and includes: first, receiving a target data frame, where the target data frame includes target data and a PSB; next, generating a preload pattern based on a target bit, where the target bit is a part of bits in an SFC value corresponding to the target data frame; and further, descrambling the target data based on the preload pattern to obtain raw data.
It should be noted that the target bit extracted from the SFC value is the same as a target bit determined by a data transmitting end. In addition, a data receiving end needs to encode the target bit in an encoding manner the same as that of the data transmitting end, to obtain a preload pattern the same as that of the data transmitting end. Therefore, the data receiving end can restore the raw data after descrambling the target data based on the preload pattern.
Optionally, in some possible implementations, a difference between a number of bits 0 and a number of bits 1 in the preload pattern is less than a preset value. Preferably, the number of bits 0 and the number of bits 1 in the preload pattern are the same.
Optionally, in some possible implementations, if the data receiving end is the ONU, the ONU can extract the target bit from an SFC field of the target data frame, or can extract the target bit from an output value of a local SFC. If the data receiving end is the OLT, the OLT can extract the target bit only from an output value of a local SFC.
Optionally, in some possible implementations, the descrambling the target data based on the preload pattern to obtain raw data includes: first, inputting the preload pattern to the descrambler; then, performing an operation on the preload pattern according to a polynomial operation rule preset in the descrambler to generate a target pattern; and further, performing an exclusive OR operation on each bit of the target data based on the target pattern to obtain the raw data.
Optionally, in some possible implementations, a length of the preload pattern is M bits, M is an integer greater than 1, the target bit includes N least significant bits in the SFC value, and M is greater than or equal to 2 times of N. Alternatively, a length of the SFC value is K bits, K is an integer greater than 1, and K is greater than or equal to 2 times of N.
Optionally, in some possible implementations, the generating a preload pattern based on a target bit includes: first, determining an opposite value of a value of each bit in the target bit; and further, arranging the value of each bit in the target bit and the opposite value of the value of each bit in the target bit to obtain the preload pattern.
Optionally, in some possible implementations, values of two adjacent bits in the preload pattern are a value of any bit in the target bit and an opposite value of the value of the bit.
Optionally, in some possible implementations, the generating a preload pattern based on a target bit includes: generating the preload pattern based on the target bit and a preset data pattern.
Optionally, in some possible implementations, after the receiving a target data frame, and before obtaining the target bit from the superframe counter SFC value corresponding to the target data frame, the method further includes: performing frame synchronization on the target data frame, to determine a boundary between frames and the SFC field in the target data frame.
According to a third embodiment, this application provides a data scrambling apparatus, including a processor, a memory, and an optical transceiver. The processor, the memory, and the optical transceiver are connected to each other by using a line. The processor invokes program code in the memory to perform the data scrambling method shown in any implementation of the first embodiment.
According to a fourth embodiment, this application provides a data descrambling apparatus, including a processor, a memory, and an optical transceiver. The processor, the memory, and the optical transceiver are connected to each other by using a line. The processor invokes program code in the memory to perform the data descrambling method shown in any implementation of the second embodiment.
According to a fifth embodiment, this application provides an OLT, including the data scrambling apparatus shown in the third embodiment and the data descrambling apparatus shown in the fourth embodiment.
According to a sixth embodiment, this application provides an ONU, including the data scrambling apparatus shown in the third embodiment and the data descrambling apparatus shown in the fourth embodiment.
According to a seventh embodiment, this application provides a passive optical network. The passive optical network includes the OLT shown in the fifth embodiment and the ONU shown in the sixth embodiment.
According to an eighth embodiment, this application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is executed by hardware, some or all of the steps of any method according to the first embodiment and the second embodiment can be implemented.
In embodiments of this application, a part of target bits are extracted from the SFC value corresponding to the raw data frame to construct the preload pattern. Then, the raw data in the raw data frame is scrambled based on the preload pattern to obtain the to-be-sent target data. The raw data is scrambled, so that the bits 0 and the bits 1 in the scrambled target data are more evenly distributed. This reduces a possibility that consecutive bits 0 or bits 1 appear in the target data, thereby reducing the bit error rate at the data receiving end.
This application provides a data scrambling method, a data descrambling method, and a related device. Raw data is scrambled, so that bits 0 and bits 1 in scrambled target data are more evenly distributed. This reduces a possibility that consecutive bits 0 or bits 1 appear in the target data, thereby reducing a bit error rate at a data receiving end.
Currently, broadband access technologies are mainly classified into a copper access technology (for example, various DSL technologies) and an optical access technology. An access network implemented by using the optical access technology is referred to as an optical access network (OAN).
A passive optical network (PON) is an implementation technology of the optical access network, and the PON is an optical access technology for point-to-multipoint transmission. The following describes a system architecture of the PON.
The ODN includes a passive optical splitter for optical power allocation, a feeder fiber connected between the passive optical splitter and the OLT, and a distribution fiber connected between the passive optical splitter and an optical network unit (ONU). During downstream data transmission, the ODN transmits downstream data of the OLT to each ONU by using an optical splitter, and the ONU selectively receives downstream data that carries an identifier of the ONU. During upstream data transmission, the ODN combines N optical signals sent by ONUs into one optical signal to transmit to the OLT.
The ONU provides a user-side interface for the OAN and is connected to the ODN. If the ONU further provides a user port function, for example, the ONU provides an Ethernet user port or a plain old telephone service (POTS) user port, the ONU is referred to as an optical network termination (ONT).
In the PON network, to improve data transmission security and reduce a bit error rate at a data receiving end, bits 0 and bits 1 in transmitted data need to be more evenly distributed, which may be specifically implemented through data scrambling. This application provides a data scrambling method. The following describes in detail the data scrambling method provided in this application.
201: Generate a raw data frame.
The raw data frame includes raw data and a physical synchronization block (PSB). Specifically, the raw data frame in this embodiment may be a PHY frame transmitted at a transmission aggregation layer.
202: Generate a preload pattern of a scrambler based on a target bit.
In this embodiment, the target bit is a part of bits in an SFC value corresponding to the raw data frame. It should be noted that both the OLT and the ONU are locally equipped with SFCs. The local SFC counts each raw data frame. Therefore, each raw data frame has an output value of an SFC corresponding to the raw data frame, that is, an SFC value. Specifically, the SFC value may be represented in a form of a bit sequence. It can be understood that for the OLT, the PSBd includes an SFC field, and a value of the SFC field is the same as an output value of the local SFC. Then, the OLT can extract the target bit from the SFC field, or can extract the target bit from the output value of the local SFC. For the ONU, the PSBu includes no SFC field. Then, the ONU can extract the target bit only from an output value of the local SFC.
It should be noted that the SFC usually starts counting from 0 and is incremented by 1 every 125 μs. A length of the SFC value is 51 bits, that is, a decimal counting result of the SFC value may be presented by using a bit sequence whose length is 51 bits. It can be understood that an SFC value corresponding to a raw data frame that is ranked in the front is relatively small, that is, a number of bits 0 in the SFC value is extremely larger than a number of bits 1. Consequently, the bits 0 and the bits 1 are unevenly distributed. If scrambling is performed based on all bits in the SFC value, bits 0 and bits 1 in a start phase of target data obtained after the raw data is scrambled are also unevenly distributed, and a scrambling effect is poor. In addition, because in a counting process of the SFC, a least significant bit of the SFC value changes faster than a most significant bit, if the most significant bit in the SFC value is used to scramble data, a scrambling manner of a data frame that is ranked in the front has no change, and an effect of data encryption is poor.
Therefore, in an implementation, a part of least significant bits in the SFC value may be used as the target bit. Specifically, if a length of the preload pattern that needs to be input to the scrambler is M bits, where M is an integer greater than 1, target bits include N least significant bits in the SFC value, where M is greater than or equal to 2 times of N. For example, if the length of the preload pattern is 58 bits, a number of the target bits is less than or equal to 29. Alternatively, a length of the SFC value is K bits, K is an integer greater than 1, and K is greater than or equal to 2 times of N. For example, if the length of the SFC value is 51 bits, a number of target bits is less than or equal to 25.
It can be understood that the foregoing descriptions of the target bit are only some examples, and a number of the target bits is not limited in this application. In addition, the target bits may be a string of consecutive bits in the SFC value, or may be non-consecutive bits in the SFC value. This is not specifically limited herein.
In this embodiment, after the target bit in the SFC value is determined, the target bit may be encoded according to some encoding rules, to obtain the preload pattern of the scrambler. The following describes several possible encoding manners by using an example in which the length of the preload pattern is 58 bits.
In a first manner, reverse interleaving is performed after a value of the target bit is inverted.
Specifically,
In a second manner, forward interleaving is performed after a value of the target bit is inverted.
Specifically,
In a third manner, the preload pattern is generated based on the target bit and a preset data pattern.
Specifically,
It can be understood that, in the foregoing three implementations, the inversion operation is performed on the value of each of the target bits, and then arrangement is performed. This is operated to enable a number of bits 0 and a number of bits 1 in the preload pattern to be more balanced, thereby improving a scrambling effect.
It should be noted that the foregoing three implementations of constructing the preload pattern are only some examples. In actual application, any manner of constructing the preload pattern based on a part of bits in the SFC value falls within the protection scope of this application. For example, after the inversion operation is performed on the value of each of the target bits, the target bits may be combined with an inverted bit sequence in any arrangement manner, to generate a preloaded bit sequence.
203: Scramble the raw data based on the preload pattern to obtain the target data.
In this embodiment, the preload pattern is input to the scrambler; then, a target pattern is generated according to a polynomial operation rule preset in the scrambler; and further, an exclusive OR operation is performed on each bit of the raw data based on the target pattern to obtain to-be-sent target data. The scrambler usually includes a shift register and a logical operation unit. The following describes a data scrambling manner with reference to a working principle of the scrambler.
204: Send a target data frame including the target data.
In this embodiment, a format of the target data frame is similar to a format of the raw data frame described above. A difference lies only in that the scrambled target data replaces the raw data, and other same embodiments are not described one by one herein again.
In this embodiment of this application, a part of target bits are extracted from the SFC value corresponding to the raw data frame to construct the preload pattern of the scrambler. Then, the raw data in the raw data frame is scrambled based on the preload pattern to obtain the to-be-sent target data. The raw data is scrambled, so that bits 0 and bits 1 in the scrambled target data are more evenly distributed. This reduces a possibility that consecutive bits 0 or bits 1 appear in the target data, thereby reducing a bit error rate at a data receiving end. Further, because a least significant bit in the SFC value continuously changes with a number of frames, the preload pattern constructed based on the least significant bit in the SFC value also continuously changes with the number of frames, so that a scrambling manner of each frame continuously changes. Therefore, an effect of data encryption is better, and data transmission security is improved. In addition, the bits 0 and the bits 1 in the preload pattern constructed based on the least significant bit in the SFC value are more evenly distributed, thereby further ensuring even distribution of the bits 0 and the bits 1 in the scrambled target data.
The foregoing describes the data scrambling method provided in this application. It can be understood that after scrambled data reaches a data receiving end, descrambling needs to be performed on the scrambled data to restore raw data. The following describes a data descrambling method provided in this application.
1001: Receive a target data frame.
In this embodiment, the target data frame includes target data obtained after raw data is scrambled. The target data frame may be a downstream data frame sent by an OLT to an ONU, or may be an upstream data frame sent by the ONU to the OLT. For details, refer to the related descriptions in
1002: Generate a preload pattern of a descrambler based on a target bit.
In this embodiment, for descriptions of the target bit, refer to the related descriptions in step 202 of the embodiment shown in
In this embodiment, a manner of generating the preload pattern based on the target bit is similar to the related descriptions in step 203 in the embodiment shown in
1003: Descramble the target data based on the preload pattern to obtain the raw data.
In this embodiment, a structure and a working principle of the descrambler are similar to the structure and the working principle of the scrambler shown in
The following describes a data scrambling apparatus and a data descrambling apparatus provided in this application.
The following describes an OLT and an ONU provided in this application.
It should be noted that the processors shown in
It may be clearly understood by a person skilled in the art that, for the purpose of convenient and brief description, for a detailed working process of the foregoing system, apparatus, and unit, refer to a corresponding process in the foregoing method embodiment. Details are not described herein again.
A person of ordinary skill in the art may understand that all or some of the steps of the foregoing embodiments may be implemented by hardware or a program instructing related hardware. The program may be stored in a computer-readable storage medium. The storage medium may be a read-only memory, a random access memory, or the like. Specifically, for example, the foregoing processing unit or processor may be a central processing unit, a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. Whether the functions are performed by hardware or software depends on particular applications and design constraint conditions of the technical solutions. A person skilled in the art may use different methods to implement the described functions for each particular application, but it should not be considered that the implementation goes beyond the scope of this application.
When software is used to implement the foregoing embodiments, some or all of the method steps described in the foregoing embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the procedures or functions according to embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or another programmable apparatus. The computer instructions may be stored in a computer-readable storage medium or may be transmitted from a computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by the computer, or a data storage device, for example, a server or a data center, integrating one or more usable media. The available medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid-state drive Solid-State Drive (SSD)), or the like.
Finally, it should be noted that the foregoing descriptions are merely specific implementations of this application, but are not intended to limit the protection scope of this application. Any variation or replacement readily figured out by a person skilled in the art within the technical scope disclosed in this application shall fall within the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.
Number | Date | Country | Kind |
---|---|---|---|
202010712635.X | Jul 2020 | CN | national |
This application is a continuation of International Application No. PCT/CN2021/104936, filed on Jul. 7, 2021, which claims priority to Chinese Patent Application No. 202010712635.X, filed on Jul. 22, 2020. The disclosures of the aforementioned applications are hereby incorporated by reference in their entireties.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2021/104936 | Jul 2021 | US |
Child | 18156833 | US |