4
use Test::More tests => 2; # last test to print
6
use NetPacket::Ethernet;
10
my $datagram = binarize( <<'END_DATAGRAM' );
11
00 00 00 00 00 00 00 00 00 00 00 00 08 00 45 00
12
00 54 00 00 40 00 40 01 3c a7 7f 00 00 01 7f 00
13
00 01 08 00 d8 2f b6 6f 00 00 f8 11 c9 45 ba 05
14
03 00 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15
15
16 17 18 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25
16
26 27 28 29 2a 2b 2c 2d 2e 2f 30 31 32 33 34 35
20
my $eth = NetPacket::Ethernet->decode( $datagram );
21
my $ip = NetPacket::IP->decode( $eth->{data} );
22
my $icmp = NetPacket::ICMP->decode( $ip->{data} );
24
is $icmp->{cksum} => 55343, 'ICMP checksum';
26
# recompute the checksum
29
is $icmp->{cksum} => 55343, 'recomputed ICMP checksum';
34
return join '' => map { chr hex } split ' ', $string;