CN1300993C - Method of rapid calculating IP massage head checking sum - Google Patents
Method of rapid calculating IP massage head checking sum Download PDFInfo
- Publication number
- CN1300993C CN1300993C CNB021501130A CN02150113A CN1300993C CN 1300993 C CN1300993 C CN 1300993C CN B021501130 A CNB021501130 A CN B021501130A CN 02150113 A CN02150113 A CN 02150113A CN 1300993 C CN1300993 C CN 1300993C
- Authority
- CN
- China
- Prior art keywords
- verification
- former
- message
- heading
- new
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Landscapes
- Communication Control (AREA)
Abstract
The present invention relates to a method of rapidly calculating the checking sum of IP massage heads, which belongs to the technical field of data communication. In the method, firstly, the original checking sum of IP massage heads is calculated; received IP messages are retransmitted; if only the survival time of the messages is subtracted by one in a retransmission process, marks for rapidly calculating the checking sum are set for the messages; otherwise, the corresponding mark positions are empty; finally, the checking sum of the marks for rapidly calculating the checking sum is calculated. The method of the present invention obviously enhances calculation efficiency, and can be used in software retransmission systems; simultaneously, the method can be used in hardware retransmission systems.
Description
Technical field
The present invention relates to a kind of quick calculating IP heading verification and method, belong to data communication technology field.
Background technology
Carry checksum field in the IP heading, be used for guaranteeing the reliability when the IP message passes network.Forwarding unit at first calculates the verification of message and whether correct when receiving an IP message, and with verification and incorrect packet loss, carry out necessary modifications at definite forward-path and to the IP heading after, forwarding unit will recomputate verification and.The verification of IP heading and the computing time and the length of IP heading linear, for the simplest IP heading (IP message head length is 20 bytes), need carry out at least 10 internal storage access operations and add operation.This expense seems to the influence of message forward rate under the situation that software is transmitted and is even more important.In fact, forwarding unit is in most cases only to (the Time To Live of the life span in the IP heading, hereinafter to be referred as TTL, the 8th byte of IP heading, when the IP message passes through forwarding unit, the TTL territory need subtract 1) carried out subtracting 1 operation, and any modification is not carried out in other territory of heading.
Verification of IP heading and computational methods commonly used at present are exactly to regard the IP heading as one section continuous space, then according to vertical order, with two bytes is that unit carries out cutting, obtain the sequence of a short integer, these numbers are added up, after the influence of having considered carry and carrying out inversion operation, the short integer that obtains at last be exactly the IP heading verification and.The structure of IP heading as shown in Figure 1.
With length is that the IP heading of 20 bytes is an example, verification and computational process as follows:
At first, calculate 10 short integers and: short integer and S=∑ (W
i);
Then, split out respectively high 16 and low 16: short integer and high 16=short integer and/65536; Short integer and low 16=short integer and mod 65536;
Temporary variable T=short integer and high 16+short integer and low 16;
If T greater than 65535, then cuts 65535:
With temporary variable T by 16 negates, obtain final verification and: verification and C=65535-temporary variable T.
Because first byte in the IP heading has been carried the version number of IP, and the version number of IP is 4 (for the IPV4 that generally use at present), therefore first short integer W0 of correct IP heading is forever greater than 0, short integer and high 16+short integer and low by 16>0, temporary variable T is not 0 certainly, so the span of verification and C is: 0 ~ 65534
Existing technical scheme is a general-purpose algorithm of verification and calculating, it does not consider that forwarding unit only subtracts 1 operation to the TTL in the IP heading in most cases, do not revise other territories of IP heading yet, and just to the IP heading carried out again a verification and calculating, do not utilize verification last time that calculated in the IP heading and the result.Be not difficult to find out from the basic procedure of this general-purpose algorithm, when IP heading length is 2N byte, need to carry out N internal storage access operation and add operation at least.Because the minimum length of IP heading is 20, thus N more than or equal to 10, its operand will be very large.
Summary of the invention
The objective of the invention is at calculation check in the prior art and the lower shortcoming of efficient, propose a kind of quick calculating IP heading verification and method, with simplify the IP verification and calculating.
The quick calculating IP heading verification that the present invention proposes and method, comprise following each step:
1, according to vertical order, be that unit carries out cutting to the IP heading with two bytes, obtain the sequence of a short integer, former verification and be short integer sequence and;
2, the IP message that receives is transmitted, if only the life span of message has been carried out subtracting 1 operation in the repeating process, then to this message setting calculation check and sign fast, otherwise corresponding marker bit is put sky;
3, to the above-mentioned message of calculation check and sign fast that is provided with, calculate new verification and.
In the said method, calculate new verification and formula be:
For syllable sequence be low byte preceding, high byte after system, if the former verification and<65534 in the first step, then new verification and=former verification and+1, otherwise verification newly and=former verification and-65534.
For syllable sequence be high byte preceding, low byte after system, if former verification and<65279, then new verification and=former verification and+256, otherwise verification newly and=former verification and-65279.
In the said method,, be in the attached forwarding controll block of message, flag bit to be set to the message setting method of calculation check and sign fast.
The quick calculating IP heading verification that the present invention proposes and method, only need carry out internal storage access and additional calculation, with respect to original general calculation method significant raising has been arranged on computational efficiency.Consider that forwarding unit only subtracts 1 operation to the TTL in the IP heading in most cases, therefore this optimization method has practicality.From use occasion, this method both can be used in the system that software is transmitted, and also can use in the hardware repeater system.
Description of drawings
Fig. 1 is the structural representation of IP heading.
Fig. 2 is the position view of TTL in the IP head.
Embodiment
The quick calculating IP heading verification that the present invention proposes and method, at first according to vertical order, be that unit carries out cutting with two bytes to the IP heading, obtain the sequence of a short integer, W
0, W
1..., W
n, former verification and be W
0+ W
1+ ... + W
nThe IP message that receives is transmitted, if only the life span of message has been carried out subtracting 1 operation in the repeating process, then to this message setting calculation check and sign fast, otherwise corresponding marker bit is put sky; To the above-mentioned message of calculation check and sign fast that is provided with, calculation check and.
Calculation check and formula be:
For syllable sequence be low byte preceding, high byte after system, if the former verification and<65534 in the first step, then new verification and=former verification and+1, otherwise verification newly and=former verification and-65534.
For syllable sequence be high byte preceding, low byte after system, if former verification and<65279, then new verification and=former verification and+256, otherwise verification newly and=former verification and-65279.
Above-mentioned to the message setting method of calculation check and sign fast, be in the attached forwarding controll block of message, flag bit to be set.
In the IP heading, the position in TTL territory is fixed, and as shown in Figure 2, is positioned at the 8th byte of IP heading, is the 5th short integer W in verification and the calculating just
4From verification of IP heading and general-purpose algorithm, be not difficult to find the TTL territory to verification and contribution fix, irrelevant with other territories of IP heading, like this, only when the value of TTL changes, situation about can be at an easy rate changing according to TTL and former verification and, calculate the verification that makes new advances and.
Be verification and the calculating formula process that the present invention proposes below:
For being provided with the message of calculation check and sign fast, has only TTL (W
4) variation has taken place, the value of other short integers is constant, so:
Former short integer and S
Old=∑ (W
i)
New short integer and S
New=∑ (W
i'), when i=4, W
iBe not equal to W
i', to other values of i, W
i=W
i'
The difference sub=W of TTL before and after order is transmitted and handled
4-W
4', i.e. 0<sub≤65535
Then former short integer and S
Old=new short integer and S
NewThe difference sub of+TTL.
If former verification and C
OldThe difference sub of+TTL<65535, then new verification and C
New=former verification and C
OldThe difference sub of+TTL;
Otherwise new verification and C
New=former verification and C
OldThe difference sub-65535 of+TTL;
There are two kinds of different syllable sequences in system: low byte preceding, high byte back and low byte preceding, high byte after, different syllable sequences has determined that the TTL territory is a high position or low level in the 5th short integer.
For low byte preceding, high byte after system, the TTL territory is in the 5th low byte in the short integer, when TTL subtracted 1, the value of the 5th short integer also subtracted 1, i.e. the difference sub=1 of TTL, the formula that substitution is derived above, verification after the optimization and computing formula are:
If former verification and C
Old<65534, then new verification and C
New=former verification and C
Old+ 1,
Otherwise new verification and C
New=former verification and C
Old-65534;
Preceding, low byte is in the back system for high byte, and the TTL territory is in the 5th high byte in the short integer, when TTL subtracted 1, the value of the 5th short integer had reduced 256, i.e. the difference sub=1 of TTL, the formula that substitution is derived above, verification after the optimization and computing formula are:
If former verification and C
Old<65279, then new verification and C
New=former verification and C
Old+ 256;
Otherwise new verification and C
New=former verification and C
Old-65279.
Claims (2)
1, a kind of quick calculating IP heading verification and method, it is characterized in that this method comprises following each step:
(1) according to vertical order, be that unit carries out cutting to the IP heading with two bytes, obtain the sequence of a short integer, former verification and be short integer sequence and;
(2) the IP message that receives is transmitted, if only the life span of message has been carried out subtracting 1 operation in the repeating process, then to this message setting calculation check and sign fast, otherwise corresponding marker bit is put sky;
(3) to the above-mentioned message of calculation check and sign fast that is provided with, calculate new verification and;
Wherein, the new verification of described calculating and formula be:
For syllable sequence be low byte preceding, high byte after system, if described former verification and<65534, then new verification and=former verification and+1, otherwise verification newly and=former verification and-65534;
For syllable sequence be high byte preceding, low byte after system, if described former verification and<65279, then new verification and=former verification and+256, otherwise verification newly and=former verification and-65279.
2, the method for claim 1 is characterized in that in the described step (2), to the message setting method of calculation check and sign fast, is in the attached forwarding controll block of message flag bit to be set.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB021501130A CN1300993C (en) | 2002-11-02 | 2002-11-02 | Method of rapid calculating IP massage head checking sum |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CNB021501130A CN1300993C (en) | 2002-11-02 | 2002-11-02 | Method of rapid calculating IP massage head checking sum |
Publications (2)
Publication Number | Publication Date |
---|---|
CN1494279A CN1494279A (en) | 2004-05-05 |
CN1300993C true CN1300993C (en) | 2007-02-14 |
Family
ID=34233871
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CNB021501130A Expired - Fee Related CN1300993C (en) | 2002-11-02 | 2002-11-02 | Method of rapid calculating IP massage head checking sum |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN1300993C (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN102904685B (en) * | 2012-09-29 | 2016-04-27 | 杭州华三通信技术有限公司 | A kind of processing method of hardware table item check errors and device |
CN104010050A (en) * | 2014-05-30 | 2014-08-27 | 北京航空航天大学 | Method and device for achieving gateway NAPT function based on middleware |
CN113973110B (en) * | 2021-10-25 | 2024-03-15 | 北京奇艺世纪科技有限公司 | Message generation method and device and electronic equipment |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5701316A (en) * | 1995-08-31 | 1997-12-23 | Unisys Corporation | Method for generating an internet protocol suite checksum in a single macro instruction |
US5815516A (en) * | 1996-04-05 | 1998-09-29 | International Business Machines Corporation | Method and apparatus for producing transmission control protocol checksums using internet protocol fragmentation |
KR0183322B1 (en) * | 1996-11-15 | 1999-05-15 | 양승택 | Ip/icmp packet checksum generator |
US20020095642A1 (en) * | 2000-11-30 | 2002-07-18 | Stmicroelectronics, Inc. | Method and device for computing incremental checksums |
-
2002
- 2002-11-02 CN CNB021501130A patent/CN1300993C/en not_active Expired - Fee Related
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5701316A (en) * | 1995-08-31 | 1997-12-23 | Unisys Corporation | Method for generating an internet protocol suite checksum in a single macro instruction |
US5815516A (en) * | 1996-04-05 | 1998-09-29 | International Business Machines Corporation | Method and apparatus for producing transmission control protocol checksums using internet protocol fragmentation |
KR0183322B1 (en) * | 1996-11-15 | 1999-05-15 | 양승택 | Ip/icmp packet checksum generator |
US20020095642A1 (en) * | 2000-11-30 | 2002-07-18 | Stmicroelectronics, Inc. | Method and device for computing incremental checksums |
Also Published As
Publication number | Publication date |
---|---|
CN1494279A (en) | 2004-05-05 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN1163047C (en) | Equipment and method for transmitting/receiving radio data | |
EP2014056B1 (en) | Methods and systems for enhancing local repair in robust header compression | |
DE69625341T2 (en) | Method and device for data coding and transmission using noisy media | |
CN1214562C (en) | A method for processing data packets | |
CN1227816C (en) | Efficient trellis state metric normalization | |
ATE265775T1 (en) | METHOD FOR DATA SEGMENTATION IN A COMMUNICATIONS NETWORK | |
EP1416380A3 (en) | Method and apparatus for managing the integrity of data in a non-volatile memory system | |
BR9915997A (en) | Process and apparatus for the protection of a block of information bits in a telecommunication system | |
CN1534877A (en) | Encoder/decoder and encoding/decoding method | |
CN1575491A (en) | Method and apparatus for decoding a coded digital audio signal which is arranged in frames containing headers | |
CN1300993C (en) | Method of rapid calculating IP massage head checking sum | |
CN1343057A (en) | Method and equipment for grouping transmission data | |
US6728930B2 (en) | Method for computing the internet checksum | |
CN1719835A (en) | Method and apparatus of compensating for signal receiving error at receiver in packet-based communication system | |
CN101046858A (en) | Electronic information comparing system and method and anti-garbage mail system | |
CN1838666A (en) | Byte sequence switching method for crossing operating system platform | |
CN1538757A (en) | Error detecting method ofmoving image transmssion system | |
US6654422B1 (en) | Efficient automatic repeat request method using variable length sequence numbers | |
CN1889462A (en) | Method and system for realizing network management and network element configuration operation | |
CN1710860A (en) | Transmitter, communication system, and communication method | |
US7751486B2 (en) | Systems and methods for transmitting data | |
CN1190916C (en) | Bit error resisting coding and decoding method based on IP application | |
CN1250022C (en) | Reliable frame synchronizing technology in data communication | |
CN1555627A (en) | Rate adaptation device and method | |
CN1157076C (en) | High-efficiency simulation method of the performance of mobile communication system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
C10 | Entry into substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
C14 | Grant of patent or utility model | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20070214 Termination date: 20151102 |
|
EXPY | Termination of patent right or utility model |