IP Header Checksum計算c實現

2021-06-28 06:37:47 字數 1104 閱讀 5140

關於ip header checksum的計算在rfc791中有比較完整的描敘,

header checksum: 16 bits

a checksum on the header only. since some header fields change

(e.g., time to live), this is recomputed and verified at each point

that the internet header is processed.

the checksum algorithm is:

the checksum field is the 16 bit one's complement of the one's

complement sum of all 16 bit words in the header. for purposes of

computing the checksum, the value of the checksum field is zero.

this is a ****** to compute checksum and experimental evidence

indicates it is adequate, but it is provisional and may be replaced

by a crc procedure, depending on further experience.

大致意義如下:

checksum只是和ip頭相關的,當頭中的資料被改變時才需要重新計算checksum。

checksum是ip頭中,第0位開始所有16位資料的和。在計算前需要將checksum本身的值設定為0。

**:[cpp]view plain

copy

_int16 getipchecksum( byte *ptr, 

intsize)  

while

(cksum > 0xffff)  

return

~cksum;  

}  

IP Header Checksum計算c實現

關於ip header checksum的計算在rfc791中有比較完整的描敘,header checksum 16 bits a checksum on the header only.since some header fields change e.g.time to live this is...

雲計算實訓總結 雲計算 實訓報告書

單元一雲計算解決方案 1 實訓記錄 1 虛擬化主要針對儲存 伺服器 網路 軟體 桌面方面。2 什麼是雲計算?通過網路將共享資源以服務的方式按需提供給使用者的一種計算方式 3 雲計算五大特徵自助服務 資源池化 靈活排程 服務可衡量 網路分發。4 雲計算的部署模型有公共雲 混合雲 私有雲 社群雲。5 雲...

Python計算器實操

開發乙個簡單的python計算器 實現加減乘除及拓號優先順序解析 使用者輸入 1 2 60 30 40 5 9 2 5 3 7 3 99 4 2998 10 568 14 4 3 16 3 2 等類似公式 後,必須自己解析裡面的 符號和公式 不能呼叫eval等類似功能偷懶實現 運算後得出結果,結果必...