Calulate crc of an ethernet frames

 ̄綄美尐妖づ 提交于 2019-12-11 20:18:07

问题


I want to caculate in a tcl script the CRC for this frame :

00000A00080000000A00090000004500002E0000000040117AC00000000000000000003F003F001AB6EB000102030405060708090A0B0C0D0E0F1011

The expected CRC is 0x1652255A. I tried the following (found here):

% set string \x00\x00\x0A\x00\x08\x00\x00\x00\x0A\x00\x09\x00\x00\x00\x45\x00\x00\x2E\x00\x00\x00\x00\x40\x11\x7A\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3F\x00\x3F\x00\x1A\xB6\xEB\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\
x0D\x0E\x0F\x10\x11
% package require crc32
1.3
% crc::crc32 -format %X $string
690CE0EE ;# not good

% set string 00000A00080000000A00090000004500002E0000000040117AC00000000000000000003F003F001AB6EB000102030405060708090A0B0C0D0E0F1011
% set bin [binary format H* $string]
% crc::crc32 -format %X $bin
690CE0EE ;# same than previous one

There is something I don't understand with this proc, and I am not sure it is working correctly, because the result is always the same :

%  crc::crc32 -format %X foo
690CE0EE
%  crc::crc32 -format %X somethingdifferent
690CE0EE

If I go on this online tool, if find the expected result...

Is the problem coming from me or from the package ?


回答1:


I am not seeing what you're seeing.

% set string \x00\x00\x0A\x00\x08\x00\x00\x00\x0A\x00\x09\x00\x00\x00\x45\x00\x00\x2E\x00\x00\x00\x00\x40\x11\x7A\xC0\x00\x00\x00\x00\x00\x00\x00\x00\x00\x3F\x00\x3F\x00\x1A\xB6\xEB\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0A\x0B\x0C\x0D\x0E\x0F\x10\x11


    E.@zÀ??¶ë



% package require crc32
1.3.1
% crc::crc32 -format %X $string
1652255A


来源:https://stackoverflow.com/questions/20276120/calulate-crc-of-an-ethernet-frames

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!