Network Wizard for VHDL Test Benches
ICMP

ICMP for IPv6

The ICMPv6 library provides functions for creating and manipulation ICMP packets according to RFC 4443.

Functionality

  • Create ICMP packets of any length
  • Create and extract ICMP headers
  • Verify checksum of ICMP packets



More details in nw_icmpv6_pkg

Example use

Include the libraries:

library nw_util;
context nw_util.nw_util_context;
library nw_ipv6;
context nw_ipv6.nw_ipv6_context;

Assume the variable v_payload contains the ICMP payload. The variables are defined:

variable v_header : t_icmpv6_header; -- ICMP header record
variable v_ipv6_header : t_ipv6_header := C_DEFAULT_IPV6_HEADER; -- Needed for pseudo header checksum calculation
variable v_payload : t_slv_arr(0 to 3)(7 downto 0);
variable v_icmp_pkt : t_slv_arr(0 to 39)(7 downto 0); -- byte array
variable v_len : natural;

First setup the header, then calculate the total ICMP packet length before creating the packet.

v_header := C_DEFAULT_ICMP6_HEADER; -- copy default header (ping request)
v_payload := f_gen_nrs(x"80", 4); -- payload contents
v_len := f_icmpv6_create_pkt_len(v_ipv6_header, v_header, v_payload); -- calculate total packet length
v_icmp_pkt(0 to v_len - 1) := f_icmpv6_create_pkt(v_ipv6_header, v_header, v_payload); -- create the packet

The variable v_icmp_pkt is an 8-bit array. This can of course be rearranged to any word width with f_repack().

v_icmpv6_pkt_32 := f_repack(v_icmp_pkt, 32, C_MSB_FIRST); -- repack to 32bit words (padded with zeros if required)

See further examples in the test bench nw_ipv6_tb.vhd.