This application is based upon and claims the benefit of priority from the prior Japanese Patent Application No. 2008-164544, filed on Jun. 24, 2008; the entire contents of which are incorporated herein by reference.
1. Field of the Invention
The present invention relates to a check code generating apparatus, a method of generating a check code, and a communication apparatus.
2. Description of the Related Art
As a code for detecting errors in a frame and a packet for communication, there is, for example, a cyclic redundancy check code (CRC). For example, IEEE802.11 specifies that a 32-bit CRC called frame check sequence (FCS) is attached to the end of an IEEE802.11 radio frame. When frames and packets are transmitted, a part of frames and packets transmitted earlier may be rewritten and retransmitted or transferred. For example, in radio communication, it is assumed that, after transmitting a frame, a transmission side cannot receive an acknowledge (Ack) frame transmitted from a reception side, which receives the frame, as an affirmative response because of some reason (e.g., the transmitted frame does not reach the reception side or the Ack frame transmitted from the reception side does not reach the transmission side). In this case, the frame is retransmitted from the transmission side. The transmission side transmits a retransmission frame in which a retry field indicating retransmission is rewritten. In the technology in the past, although the retransmission frame has completely the same frame body as that of the frame transmitted earlier except that one bit in the part of the retry field is different, a CRC is entirely calculated again. For example, Japanese Patent Application Laid-Open No. 11-68581 discloses a technology for, in rewriting an asynchronous transfer mode (ATM) header, calculating a CRC in a rewritten section with hardware and calculating a new CRC using a calculation result.
A check code generating apparatus according to an embodiment of the present invention comprises: a check-code calculating unit that generates a first check code that is a check code concerning exclusive OR of first data and second data obtained by rewriting a part of the first data; and an exclusive-OR calculating unit that calculates an exclusive OR of the first check code generated by the check-code calculating unit and a second check code that is a check code attached to the first data.
A method of generating a check code according to an embodiment of the present invention comprises: generating a first check code that is a check code concerning exclusive OR of first data and second data obtained by rewriting a part of the first data; and calculating an exclusive OR of the first check code and a second check code that is a check code attached to the first data.
A communication apparatus according to an embodiment of the present invention comprises: a check-code calculating unit that generates a first check code that is a check code concerning exclusive OR of first data and second data obtained by rewriting a part of the first data; and an exclusive-OR calculating unit that calculates an exclusive OR of the first check code generated by the check-code calculating unit and a second check code that is a check code attached to the first data.
Exemplary embodiments of a check code generating apparatus, a method of generating check code, and a communication apparatus according to the present invention will be explained below in detail with reference to the accompanying drawings.
A first frame sending unit 11 (a first data sending unit) is a unit that sends a frame 101 (first data) shown in
A sent-data selecting unit 15 selects data to be input to a physical layer 16. The sent-data selecting unit 15 selects output from the first frame sending unit 11 and sends the output to the physical layer 16 while a body of the frame 101 is output from the first frame sending unit 11. When the first frame sending unit 11 finishes the output, the sent-data selecting unit 15 selects output from the first CRC calculating unit 13 and sends the output to the physical layer 16.
Besides being directly sent from the first frame sending unit 11 to the sent-data selecting unit 15, the frame 101 can be sent from the first frame sending unit 11 to the sent-data selecting unit 15 through the first RC calculating unit 13. In this case, the first CRC calculating unit 13 causes the frame 101 to pass through the first CRC calculating unit 13 while the first frame sending unit 11 outputs the frame 101. When the first frame sending unit 11 finishes the output, the first CRC calculating unit 13 sends the CRC 102 to the sent-data selecting unit 15. Data is converted into an analog signal in the physical layer 16 and transmitted to a not-shown reception side from an antenna 17 via a radio wave.
A retry field 104 is a flag present in a twelfth bit from the top of an MAC header in a radio LAN frame. The retry field 104 is set to “0” in the frame 101 transmitted in the first time. A retransmission frame 103 has the same frame body as that of the frame 101 except that the retry field 104 is rewritten from “0” to “1”. When the frame 101 is first data, the retransmission frame 103 is second data obtained by rewriting a part of the first data. The CRC 102 attached to the frame 101 and a CRC 105 attached to the retransmission frame 103 are check codes including linear codes.
After the frame 101 is transmitted, when a transmission side cannot receive an Ack frame because of some reason, the first frame sending unit 11 sends the retransmission frame 103 obtained by changing the retry field 104 to “1” from the frame 101 sent in the first time. While a body of the retransmission frame 103 is output from the first frame sending unit 11, the sent-data selecting unit 15 selects output from the first frame sending unit 11 and sends the output to the physical layer 16.
A second frame sending unit 12 (a second data sending unit) sends a frame 201 shown in
An arithmetic circuit 18 functions as an exclusive-OR calculating unit that calculates exclusive OR of the CRC 202 generated by the second CRC calculating unit 14 and the CRC 102 (the second check code) generated by the first CRC calculating unit 13. The second CRC calculating unit 14 and the arithmetic circuit 18 function as a check code generating apparatus that generates a CRC 105 attached to the retransmission frame 103.
When the first frame sending unit 11 finishes the output of the body of the retransmission frame 103, the sent-data selecting unit 15 selects exclusive OR output by the arithmetic circuit 18. In this way, the CRC 105 attached to the retransmission frame 103 is input to the physical layer 16. According to the present invention, when a part of a frame having a check code including a linear code is changed, it is possible to generate a check code concerning a new frame with simple calculation compared with generation of a check code by a normal method.
In this embodiment, besides storing only the CRC 202 of the frame 201 and using the CRC 202 for calculation, the entire frame 201 including the CRC 202 can be stored. In this case, the retransmission frame 103 can be generated by calculating exclusive OR of the entire frame 201 and the entire frame 101 to be transmitted in the first time.
The second frame sending unit 12 can generate the frame 201 with relatively easy calculation based on the frame 101 generated by the first sending unit 11. Therefore, the second frame sending unit 12 can be configured simpler than the first frame sending unit 11. Besides being configured to include the first frame sending unit 11 and the second frame sending unit 12 independent from each other, the radio communication apparatus can be configured to cause one component to function as the first frame sending unit 11 and the second frame sending unit 12. The radio communication apparatus can also attach an error detection correction code including a linear code to the physical layer 16. The present invention can be applied to generation of an error detection correction code in the physical layer 16.
The present invention is not limited to the application to the IEEE802.11 radio frame explained in this embodiment. The present invention is widely applicable to data such as a frame and a packet having a check code including a linear code. The present invention is applied not only to retransmission or transfer of the data such as a frame and a packet and but also to both the transmission and the transfer. The present invention is not only used for generation of a CRC but also used for generation of a linear code except the CRC, for example, a Reed Solomon (RS) code.
A method of generating a check code according to this embodiment can be both a method of using processing by a hardware configuration and a method of using processing by a software configuration. When the processing by the hardware configuration is used, for example, a multiplexer can be used as the sent-data selecting unit 15. In the case of the processing by the software configuration, an increase in a computational amount often causes a problem. Therefore, the method of generating a check code according to this embodiment is useful.
Besides, the IP header 401 includes fields of a version, Internet header length (IHL), a type of service, total length, identification, flags, fragment offset, a protocol, a source address, and a destination address. Detailed explanation of the fields except the TTL field 402 and the header checksum 403 of the IP header 401 is omitted.
The header checksum 403 of the IP header 401 generally used is not a linear code. However, the Internet Engineering Task Force (IETF) refers to, in RFC791, use of a CRC as a linear code instead of a checksum (see, for example, http://tools.ietf.org/html/rfc791). In the explanation of this embodiment, it is assumed that a CRC is used instead of a checksum.
A TTL field 522 of the transfer packet 521 is updated to a value obtained by reducing a value of the TTL field 502 of the reception packet by one. The CRC 523 attached to the transfer packet 521 needs to be generated anew according to the update of the value of the TTL field 522. In this embodiment, before the CRC 523 of the transfer packet 521 is generated, a CRC 513 concerning a packet 511 shown in
When the table is created, concerning values excluding “1” and “0” among values that the TTL field 502 can take, the TTL difference 512 as exclusive OR of a value of the TTL field 502 and a value obtained by reducing one from the value is calculated. The CRC 513 is calculated for an IP header, sections of which except the TTL difference 512 are “0”, by using the TTL difference 512. When values of the TTL field 502 are “1” and “0”, because the transfer packet 521 is not generated, the values can be excluded from the table. In this embodiment, the table for associating the values of the TTL field 502 of the reception packet 501 and the generated CRC 513 is stored. The CRC 523 of the transfer packet 521 is generated by using the CRC 513 obtained with reference to the table.
The table stores 254 values 0xFF to 0x02 excluding 0x01 and 0x00 among 8 bits, which the TTL field 502 can take, and the CRC 513 in association with each other. The notation of “0x??” represents hexadecimal number. It is possible to easily create the table by calculating in advance the CRC check code 513 for values excluding “1” and “0” among the values that the TTL field 502 can take. A communication apparatus can store the table in advance from, for example, a point of manufacturing of the communication apparatus. By performing calculation during initial setting when a power supply for the communication apparatus is turned on, the table can be created every time the power supply for the communication apparatus is turned on.
The CRC 513 corresponding to the value of the TTL field 502 is calculated by referring to the table explained with reference to
Besides being generated in a memory area different from that of the reception packet 501, the transfer packet 521 can be generated by directly rewriting, on a memory area, the TTL field 502 and the CRC 513 of the reception packet 501. In this case, copying on the memory concerning sections except the TTL field 502 and the CRC 503 of the reception packet 501, i.e., sections that do not need to be written in transfer can be omitted.
As explained above, in this embodiment, the table is referred to when the transfer packet 521 including the second data is generated. Consequently, when a part of a packet having a check code including a linear code is changed, it is possible to generate a check code for a new packet with simple calculation compared with generation of a check code by the normal method.
The processing for calculating a value obtained by reducing the value of the TTL field 502 by one does not always have to be performed before the processing for generating the CRC 523 of the transfer packet 521. These kinds of processing can be performed in any order. The table referred to when the CRC 523 is generated does not always have to include the value of the TTL field 502 of the reception packet 501. The table can include, for example, a value of the TTL field 522 obtained by reducing the value of the TTL field 502 of the reception packet 501 by one. This embodiment is not only applied to the IP packet that uses the CRC instead of the checksum and can be widely applied to data such as a frame and a packet having a check code including a linear code.
When the value of the TTL field 502 is an 8-bit value, the TTL difference 512 as exclusive OR of the 8-bit value and a value obtained by reducing one from the value is any one of seven values 0x7F to 0x01 as shown in
Subsequently, the TTL difference 512 is generated by calculating exclusive OR of the value of the TTL field 502 of the reception packet 501 and the value obtained by reducing one from the value. After the TTL difference 512 is generated, the CRC 513 corresponding to a value of the TTL difference 512 is calculated by referring to the table explained with reference to
A value same as that of the reception packet 501 is written in sections except the TTL field 522 and the CRC 523 of the transfer packet 521. In this way, the transfer packet 521 is generated. In this embodiment, as in the second embodiment, besides being generated in a memory area different from that of the reception packet 501, the transfer packet 521 can be generated by directly rewriting the TTL field 502 and the CRC 513 of the reception packet 501 on a memory area.
The TTL difference 512 is generated by calculation at any time. Besides, a table that stores values of the TTL field 502 of the reception packet 501 or values of the TTL field 522 of the transfer packet 521 and the TTL difference 512 in association with each other is separately prepared. The TTL difference 512 can be calculated by referring to the table.
The sending of the frame 201 by the second frame sending unit 12 and the calculation of the CRC 202 by the second CRC calculating unit 14 are performed in parallel to the sending of the frame 101 by the first frame sending unit 11 and the calculation of the CRC 102 by the first CRC calculating unit 13. The CRC check code 202 calculated by the second CRC calculating unit 14 is not used in transmitting the frame 101 in the first time and stored in the second CRC calculating unit 14. When a transmission side receives an Ack frame from a reception side, the CRC 202 stored in the second CRC calculating unit 14 is erased because the CRC 202 is unnecessary.
After the frame 101 is transmitted, when the transmission side cannot receive the Ack frame because of some reason, the first frame sending unit 11 sends the retransmission frame 103 obtained by changing the retry field 104 to “1” from the frame 101 sent in the first time. While a body of the retransmission frame 103 is output from the first frame sending unit 11, the sent-data selecting unit 15 selects output from the first frame sending unit 11 and sends the output to the physical layer 16. While the output from the first frame sending unit 11 is selected by the sent-data selecting unit 15, the calculation by the first CRC calculating unit 13 and the second CRC calculating unit 14 is stopped.
In this embodiment, when the retransmission frame 103 as the second data is sent, the arithmetic circuit 18 calculates exclusive OR of the CRC 202 (the first check code) and the CRC 102 (the second check code). When first frame sending unit 11 finishes the output of the body of the retransmission frame 103, the sent-data selecting unit 15 selects exclusive OR output by the arithmetic circuit 18. In this way, the CRC 105 attached to the retransmission frame 103 is input to the physical layer 16.
As explained above, the CRC 202 is generated in parallel to the sending of the frame 101 by the first frame sending unit 11 and the generation of the CRC 102 by the first CRC calculating unit 13. Consequently, even when the length of the frame 101 is not fixed, it is possible to generate the CRC 202 corresponding to the frame 101 every time the frame 101 is sent. Because the CRC 202 is generated in parallel to the generation of the CRC 102, it is possible to omit calculation of a CRC at the time of transmission of the retransmission frame 103 without calculating the CRC 202 in advance.
The monitoring unit 601 monitors a communication state at the time when the radio communication apparatus transmits a frame via a radio wave. The monitoring unit 601 counts the number of times of retransmission of the frame and determines a radio wave state from the number of times of retransmission. For example, the monitoring unit 601 sets a threshold of the number of times of retransmission in a fixed period or a fixed number of times of transmission in advance. The monitoring unit 601 determines whether the radio wave state is satisfactory according to whether the number of times of retransmission is equal to or smaller than the threshold determined from statistics in the past. The monitoring unit 601 controls, according to the communication state, the operation of the second frame sending unit 12 and the second CRC calculating unit 14. When the number of times of retransmission is equal to or smaller than the threshold and the monitoring unit 601 determines that the radio wave state is satisfactory, the monitoring unit 601 stops the operation of the second frame sending unit 12 and the second CRC calculating unit 14. In transmitting the retransmission frame 103, the radio communication apparatus generates the CRC 202 according to the calculation by the first CRC calculating unit 13 during the retransmission. The sent-data selecting unit 15 sequentially selects, according to the determination of the monitoring unit 601 that the radio wave state is satisfactory, output from the first frame sending unit 11 and output from the first CRC calculating unit 13.
When the monitoring unit 601 determines that the number of times of retransmission is larger than the predetermined threshold and the radio wave state is unsatisfactory, the monitoring unit 601 actuates the second frame sending unit 12 and the second CRC calculating unit 14. The sent-data selecting unit 15 sequentially selects, according to the determination of the monitoring unit 601 that the radio wave state is unsatisfactory, output from the first frame sending unit 11, output from the first CRC calculating unit 13, and exclusive OR output by the arithmetic circuit 18. This makes it possible to stop the calculation of the second frame sending unit 12 and the second CRC calculating unit 14 when the radio wave state is satisfactory and a frequency of retransmission is low and reduce calculation and a memory capacity that are wasted because the retransmission frame 103 is not transmitted. The determination of a communication state by the monitoring unit 601 is not limited to the method of determining the communication state using a threshold of the number of times of retransmission determined from statistics in the past. Any determination method may be used.
Additional advantages and modifications will readily occur to those skilled in the art. Therefore, the invention in its broader aspects is not limited to the specific details and representative embodiments shown and described herein. Accordingly, various modifications may be made without departing from the spirit or scope of the general inventive concept as defined by the appended claims and their equivalents.
Number | Date | Country | Kind |
---|---|---|---|
2008-164544 | Jun 2008 | JP | national |