Description
This source file is an example of how to transmit a sequence of packets on timestamp multiple times, but instead of manually reconfiguring the delta for each iteration, TXSETCLOCK is used to advance the delta with the duration of a single replay iteration. An example application of this functionality would be where one wishes to replay a single capture file multiple times.
This example will transmit 100000 packets of 296 bytes from port 0 at a rate of approximately 5 Mb/s. The packet contains an incrementing 32bit pattern.
The transmit on timestamp functionality is also available in segment mode. See the net/transmit_segment/transmit_segment_example.c example code to see how to use the segment interface.
The following NTAPI functions are used:
- NT_Init()
- NT_ConfigOpen()
- NT_ConfigRead()
- NT_ConfigWrite()
- NT_ConfigClose()
- NT_NetTxOpen()
- NT_NetTxGet()
- NT_NET_SET_PKT_TIMESTAMP()
- NT_NET_SET_PKT_TXSETCLOCK()
- NT_NET_GET_PKT_L2_PTR()
- NT_NetTxRelease()
- NT_NetTxClose()
- NT_Done()
- NT_ExplainError()
Prerequisites
- This example is only compatible with adapters supporting 4GA transmit on timestamp.
- The ntservice.ini must have at least one HostBuffersTx defined. Below is an example of a minimum ini-file. It will create a 4MB TX hostbuffer from NUMA node 0.
Program flow
The following is required to transmit packages:
- #include/nt.h - Applications/Tools only need to include nt.h to obtain prototypes, macros etc. from NTAPI.
- NT_Init(NTAPI_VERSION) - Initialize the NTAPI library. NTAPI_VERSION is a define that describes the version of the API described in the header files included by nt.h. NT_Init() will ask the NTAPI library to convert return data to the NTAPI_VERSION if possible. This will ensure that applications can run on NTAPI libraries of newer versions.
- NT_ConfigOpen() - Open the config stream.
- NT_ConfigRead() - Use the config stream to read the current adapter time.
- NT_ConfigWrite() - Use the config stream to configure transmit on timestamp, using the retrieved adapter time.
- NT_NetTxOpen() - Open a hostbuffer than can transmit packets to port 0.
- NT_NetTxGet() - Get an empty tx buffer. This will get a 296 byte wire length packet buffer that will be sent onto port 0 when the packet buffer is released, and the timestamp has been reached on the adapter.
- NT_NET_GET_PKT_L2_PTR() is used to get the L2 pointer to the tx buffer, this is where the payload is placed.
- NT_NET_SET_PKT_TXSETCLOCK() is used to enable txsetclock on the first packet in the replay sequence.
- NT_NET_SET_PKT_TIMESTAMP() is used to set the timestamp of the packet
- NT_NetTxRelease() - Release the tx packet buffer. Once a tx buffer is released it will be transmitted
- NT_ConfigRead() - Read the adapter timestamp to check if the last packet should have been transmitted. We need to do this in order to avoid disabling transmit on timestamp too early.
- NT_ConfigWrite() - Disable transmit on timestamp.
- NT_NetTxClose() - Close the TX stream.
- NT_Done() - Close down the NTAPI library.