NetPacket::ICMP(3)

πŸ’– NetPacket::ICMP β€” the manual, but make it cute πŸ’–

okay so bestie, this is the NetPacket::ICMP(3) page from the User Contributed Perl Documentation, and it's literally all about building and taking apart ICMP (Internet Control Message Protocol) packets. it's giving low-level network gossip and honestly? we're obsessed. πŸ¦‹


✨ NAME ✨

NetPacket::ICMP β€” Assemble and disassemble ICMP (Internet Control Message Protocol) packets.

🌸 VERSION 🌸

version 1.8.0

πŸŽ€ SYNOPSIS πŸŽ€

  use NetPacket::ICMP;

  $icmp_obj = NetPacket::ICMP->decode($raw_pkt);
  $icmp_pkt = NetPacket::ICMP->encode();
  $icmp_data = NetPacket::ICMP::strip($raw_pkt);

πŸ’… DESCRIPTION πŸ’…

NetPacket::ICMP provides a set of routines for assembling and disassembling packets using ICMP (Internet Control Message Protocol). no cap, that's the whole vibe. 🫢

🧚 Methods

  • NetPacket::ICMP->decode([RAW PACKET]) β€” Decode the raw packet data given and return an object containing instance data. ⚠️ heads up bestie: this method will quite happily decode garbage input. it does not care. it will eat trash and thank you for it. It is the responsibility of the programmer to ensure valid packet data is passed to this method. so like, that's on you, not on it. 😭
  • NetPacket::ICMP->encode() β€” Return an ICMP packet encoded with the instance data specified. slay, it builds the packet from whatever instance data you gave it. ✨

🌈 Functions

  • NetPacket::ICMP::strip([RAW PACKET]) β€” Return the encapsulated data (or payload) contained in the ICMP packet. it strips the ICMP wrapper off and hands you the lil payload inside. πŸ“

πŸ‘‘ Instance data

The instance data for the NetPacket::ICMP object consists of the following fields.

  • type β€” The ICMP message type of this packet.
  • code β€” The ICMP message code of this packet.
  • cksum β€” The checksum for this packet.
  • data β€” The encapsulated data (payload) for this packet.

πŸ’œ Exports

default

  • none

exportable

ICMP message types:

ICMP_ECHOREPLY ICMP_UNREACH ICMP_SOURCEQUENCH
ICMP_REDIRECT ICMP_ECHO ICMP_ROUTERADVERT
ICMP_ROUTERSOLICIT ICMP_TIMXCEED ICMP_PARAMPROB
ICMP_TSTAMP ICMP_TSTAMPREPLY ICMP_IREQ ICMP_IREQREPLY
ICMP_MASKREQ ICMP_MASKREPLY

tags

The following tags group together related exportable items.

  • :types
ICMP_ECHOREPLY ICMP_UNREACH ICMP_SOURCEQUENCH
ICMP_REDIRECT ICMP_ECHO ICMP_ROUTERADVERT
ICMP_ROUTERSOLICIT ICMP_TIMXCEED ICMP_PARAMPROB
ICMP_TSTAMP ICMP_TSTAMPREPLY ICMP_IREQ
ICMP_IREQREPLY ICMP_MASKREQ ICMP_MASKREPLY
  • :strip β€” Import the strip function icmp_strip.
  • :ALL β€” All the above exportable items. the whole buffet, bestie. 🍽️

πŸ”₯ EXAMPLE πŸ”₯

The following example prints the ICMP type, code, and checksum fields. it's short, it's iconic, it ate:

  #!/usr/bin/perl -w

  use strict;
  use Net::PcapUtils;
  use NetPacket::Ethernet qw(:strip);
  use NetPacket::IP qw(:strip);
  use NetPacket::ICMP;

  sub process_pkt {
      my ($user, $hdr, $pkt) = @_;

      my $ip_obj = NetPacket::IP->decode(eth_strip($pkt));
      my $icmp_obj = NetPacket::ICMP->decode(ip_strip($ip_obj));

      print("Type: $icmp_obj->{type}\n");
      print("Code: $icmp_obj->{code}\n");
      print("Checksum: $icmp_obj->{cksum}\n\n");
  }

  Net::PcapUtils::loop(\&process_pkt, FILTER => 'icmp');

πŸ¦‹ TODO πŸ¦‹

Create constants

Copyright (c) 2001 Tim Potter and Stephanie Wehner.

Copyright (c) 1995,1996,1997,1998,1999 ANU and CSIRO on behalf of the participants in the CRC for Advanced Computational Systems ('ACSys').

This module is free software. You can redistribute it and/or modify it under the terms of the Artistic License 2.0.

This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose.

πŸ’– AUTHOR πŸ’–

Tim Potter <tpot@samba.org>

Stephanie Wehner <atrak@itsx.com>


and that's the whole page, bestie!! this was perl v5.42.0, dated 2026-02-05, and it's the NetPacket::ICMP(3) manpage β€” go forth and decode responsibly (or don't, it'll decode garbage anyway πŸ™ˆ). mwah! πŸ’‹

πŸ“¦ where this page comes from