File Network Stream

Reference Documentation

product_line_custom
Intel® PAC
Napatech SmartNIC
category
Reference Information
Napatech Software Suite: File Network Stream

Detailed Description

The File network stream is used for packet-by-packet offline analysis of the packets captured with the segment RX interface. See Segment interface for a description of how to accomplish this.

To open a file network stream, call the NT_NetFileOpen with the name of the captured file as argument. To get the next packet from the file network stream, call the NT_NetFileGet. Use the packet macros to access the packet data. When finished with the packet, call NT_NetFileRelease to release it again. When finished with the stream, call NT_NetFileClose to close it.

Supported files are native NT captured files, pcap and pcap-ng files. When using pcap or pcap-ng files, the received port information is always set to 0.

For an example on how to use the file network stream interface, see net/replay/replay_example.c.

Functions

int NT_NetFileOpen (NtNetStreamFile_t *hStream, const char *name, enum NtNetInterface_e netIntf, const char *file)
 Opens a capture file. More...
 
int NT_NetFileOpen_v2 (NtNetStreamFile_t *hStream, const char *name, enum NtNetInterface_e netIntf, const char *file, bool noConvert)
 Opens a capture file (extended version) More...
 
int NT_NetFileGet (NtNetStreamFile_t hStream, NtNetBuf_t *netBuf)
 Gets packets/segments from a file stream. More...
 
int NT_NetFileRelease (NtNetStreamFile_t hStream, NtNetBuf_t netBuf)
 Releases the network buffer. More...
 
int NT_NetFileClose (NtNetStreamFile_t hStream)
 Closes a file stream. More...
 
int NT_NetFileRead (NtNetStreamFile_t hStream, NtNetFileRead_t *data)
 Read information about a file stream. More...
 

Typedefs

typedef struct NtNetStreamFile_s * NtNetStreamFile_t
 

Function Documentation

int NT_NetFileOpen ( NtNetStreamFile_t hStream,
const char *  name,
enum NtNetInterface_e  netIntf,
const char *  file 
)

Opens a capture file.

This function is called to open a capture file, captured with a segment-based stream. The capture file must have an NT, PCAP or PCAP-NG file header otherwise it will fail when opening the capture file.

Parameters
[out]hStreamReference to a NetFile_t stream pointer
[in]nameA stream friendly name - used in, for example, logging statements
[in]netIntfDeliver packets or segments
[in]fileThe capture file to open
Return values
NT_SUCCESSSuccess
!=NT_SUCCESSError - use NT_ExplainError for an error description
Examples:
net/readcapfile/readcapfile_example.c, net/replay/replay_example.c, net/replay4GA/replay4ga_example.c, and net/replayGS/replayGS_example.c.

Referenced by GetTimeStamp(), and main().

int NT_NetFileOpen_v2 ( NtNetStreamFile_t hStream,
const char *  name,
enum NtNetInterface_e  netIntf,
const char *  file,
bool  noConvert 
)

Opens a capture file (extended version)

This function is called to open a capture file, captured with a segment-based stream. The capture file must have an NT, PCAP or PCAP-NG file header otherwise it will fail when opening the capture file.

Parameters
[out]hStreamReference to a NetFile_t stream pointer
[in]nameA stream friendly name - used in, for example, logging statements
[in]netIntfDeliver packets or segments
[in]fileThe capture file to open
[in]noConvertDo not convert PCAP files (Native PCAP tx for 4GA)
Return values
NT_SUCCESSSuccess
!=NT_SUCCESSError - use NT_ExplainError for an error description
int NT_NetFileGet ( NtNetStreamFile_t  hStream,
NtNetBuf_t netBuf 
)

Gets packets/segments from a file stream.

This function is called to retrieve packets or segments from a capture file

Note
This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
Parameters
[in]hStreamNetFile stream handle
[out]netBufPacket/segment container reference
Return values
NT_SUCCESS(0) Success
NT_STATUS_END_OF_FILEEOF indicator - See note
otherwiseError - use NT_ExplainError for an error description
Note
When NT_STATUS_END_OF_FILE is returned the internal file offset that been reset making it possible to call NT_NetFileGet() again without having to close and open the file, which improves performance when replaying a file continuously.
Examples:
net/readcapfile/readcapfile_example.c, net/replay/replay_example.c, net/replay4GA/replay4ga_example.c, and net/replayGS/replayGS_example.c.

Referenced by GetTimeStamp(), and main().

int NT_NetFileRelease ( NtNetStreamFile_t  hStream,
NtNetBuf_t  netBuf 
)

Releases the network buffer.

This function will release the netBuf data obtained via NT_FileGet

Note
This function has no mutex protection, therefore the same hStream cannot be used by multiple threads
Parameters
[in]hStreamNetStreamFile stream handle
[in]netBufThe network buffer is received via NT_FileGet
Return values
NT_SUCCESSSuccess
!=NT_SUCCESSError - use NT_ExplainError for an error description
Examples:
net/readcapfile/readcapfile_example.c, net/replay/replay_example.c, net/replay4GA/replay4ga_example.c, and net/replayGS/replayGS_example.c.

Referenced by main().

int NT_NetFileClose ( NtNetStreamFile_t  hStream)

Closes a file stream.

This function is called to close a file stream

Parameters
[in]hStreamThe file stream handle to close
Return values
NT_SUCCESSSuccess
!=NT_SUCCESSError - use NT_ExplainError for an error description
Examples:
net/readcapfile/readcapfile_example.c, net/replay/replay_example.c, net/replay4GA/replay4ga_example.c, and net/replayGS/replayGS_example.c.

Referenced by GetTimeStamp(), and main().

int NT_NetFileRead ( NtNetStreamFile_t  hStream,
NtNetFileRead_t data 
)

Read information about a file stream.

This function is called to read information about a file stream

Parameters
[in]hStreamThe file stream handle
[in,out]dataStructure containing command and returned data
Return values
NT_SUCCESSSuccess
!=NT_SUCCESSError - use NT_ExplainError for an error description
Examples:
net/replay4GA/replay4ga_example.c, and net/replayGS/replayGS_example.c.

Referenced by main().

Typedef Documentation

typedef struct NtNetStreamFile_s* NtNetStreamFile_t

Network file stream handle - used for file streams

Definition at line 1468 of file stream_net.h.