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:
- 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.
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_NetTxOpen_v2() - 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_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_ConfigClose() - Close the configuration stream.
- NT_NetTxClose() - Close the TX stream.
- NT_Done() - Close down the NTAPI library.