Network Wizard for VHDL Test Benches
nw_pcap_pkg Package Body Reference
Package >> nw_pcap_pkg

Functions

t_slv_arr   f_pcap_read_pkt (
name: in string
pkt_no: in natural
pkt_len: in natural
bigendian: in boolean
[ impure ]
integer   f_pcap_get_pkt_cnt ( name: in string [ impure ]
 Get PCAP file packet count.
natural   f_pcap_get_pkt_len ( name: in string , pkt_no: in natural [ impure ]
 Get length of network packet.
t_slv_arr   f_pcap_get_pkt (
name: in string
pkt_no: in natural
pkt_len: in natural
[ impure ]
 Extract packet from file.

Member Function Documentation

◆ f_pcap_get_pkt_cnt()

integer f_pcap_get_pkt_cnt (   name in string  
) impure
Function

Get PCAP file packet count.

Parameters
namePCAP file name
Returns
Number of network packets in file (-1 on failure).

Get the number of network packets in PCAP file. Supports both PCAP and PCAPNG formats (only the first section in the latter format).

Example use

v_cnt := f_pcap_get_pkt_cnt("../nw_pcap/tb/ipv6-smtp.pcapng"); -- v_cnt is now 17 (17 packets in this file)
v_cnt := f_pcap_get_pkt_cnt("../nw_pcap/tb/PPTP_negotiation.pcap"); -- v_cnt is now 28 (28 packets in this file)

◆ f_pcap_get_pkt_len()

natural f_pcap_get_pkt_len (   name in string ,
  pkt_no in natural  
) impure
Function

Get length of network packet.

Parameters
namePCAP file name
pkt_noIndex of network packet in file (0 is first)
Returns
Number of bytes in network packet

Get the length of a specific network packet in a PCAP file.

Example use

v_len := f_pcap_get_pkt_len("../nw_pcap/tb/ipv6-smtp.pcapng", 3); -- v_len is now 125 (length of packet #3)
v_len := f_pcap_get_pkt_cnt("../nw_pcap/tb/PPTP_negotiation.pcap", 26); -- v_len is now 138 (length of packet #26)

◆ f_pcap_get_pkt()

t_slv_arr f_pcap_get_pkt (   name in string ,
  pkt_no in natural ,
  pkt_len in natural  
) impure
Function

Extract packet from file.

Parameters
namePCAP file name
pkt_noIndex of network packet in file (0 is first)
pkt_lenNumber of bytes to read
Returns
8bit data array with packet

Get a specific packet from file.

Example use

v_len := f_pcap_get_pkt_len("../nw_pcap/tb/ipv6-smtp.pcapng", 3); -- v_len is now 125 (length of packet #3)
v_data(0 to v_len - 1) := f_pcap_get_pkt("../nw_pcap/tb/ipv6-smtp.pcapng", 3, v_len);

The documentation for this class was generated from the following file: